X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/02fe86a56f080ed1d5770ad6c6856a15f50ab508..b1250d13a43d4351c6cbca7990c996b3219693d0:/src/store/navigation/navigation-action.ts diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts index f2f1cea6..d663ae37 100644 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@ -14,26 +14,45 @@ import { GROUPS_PANEL_LABEL } from '~/store/breadcrumbs/breadcrumbs-actions'; export const navigateTo = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState) => { const kind = extractUuidKind(uuid); - if (kind === ResourceKind.PROJECT || kind === ResourceKind.USER || kind === ResourceKind.COLLECTION || kind === ResourceKind.CONTAINER_REQUEST) { - dispatch(pushOrGoto(getNavUrl(uuid, getState().auth))); - } else if (kind === ResourceKind.VIRTUAL_MACHINE) { - dispatch(navigateToAdminVirtualMachines); + switch (kind) { + case ResourceKind.PROJECT: + case ResourceKind.USER: + case ResourceKind.COLLECTION: + case ResourceKind.CONTAINER_REQUEST: + dispatch(pushOrGoto(getNavUrl(uuid, getState().auth))); + return; + case ResourceKind.VIRTUAL_MACHINE: + dispatch(navigateToAdminVirtualMachines); + return; } - if (uuid === SidePanelTreeCategory.FAVORITES) { - dispatch(navigateToFavorites); - } else if (uuid === SidePanelTreeCategory.PUBLIC_FAVORITES) { - dispatch(navigateToPublicFavorites); - } else if (uuid === SidePanelTreeCategory.SHARED_WITH_ME) { - dispatch(navigateToSharedWithMe); - } else if (uuid === SidePanelTreeCategory.WORKFLOWS) { - dispatch(navigateToWorkflows); - } else if (uuid === SidePanelTreeCategory.TRASH) { - dispatch(navigateToTrash); - } else if (uuid === GROUPS_PANEL_LABEL) { - dispatch(navigateToGroups); + + switch (uuid) { + case SidePanelTreeCategory.FAVORITES: + dispatch(navigateToFavorites); + return; + case SidePanelTreeCategory.PUBLIC_FAVORITES: + dispatch(navigateToPublicFavorites); + return; + case SidePanelTreeCategory.SHARED_WITH_ME: + dispatch(navigateToSharedWithMe); + return; + case SidePanelTreeCategory.WORKFLOWS: + dispatch(navigateToWorkflows); + return; + case SidePanelTreeCategory.TRASH: + dispatch(navigateToTrash); + return; + case GROUPS_PANEL_LABEL: + dispatch(navigateToGroups); + return; + case SidePanelTreeCategory.ALL_PROCESSES: + dispatch(navigateToAllProcesses); + return; } }; +export const navigateToNotFound = push(Routes.NO_MATCH); + export const navigateToRoot = push(Routes.ROOT); export const navigateToFavorites = push(Routes.FAVORITES); @@ -59,9 +78,9 @@ export const pushOrGoto = (url: string): AnyAction => { export const navigateToProcessLogs = compose(push, getProcessLogUrl); export const navigateToRootProject = (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const rootProjectUuid = services.authService.getUuid(); - if (rootProjectUuid) { - dispatch(navigateTo(rootProjectUuid)); + const usr = getState().auth.user; + if (usr) { + dispatch(navigateTo(usr.uuid)); } }; @@ -69,7 +88,13 @@ export const navigateToSharedWithMe = push(Routes.SHARED_WITH_ME); export const navigateToRunProcess = push(Routes.RUN_PROCESS); -export const navigateToSearchResults = push(Routes.SEARCH_RESULTS); +export const navigateToSearchResults = (searchValue: string) => { + if (searchValue !== "") { + return push({ pathname: Routes.SEARCH_RESULTS, search: '?q=' + encodeURIComponent(searchValue) }); + } else { + return push({ pathname: Routes.SEARCH_RESULTS }); + } +}; export const navigateToUserVirtualMachines = push(Routes.VIRTUAL_MACHINES_USER); @@ -102,3 +127,5 @@ export const navigateToGroupDetails = compose(push, getGroupUrl); export const navigateToLinks = push(Routes.LINKS); export const navigateToCollectionsContentAddress = push(Routes.COLLECTIONS_CONTENT_ADDRESS); + +export const navigateToAllProcesses = push(Routes.ALL_PROCESSES);