1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } from 'redux';
6 import { RootState } from "~/store/store";
7 import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
8 import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
9 import { favoritePanelActions, loadFavoritePanel } from '~/store/favorite-panel/favorite-panel-action';
11 getProjectPanelCurrentUuid,
14 setIsProjectPanelTrashed
15 } from '~/store/project-panel/project-panel-action';
17 activateSidePanelTreeItem,
19 loadSidePanelTreeProjects,
21 } from '~/store/side-panel-tree/side-panel-tree-actions';
22 import { loadResource, updateResources } from '~/store/resources/resources-actions';
23 import { projectPanelColumns } from '~/views/project-panel/project-panel';
24 import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
25 import { matchRootRoute } from '~/routes/routes';
28 setGroupDetailsBreadcrumbs,
30 setProcessBreadcrumbs,
31 setSharedWithMeBreadcrumbs,
32 setSidePanelBreadcrumbs,
34 } from '~/store/breadcrumbs/breadcrumbs-actions';
35 import { navigateToProject } from '~/store/navigation/navigation-action';
36 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
37 import { ServiceRepository } from '~/services/services';
38 import { getResource } from '~/store/resources/resources';
39 import * as projectCreateActions from '~/store/projects/project-create-actions';
40 import * as projectMoveActions from '~/store/projects/project-move-actions';
41 import * as projectUpdateActions from '~/store/projects/project-update-actions';
42 import * as collectionCreateActions from '~/store/collections/collection-create-actions';
43 import * as collectionCopyActions from '~/store/collections/collection-copy-actions';
44 import * as collectionUpdateActions from '~/store/collections/collection-update-actions';
45 import * as collectionMoveActions from '~/store/collections/collection-move-actions';
46 import * as processesActions from '~/store/processes/processes-actions';
47 import * as processMoveActions from '~/store/processes/process-move-actions';
48 import * as processUpdateActions from '~/store/processes/process-update-actions';
49 import * as processCopyActions from '~/store/processes/process-copy-actions';
50 import { trashPanelColumns } from "~/views/trash-panel/trash-panel";
51 import { loadTrashPanel, trashPanelActions } from "~/store/trash-panel/trash-panel-action";
52 import { initProcessLogsPanel } from '~/store/process-logs-panel/process-logs-panel-actions';
53 import { loadProcessPanel } from '~/store/process-panel/process-panel-actions';
55 loadSharedWithMePanel,
56 sharedWithMePanelActions
57 } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
58 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
59 import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
60 import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh';
61 import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
62 import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
63 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
64 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
65 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
66 import { extractUuidKind, ResourceKind } from '~/models/resource';
67 import { FilterBuilder } from '~/services/api/filter-builder';
68 import { GroupContentsResource } from '~/services/groups-service/groups-service';
69 import { MatchCases, ofType, unionize, UnionOf } from '~/common/unionize';
70 import { loadRunProcessPanel } from '~/store/run-process-panel/run-process-panel-actions';
71 import { loadCollectionFiles } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
72 import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
73 import { CollectionResource } from "~/models/collection";
75 loadSearchResultsPanel,
76 searchResultsPanelActions
77 } from '~/store/search-results-panel/search-results-panel-actions';
78 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
79 import { loadVirtualMachinesPanel } from '~/store/virtual-machines/virtual-machines-actions';
80 import { loadRepositoriesPanel } from '~/store/repositories/repositories-actions';
81 import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
82 import { loadUsersPanel, userBindedActions } from '~/store/users/users-actions';
83 import { linkPanelActions, loadLinkPanel } from '~/store/link-panel/link-panel-actions';
84 import { computeNodesActions, loadComputeNodesPanel } from '~/store/compute-nodes/compute-nodes-actions';
85 import { linkPanelColumns } from '~/views/link-panel/link-panel-root';
86 import { userPanelColumns } from '~/views/user-panel/user-panel';
87 import { computeNodePanelColumns } from '~/views/compute-node-panel/compute-node-panel-root';
88 import { loadApiClientAuthorizationsPanel, apiClientAuthorizationsActions } from '~/store/api-client-authorizations/api-client-authorizations-actions';
89 import { apiClientAuthorizationPanelColumns } from '~/views/api-client-authorization-panel/api-client-authorization-panel-root';
90 import * as groupPanelActions from '~/store/groups-panel/groups-panel-actions';
91 import { groupsPanelColumns } from '~/views/groups-panel/groups-panel';
92 import * as groupDetailsPanelActions from '~/store/group-details-panel/group-details-panel-actions';
93 import { groupDetailsPanelColumns } from '~/views/group-details-panel/group-details-panel';
94 import { DataTableFetchMode } from "~/components/data-table/data-table";
96 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
98 export const isWorkbenchLoading = (state: RootState) => {
99 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
100 return progress ? progress.working : false;
103 const handleFirstTimeLoad = (action: any) =>
104 async (dispatch: Dispatch<any>, getState: () => RootState) => {
106 await dispatch(action);
108 if (isWorkbenchLoading(getState())) {
109 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
114 export const loadWorkbench = () =>
115 async (dispatch: Dispatch, getState: () => RootState) => {
116 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
117 const { auth, router } = getState();
118 const { user } = auth;
120 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
121 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
122 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
123 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
124 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
125 dispatch(searchResultsPanelActions.SET_FETCH_MODE({ fetchMode: DataTableFetchMode.INFINITE }));
126 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
127 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
128 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
129 dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({ columns: groupDetailsPanelColumns }));
130 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
131 dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
132 dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
134 dispatch<any>(initSidePanelTree());
135 if (router.location) {
136 const match = matchRootRoute(router.location.pathname);
138 dispatch(navigateToProject(user.uuid));
142 dispatch(userIsNotAuthenticated);
146 export const loadFavorites = () =>
148 (dispatch: Dispatch) => {
149 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
150 dispatch<any>(loadFavoritePanel());
151 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
154 export const loadTrash = () =>
156 (dispatch: Dispatch) => {
157 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
158 dispatch<any>(loadTrashPanel());
159 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
162 export const loadProject = (uuid: string) =>
164 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
165 const userUuid = services.authService.getUuid();
166 dispatch(setIsProjectPanelTrashed(false));
168 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
169 // Load another users home projects
170 dispatch(finishLoadingProject(uuid));
171 } else if (userUuid !== uuid) {
172 const match = await loadGroupContentsResource({ uuid, userUuid, services });
174 OWNED: async project => {
175 await dispatch(activateSidePanelTreeItem(uuid));
176 dispatch<any>(setSidePanelBreadcrumbs(uuid));
177 dispatch(finishLoadingProject(project));
180 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
181 dispatch(activateSidePanelTreeItem(uuid));
182 dispatch(finishLoadingProject(project));
184 TRASHED: project => {
185 dispatch<any>(setTrashBreadcrumbs(uuid));
186 dispatch(setIsProjectPanelTrashed(true));
187 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
188 dispatch(finishLoadingProject(project));
192 await dispatch(activateSidePanelTreeItem(userUuid));
193 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
194 dispatch(finishLoadingProject(userUuid));
199 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
200 async (dispatch: Dispatch) => {
201 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
203 dispatch(snackbarActions.OPEN_SNACKBAR({
204 message: "Project has been successfully created.",
206 kind: SnackbarKind.SUCCESS
208 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
209 dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
213 export const moveProject = (data: MoveToFormDialogData) =>
214 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
216 const oldProject = getResource(data.uuid)(getState().resources);
217 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
218 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
220 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
222 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
224 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
227 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
231 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
232 async (dispatch: Dispatch) => {
233 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
234 if (updatedProject) {
235 dispatch(snackbarActions.OPEN_SNACKBAR({
236 message: "Project has been successfully updated.",
238 kind: SnackbarKind.SUCCESS
240 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
241 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
245 export const loadCollection = (uuid: string) =>
247 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
248 const userUuid = services.authService.getUuid();
250 const match = await loadGroupContentsResource({ uuid, userUuid, services });
252 OWNED: async collection => {
253 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
254 dispatch(updateResources([collection]));
255 await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
256 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
257 dispatch(loadCollectionFiles(collection.uuid));
259 SHARED: collection => {
260 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
261 dispatch(updateResources([collection]));
262 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
263 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
264 dispatch(loadCollectionFiles(collection.uuid));
266 TRASHED: collection => {
267 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
268 dispatch(updateResources([collection]));
269 dispatch(setTrashBreadcrumbs(''));
270 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
271 dispatch(loadCollectionFiles(collection.uuid));
278 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
279 async (dispatch: Dispatch) => {
280 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
282 dispatch(snackbarActions.OPEN_SNACKBAR({
283 message: "Collection has been successfully created.",
285 kind: SnackbarKind.SUCCESS
287 dispatch<any>(updateResources([collection]));
288 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
292 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
293 async (dispatch: Dispatch) => {
294 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
296 dispatch(snackbarActions.OPEN_SNACKBAR({
297 message: "Collection has been successfully updated.",
299 kind: SnackbarKind.SUCCESS
301 dispatch<any>(updateResources([collection]));
302 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
306 export const copyCollection = (data: CopyFormDialogData) =>
307 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
309 const copyToProject = getResource(data.ownerUuid)(getState().resources);
310 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
311 if (copyToProject && collection) {
312 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
313 dispatch(snackbarActions.OPEN_SNACKBAR({
314 message: 'Collection has been copied.',
316 kind: SnackbarKind.SUCCESS,
317 link: collection.ownerUuid
321 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
325 export const moveCollection = (data: MoveToFormDialogData) =>
326 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
328 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
329 dispatch<any>(updateResources([collection]));
330 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
331 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
333 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
337 export const loadProcess = (uuid: string) =>
339 async (dispatch: Dispatch, getState: () => RootState) => {
340 dispatch<any>(loadProcessPanel(uuid));
341 const process = await dispatch<any>(processesActions.loadProcess(uuid));
342 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
343 dispatch<any>(setProcessBreadcrumbs(uuid));
344 dispatch(loadDetailsPanel(uuid));
347 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
348 async (dispatch: Dispatch) => {
350 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
352 dispatch(snackbarActions.OPEN_SNACKBAR({
353 message: "Process has been successfully updated.",
355 kind: SnackbarKind.SUCCESS
357 dispatch<any>(updateResources([process]));
358 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
361 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
365 export const moveProcess = (data: MoveToFormDialogData) =>
366 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
368 const process = await dispatch<any>(processMoveActions.moveProcess(data));
369 dispatch<any>(updateResources([process]));
370 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
371 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
373 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
377 export const copyProcess = (data: CopyFormDialogData) =>
378 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
380 const process = await dispatch<any>(processCopyActions.copyProcess(data));
381 dispatch<any>(updateResources([process]));
382 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
383 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
385 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
389 export const loadProcessLog = (uuid: string) =>
391 async (dispatch: Dispatch) => {
392 const process = await dispatch<any>(processesActions.loadProcess(uuid));
393 dispatch<any>(setProcessBreadcrumbs(uuid));
394 dispatch<any>(initProcessLogsPanel(uuid));
395 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
398 export const resourceIsNotLoaded = (uuid: string) =>
399 snackbarActions.OPEN_SNACKBAR({
400 message: `Resource identified by ${uuid} is not loaded.`,
401 kind: SnackbarKind.ERROR
404 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
405 message: 'User is not authenticated',
406 kind: SnackbarKind.ERROR
409 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
410 message: 'Could not load user',
411 kind: SnackbarKind.ERROR
414 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
415 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
416 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
417 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
418 dispatch<any>(loadProject(currentProjectPanelUuid));
422 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
423 dispatch<any>(loadSharedWithMePanel());
424 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
425 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
428 export const loadRunProcess = handleFirstTimeLoad(
429 async (dispatch: Dispatch) => {
430 await dispatch<any>(loadRunProcessPanel());
434 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
435 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
436 await dispatch(loadWorkflowPanel());
437 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
440 export const loadSearchResults = handleFirstTimeLoad(
441 async (dispatch: Dispatch<any>) => {
442 await dispatch(loadSearchResultsPanel());
445 export const loadLinks = handleFirstTimeLoad(
446 async (dispatch: Dispatch<any>) => {
447 await dispatch(loadLinkPanel());
450 export const loadVirtualMachines = handleFirstTimeLoad(
451 async (dispatch: Dispatch<any>) => {
452 await dispatch(loadVirtualMachinesPanel());
453 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
456 export const loadRepositories = handleFirstTimeLoad(
457 async (dispatch: Dispatch<any>) => {
458 await dispatch(loadRepositoriesPanel());
459 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
462 export const loadSshKeys = handleFirstTimeLoad(
463 async (dispatch: Dispatch<any>) => {
464 await dispatch(loadSshKeysPanel());
467 export const loadSiteManager = handleFirstTimeLoad(
468 async (dispatch: Dispatch<any>) => {
469 await dispatch(loadSiteManagerPanel());
472 export const loadMyAccount = handleFirstTimeLoad(
473 (dispatch: Dispatch<any>) => {
474 dispatch(loadMyAccountPanel());
477 export const loadKeepServices = handleFirstTimeLoad(
478 async (dispatch: Dispatch<any>) => {
479 await dispatch(loadKeepServicesPanel());
482 export const loadUsers = handleFirstTimeLoad(
483 async (dispatch: Dispatch<any>) => {
484 await dispatch(loadUsersPanel());
485 dispatch(setBreadcrumbs([{ label: 'Users' }]));
488 export const loadComputeNodes = handleFirstTimeLoad(
489 async (dispatch: Dispatch<any>) => {
490 await dispatch(loadComputeNodesPanel());
493 export const loadApiClientAuthorizations = handleFirstTimeLoad(
494 async (dispatch: Dispatch<any>) => {
495 await dispatch(loadApiClientAuthorizationsPanel());
498 export const loadGroupsPanel = handleFirstTimeLoad(
499 (dispatch: Dispatch<any>) => {
500 dispatch(setGroupsBreadcrumbs());
501 dispatch(groupPanelActions.loadGroupsPanel());
505 export const loadGroupDetailsPanel = (groupUuid: string) =>
507 (dispatch: Dispatch<any>) => {
508 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
509 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
512 const finishLoadingProject = (project: GroupContentsResource | string) =>
513 async (dispatch: Dispatch<any>) => {
514 const uuid = typeof project === 'string' ? project : project.uuid;
515 dispatch(openProjectPanel(uuid));
516 dispatch(loadDetailsPanel(uuid));
517 if (typeof project !== 'string') {
518 dispatch(updateResources([project]));
522 const loadGroupContentsResource = async (params: {
525 services: ServiceRepository
527 const filters = new FilterBuilder()
528 .addEqual('uuid', params.uuid)
530 const { items } = await params.services.groupsService.contents(params.userUuid, {
535 const resource = items.shift();
536 let handler: GroupContentsHandler;
538 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
539 ? groupContentsHandlers.TRASHED(resource)
540 : groupContentsHandlers.OWNED(resource);
542 const kind = extractUuidKind(params.uuid);
543 let resource: GroupContentsResource;
544 if (kind === ResourceKind.COLLECTION) {
545 resource = await params.services.collectionService.get(params.uuid);
546 } else if (kind === ResourceKind.PROJECT) {
547 resource = await params.services.projectService.get(params.uuid);
549 resource = await params.services.containerRequestService.get(params.uuid);
551 handler = groupContentsHandlers.SHARED(resource);
553 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
554 groupContentsHandlers.match(handler, cases);
558 const groupContentsHandlersRecord = {
559 TRASHED: ofType<GroupContentsResource>(),
560 SHARED: ofType<GroupContentsResource>(),
561 OWNED: ofType<GroupContentsResource>(),
564 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
566 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;