X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c055c90f752c104305e4097a9b7b5d029615e08f..a74d278febca225076a72413a8343e13f5488a58:/src/store/collections/collection-create-actions.ts?ds=sidebyside diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts index 83b3e89c..b6f0ddcc 100644 --- a/src/store/collections/collection-create-actions.ts +++ b/src/store/collections/collection-create-actions.ts @@ -12,7 +12,7 @@ import { getCommonResourceServiceError, CommonResourceServiceError } from "~/ser import { uploadCollectionFiles } from './collection-upload-actions'; import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions'; import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions"; -import { isItemNotInProject, isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions'; +import { isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions'; import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; import { CollectionResource } from "~/models/collection"; @@ -26,12 +26,11 @@ export const COLLECTION_CREATE_FORM_NAME = "collectionCreateFormName"; export const openCollectionCreateDialog = (ownerUuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const router = getState(); - const properties = getState().properties; - if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) { + const { router } = getState(); + if (!isProjectOrRunProcessRoute(router)) { const userUuid = getUserUuid(getState()); if (!userUuid) { return; } - dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { userUuid })); + dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid: userUuid })); } else { dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid })); } @@ -42,7 +41,7 @@ export const openCollectionCreateDialog = (ownerUuid: string) => export const createCollection = (data: CollectionCreateFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME)); - let newCollection: CollectionResource; + let newCollection: CollectionResource | undefined; try { dispatch(progressIndicatorActions.START_WORKING(COLLECTION_CREATE_FORM_NAME)); newCollection = await services.collectionService.create(data); @@ -62,7 +61,7 @@ export const createCollection = (data: CollectionCreateFormDialogData) => hideDuration: 2000, kind: SnackbarKind.ERROR })); - await services.collectionService.delete(newCollection!.uuid); + if (newCollection) { await services.collectionService.delete(newCollection.uuid); } } return; } finally {