1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch, compose } from 'redux';
6 import { push } from "react-router-redux";
7 import { ResourceKind, extractUuidKind } from '~/models/resource';
8 import { getCollectionUrl } from "~/models/collection";
9 import { getProjectUrl } from "~/models/project";
11 import { SidePanelTreeCategory } from '../side-panel-tree/side-panel-tree-actions';
12 import { Routes, getProcessUrl } from '~/routes/routes';
14 export const navigateTo = (uuid: string) =>
15 async (dispatch: Dispatch) => {
16 const kind = extractUuidKind(uuid);
17 if (kind === ResourceKind.PROJECT || kind === ResourceKind.USER) {
18 dispatch<any>(navigateToProject(uuid));
19 } else if (kind === ResourceKind.COLLECTION) {
20 dispatch<any>(navigateToCollection(uuid));
21 } else if (kind === ResourceKind.CONTAINER_REQUEST) {
22 dispatch<any>(navigateToProcess(uuid));
24 if (uuid === SidePanelTreeCategory.FAVORITES) {
25 dispatch<any>(navigateToFavorites);
29 export const navigateToFavorites = push(Routes.FAVORITES);
31 export const navigateToProject = compose(push, getProjectUrl);
33 export const navigateToCollection = compose(push, getCollectionUrl);
35 export const navigateToProcess = compose(push, getProcessUrl);