X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bfaee40696c3c15556ef089e69da47bb832b08db..04704ea80b294655fe14d0c8cddf4ec1a6b21b4d:/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts diff --git a/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts b/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts index eab16882e0..37b96bd9b0 100644 --- a/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts +++ b/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts @@ -8,14 +8,14 @@ import { ServiceRepository } from 'services/services'; import { bindDataExplorerActions } from 'store/data-explorer/data-explorer-action'; import { propertiesActions } from 'store/properties/properties-actions'; import { getProperty } from 'store/properties/properties'; -import { navigateToRunProcess } from 'store/navigation/navigation-action'; +import { navigateToRunProcess, navigateTo } from 'store/navigation/navigation-action'; import { goToStep, runProcessPanelActions, loadPresets, getWorkflowRunnerSettings } from 'store/run-process-panel/run-process-panel-actions'; -import { snackbarActions } from 'store/snackbar/snackbar-actions'; +import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; import { initialize } from 'redux-form'; import { RUN_PROCESS_BASIC_FORM } from 'views/run-process-panel/run-process-basic-form'; import { RUN_PROCESS_INPUTS_FORM } from 'views/run-process-panel/run-process-inputs-form'; @@ -23,7 +23,6 @@ import { RUN_PROCESS_ADVANCED_FORM } from 'views/run-process-panel/run-process-a import { getResource } from 'store/resources/resources'; import { ProjectResource } from 'models/project'; import { UserResource } from 'models/user'; -import { getUserUuid } from "common/getuser"; import { getWorkflowInputs, parseWorkflowDefinition } from 'models/workflow'; export const WORKFLOW_PANEL_ID = "workflowPanel"; @@ -31,6 +30,9 @@ const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix'; const WORKFLOW_PANEL_DETAILS_UUID = 'workflowPanelDetailsUuid'; export const workflowPanelActions = bindDataExplorerActions(WORKFLOW_PANEL_ID); +export const WORKFLOW_PROCESSES_PANEL_ID = "workflowProcessesPanel"; +export const workflowProcessesPanelActions = bindDataExplorerActions(WORKFLOW_PROCESSES_PANEL_ID); + export const loadWorkflowPanel = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(workflowPanelActions.REQUEST_ITEMS()); @@ -49,9 +51,10 @@ export const openRunProcess = (workflowUuid: string, ownerUuid?: string, name?: async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const response = await services.workflowService.list(); dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items)); - + const workflows = getState().runProcessPanel.searchWorkflows; - const workflow = workflows.find(workflow => workflow.uuid === workflowUuid); + const listedWorkflow = workflows.find(workflow => workflow.uuid === workflowUuid); + const workflow = listedWorkflow || await services.workflowService.get(workflowUuid); if (workflow) { dispatch(navigateToRunProcess); dispatch(goToStep(1)); @@ -63,9 +66,8 @@ export const openRunProcess = (workflowUuid: string, ownerUuid?: string, name?: let owner; if (ownerUuid) { // Must be writable. - const userUuid = getUserUuid(getState()); owner = getResource(ownerUuid)(getState().resources); - if (!owner || !userUuid || owner.writableBy.indexOf(userUuid) === -1) { + if (!owner || !owner.canWrite) { owner = undefined; } } @@ -117,3 +119,11 @@ export const getWorkflowDetails = (state: RootState) => { const workflow = workflows.find(workflow => workflow.uuid === uuid); return workflow || undefined; }; + +export const deleteWorkflow = (workflowUuid: string, ownerUuid: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + dispatch(navigateTo(ownerUuid)); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...', kind: SnackbarKind.INFO })); + await services.workflowService.delete(workflowUuid); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); + };