17119: add basic filter group support.
[arvados.git] / src / store / side-panel / side-panel-action.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from 'redux';
6 import { isSidePanelTreeCategory, SidePanelTreeCategory } from '~/store/side-panel-tree/side-panel-tree-actions';
7 import { navigateToFavorites, navigateTo, navigateToTrash, navigateToSharedWithMe, navigateToWorkflows, navigateToPublicFavorites, navigateToAllProcesses } from '~/store/navigation/navigation-action';
8 import {snackbarActions, SnackbarKind} from '~/store/snackbar/snackbar-actions';
9
10 export const navigateFromSidePanel = (id: string) =>
11     (dispatch: Dispatch) => {
12         if (isSidePanelTreeCategory(id)) {
13             dispatch<any>(getSidePanelTreeCategoryAction(id));
14         } else {
15             dispatch<any>(navigateTo(id));
16         }
17     };
18
19 const getSidePanelTreeCategoryAction = (id: string) => {
20     switch (id) {
21         case SidePanelTreeCategory.FAVORITES:
22             return navigateToFavorites;
23         case SidePanelTreeCategory.PUBLIC_FAVORITES:
24             return navigateToPublicFavorites;
25         case SidePanelTreeCategory.TRASH:
26             return navigateToTrash;
27         case SidePanelTreeCategory.SHARED_WITH_ME:
28             return navigateToSharedWithMe;
29         case SidePanelTreeCategory.WORKFLOWS:
30             return navigateToWorkflows;
31         case SidePanelTreeCategory.ALL_PROCESSES:
32             return navigateToAllProcesses;
33         default:
34             return sidePanelTreeCategoryNotAvailable(id);
35     }
36 };
37
38 const sidePanelTreeCategoryNotAvailable = (id: string) =>
39     snackbarActions.OPEN_SNACKBAR({
40         message: `${id} not available`,
41         hideDuration: 3000,
42         kind: SnackbarKind.ERROR
43     });