Set up data explorer for group details panel
[arvados-workbench2.git] / src / routes / route-change-handlers.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { History, Location } from 'history';
6 import { RootStore } from '~/store/store';
7 import * as Routes from '~/routes/routes';
8 import * as WorkbenchActions from '~/store/workbench/workbench-actions';
9 import { navigateToRootProject } from '~/store/navigation/navigation-action';
10
11 export const addRouteChangeHandlers = (history: History, store: RootStore) => {
12     const handler = handleLocationChange(store);
13     handler(history.location);
14     history.listen(handler);
15 };
16
17 const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
18     const rootMatch = Routes.matchRootRoute(pathname);
19     const projectMatch = Routes.matchProjectRoute(pathname);
20     const collectionMatch = Routes.matchCollectionRoute(pathname);
21     const favoriteMatch = Routes.matchFavoritesRoute(pathname);
22     const trashMatch = Routes.matchTrashRoute(pathname);
23     const processMatch = Routes.matchProcessRoute(pathname);
24     const processLogMatch = Routes.matchProcessLogRoute(pathname);
25     const repositoryMatch = Routes.matchRepositoriesRoute(pathname);
26     const searchResultsMatch = Routes.matchSearchResultsRoute(pathname);
27     const sharedWithMeMatch = Routes.matchSharedWithMeRoute(pathname);
28     const runProcessMatch = Routes.matchRunProcessRoute(pathname);
29     const virtualMachineMatch = Routes.matchVirtualMachineRoute(pathname);
30     const workflowMatch = Routes.matchWorkflowRoute(pathname);
31     const sshKeysMatch = Routes.matchSshKeysRoute(pathname);
32     const keepServicesMatch = Routes.matchKeepServicesRoute(pathname);
33     const computeNodesMatch = Routes.matchComputeNodesRoute(pathname);
34     const apiClientAuthorizationsMatch = Routes.matchApiClientAuthorizationsRoute(pathname);
35     const myAccountMatch = Routes.matchMyAccountRoute(pathname);
36     const userMatch = Routes.matchUsersRoute(pathname);
37     const groupsMatch = Routes.matchGroupsRoute(pathname);
38     const groupDetailsMatch = Routes.matchGroupDetailsRoute(pathname);
39
40     if (projectMatch) {
41         store.dispatch(WorkbenchActions.loadProject(projectMatch.params.id));
42     } else if (collectionMatch) {
43         store.dispatch(WorkbenchActions.loadCollection(collectionMatch.params.id));
44     } else if (favoriteMatch) {
45         store.dispatch(WorkbenchActions.loadFavorites());
46     } else if (trashMatch) {
47         store.dispatch(WorkbenchActions.loadTrash());
48     } else if (processMatch) {
49         store.dispatch(WorkbenchActions.loadProcess(processMatch.params.id));
50     } else if (processLogMatch) {
51         store.dispatch(WorkbenchActions.loadProcessLog(processLogMatch.params.id));
52     } else if (rootMatch) {
53         store.dispatch(navigateToRootProject);
54     } else if (sharedWithMeMatch) {
55         store.dispatch(WorkbenchActions.loadSharedWithMe);
56     } else if (runProcessMatch) {
57         store.dispatch(WorkbenchActions.loadRunProcess);
58     } else if (workflowMatch) {
59         store.dispatch(WorkbenchActions.loadWorkflow);
60     } else if (searchResultsMatch) {
61         store.dispatch(WorkbenchActions.loadSearchResults);
62     } else if (virtualMachineMatch) {
63         store.dispatch(WorkbenchActions.loadVirtualMachines);
64     } else if(repositoryMatch) {
65         store.dispatch(WorkbenchActions.loadRepositories);
66     } else if (sshKeysMatch) {
67         store.dispatch(WorkbenchActions.loadSshKeys);
68     } else if (keepServicesMatch) {
69         store.dispatch(WorkbenchActions.loadKeepServices);
70     } else if (computeNodesMatch) {
71         store.dispatch(WorkbenchActions.loadComputeNodes);
72     } else if (apiClientAuthorizationsMatch) {
73         store.dispatch(WorkbenchActions.loadApiClientAuthorizations);
74     } else if (myAccountMatch) {
75         store.dispatch(WorkbenchActions.loadMyAccount);
76     }else if (userMatch) {
77         store.dispatch(WorkbenchActions.loadUsers);
78     } else if (groupsMatch) {
79         store.dispatch(WorkbenchActions.loadGroupsPanel);
80     } else if (groupDetailsMatch) {
81         store.dispatch(WorkbenchActions.loadGroupDetailsPanel(groupDetailsMatch.params.id));
82     }
83 };