X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/89c3c647797787377f4d950b38d320ee3b28e92c..25216cc7acedc987c26a159f0b640210c0ef101e:/src/store/processes/process-update-actions.ts diff --git a/src/store/processes/process-update-actions.ts b/src/store/processes/process-update-actions.ts index 372e1882..c7fd1b55 100644 --- a/src/store/processes/process-update-actions.ts +++ b/src/store/processes/process-update-actions.ts @@ -4,17 +4,18 @@ import { Dispatch } from "redux"; import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form'; -import { RootState } from "~/store/store"; -import { dialogActions } from "~/store/dialog/dialog-actions"; -import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service"; -import { ServiceRepository } from "~/services/services"; -import { getProcess } from '~/store/processes/process'; -import { projectPanelActions } from '~/store/project-panel/project-panel-action'; -import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { RootState } from "store/store"; +import { dialogActions } from "store/dialog/dialog-actions"; +import { getCommonResourceServiceError, CommonResourceServiceError } from "services/common-service/common-resource-service"; +import { ServiceRepository } from "services/services"; +import { getProcess } from 'store/processes/process'; +import { projectPanelActions } from 'store/project-panel/project-panel-action'; +import {snackbarActions, SnackbarKind} from 'store/snackbar/snackbar-actions'; export interface ProcessUpdateFormDialogData { uuid: string; name: string; + description?: string; } export const PROCESS_UPDATE_FORM_NAME = 'processUpdateFormName'; @@ -26,7 +27,7 @@ export const openProcessUpdateDialog = (resource: ProcessUpdateFormDialogData) = dispatch(initialize(PROCESS_UPDATE_FORM_NAME, { ...resource, name: process.containerRequest.name })); dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_UPDATE_FORM_NAME, data: {} })); } else { - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process not found', hideDuration: 2000 })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process not found', hideDuration: 2000, kind: SnackbarKind.ERROR })); } }; @@ -34,17 +35,17 @@ export const updateProcess = (resource: ProcessUpdateFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(startSubmit(PROCESS_UPDATE_FORM_NAME)); try { - const updatedProcess = await services.containerRequestService.update(resource.uuid, { name: resource.name }); + const updatedProcess = await services.containerRequestService.update(resource.uuid, { name: resource.name, description: resource.description }); dispatch(projectPanelActions.REQUEST_ITEMS()); dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME })); return updatedProcess; } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'Process with the same name already exists.' } as FormErrors)); } else { dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME })); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not update the process.', hideDuration: 2000 })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not update the process.', hideDuration: 2000, kind: SnackbarKind.ERROR })); } return; }