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 } 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));
22 if (uuid === SidePanelTreeCategory.FAVORITES) {
23 dispatch<any>(navigateToFavorites);
27 export const navigateToFavorites = push(Routes.FAVORITES);
29 export const navigateToProject = compose(push, getProjectUrl);
31 export const navigateToCollection = compose(push, getCollectionUrl);