X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f63f3a5360ae6381d4b332bf86ef52b4e22107fb..e69ce2f8f14e4272acf5efa4c8a252bc101227ca:/src/store/projects/project-update-actions.ts diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts index 39b97b24..b9206976 100644 --- a/src/store/projects/project-update-actions.ts +++ b/src/store/projects/project-update-actions.ts @@ -3,13 +3,15 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from "redux"; -import { initialize, startSubmit, stopSubmit } from 'redux-form'; +import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form'; import { RootState } from "~/store/store"; import { dialogActions } from "~/store/dialog/dialog-actions"; -import { ContextMenuResource } from '~/store/context-menu/context-menu-reducer'; -import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service"; +import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service"; import { ServiceRepository } from "~/services/services"; import { ProjectResource } from '~/models/project'; +import { ContextMenuResource } from "~/store/context-menu/context-menu-actions"; +import { getResource } from '~/store/resources/resources'; +import { projectPanelActions } from '~/store/project-panel/project-panel-action'; export interface ProjectUpdateFormDialogData { uuid: string; @@ -20,8 +22,9 @@ export interface ProjectUpdateFormDialogData { export const PROJECT_UPDATE_FORM_NAME = 'projectUpdateFormName'; export const openProjectUpdateDialog = (resource: ContextMenuResource) => - (dispatch: Dispatch) => { - dispatch(initialize(PROJECT_UPDATE_FORM_NAME, resource)); + (dispatch: Dispatch, getState: () => RootState) => { + const project = getResource(resource.uuid)(getState().resources); + dispatch(initialize(PROJECT_UPDATE_FORM_NAME, project)); dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: {} })); }; @@ -31,13 +34,14 @@ export const updateProject = (project: Partial) => dispatch(startSubmit(PROJECT_UPDATE_FORM_NAME)); try { const updatedProject = await services.projectService.update(uuid, project); + dispatch(projectPanelActions.REQUEST_ITEMS()); dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME })); return updatedProject; } catch (e) { const error = getCommonResourceServiceError(e); if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { - dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' })); + dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors)); } return ; } - }; \ No newline at end of file + };