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 const userResource = await dispatch<any>(loadResource(user.uuid));
122 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
123 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
124 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
125 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
126 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
127 dispatch(searchResultsPanelActions.SET_FETCH_MODE({ fetchMode: DataTableFetchMode.INFINITE }));
128 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
129 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
130 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
131 dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({columns: groupDetailsPanelColumns}));
132 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
133 dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
134 dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
136 dispatch<any>(initSidePanelTree());
137 if (router.location) {
138 const match = matchRootRoute(router.location.pathname);
140 dispatch(navigateToProject(userResource.uuid));
144 dispatch(userIsNotAuthenticated);
147 dispatch(userIsNotAuthenticated);
151 export const loadFavorites = () =>
153 (dispatch: Dispatch) => {
154 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
155 dispatch<any>(loadFavoritePanel());
156 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
159 export const loadTrash = () =>
161 (dispatch: Dispatch) => {
162 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
163 dispatch<any>(loadTrashPanel());
164 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
167 export const loadProject = (uuid: string) =>
169 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
170 const userUuid = services.authService.getUuid();
171 dispatch(setIsProjectPanelTrashed(false));
173 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
174 // Load another users home projects
175 dispatch(finishLoadingProject(uuid));
176 } else if (userUuid !== uuid) {
177 const match = await loadGroupContentsResource({ uuid, userUuid, services });
179 OWNED: async project => {
180 await dispatch(activateSidePanelTreeItem(uuid));
181 dispatch<any>(setSidePanelBreadcrumbs(uuid));
182 dispatch(finishLoadingProject(project));
185 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
186 dispatch(activateSidePanelTreeItem(uuid));
187 dispatch(finishLoadingProject(project));
189 TRASHED: project => {
190 dispatch<any>(setTrashBreadcrumbs(uuid));
191 dispatch(setIsProjectPanelTrashed(true));
192 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
193 dispatch(finishLoadingProject(project));
197 await dispatch(activateSidePanelTreeItem(userUuid));
198 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
199 dispatch(finishLoadingProject(userUuid));
204 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
205 async (dispatch: Dispatch) => {
206 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
208 dispatch(snackbarActions.OPEN_SNACKBAR({
209 message: "Project has been successfully created.",
211 kind: SnackbarKind.SUCCESS
213 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
214 dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
218 export const moveProject = (data: MoveToFormDialogData) =>
219 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
221 const oldProject = getResource(data.uuid)(getState().resources);
222 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
223 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
225 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
227 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
229 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
232 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
236 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
237 async (dispatch: Dispatch) => {
238 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
239 if (updatedProject) {
240 dispatch(snackbarActions.OPEN_SNACKBAR({
241 message: "Project has been successfully updated.",
243 kind: SnackbarKind.SUCCESS
245 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
246 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
250 export const loadCollection = (uuid: string) =>
252 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
253 const userUuid = services.authService.getUuid();
255 const match = await loadGroupContentsResource({ uuid, userUuid, services });
257 OWNED: async collection => {
258 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
259 dispatch(updateResources([collection]));
260 await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
261 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
262 dispatch(loadCollectionFiles(collection.uuid));
264 SHARED: collection => {
265 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
266 dispatch(updateResources([collection]));
267 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
268 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
269 dispatch(loadCollectionFiles(collection.uuid));
271 TRASHED: collection => {
272 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
273 dispatch(updateResources([collection]));
274 dispatch(setTrashBreadcrumbs(''));
275 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
276 dispatch(loadCollectionFiles(collection.uuid));
283 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
284 async (dispatch: Dispatch) => {
285 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
287 dispatch(snackbarActions.OPEN_SNACKBAR({
288 message: "Collection has been successfully created.",
290 kind: SnackbarKind.SUCCESS
292 dispatch<any>(updateResources([collection]));
293 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
297 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
298 async (dispatch: Dispatch) => {
299 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
301 dispatch(snackbarActions.OPEN_SNACKBAR({
302 message: "Collection has been successfully updated.",
304 kind: SnackbarKind.SUCCESS
306 dispatch<any>(updateResources([collection]));
307 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
311 export const copyCollection = (data: CopyFormDialogData) =>
312 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
314 const copyToProject = getResource(data.ownerUuid)(getState().resources);
315 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
316 if (copyToProject && collection) {
317 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
318 dispatch(snackbarActions.OPEN_SNACKBAR({
319 message: 'Collection has been copied.',
321 kind: SnackbarKind.SUCCESS,
322 link: collection.ownerUuid
326 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
330 export const moveCollection = (data: MoveToFormDialogData) =>
331 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
333 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
334 dispatch<any>(updateResources([collection]));
335 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
336 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
338 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
342 export const loadProcess = (uuid: string) =>
344 async (dispatch: Dispatch, getState: () => RootState) => {
345 dispatch<any>(loadProcessPanel(uuid));
346 const process = await dispatch<any>(processesActions.loadProcess(uuid));
347 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
348 dispatch<any>(setProcessBreadcrumbs(uuid));
349 dispatch(loadDetailsPanel(uuid));
352 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
353 async (dispatch: Dispatch) => {
355 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
357 dispatch(snackbarActions.OPEN_SNACKBAR({
358 message: "Process has been successfully updated.",
360 kind: SnackbarKind.SUCCESS
362 dispatch<any>(updateResources([process]));
363 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
366 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
370 export const moveProcess = (data: MoveToFormDialogData) =>
371 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
373 const process = await dispatch<any>(processMoveActions.moveProcess(data));
374 dispatch<any>(updateResources([process]));
375 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
376 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
378 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
382 export const copyProcess = (data: CopyFormDialogData) =>
383 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
385 const process = await dispatch<any>(processCopyActions.copyProcess(data));
386 dispatch<any>(updateResources([process]));
387 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
388 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
390 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
394 export const loadProcessLog = (uuid: string) =>
396 async (dispatch: Dispatch) => {
397 const process = await dispatch<any>(processesActions.loadProcess(uuid));
398 dispatch<any>(setProcessBreadcrumbs(uuid));
399 dispatch<any>(initProcessLogsPanel(uuid));
400 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
403 export const resourceIsNotLoaded = (uuid: string) =>
404 snackbarActions.OPEN_SNACKBAR({
405 message: `Resource identified by ${uuid} is not loaded.`,
406 kind: SnackbarKind.ERROR
409 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
410 message: 'User is not authenticated',
411 kind: SnackbarKind.ERROR
414 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
415 message: 'Could not load user',
416 kind: SnackbarKind.ERROR
419 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
420 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
421 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
422 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
423 dispatch<any>(loadProject(currentProjectPanelUuid));
427 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
428 dispatch<any>(loadSharedWithMePanel());
429 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
430 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
433 export const loadRunProcess = handleFirstTimeLoad(
434 async (dispatch: Dispatch) => {
435 await dispatch<any>(loadRunProcessPanel());
439 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
440 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
441 await dispatch(loadWorkflowPanel());
442 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
445 export const loadSearchResults = handleFirstTimeLoad(
446 async (dispatch: Dispatch<any>) => {
447 await dispatch(loadSearchResultsPanel());
450 export const loadLinks = handleFirstTimeLoad(
451 async (dispatch: Dispatch<any>) => {
452 await dispatch(loadLinkPanel());
455 export const loadVirtualMachines = handleFirstTimeLoad(
456 async (dispatch: Dispatch<any>) => {
457 await dispatch(loadVirtualMachinesPanel());
458 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
461 export const loadRepositories = handleFirstTimeLoad(
462 async (dispatch: Dispatch<any>) => {
463 await dispatch(loadRepositoriesPanel());
464 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
467 export const loadSshKeys = handleFirstTimeLoad(
468 async (dispatch: Dispatch<any>) => {
469 await dispatch(loadSshKeysPanel());
472 export const loadSiteManager = handleFirstTimeLoad(
473 async (dispatch: Dispatch<any>) => {
474 await dispatch(loadSiteManagerPanel());
477 export const loadMyAccount = handleFirstTimeLoad(
478 (dispatch: Dispatch<any>) => {
479 dispatch(loadMyAccountPanel());
482 export const loadKeepServices = handleFirstTimeLoad(
483 async (dispatch: Dispatch<any>) => {
484 await dispatch(loadKeepServicesPanel());
487 export const loadUsers = handleFirstTimeLoad(
488 async (dispatch: Dispatch<any>) => {
489 await dispatch(loadUsersPanel());
490 dispatch(setBreadcrumbs([{ label: 'Users' }]));
493 export const loadComputeNodes = handleFirstTimeLoad(
494 async (dispatch: Dispatch<any>) => {
495 await dispatch(loadComputeNodesPanel());
498 export const loadApiClientAuthorizations = handleFirstTimeLoad(
499 async (dispatch: Dispatch<any>) => {
500 await dispatch(loadApiClientAuthorizationsPanel());
503 export const loadGroupsPanel = handleFirstTimeLoad(
504 (dispatch: Dispatch<any>) => {
505 dispatch(setGroupsBreadcrumbs());
506 dispatch(groupPanelActions.loadGroupsPanel());
510 export const loadGroupDetailsPanel = (groupUuid: string) =>
512 (dispatch: Dispatch<any>) => {
513 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
514 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
517 const finishLoadingProject = (project: GroupContentsResource | string) =>
518 async (dispatch: Dispatch<any>) => {
519 const uuid = typeof project === 'string' ? project : project.uuid;
520 dispatch(openProjectPanel(uuid));
521 dispatch(loadDetailsPanel(uuid));
522 if (typeof project !== 'string') {
523 dispatch(updateResources([project]));
527 const loadGroupContentsResource = async (params: {
530 services: ServiceRepository
532 const filters = new FilterBuilder()
533 .addEqual('uuid', params.uuid)
535 const { items } = await params.services.groupsService.contents(params.userUuid, {
540 const resource = items.shift();
541 let handler: GroupContentsHandler;
543 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
544 ? groupContentsHandlers.TRASHED(resource)
545 : groupContentsHandlers.OWNED(resource);
547 const kind = extractUuidKind(params.uuid);
548 let resource: GroupContentsResource;
549 if (kind === ResourceKind.COLLECTION) {
550 resource = await params.services.collectionService.get(params.uuid);
551 } else if (kind === ResourceKind.PROJECT) {
552 resource = await params.services.projectService.get(params.uuid);
554 resource = await params.services.containerRequestService.get(params.uuid);
556 handler = groupContentsHandlers.SHARED(resource);
558 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
559 groupContentsHandlers.match(handler, cases);
563 const groupContentsHandlersRecord = {
564 TRASHED: ofType<GroupContentsResource>(),
565 SHARED: ofType<GroupContentsResource>(),
566 OWNED: ofType<GroupContentsResource>(),
569 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
571 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;