X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/2e21cc7eeaecd3282d464c096549486b391c9461..bc80b56b75691f7571e3b86f3bb50cc26ce9d5b0:/src/store/workbench/workbench-actions.ts diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts index 1cf71706..a3c3a096 100644 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@ -13,7 +13,6 @@ import { } from 'store/favorite-panel/favorite-panel-action'; import { getProjectPanelCurrentUuid, - openProjectPanel, projectPanelActions, setIsProjectPanelTrashed, } from 'store/project-panel/project-panel-action'; @@ -87,6 +86,7 @@ import { loadCollectionPanel, } from 'store/collection-panel/collection-panel-action'; import { CollectionResource } from 'models/collection'; +import { WorkflowResource } from 'models/workflow'; import { loadSearchResultsPanel, searchResultsPanelActions, @@ -452,41 +452,34 @@ export const loadCollection = (uuid: string) => userUuid, services, }); + let collection: CollectionResource | undefined; + let breadcrumbfunc: ((uuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => Promise) | undefined; + let sidepanel: string | undefined; match({ - OWNED: (collection) => { - dispatch( - collectionPanelActions.SET_COLLECTION( - collection as CollectionResource - ) - ); - dispatch(updateResources([collection])); - dispatch(activateSidePanelTreeItem(collection.ownerUuid)); - dispatch(setSidePanelBreadcrumbs(collection.ownerUuid)); - dispatch(loadCollectionPanel(collection.uuid)); + OWNED: (thecollection) => { + collection = thecollection as CollectionResource; + sidepanel = collection.ownerUuid; + breadcrumbfunc = setSidePanelBreadcrumbs; }, - SHARED: (collection) => { - dispatch( - collectionPanelActions.SET_COLLECTION( - collection as CollectionResource - ) - ); - dispatch(updateResources([collection])); - dispatch(setSharedWithMeBreadcrumbs(collection.ownerUuid)); - dispatch(activateSidePanelTreeItem(collection.ownerUuid)); - dispatch(loadCollectionPanel(collection.uuid)); + SHARED: (thecollection) => { + collection = thecollection as CollectionResource; + sidepanel = collection.ownerUuid; + breadcrumbfunc = setSharedWithMeBreadcrumbs; }, - TRASHED: (collection) => { - dispatch( - collectionPanelActions.SET_COLLECTION( - collection as CollectionResource - ) - ); - dispatch(updateResources([collection])); - dispatch(setTrashBreadcrumbs('')); - dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH)); - dispatch(loadCollectionPanel(collection.uuid)); + TRASHED: (thecollection) => { + collection = thecollection as CollectionResource; + sidepanel = SidePanelTreeCategory.TRASH; + breadcrumbfunc = () => setTrashBreadcrumbs(''); }, }); + if (collection && breadcrumbfunc && sidepanel) { + dispatch(updateResources([collection])); + await dispatch(finishLoadingProject(collection.ownerUuid)); + dispatch(collectionPanelActions.SET_COLLECTION(collection)); + await dispatch(activateSidePanelTreeItem(sidepanel)); + dispatch(breadcrumbfunc(collection.ownerUuid)); + dispatch(loadCollectionPanel(collection.uuid)); + } } } ); @@ -580,6 +573,7 @@ export const loadProcess = (uuid: string) => dispatch(loadProcessPanel(uuid)); const process = await dispatch(processesActions.loadProcess(uuid)); if (process) { + await dispatch(finishLoadingProject(process.containerRequest.ownerUuid)); await dispatch( activateSidePanelTreeItem(process.containerRequest.ownerUuid) ); @@ -588,6 +582,40 @@ export const loadProcess = (uuid: string) => } }); +export const loadRegisteredWorkflow = (uuid: string) => + handleFirstTimeLoad(async (dispatch: Dispatch, + getState: () => RootState, + services: ServiceRepository) => { + + const userUuid = getUserUuid(getState()); + if (userUuid) { + const match = await loadGroupContentsResource({ + uuid, + userUuid, + services, + }); + let workflow: WorkflowResource | undefined; + let breadcrumbfunc: ((uuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => Promise) | undefined; + match({ + OWNED: async (theworkflow) => { + workflow = theworkflow as WorkflowResource; + breadcrumbfunc = setSidePanelBreadcrumbs; + }, + SHARED: async (theworkflow) => { + workflow = theworkflow as WorkflowResource; + breadcrumbfunc = setSharedWithMeBreadcrumbs; + }, + TRASHED: () => { } + }); + if (workflow && breadcrumbfunc) { + dispatch(updateResources([workflow])); + await dispatch(finishLoadingProject(workflow.ownerUuid)); + await dispatch(activateSidePanelTreeItem(workflow.ownerUuid)); + dispatch(breadcrumbfunc(workflow.ownerUuid)); + } + } + }); + export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) => async (dispatch: Dispatch) => { @@ -837,7 +865,6 @@ const finishLoadingProject = (project: GroupContentsResource | string) => async (dispatch: Dispatch) => { const uuid = typeof project === 'string' ? project : project.uuid; - dispatch(openProjectPanel(uuid)); dispatch(loadDetailsPanel(uuid)); if (typeof project !== 'string') { dispatch(updateResources([project])); @@ -876,8 +903,12 @@ const loadGroupContentsResource = async (params: { resource = await params.services.collectionService.get(params.uuid); } else if (kind === ResourceKind.PROJECT) { resource = await params.services.projectService.get(params.uuid); - } else { + } else if (kind === ResourceKind.WORKFLOW) { + resource = await params.services.workflowService.get(params.uuid); + } else if (kind === ResourceKind.CONTAINER_REQUEST) { resource = await params.services.containerRequestService.get(params.uuid); + } else { + throw new Error("loadGroupContentsResource unsupported kind " + kind) } handler = groupContentsHandlers.SHARED(resource); }