X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a37c2265b5f60351bc1f50c22e74650a79110319..6b562ae2431132439e488f509d698800ee8ebe7d:/src/store/workflow-panel/workflow-panel-actions.ts diff --git a/src/store/workflow-panel/workflow-panel-actions.ts b/src/store/workflow-panel/workflow-panel-actions.ts index 733fab16..3d51cbb8 100644 --- a/src/store/workflow-panel/workflow-panel-actions.ts +++ b/src/store/workflow-panel/workflow-panel-actions.ts @@ -6,11 +6,56 @@ import { Dispatch } from 'redux'; import { RootState } from '~/store/store'; import { ServiceRepository } from '~/services/services'; import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action'; +import { propertiesActions } from '~/store/properties/properties-actions'; +import { getResource } from '../resources/resources'; +import { getProperty } from '~/store/properties/properties'; +import { WorkflowResource } from '~/models/workflow'; +import { navigateToRunProcess } from '~/store/navigation/navigation-action'; +import { goToStep, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions'; export const WORKFLOW_PANEL_ID = "workflowPanel"; +const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix'; +const WORKFLOW_PANEL_DETAILS_UUID = 'workflowPanelDetailsUuid'; export const workflowPanelActions = bindDataExplorerActions(WORKFLOW_PANEL_ID); export const loadWorkflowPanel = () => - (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(workflowPanelActions.REQUEST_ITEMS()); - }; \ No newline at end of file + const response = await services.workflowService.list(); + dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items)); + }; + +export const setUuidPrefix = (uuidPrefix: string) => + propertiesActions.SET_PROPERTY({ key: UUID_PREFIX_PROPERTY_NAME, value: uuidPrefix }); + +export const getUuidPrefix = (state: RootState) => { + return state.properties.uuidPrefix; +}; + +export const openRunProcess = (uuid: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const workflows = getState().runProcessPanel.searchWorkflows; + const workflow = workflows.find(workflow => workflow.uuid === uuid); + dispatch(navigateToRunProcess); + dispatch(runProcessPanelActions.RESET_RUN_PROCESS_PANEL()); + dispatch(goToStep(1)); + dispatch(runProcessPanelActions.SET_STEP_CHANGED(true)); + dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow!)); + }; + +export const getPublicUserUuid = (state: RootState) => { + const prefix = getProperty(UUID_PREFIX_PROPERTY_NAME)(state.properties); + return `${prefix}-tpzed-anonymouspublic`; +}; +export const getPublicGroupUuid = (state: RootState) => { + const prefix = getProperty(UUID_PREFIX_PROPERTY_NAME)(state.properties); + return `${prefix}-j7d0g-anonymouspublic`; +}; + +export const showWorkflowDetails = (uuid: string) => + propertiesActions.SET_PROPERTY({ key: WORKFLOW_PANEL_DETAILS_UUID, value: uuid }); + +export const getWorkflowDetails = (state: RootState) => { + const uuid = getProperty(WORKFLOW_PANEL_DETAILS_UUID)(state.properties); + return uuid ? getResource(uuid)(state.resources) : undefined; +};