Update navigation with processes
[arvados-workbench2.git] / src / routes / routes.ts
index 0bf7110126df7849f4571cfbe6e2c21dffa49fdd..c46239e2a1cbe5deeff10fc60b42718181c82817 100644 (file)
@@ -31,6 +31,8 @@ export const getResourceUrl = (uuid: string) => {
     }
 };
 
+export const getProcessUrl = (uuid: string) => `/processes/${uuid}`;
+
 export const addRouteChangeHandlers = (history: History, store: RootStore) => {
     const handler = handleLocationChange(store);
     handler(history.location);
@@ -43,30 +45,32 @@ export const matchRootRoute = (route: string) =>
 export const matchFavoritesRoute = (route: string) =>
     matchPath(route, { path: Routes.FAVORITES });
 
-export interface ProjectRouteParams {
+export interface ResourceRouteParams {
     id: string;
 }
 
 export const matchProjectRoute = (route: string) =>
-    matchPath<ProjectRouteParams>(route, { path: Routes.PROJECTS });
-
-export interface CollectionRouteParams {
-    id: string;
-}
+    matchPath<ResourceRouteParams>(route, { path: Routes.PROJECTS });
 
 export const matchCollectionRoute = (route: string) =>
-    matchPath<CollectionRouteParams>(route, { path: Routes.COLLECTIONS });
+    matchPath<ResourceRouteParams>(route, { path: Routes.COLLECTIONS });
+
+export const matchProcessRoute = (route: string) =>
+    matchPath<ResourceRouteParams>(route, { path: Routes.COLLECTIONS });
 
 
 const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const projectMatch = matchProjectRoute(pathname);
     const collectionMatch = matchCollectionRoute(pathname);
     const favoriteMatch = matchFavoritesRoute(pathname);
+    const processMatch = matchProcessRoute(pathname);
     if (projectMatch) {
         store.dispatch(loadProject(projectMatch.params.id));
     } else if (collectionMatch) {
         store.dispatch(loadCollection(collectionMatch.params.id));
     } else if (favoriteMatch) {
         store.dispatch(loadFavorites());
+    } else if (processMatch) {
+        store.dispatch(processMatch.params.id);
     }
 };