Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function* waitFor(collectionName, interval = 10) {
// eslint-disable-next-line no-constant-condition
while (true) {
const collection = yield select(api.selectors.collections.get, collectionName);
if (collection !== undefined) {
break;
}
yield call(delay, interval);
}
}
/**
export const mapStateToProps = state => ({
...cmf.selectors.collections.toJS(state, Constants.COLLECTION_ID),
});
export function mapStateToProps(state, ownProps) {
const props = {
productsItems: cmf.selectors.collections.toJS(state, Constants.COLLECTION_ID),
};
const expression = get(ownProps, 'callToAction.renderIfExpression');
if (expression) {
props.callToAction = Object.assign(
{},
ownProps.callToAction,
cmf.expression.mapStateToProps(state, ownProps.callToAction),
);
if (props.callToAction.renderIf === false) {
props.callToAction = null;
}
}
return props;
}
export function* deleteResourceValidate(
uri,
resourceType,
itemId,
resourcePath,
collectionId,
resourceUri,
) {
const action = yield take(deleteResourceConst.DIALOG_BOX_DELETE_RESOURCE_OK);
const safeURI = get(action, 'data.model.uri', uri);
const safeType = get(action, 'data.model.resourceType', resourceType);
const safeId = get(action, 'data.model.id', itemId);
const safePath = get(action, 'data.model.resourcePath', resourcePath);
const resourceCollectionId = get(action, 'data.model.collectionId', collectionId);
const resourceLocator = getResourceLocator(resourceCollectionId || safeType, safePath);
const resource = yield select(cmf.selectors.collections.findListItem, resourceLocator, safeId);
const safeResourceUri = get(
action,
'data.model.resourceUri',
resourceUri || `${safeURI}/${safeType}/${safeId}`,
);
if (resource && safeResourceUri) {
const result = yield call(cmf.sagas.http.delete, safeResourceUri);
if (result.response.ok) {
yield put({
type: deleteResourceConst.DIALOG_BOX_DELETE_RESOURCE_SUCCESS,
model: {
...get(action, 'data.model', {}),
id: safeId,
labelResource: resource.get('label') || resource.get('name', ''),
},
});