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 } 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, setGroupDetailsBreadcrumbs, setGroupsBreadcrumbs } 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-ssh';
43 import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
44 import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
45 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
46 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
47 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
48 import { ResourceKind, extractUuidKind } from '~/models/resource';
49 import { FilterBuilder } from '~/services/api/filter-builder';
50 import { GroupContentsResource } from '~/services/groups-service/groups-service';
51 import { unionize, ofType, UnionOf, MatchCases } from '~/common/unionize';
52 import { loadRunProcessPanel } from '~/store/run-process-panel/run-process-panel-actions';
53 import { loadCollectionFiles } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
54 import { SnackbarKind } from '~/store/snackbar/snackbar-actions';
55 import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
56 import { CollectionResource } from "~/models/collection";
57 import { searchResultsPanelActions, loadSearchResultsPanel } from '~/store/search-results-panel/search-results-panel-actions';
58 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
59 import { loadVirtualMachinesPanel } from '~/store/virtual-machines/virtual-machines-actions';
60 import { loadRepositoriesPanel } from '~/store/repositories/repositories-actions';
61 import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
62 import { loadUsersPanel, userBindedActions } from '~/store/users/users-actions';
63 import { loadLinkPanel, linkPanelActions } from '~/store/link-panel/link-panel-actions';
64 import { loadComputeNodesPanel, computeNodesActions } from '~/store/compute-nodes/compute-nodes-actions';
65 import { linkPanelColumns } from '~/views/link-panel/link-panel-root';
66 import { userPanelColumns } from '~/views/user-panel/user-panel';
67 import { computeNodePanelColumns } from '~/views/compute-node-panel/compute-node-panel-root';
68 import { loadApiClientAuthorizationsPanel } from '~/store/api-client-authorizations/api-client-authorizations-actions';
69 import * as groupPanelActions from '~/store/groups-panel/groups-panel-actions';
70 import { groupsPanelColumns } from '~/views/groups-panel/groups-panel';
71 import * as groupDetailsPanelActions from '~/store/group-details-panel/group-details-panel-actions';
72 import { groupDetailsPanelColumns } from '~/views/group-details-panel/group-details-panel';
74 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
76 export const isWorkbenchLoading = (state: RootState) => {
77 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
78 return progress ? progress.working : false;
81 const handleFirstTimeLoad = (action: any) =>
82 async (dispatch: Dispatch<any>, getState: () => RootState) => {
84 await dispatch(action);
86 if (isWorkbenchLoading(getState())) {
87 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
92 export const loadWorkbench = () =>
93 async (dispatch: Dispatch, getState: () => RootState) => {
94 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
95 const { auth, router } = getState();
96 const { user } = auth;
98 const userResource = await dispatch<any>(loadResource(user.uuid));
100 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
101 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
102 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
103 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
104 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
105 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
106 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
107 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
108 dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({columns: groupDetailsPanelColumns}));
109 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
110 dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
111 dispatch<any>(initSidePanelTree());
112 if (router.location) {
113 const match = matchRootRoute(router.location.pathname);
115 dispatch(navigateToProject(userResource.uuid));
119 dispatch(userIsNotAuthenticated);
122 dispatch(userIsNotAuthenticated);
126 export const loadFavorites = () =>
128 (dispatch: Dispatch) => {
129 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
130 dispatch<any>(loadFavoritePanel());
131 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
134 export const loadTrash = () =>
136 (dispatch: Dispatch) => {
137 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
138 dispatch<any>(loadTrashPanel());
139 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
142 export const loadProject = (uuid: string) =>
144 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
145 const userUuid = services.authService.getUuid();
146 dispatch(setIsProjectPanelTrashed(false));
148 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
149 // Load another users home projects
150 dispatch(finishLoadingProject(uuid));
151 } else if (userUuid !== uuid) {
152 const match = await loadGroupContentsResource({ uuid, userUuid, services });
154 OWNED: async project => {
155 await dispatch(activateSidePanelTreeItem(uuid));
156 dispatch<any>(setSidePanelBreadcrumbs(uuid));
157 dispatch(finishLoadingProject(project));
160 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
161 dispatch(activateSidePanelTreeItem(uuid));
162 dispatch(finishLoadingProject(project));
164 TRASHED: project => {
165 dispatch<any>(setTrashBreadcrumbs(uuid));
166 dispatch(setIsProjectPanelTrashed(true));
167 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
168 dispatch(finishLoadingProject(project));
172 await dispatch(activateSidePanelTreeItem(userUuid));
173 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
174 dispatch(finishLoadingProject(userUuid));
179 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
180 async (dispatch: Dispatch) => {
181 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
183 dispatch(snackbarActions.OPEN_SNACKBAR({
184 message: "Project has been successfully created.",
186 kind: SnackbarKind.SUCCESS
188 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
189 dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
193 export const moveProject = (data: MoveToFormDialogData) =>
194 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
196 const oldProject = getResource(data.uuid)(getState().resources);
197 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
198 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
200 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
202 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
204 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
207 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
211 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
212 async (dispatch: Dispatch) => {
213 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
214 if (updatedProject) {
215 dispatch(snackbarActions.OPEN_SNACKBAR({
216 message: "Project has been successfully updated.",
218 kind: SnackbarKind.SUCCESS
220 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
221 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
225 export const loadCollection = (uuid: string) =>
227 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
228 const userUuid = services.authService.getUuid();
230 const match = await loadGroupContentsResource({ uuid, userUuid, services });
232 OWNED: async collection => {
233 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
234 dispatch(updateResources([collection]));
235 await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
236 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
237 dispatch(loadCollectionFiles(collection.uuid));
239 SHARED: collection => {
240 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
241 dispatch(updateResources([collection]));
242 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
243 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
244 dispatch(loadCollectionFiles(collection.uuid));
246 TRASHED: collection => {
247 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
248 dispatch(updateResources([collection]));
249 dispatch(setTrashBreadcrumbs(''));
250 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
251 dispatch(loadCollectionFiles(collection.uuid));
258 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
259 async (dispatch: Dispatch) => {
260 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
262 dispatch(snackbarActions.OPEN_SNACKBAR({
263 message: "Collection has been successfully created.",
265 kind: SnackbarKind.SUCCESS
267 dispatch<any>(updateResources([collection]));
268 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
272 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
273 async (dispatch: Dispatch) => {
274 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
276 dispatch(snackbarActions.OPEN_SNACKBAR({
277 message: "Collection has been successfully updated.",
279 kind: SnackbarKind.SUCCESS
281 dispatch<any>(updateResources([collection]));
282 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
286 export const copyCollection = (data: CopyFormDialogData) =>
287 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
289 const copyToProject = getResource(data.ownerUuid)(getState().resources);
290 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
291 if (copyToProject && collection) {
292 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
293 dispatch(snackbarActions.OPEN_SNACKBAR({
294 message: 'Collection has been copied.',
296 kind: SnackbarKind.SUCCESS,
297 link: collection.ownerUuid
301 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
305 export const moveCollection = (data: MoveToFormDialogData) =>
306 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
308 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
309 dispatch<any>(updateResources([collection]));
310 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
311 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
313 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
317 export const loadProcess = (uuid: string) =>
319 async (dispatch: Dispatch, getState: () => RootState) => {
320 dispatch<any>(loadProcessPanel(uuid));
321 const process = await dispatch<any>(processesActions.loadProcess(uuid));
322 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
323 dispatch<any>(setProcessBreadcrumbs(uuid));
324 dispatch(loadDetailsPanel(uuid));
327 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
328 async (dispatch: Dispatch) => {
330 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
332 dispatch(snackbarActions.OPEN_SNACKBAR({
333 message: "Process has been successfully updated.",
335 kind: SnackbarKind.SUCCESS
337 dispatch<any>(updateResources([process]));
338 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
341 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
345 export const moveProcess = (data: MoveToFormDialogData) =>
346 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
348 const process = await dispatch<any>(processMoveActions.moveProcess(data));
349 dispatch<any>(updateResources([process]));
350 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
351 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
353 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
357 export const copyProcess = (data: CopyFormDialogData) =>
358 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
360 const process = await dispatch<any>(processCopyActions.copyProcess(data));
361 dispatch<any>(updateResources([process]));
362 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
363 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
365 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
369 export const loadProcessLog = (uuid: string) =>
371 async (dispatch: Dispatch) => {
372 const process = await dispatch<any>(processesActions.loadProcess(uuid));
373 dispatch<any>(setProcessBreadcrumbs(uuid));
374 dispatch<any>(initProcessLogsPanel(uuid));
375 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
378 export const resourceIsNotLoaded = (uuid: string) =>
379 snackbarActions.OPEN_SNACKBAR({
380 message: `Resource identified by ${uuid} is not loaded.`,
381 kind: SnackbarKind.ERROR
384 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
385 message: 'User is not authenticated',
386 kind: SnackbarKind.ERROR
389 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
390 message: 'Could not load user',
391 kind: SnackbarKind.ERROR
394 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
395 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
396 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
397 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
398 dispatch<any>(loadProject(currentProjectPanelUuid));
402 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
403 dispatch<any>(loadSharedWithMePanel());
404 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
405 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
408 export const loadRunProcess = handleFirstTimeLoad(
409 async (dispatch: Dispatch) => {
410 await dispatch<any>(loadRunProcessPanel());
414 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
415 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
416 await dispatch(loadWorkflowPanel());
417 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
420 export const loadSearchResults = handleFirstTimeLoad(
421 async (dispatch: Dispatch<any>) => {
422 await dispatch(loadSearchResultsPanel());
425 export const loadLinks = handleFirstTimeLoad(
426 async (dispatch: Dispatch<any>) => {
427 await dispatch(loadLinkPanel());
430 export const loadVirtualMachines = handleFirstTimeLoad(
431 async (dispatch: Dispatch<any>) => {
432 await dispatch(loadVirtualMachinesPanel());
433 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
436 export const loadRepositories = handleFirstTimeLoad(
437 async (dispatch: Dispatch<any>) => {
438 await dispatch(loadRepositoriesPanel());
439 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
442 export const loadSshKeys = handleFirstTimeLoad(
443 async (dispatch: Dispatch<any>) => {
444 await dispatch(loadSshKeysPanel());
447 export const loadSiteManager = handleFirstTimeLoad(
448 async (dispatch: Dispatch<any>) => {
449 await dispatch(loadSiteManagerPanel());
452 export const loadMyAccount = handleFirstTimeLoad(
453 (dispatch: Dispatch<any>) => {
454 dispatch(loadMyAccountPanel());
457 export const loadKeepServices = handleFirstTimeLoad(
458 async (dispatch: Dispatch<any>) => {
459 await dispatch(loadKeepServicesPanel());
462 export const loadUsers = handleFirstTimeLoad(
463 async (dispatch: Dispatch<any>) => {
464 await dispatch(loadUsersPanel());
465 dispatch(setBreadcrumbs([{ label: 'Users' }]));
468 export const loadComputeNodes = handleFirstTimeLoad(
469 async (dispatch: Dispatch<any>) => {
470 await dispatch(loadComputeNodesPanel());
473 export const loadApiClientAuthorizations = handleFirstTimeLoad(
474 async (dispatch: Dispatch<any>) => {
475 await dispatch(loadApiClientAuthorizationsPanel());
478 export const loadGroupsPanel = handleFirstTimeLoad(
479 (dispatch: Dispatch<any>) => {
480 dispatch(setGroupsBreadcrumbs());
481 dispatch(groupPanelActions.loadGroupsPanel());
485 export const loadGroupDetailsPanel = (groupUuid: string) =>
487 (dispatch: Dispatch<any>) => {
488 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
489 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
492 const finishLoadingProject = (project: GroupContentsResource | string) =>
493 async (dispatch: Dispatch<any>) => {
494 const uuid = typeof project === 'string' ? project : project.uuid;
495 dispatch(openProjectPanel(uuid));
496 dispatch(loadDetailsPanel(uuid));
497 if (typeof project !== 'string') {
498 dispatch(updateResources([project]));
502 const loadGroupContentsResource = async (params: {
505 services: ServiceRepository
507 const filters = new FilterBuilder()
508 .addEqual('uuid', params.uuid)
510 const { items } = await params.services.groupsService.contents(params.userUuid, {
515 const resource = items.shift();
516 let handler: GroupContentsHandler;
518 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
519 ? groupContentsHandlers.TRASHED(resource)
520 : groupContentsHandlers.OWNED(resource);
522 const kind = extractUuidKind(params.uuid);
523 let resource: GroupContentsResource;
524 if (kind === ResourceKind.COLLECTION) {
525 resource = await params.services.collectionService.get(params.uuid);
526 } else if (kind === ResourceKind.PROJECT) {
527 resource = await params.services.projectService.get(params.uuid);
529 resource = await params.services.containerRequestService.get(params.uuid);
531 handler = groupContentsHandlers.SHARED(resource);
533 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
534 groupContentsHandlers.match(handler, cases);
538 const groupContentsHandlersRecord = {
539 TRASHED: ofType<GroupContentsResource>(),
540 SHARED: ofType<GroupContentsResource>(),
541 OWNED: ofType<GroupContentsResource>(),
544 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
546 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;