From 4417a36247e40e7b2204b19324922940395c5361 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Wed, 11 Oct 2023 09:21:05 -0400 Subject: [PATCH] 15768: made separate file for project panel action binding Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../collections/collection-move-actions.ts | 3 +- .../data-explorer/data-explorer-action.ts | 3 - src/store/processes/process-move-actions.ts | 3 +- src/store/processes/process-update-actions.ts | 31 +++++---- src/store/processes/processes-actions.ts | 2 +- .../project-panel-action-bind.ts | 9 +++ .../project-panel/project-panel-action.ts | 3 +- .../project-panel-middleware-service.ts | 2 +- src/store/projects/project-lock-actions.ts | 2 +- src/store/projects/project-move-actions.ts | 2 +- src/store/projects/project-update-actions.ts | 65 +++++++++---------- src/store/trash/trash-actions.ts | 2 +- src/store/workbench/workbench-actions.ts | 2 +- src/websocket/websocket.ts | 2 +- 14 files changed, 65 insertions(+), 66 deletions(-) create mode 100644 src/store/project-panel/project-panel-action-bind.ts diff --git a/src/store/collections/collection-move-actions.ts b/src/store/collections/collection-move-actions.ts index 16d31405..56c7b24c 100644 --- a/src/store/collections/collection-move-actions.ts +++ b/src/store/collections/collection-move-actions.ts @@ -9,8 +9,7 @@ import { ServiceRepository } from "services/services"; import { RootState } from "store/store"; import { getCommonResourceServiceError, CommonResourceServiceError } from "services/common-service/common-resource-service"; import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; -// import { projectPanelActions } from 'store/project-panel/project-panel-action'; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { MoveToFormDialogData } from "store/move-to-dialog/move-to-dialog"; import { resetPickerProjectTree } from "store/project-tree-picker/project-tree-picker-actions"; import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions"; diff --git a/src/store/data-explorer/data-explorer-action.ts b/src/store/data-explorer/data-explorer-action.ts index 483ec14c..f686c939 100644 --- a/src/store/data-explorer/data-explorer-action.ts +++ b/src/store/data-explorer/data-explorer-action.ts @@ -52,6 +52,3 @@ export const bindDataExplorerActions = (id: string) => ({ RESET_EXPLORER_SEARCH_VALUE: () => dataExplorerActions.RESET_EXPLORER_SEARCH_VALUE({ id }), SET_REQUEST_STATE: (payload: { requestState: DataTableRequestState }) => dataExplorerActions.SET_REQUEST_STATE({ ...payload, id }), }); - -const PROJECT_PANEL_ID = "projectPanel"; -export const projectPanelActions = bindDataExplorerActions(PROJECT_PANEL_ID); diff --git a/src/store/processes/process-move-actions.ts b/src/store/processes/process-move-actions.ts index 6f9e157f..c3ac75f9 100644 --- a/src/store/processes/process-move-actions.ts +++ b/src/store/processes/process-move-actions.ts @@ -11,8 +11,7 @@ import { getCommonResourceServiceError, CommonResourceServiceError } from "servi import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; import { MoveToFormDialogData } from "store/move-to-dialog/move-to-dialog"; import { resetPickerProjectTree } from "store/project-tree-picker/project-tree-picker-actions"; -// import { projectPanelActions } from 'store/project-panel/project-panel-action'; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { getProcess } from "store/processes/process"; import { initProjectsTreePicker } from "store/tree-picker/tree-picker-actions"; diff --git a/src/store/processes/process-update-actions.ts b/src/store/processes/process-update-actions.ts index c7fd1b55..c7bd2c7b 100644 --- a/src/store/processes/process-update-actions.ts +++ b/src/store/processes/process-update-actions.ts @@ -3,14 +3,14 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from "redux"; -import { FormErrors, 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 { 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'; +import { getProcess } from "store/processes/process"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; +import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; export interface ProcessUpdateFormDialogData { uuid: string; @@ -18,34 +18,37 @@ export interface ProcessUpdateFormDialogData { description?: string; } -export const PROCESS_UPDATE_FORM_NAME = 'processUpdateFormName'; +export const PROCESS_UPDATE_FORM_NAME = "processUpdateFormName"; -export const openProcessUpdateDialog = (resource: ProcessUpdateFormDialogData) => - (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { +export const openProcessUpdateDialog = + (resource: ProcessUpdateFormDialogData) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const process = getProcess(resource.uuid)(getState().resources); - if(process) { + if (process) { 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, kind: SnackbarKind.ERROR })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Process not found", hideDuration: 2000, kind: SnackbarKind.ERROR })); } }; -export const updateProcess = (resource: ProcessUpdateFormDialogData) => - async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { +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, description: resource.description }); + 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_NAME_VIOLATION) { - dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'Process with the same name already exists.' } as FormErrors)); + 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, kind: SnackbarKind.ERROR })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Could not update the process.", hideDuration: 2000, kind: SnackbarKind.ERROR })); } return; } diff --git a/src/store/processes/processes-actions.ts b/src/store/processes/processes-actions.ts index 57dc7b17..1cf5f49a 100644 --- a/src/store/processes/processes-actions.ts +++ b/src/store/processes/processes-actions.ts @@ -9,7 +9,7 @@ import { updateResources } from "store/resources/resources-actions"; import { Process } from "./process"; import { dialogActions } from "store/dialog/dialog-actions"; import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { navigateToRunProcess } from "store/navigation/navigation-action"; import { goToStep, runProcessPanelActions } from "store/run-process-panel/run-process-panel-actions"; import { getResource } from "store/resources/resources"; diff --git a/src/store/project-panel/project-panel-action-bind.ts b/src/store/project-panel/project-panel-action-bind.ts new file mode 100644 index 00000000..31a5f8d6 --- /dev/null +++ b/src/store/project-panel/project-panel-action-bind.ts @@ -0,0 +1,9 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { bindDataExplorerActions } from "store/data-explorer/data-explorer-action"; + +const PROJECT_PANEL_ID = "projectPanel"; + +export const projectPanelActions = bindDataExplorerActions(PROJECT_PANEL_ID); diff --git a/src/store/project-panel/project-panel-action.ts b/src/store/project-panel/project-panel-action.ts index 1a7caa6f..305799e8 100644 --- a/src/store/project-panel/project-panel-action.ts +++ b/src/store/project-panel/project-panel-action.ts @@ -3,12 +3,11 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from "redux"; -import { bindDataExplorerActions } from "store/data-explorer/data-explorer-action"; import { propertiesActions } from "store/properties/properties-actions"; import { RootState } from "store/store"; import { getProperty } from "store/properties/properties"; import { loadProject } from "store/workbench/workbench-actions"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; export const PROJECT_PANEL_ID = "projectPanel"; export const PROJECT_PANEL_CURRENT_UUID = "projectPanelCurrentUuid"; diff --git a/src/store/project-panel/project-panel-middleware-service.ts b/src/store/project-panel/project-panel-middleware-service.ts index 0eca18e2..7204993b 100644 --- a/src/store/project-panel/project-panel-middleware-service.ts +++ b/src/store/project-panel/project-panel-middleware-service.ts @@ -18,7 +18,7 @@ import { FilterBuilder, joinFilters } from "services/api/filter-builder"; import { GroupContentsResource, GroupContentsResourcePrefix } from "services/groups-service/groups-service"; import { updateFavorites } from "store/favorites/favorites-actions"; import { IS_PROJECT_PANEL_TRASHED, getProjectPanelCurrentUuid } from "store/project-panel/project-panel-action"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { Dispatch, MiddlewareAPI } from "redux"; import { ProjectResource } from "models/project"; import { updateResources } from "store/resources/resources-actions"; diff --git a/src/store/projects/project-lock-actions.ts b/src/store/projects/project-lock-actions.ts index 4a5cbfef..84f886d6 100644 --- a/src/store/projects/project-lock-actions.ts +++ b/src/store/projects/project-lock-actions.ts @@ -4,7 +4,7 @@ import { Dispatch } from "redux"; import { ServiceRepository } from "services/services"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { loadResource } from "store/resources/resources-actions"; import { RootState } from "store/store"; diff --git a/src/store/projects/project-move-actions.ts b/src/store/projects/project-move-actions.ts index 8fb0dc60..97cd5dbe 100644 --- a/src/store/projects/project-move-actions.ts +++ b/src/store/projects/project-move-actions.ts @@ -12,7 +12,7 @@ import { getCommonResourceServiceError, CommonResourceServiceError } from "servi import { MoveToFormDialogData } from "store/move-to-dialog/move-to-dialog"; import { resetPickerProjectTree } from "store/project-tree-picker/project-tree-picker-actions"; import { initProjectsTreePicker } from "store/tree-picker/tree-picker-actions"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { loadSidePanelTreeProjects } from "../side-panel-tree/side-panel-tree-actions"; export const PROJECT_MOVE_FORM_NAME = "projectMoveFormName"; diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts index 057c7cfa..81249031 100644 --- a/src/store/projects/project-update-actions.ts +++ b/src/store/projects/project-update-actions.ts @@ -3,22 +3,12 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from "redux"; -import { - FormErrors, - formValueSelector, - initialize, - reset, - startSubmit, - stopSubmit -} from 'redux-form'; +import { FormErrors, formValueSelector, initialize, reset, 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 { getCommonResourceServiceError, CommonResourceServiceError } from "services/common-service/common-resource-service"; import { ServiceRepository } from "services/services"; -import { projectPanelActions } from 'store/project-panel/project-panel-action'; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { GroupClass } from "models/group"; import { Participant } from "views-components/sharing-dialog/participant-select"; import { ProjectProperties } from "./project-create-actions"; @@ -34,26 +24,27 @@ export interface ProjectUpdateFormDialogData { properties?: ProjectProperties; } -export const PROJECT_UPDATE_FORM_NAME = 'projectUpdateFormName'; -export const PROJECT_UPDATE_PROPERTIES_FORM_NAME = 'projectUpdatePropertiesFormName'; +export const PROJECT_UPDATE_FORM_NAME = "projectUpdateFormName"; +export const PROJECT_UPDATE_PROPERTIES_FORM_NAME = "projectUpdatePropertiesFormName"; export const PROJECT_UPDATE_FORM_SELECTOR = formValueSelector(PROJECT_UPDATE_FORM_NAME); -export const openProjectUpdateDialog = (resource: ProjectUpdateFormDialogData) => - (dispatch: Dispatch, getState: () => RootState) => { - // Get complete project resource from store to handle consumers passing in partial resources - const project = getResource(resource.uuid)(getState().resources); - dispatch(initialize(PROJECT_UPDATE_FORM_NAME, project)); - dispatch(dialogActions.OPEN_DIALOG({ +export const openProjectUpdateDialog = (resource: ProjectUpdateFormDialogData) => (dispatch: Dispatch, getState: () => RootState) => { + // Get complete project resource from store to handle consumers passing in partial resources + const project = getResource(resource.uuid)(getState().resources); + dispatch(initialize(PROJECT_UPDATE_FORM_NAME, project)); + dispatch( + dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: { sourcePanel: GroupClass.PROJECT, - } - })); - }; + }, + }) + ); +}; -export const updateProject = (project: ProjectUpdateFormDialogData) => - async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const uuid = project.uuid || ''; +export const updateProject = + (project: ProjectUpdateFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const uuid = project.uuid || ""; dispatch(startSubmit(PROJECT_UPDATE_FORM_NAME)); try { const updatedProject = await services.projectService.update( @@ -63,7 +54,8 @@ export const updateProject = (project: ProjectUpdateFormDialogData) => description: project.description, properties: project.properties, }, - false); + false + ); dispatch(projectPanelActions.REQUEST_ITEMS()); dispatch(reset(PROJECT_UPDATE_FORM_NAME)); dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME })); @@ -71,16 +63,17 @@ export const updateProject = (project: ProjectUpdateFormDialogData) => } catch (e) { const error = getCommonResourceServiceError(e); if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { - dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors)); + dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: "Project with the same name already exists." } as FormErrors)); } else { dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME })); - const errMsg = e.errors - ? e.errors.join('') - : 'There was an error while updating the project'; - dispatch(snackbarActions.OPEN_SNACKBAR({ - message: errMsg, - hideDuration: 2000, - kind: SnackbarKind.ERROR })); + const errMsg = e.errors ? e.errors.join("") : "There was an error while updating the project"; + dispatch( + snackbarActions.OPEN_SNACKBAR({ + message: errMsg, + hideDuration: 2000, + kind: SnackbarKind.ERROR, + }) + ); } return; } diff --git a/src/store/trash/trash-actions.ts b/src/store/trash/trash-actions.ts index 33442f46..884293a9 100644 --- a/src/store/trash/trash-actions.ts +++ b/src/store/trash/trash-actions.ts @@ -8,7 +8,7 @@ import { ServiceRepository } from "services/services"; import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; import { trashPanelActions } from "store/trash-panel/trash-panel-action"; import { activateSidePanelTreeItem, loadSidePanelTreeProjects } from "store/side-panel-tree/side-panel-tree-actions"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { ResourceKind } from "models/resource"; import { navigateTo, navigateToTrash } from "store/navigation/navigation-action"; import { matchCollectionRoute } from "routes/routes"; diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts index cd120f42..294aeaf8 100644 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@ -9,7 +9,7 @@ import { loadDetailsPanel } from "store/details-panel/details-panel-action"; import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; import { favoritePanelActions, loadFavoritePanel } from "store/favorite-panel/favorite-panel-action"; import { getProjectPanelCurrentUuid, setIsProjectPanelTrashed } from "store/project-panel/project-panel-action"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { activateSidePanelTreeItem, initSidePanelTree, diff --git a/src/websocket/websocket.ts b/src/websocket/websocket.ts index 0a6a05df..a7be6ba1 100644 --- a/src/websocket/websocket.ts +++ b/src/websocket/websocket.ts @@ -12,7 +12,7 @@ import { loadProcess } from "store/processes/processes-actions"; import { getProcess, getSubprocesses } from "store/processes/process"; import { LogEventType } from "models/log"; import { subprocessPanelActions } from "store/subprocess-panel/subprocess-panel-actions"; -import { projectPanelActions } from "store/data-explorer/data-explorer-action"; +import { projectPanelActions } from "store/project-panel/project-panel-action-bind"; import { getProjectPanelCurrentUuid } from "store/project-panel/project-panel-action"; import { allProcessesPanelActions } from "store/all-processes-panel/all-processes-panel-action"; import { loadCollection } from "store/workbench/workbench-actions"; -- 2.30.2