X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f06094d87f1c1b1bb8e886dd723bcdf17f0b727d..6ad3586e61737306f61a330eca545ca494f16304:/src/store/workbench/workbench-actions.ts diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts index fb85c0e0..e2ff01f7 100644 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@ -4,6 +4,7 @@ import { Dispatch } from 'redux'; import { RootState } from "~/store/store"; +import { getUserUuid } from "~/common/getuser"; 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'; @@ -19,7 +20,7 @@ import { loadSidePanelTreeProjects, SidePanelTreeCategory } from '~/store/side-panel-tree/side-panel-tree-actions'; -import { loadResource, updateResources } from '~/store/resources/resources-actions'; +import { updateResources } from '~/store/resources/resources-actions'; import { projectPanelColumns } from '~/views/project-panel/project-panel'; import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel'; import { matchRootRoute } from '~/routes/routes'; @@ -59,6 +60,7 @@ import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog'; import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions'; import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh'; import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions'; +import { loadLinkAccountPanel, linkAccountPanelActions } from '~/store/link-account-panel/link-account-panel-actions'; import { loadSiteManagerPanel } from '~/store/auth/auth-action-session'; import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view'; import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions'; @@ -95,6 +97,10 @@ import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/pub import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel'; import { loadCollectionsContentAddressPanel, collectionsContentAddressActions } from '~/store/collections-content-address-panel/collections-content-address-panel-actions'; import { collectionContentAddressPanelColumns } from '~/views/collection-content-address-panel/collection-content-address-panel'; +import { subprocessPanelActions } from '~/store/subprocess-panel/subprocess-panel-actions'; +import { subprocessPanelColumns } from '~/views/subprocess-panel/subprocess-panel-root'; +import { loadAllProcessesPanel, allProcessesPanelActions } from '../all-processes-panel/all-processes-panel-action'; +import { allProcessesPanelColumns } from '~/views/all-processes-panel/all-processes-panel'; export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen'; @@ -115,13 +121,14 @@ const handleFirstTimeLoad = (action: any) => }; export const loadWorkbench = () => - async (dispatch: Dispatch, getState: () => RootState) => { + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN)); const { auth, router } = getState(); const { user } = auth; if (user) { dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns })); dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns })); + dispatch(allProcessesPanelActions.SET_COLUMNS({ columns: allProcessesPanelColumns })); dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns })); dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns })); dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns })); @@ -135,6 +142,11 @@ export const loadWorkbench = () => dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns })); dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns })); dispatch(collectionsContentAddressActions.SET_COLUMNS({ columns: collectionContentAddressPanelColumns })); + dispatch(subprocessPanelActions.SET_COLUMNS({ columns: subprocessPanelColumns })); + + if (services.linkAccountService.getAccountToLink()) { + dispatch(linkAccountPanelActions.HAS_SESSION_DATA()); + } dispatch(initSidePanelTree()); if (router.location) { @@ -169,10 +181,19 @@ export const loadTrash = () => dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH)); }); +export const loadAllProcesses = () => + handleFirstTimeLoad( + (dispatch: Dispatch) => { + dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.ALL_PROCESSES)); + dispatch(loadAllProcessesPanel()); + dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.ALL_PROCESSES)); + } + ); + export const loadProject = (uuid: string) => handleFirstTimeLoad( async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const userUuid = services.authService.getUuid(); + const userUuid = getUserUuid(getState()); dispatch(setIsProjectPanelTrashed(false)); if (userUuid) { if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) { @@ -216,7 +237,7 @@ export const createProject = (data: projectCreateActions.ProjectCreateFormDialog kind: SnackbarKind.SUCCESS })); await dispatch(loadSidePanelTreeProjects(newProject.ownerUuid)); - dispatch(reloadProjectMatchingUuid([newProject.ownerUuid])); + dispatch(navigateTo(newProject.uuid)); } }; @@ -255,14 +276,14 @@ export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialog export const loadCollection = (uuid: string) => handleFirstTimeLoad( async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const userUuid = services.authService.getUuid(); + const userUuid = getUserUuid(getState()); if (userUuid) { const match = await loadGroupContentsResource({ uuid, userUuid, services }); match({ OWNED: async collection => { dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource)); dispatch(updateResources([collection])); - await dispatch(activateSidePanelTreeItem(collection.ownerUuid)); + dispatch(activateSidePanelTreeItem(collection.ownerUuid)); dispatch(setSidePanelBreadcrumbs(collection.ownerUuid)); dispatch(loadCollectionPanel(collection.uuid)); }, @@ -280,7 +301,6 @@ export const loadCollection = (uuid: string) => dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH)); dispatch(loadCollectionPanel(collection.uuid)); }, - }); } }); @@ -295,21 +315,25 @@ export const createCollection = (data: collectionCreateActions.CollectionCreateF kind: SnackbarKind.SUCCESS })); dispatch(updateResources([collection])); - dispatch(reloadProjectMatchingUuid([collection.ownerUuid])); + dispatch(navigateTo(collection.uuid)); } }; export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) => async (dispatch: Dispatch) => { - const collection = await dispatch(collectionUpdateActions.updateCollection(data)); - if (collection) { - dispatch(snackbarActions.OPEN_SNACKBAR({ - message: "Collection has been successfully updated.", - hideDuration: 2000, - kind: SnackbarKind.SUCCESS - })); - dispatch(updateResources([collection])); - dispatch(reloadProjectMatchingUuid([collection.ownerUuid])); + try { + const collection = await dispatch(collectionUpdateActions.updateCollection(data)); + if (collection) { + dispatch(snackbarActions.OPEN_SNACKBAR({ + message: "Collection has been successfully updated.", + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })); + dispatch(updateResources([collection])); + dispatch(reloadProjectMatchingUuid([collection.ownerUuid])); + } + } catch (e) { + dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors.join(''), hideDuration: 2000, kind: SnackbarKind.ERROR })); } }; @@ -492,6 +516,11 @@ export const loadMyAccount = handleFirstTimeLoad( dispatch(loadMyAccountPanel()); }); +export const loadLinkAccount = handleFirstTimeLoad( + (dispatch: Dispatch) => { + dispatch(loadLinkAccountPanel()); + }); + export const loadKeepServices = handleFirstTimeLoad( async (dispatch: Dispatch) => { await dispatch(loadKeepServicesPanel());