Setup navigation and create slot for groups panel
[arvados-workbench2.git] / src / store / workbench / workbench-actions.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 { RootState } from "~/store/store";
7 import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
8 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
9 import { loadFavoritePanel } from '~/store/favorite-panel/favorite-panel-action';
10 import { openProjectPanel, projectPanelActions, setIsProjectPanelTrashed } from '~/store/project-panel/project-panel-action';
11 import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory, loadSidePanelTreeProjects } from '~/store/side-panel-tree/side-panel-tree-actions';
12 import { loadResource, updateResources } from '~/store/resources/resources-actions';
13 import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
14 import { projectPanelColumns } from '~/views/project-panel/project-panel';
15 import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
16 import { matchRootRoute } from '~/routes/routes';
17 import { setSidePanelBreadcrumbs, setProcessBreadcrumbs, setSharedWithMeBreadcrumbs, setTrashBreadcrumbs, setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
18 import { navigateToProject } from '~/store/navigation/navigation-action';
19 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
20 import { ServiceRepository } from '~/services/services';
21 import { getResource } from '~/store/resources/resources';
22 import { getProjectPanelCurrentUuid } from '~/store/project-panel/project-panel-action';
23 import * as projectCreateActions from '~/store/projects/project-create-actions';
24 import * as projectMoveActions from '~/store/projects/project-move-actions';
25 import * as projectUpdateActions from '~/store/projects/project-update-actions';
26 import * as collectionCreateActions from '~/store/collections/collection-create-actions';
27 import * as collectionCopyActions from '~/store/collections/collection-copy-actions';
28 import * as collectionUpdateActions from '~/store/collections/collection-update-actions';
29 import * as collectionMoveActions from '~/store/collections/collection-move-actions';
30 import * as processesActions from '~/store/processes/processes-actions';
31 import * as processMoveActions from '~/store/processes/process-move-actions';
32 import * as processUpdateActions from '~/store/processes/process-update-actions';
33 import * as processCopyActions from '~/store/processes/process-copy-actions';
34 import { trashPanelColumns } from "~/views/trash-panel/trash-panel";
35 import { loadTrashPanel, trashPanelActions } from "~/store/trash-panel/trash-panel-action";
36 import { initProcessLogsPanel } from '~/store/process-logs-panel/process-logs-panel-actions';
37 import { loadProcessPanel } from '~/store/process-panel/process-panel-actions';
38 import { sharedWithMePanelActions } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
39 import { loadSharedWithMePanel } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
40 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
41 import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
42 import { loadSshKeysPanel } from '~/store/auth/auth-action';
43 import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
44 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
45 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
46 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
47 import { ResourceKind, extractUuidKind } from '~/models/resource';
48 import { FilterBuilder } from '~/services/api/filter-builder';
49 import { GroupContentsResource } from '~/services/groups-service/groups-service';
50 import { unionize, ofType, UnionOf, MatchCases } from '~/common/unionize';
51 import { loadRunProcessPanel } from '~/store/run-process-panel/run-process-panel-actions';
52 import { loadCollectionFiles } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
53 import { SnackbarKind } from '~/store/snackbar/snackbar-actions';
54 import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
55 import { CollectionResource } from "~/models/collection";
56 import { searchResultsPanelActions, loadSearchResultsPanel } from '~/store/search-results-panel/search-results-panel-actions';
57 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
58 import { loadVirtualMachinesPanel } from '~/store/virtual-machines/virtual-machines-actions';
59 import { loadRepositoriesPanel } from '~/store/repositories/repositories-actions';
60 import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
61 import { loadUsersPanel, userBindedActions } from '~/store/users/users-actions';
62 import { userPanelColumns } from '~/views/user-panel/user-panel';
63 import { loadComputeNodesPanel } from '~/store/compute-nodes/compute-nodes-actions';
64 import { loadApiClientAuthorizationsPanel } from '~/store/api-client-authorizations/api-client-authorizations-actions';
65
66 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
67
68 export const isWorkbenchLoading = (state: RootState) => {
69     const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
70     return progress ? progress.working : false;
71 };
72
73 const handleFirstTimeLoad = (action: any) =>
74     async (dispatch: Dispatch<any>, getState: () => RootState) => {
75         try {
76             await dispatch(action);
77         } finally {
78             if (isWorkbenchLoading(getState())) {
79                 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
80             }
81         }
82     };
83
84 export const loadWorkbench = () =>
85     async (dispatch: Dispatch, getState: () => RootState) => {
86         dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
87         const { auth, router } = getState();
88         const { user } = auth;
89         if (user) {
90             const userResource = await dispatch<any>(loadResource(user.uuid));
91             if (userResource) {
92                 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
93                 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
94                 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
95                 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
96                 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
97                 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
98                 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
99                 dispatch<any>(initSidePanelTree());
100                 if (router.location) {
101                     const match = matchRootRoute(router.location.pathname);
102                     if (match) {
103                         dispatch(navigateToProject(userResource.uuid));
104                     }
105                 }
106             } else {
107                 dispatch(userIsNotAuthenticated);
108             }
109         } else {
110             dispatch(userIsNotAuthenticated);
111         }
112     };
113
114 export const loadFavorites = () =>
115     handleFirstTimeLoad(
116         (dispatch: Dispatch) => {
117             dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
118             dispatch<any>(loadFavoritePanel());
119             dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
120         });
121
122 export const loadTrash = () =>
123     handleFirstTimeLoad(
124         (dispatch: Dispatch) => {
125             dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
126             dispatch<any>(loadTrashPanel());
127             dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
128         });
129
130 export const loadProject = (uuid: string) =>
131     handleFirstTimeLoad(
132         async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
133             const userUuid = services.authService.getUuid();
134             dispatch(setIsProjectPanelTrashed(false));
135             if (userUuid) {
136                 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
137                     // Load another users home projects
138                     dispatch(finishLoadingProject(uuid));
139                 } else if (userUuid !== uuid) {
140                     const match = await loadGroupContentsResource({ uuid, userUuid, services });
141                     match({
142                         OWNED: async project => {
143                             await dispatch(activateSidePanelTreeItem(uuid));
144                             dispatch<any>(setSidePanelBreadcrumbs(uuid));
145                             dispatch(finishLoadingProject(project));
146                         },
147                         SHARED: project => {
148                             dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
149                             dispatch(activateSidePanelTreeItem(uuid));
150                             dispatch(finishLoadingProject(project));
151                         },
152                         TRASHED: project => {
153                             dispatch<any>(setTrashBreadcrumbs(uuid));
154                             dispatch(setIsProjectPanelTrashed(true));
155                             dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
156                             dispatch(finishLoadingProject(project));
157                         }
158                     });
159                 } else {
160                     await dispatch(activateSidePanelTreeItem(userUuid));
161                     dispatch<any>(setSidePanelBreadcrumbs(userUuid));
162                     dispatch(finishLoadingProject(userUuid));
163                 }
164             }
165         });
166
167 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
168     async (dispatch: Dispatch) => {
169         const newProject = await dispatch<any>(projectCreateActions.createProject(data));
170         if (newProject) {
171             dispatch(snackbarActions.OPEN_SNACKBAR({
172                 message: "Project has been successfully created.",
173                 hideDuration: 2000
174             }));
175             await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
176             dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
177         }
178     };
179
180 export const moveProject = (data: MoveToFormDialogData) =>
181     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
182         try {
183             const oldProject = getResource(data.uuid)(getState().resources);
184             const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
185             const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
186             if (movedProject) {
187                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000 }));
188                 if (oldProject) {
189                     await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
190                 }
191                 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
192             }
193         } catch (e) {
194             dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
195         }
196     };
197
198 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
199     async (dispatch: Dispatch) => {
200         const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
201         if (updatedProject) {
202             dispatch(snackbarActions.OPEN_SNACKBAR({
203                 message: "Project has been successfully updated.",
204                 hideDuration: 2000
205             }));
206             await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
207             dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
208         }
209     };
210
211 export const loadCollection = (uuid: string) =>
212     handleFirstTimeLoad(
213         async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
214             const userUuid = services.authService.getUuid();
215             if (userUuid) {
216                 const match = await loadGroupContentsResource({ uuid, userUuid, services });
217                 match({
218                     OWNED: async collection => {
219                         dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
220                         dispatch(updateResources([collection]));
221                         await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
222                         dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
223                         dispatch(loadCollectionFiles(collection.uuid));
224                     },
225                     SHARED: collection => {
226                         dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
227                         dispatch(updateResources([collection]));
228                         dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
229                         dispatch(activateSidePanelTreeItem(collection.ownerUuid));
230                         dispatch(loadCollectionFiles(collection.uuid));
231                     },
232                     TRASHED: collection => {
233                         dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
234                         dispatch(updateResources([collection]));
235                         dispatch(setTrashBreadcrumbs(''));
236                         dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
237                         dispatch(loadCollectionFiles(collection.uuid));
238                     },
239
240                 });
241             }
242         });
243
244 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
245     async (dispatch: Dispatch) => {
246         const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
247         if (collection) {
248             dispatch(snackbarActions.OPEN_SNACKBAR({
249                 message: "Collection has been successfully created.",
250                 hideDuration: 2000
251             }));
252             dispatch<any>(updateResources([collection]));
253             dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
254         }
255     };
256
257 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
258     async (dispatch: Dispatch) => {
259         const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
260         if (collection) {
261             dispatch(snackbarActions.OPEN_SNACKBAR({
262                 message: "Collection has been successfully updated.",
263                 hideDuration: 2000
264             }));
265             dispatch<any>(updateResources([collection]));
266             dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
267         }
268     };
269
270 export const copyCollection = (data: CopyFormDialogData) =>
271     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
272         try {
273             const copyToProject = getResource(data.ownerUuid)(getState().resources);
274             const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
275             if (copyToProject && collection) {
276                 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
277                 dispatch(snackbarActions.OPEN_SNACKBAR({
278                     message: 'Collection has been copied.',
279                     hideDuration: 3000,
280                     kind: SnackbarKind.SUCCESS,
281                     link: collection.ownerUuid
282                 }));
283             }
284         } catch (e) {
285             dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
286         }
287     };
288
289 export const moveCollection = (data: MoveToFormDialogData) =>
290     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
291         try {
292             const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
293             dispatch<any>(updateResources([collection]));
294             dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
295             dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
296         } catch (e) {
297             dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
298         }
299     };
300
301 export const loadProcess = (uuid: string) =>
302     handleFirstTimeLoad(
303         async (dispatch: Dispatch, getState: () => RootState) => {
304             dispatch<any>(loadProcessPanel(uuid));
305             const process = await dispatch<any>(processesActions.loadProcess(uuid));
306             await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
307             dispatch<any>(setProcessBreadcrumbs(uuid));
308             dispatch(loadDetailsPanel(uuid));
309         });
310
311 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
312     async (dispatch: Dispatch) => {
313         try {
314             const process = await dispatch<any>(processUpdateActions.updateProcess(data));
315             if (process) {
316                 dispatch(snackbarActions.OPEN_SNACKBAR({
317                     message: "Process has been successfully updated.",
318                     hideDuration: 2000
319                 }));
320                 dispatch<any>(updateResources([process]));
321                 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
322             }
323         } catch (e) {
324             dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
325         }
326     };
327
328 export const moveProcess = (data: MoveToFormDialogData) =>
329     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
330         try {
331             const process = await dispatch<any>(processMoveActions.moveProcess(data));
332             dispatch<any>(updateResources([process]));
333             dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
334             dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000 }));
335         } catch (e) {
336             dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
337         }
338     };
339
340 export const copyProcess = (data: CopyFormDialogData) =>
341     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
342         try {
343             const process = await dispatch<any>(processCopyActions.copyProcess(data));
344             dispatch<any>(updateResources([process]));
345             dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
346             dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000 }));
347         } catch (e) {
348             dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
349         }
350     };
351
352 export const loadProcessLog = (uuid: string) =>
353     handleFirstTimeLoad(
354         async (dispatch: Dispatch) => {
355             const process = await dispatch<any>(processesActions.loadProcess(uuid));
356             dispatch<any>(setProcessBreadcrumbs(uuid));
357             dispatch<any>(initProcessLogsPanel(uuid));
358             await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
359         });
360
361 export const resourceIsNotLoaded = (uuid: string) =>
362     snackbarActions.OPEN_SNACKBAR({
363         message: `Resource identified by ${uuid} is not loaded.`
364     });
365
366 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
367     message: 'User is not authenticated'
368 });
369
370 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
371     message: 'Could not load user'
372 });
373
374 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
375     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
376         const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
377         if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
378             dispatch<any>(loadProject(currentProjectPanelUuid));
379         }
380     };
381
382 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
383     dispatch<any>(loadSharedWithMePanel());
384     await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
385     await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
386 });
387
388 export const loadRunProcess = handleFirstTimeLoad(
389     async (dispatch: Dispatch) => {
390         await dispatch<any>(loadRunProcessPanel());
391     }
392 );
393
394 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
395     dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
396     await dispatch(loadWorkflowPanel());
397     dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
398 });
399
400 export const loadSearchResults = handleFirstTimeLoad(
401     async (dispatch: Dispatch<any>) => {
402         await dispatch(loadSearchResultsPanel());
403     });
404
405 export const loadVirtualMachines = handleFirstTimeLoad(
406     async (dispatch: Dispatch<any>) => {
407         await dispatch(loadVirtualMachinesPanel());
408         dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
409     });
410
411 export const loadRepositories = handleFirstTimeLoad(
412     async (dispatch: Dispatch<any>) => {
413         await dispatch(loadRepositoriesPanel());
414         dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
415     });
416
417 export const loadSshKeys = handleFirstTimeLoad(
418     async (dispatch: Dispatch<any>) => {
419         await dispatch(loadSshKeysPanel());
420     });
421
422 export const loadMyAccount = handleFirstTimeLoad(
423     (dispatch: Dispatch<any>) => {
424         dispatch(loadMyAccountPanel());
425     });
426
427 export const loadKeepServices = handleFirstTimeLoad(
428     async (dispatch: Dispatch<any>) => {
429         await dispatch(loadKeepServicesPanel());
430     });
431
432 export const loadUsers = handleFirstTimeLoad(
433     async (dispatch: Dispatch<any>) => {
434         await dispatch(loadUsersPanel());
435         dispatch(setBreadcrumbs([{ label: 'Users' }]));
436     });
437
438 export const loadComputeNodes = handleFirstTimeLoad(
439     async (dispatch: Dispatch<any>) => {
440         await dispatch(loadComputeNodesPanel());
441     });
442
443 export const loadApiClientAuthorizations = handleFirstTimeLoad(
444     async (dispatch: Dispatch<any>) => {
445         await dispatch(loadApiClientAuthorizationsPanel());
446     });
447
448 export const loadGroupsPanel = handleFirstTimeLoad(
449     (dispatch: Dispatch<any>) => {
450         dispatch(setBreadcrumbs([{ label: 'Groups' }]));
451     });
452
453 const finishLoadingProject = (project: GroupContentsResource | string) =>
454     async (dispatch: Dispatch<any>) => {
455         const uuid = typeof project === 'string' ? project : project.uuid;
456         dispatch(openProjectPanel(uuid));
457         dispatch(loadDetailsPanel(uuid));
458         if (typeof project !== 'string') {
459             dispatch(updateResources([project]));
460         }
461     };
462
463 const loadGroupContentsResource = async (params: {
464     uuid: string,
465     userUuid: string,
466     services: ServiceRepository
467 }) => {
468     const filters = new FilterBuilder()
469         .addEqual('uuid', params.uuid)
470         .getFilters();
471     const { items } = await params.services.groupsService.contents(params.userUuid, {
472         filters,
473         recursive: true,
474         includeTrash: true,
475     });
476     const resource = items.shift();
477     let handler: GroupContentsHandler;
478     if (resource) {
479         handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
480             ? groupContentsHandlers.TRASHED(resource)
481             : groupContentsHandlers.OWNED(resource);
482     } else {
483         const kind = extractUuidKind(params.uuid);
484         let resource: GroupContentsResource;
485         if (kind === ResourceKind.COLLECTION) {
486             resource = await params.services.collectionService.get(params.uuid);
487         } else if (kind === ResourceKind.PROJECT) {
488             resource = await params.services.projectService.get(params.uuid);
489         } else {
490             resource = await params.services.containerRequestService.get(params.uuid);
491         }
492         handler = groupContentsHandlers.SHARED(resource);
493     }
494     return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
495         groupContentsHandlers.match(handler, cases);
496
497 };
498
499 const groupContentsHandlersRecord = {
500     TRASHED: ofType<GroupContentsResource>(),
501     SHARED: ofType<GroupContentsResource>(),
502     OWNED: ofType<GroupContentsResource>(),
503 };
504
505 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
506
507 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;