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);

	let resource;

	if (get(action, 'data.model.resource')) {
		resource = get(action, 'data.model.resource');
	} else {
		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', ''),
				},
			});
			yield call(redirect, get(action, 'data.model.redirectUrl'));
		} else {
			yield put({
				type: deleteResourceConst.DIALOG_BOX_DELETE_RESOURCE_ERROR,
				error: result.data,
			});
		}
	}
}
/**
 * Waiting for confirmation event.
 * Resolve the resource to delete.
 * Call the requested uri.
 * Redirect the user.
 * @param {string} uri
 * @param {string} resourceType
 * @param {string} itemId
 * @param {Array<String>} [resourcePath]
 * @param {string} collectionId - collection which stores resources
 * @param {string} resourceUri - uri to delete resource on backend
 */
Waiting for confirmation event.
Resolve the resource to delete.
Call the requested uri.
Redirect the user.
Waiting for confirmation event . Resolve the resource to delete . Call the requested uri . Redirect the user .
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);
	let resource;
	if (get(action, 'data.model.resource')) {
		resource = get(action, 'data.model.resource');
	} else {
		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', ''),
				},
			});
			yield call(redirect, get(action, 'data.model.redirectUrl'));
		} else {
			yield put({
				type: deleteResourceConst.DIALOG_BOX_DELETE_RESOURCE_ERROR,
				error: result.data,
			});
		}
	}
}
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 ) ; let resource ; if ( get ( action , 'data.model.resource' ) ) { resource = get ( action , 'data.model.resource' ) ; } else { 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' , '' ) , } , } ) ; yield call ( redirect , get ( action , 'data.model.redirectUrl' ) ) ; } else { yield put ( { type : deleteResourceConst . DIALOG_BOX_DELETE_RESOURCE_ERROR , error : result . data , } ) ; } } }
Waiting for confirmation event.
Waiting for confirmation event .