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 { collectionPanelActions, loadCollectionPanel } from "~/store/collection-panel/collection-panel-action";
72 import { CollectionResource } from "~/models/collection";
74 loadSearchResultsPanel,
75 searchResultsPanelActions
76 } from '~/store/search-results-panel/search-results-panel-actions';
77 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
78 import { loadVirtualMachinesPanel } from '~/store/virtual-machines/virtual-machines-actions';
79 import { loadRepositoriesPanel } from '~/store/repositories/repositories-actions';
80 import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
81 import { loadUsersPanel, userBindedActions } from '~/store/users/users-actions';
82 import { linkPanelActions, loadLinkPanel } from '~/store/link-panel/link-panel-actions';
83 import { computeNodesActions, loadComputeNodesPanel } from '~/store/compute-nodes/compute-nodes-actions';
84 import { linkPanelColumns } from '~/views/link-panel/link-panel-root';
85 import { userPanelColumns } from '~/views/user-panel/user-panel';
86 import { computeNodePanelColumns } from '~/views/compute-node-panel/compute-node-panel-root';
87 import { loadApiClientAuthorizationsPanel, apiClientAuthorizationsActions } from '~/store/api-client-authorizations/api-client-authorizations-actions';
88 import { apiClientAuthorizationPanelColumns } from '~/views/api-client-authorization-panel/api-client-authorization-panel-root';
89 import * as groupPanelActions from '~/store/groups-panel/groups-panel-actions';
90 import { groupsPanelColumns } from '~/views/groups-panel/groups-panel';
91 import * as groupDetailsPanelActions from '~/store/group-details-panel/group-details-panel-actions';
92 import { groupDetailsPanelColumns } from '~/views/group-details-panel/group-details-panel';
93 import { DataTableFetchMode } from "~/components/data-table/data-table";
94 import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action';
95 import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel';
97 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
99 export const isWorkbenchLoading = (state: RootState) => {
100 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
101 return progress ? progress.working : false;
104 const handleFirstTimeLoad = (action: any) =>
105 async (dispatch: Dispatch<any>, getState: () => RootState) => {
107 await dispatch(action);
109 if (isWorkbenchLoading(getState())) {
110 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
115 export const loadWorkbench = () =>
116 async (dispatch: Dispatch, getState: () => RootState) => {
117 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
118 const { auth, router } = getState();
119 const { user } = auth;
121 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
122 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
123 dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns }));
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(user.uuid));
144 dispatch(userIsNotAuthenticated);
148 export const loadFavorites = () =>
150 (dispatch: Dispatch) => {
151 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
152 dispatch<any>(loadFavoritePanel());
153 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
156 export const loadTrash = () =>
158 (dispatch: Dispatch) => {
159 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
160 dispatch<any>(loadTrashPanel());
161 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
164 export const loadProject = (uuid: string) =>
166 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
167 const userUuid = services.authService.getUuid();
168 dispatch(setIsProjectPanelTrashed(false));
170 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
171 // Load another users home projects
172 dispatch(finishLoadingProject(uuid));
173 } else if (userUuid !== uuid) {
174 const match = await loadGroupContentsResource({ uuid, userUuid, services });
176 OWNED: async project => {
177 await dispatch(activateSidePanelTreeItem(uuid));
178 dispatch<any>(setSidePanelBreadcrumbs(uuid));
179 dispatch(finishLoadingProject(project));
182 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
183 dispatch(activateSidePanelTreeItem(uuid));
184 dispatch(finishLoadingProject(project));
186 TRASHED: project => {
187 dispatch<any>(setTrashBreadcrumbs(uuid));
188 dispatch(setIsProjectPanelTrashed(true));
189 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
190 dispatch(finishLoadingProject(project));
194 await dispatch(activateSidePanelTreeItem(userUuid));
195 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
196 dispatch(finishLoadingProject(userUuid));
201 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
202 async (dispatch: Dispatch) => {
203 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
205 dispatch(snackbarActions.OPEN_SNACKBAR({
206 message: "Project has been successfully created.",
208 kind: SnackbarKind.SUCCESS
210 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
211 dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
215 export const moveProject = (data: MoveToFormDialogData) =>
216 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
218 const oldProject = getResource(data.uuid)(getState().resources);
219 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
220 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
222 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
224 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
226 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
229 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
233 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
234 async (dispatch: Dispatch) => {
235 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
236 if (updatedProject) {
237 dispatch(snackbarActions.OPEN_SNACKBAR({
238 message: "Project has been successfully updated.",
240 kind: SnackbarKind.SUCCESS
242 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
243 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
247 export const loadCollection = (uuid: string) =>
249 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
250 const userUuid = services.authService.getUuid();
252 const match = await loadGroupContentsResource({ uuid, userUuid, services });
254 OWNED: async collection => {
255 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
256 dispatch(updateResources([collection]));
257 await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
258 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
259 dispatch(loadCollectionPanel(collection.uuid));
261 SHARED: collection => {
262 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
263 dispatch(updateResources([collection]));
264 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
265 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
266 dispatch(loadCollectionPanel(collection.uuid));
268 TRASHED: collection => {
269 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
270 dispatch(updateResources([collection]));
271 dispatch(setTrashBreadcrumbs(''));
272 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
273 dispatch(loadCollectionPanel(collection.uuid));
280 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
281 async (dispatch: Dispatch) => {
282 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
284 dispatch(snackbarActions.OPEN_SNACKBAR({
285 message: "Collection has been successfully created.",
287 kind: SnackbarKind.SUCCESS
289 dispatch<any>(updateResources([collection]));
290 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
294 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
295 async (dispatch: Dispatch) => {
296 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
298 dispatch(snackbarActions.OPEN_SNACKBAR({
299 message: "Collection has been successfully updated.",
301 kind: SnackbarKind.SUCCESS
303 dispatch<any>(updateResources([collection]));
304 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
308 export const copyCollection = (data: CopyFormDialogData) =>
309 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
311 const copyToProject = getResource(data.ownerUuid)(getState().resources);
312 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
313 if (copyToProject && collection) {
314 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
315 dispatch(snackbarActions.OPEN_SNACKBAR({
316 message: 'Collection has been copied.',
318 kind: SnackbarKind.SUCCESS,
319 link: collection.ownerUuid
323 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
327 export const moveCollection = (data: MoveToFormDialogData) =>
328 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
330 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
331 dispatch<any>(updateResources([collection]));
332 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
333 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
335 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
339 export const loadProcess = (uuid: string) =>
341 async (dispatch: Dispatch, getState: () => RootState) => {
342 dispatch<any>(loadProcessPanel(uuid));
343 const process = await dispatch<any>(processesActions.loadProcess(uuid));
344 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
345 dispatch<any>(setProcessBreadcrumbs(uuid));
346 dispatch(loadDetailsPanel(uuid));
349 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
350 async (dispatch: Dispatch) => {
352 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
354 dispatch(snackbarActions.OPEN_SNACKBAR({
355 message: "Process has been successfully updated.",
357 kind: SnackbarKind.SUCCESS
359 dispatch<any>(updateResources([process]));
360 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
363 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
367 export const moveProcess = (data: MoveToFormDialogData) =>
368 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
370 const process = await dispatch<any>(processMoveActions.moveProcess(data));
371 dispatch<any>(updateResources([process]));
372 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
373 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
375 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
379 export const copyProcess = (data: CopyFormDialogData) =>
380 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
382 const process = await dispatch<any>(processCopyActions.copyProcess(data));
383 dispatch<any>(updateResources([process]));
384 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
385 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
387 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
391 export const loadProcessLog = (uuid: string) =>
393 async (dispatch: Dispatch) => {
394 const process = await dispatch<any>(processesActions.loadProcess(uuid));
395 dispatch<any>(setProcessBreadcrumbs(uuid));
396 dispatch<any>(initProcessLogsPanel(uuid));
397 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
400 export const resourceIsNotLoaded = (uuid: string) =>
401 snackbarActions.OPEN_SNACKBAR({
402 message: `Resource identified by ${uuid} is not loaded.`,
403 kind: SnackbarKind.ERROR
406 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
407 message: 'User is not authenticated',
408 kind: SnackbarKind.ERROR
411 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
412 message: 'Could not load user',
413 kind: SnackbarKind.ERROR
416 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
417 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
418 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
419 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
420 dispatch<any>(loadProject(currentProjectPanelUuid));
424 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
425 dispatch<any>(loadSharedWithMePanel());
426 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
427 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
430 export const loadRunProcess = handleFirstTimeLoad(
431 async (dispatch: Dispatch) => {
432 await dispatch<any>(loadRunProcessPanel());
436 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
437 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
438 await dispatch(loadWorkflowPanel());
439 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
442 export const loadPublicFavorites = () =>
444 (dispatch: Dispatch) => {
445 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES));
446 dispatch<any>(loadPublicFavoritePanel());
447 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES));
450 export const loadSearchResults = handleFirstTimeLoad(
451 async (dispatch: Dispatch<any>) => {
452 await dispatch(loadSearchResultsPanel());
455 export const loadLinks = handleFirstTimeLoad(
456 async (dispatch: Dispatch<any>) => {
457 await dispatch(loadLinkPanel());
460 export const loadVirtualMachines = handleFirstTimeLoad(
461 async (dispatch: Dispatch<any>) => {
462 await dispatch(loadVirtualMachinesPanel());
463 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
466 export const loadRepositories = handleFirstTimeLoad(
467 async (dispatch: Dispatch<any>) => {
468 await dispatch(loadRepositoriesPanel());
469 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
472 export const loadSshKeys = handleFirstTimeLoad(
473 async (dispatch: Dispatch<any>) => {
474 await dispatch(loadSshKeysPanel());
477 export const loadSiteManager = handleFirstTimeLoad(
478 async (dispatch: Dispatch<any>) => {
479 await dispatch(loadSiteManagerPanel());
482 export const loadMyAccount = handleFirstTimeLoad(
483 (dispatch: Dispatch<any>) => {
484 dispatch(loadMyAccountPanel());
487 export const loadKeepServices = handleFirstTimeLoad(
488 async (dispatch: Dispatch<any>) => {
489 await dispatch(loadKeepServicesPanel());
492 export const loadUsers = handleFirstTimeLoad(
493 async (dispatch: Dispatch<any>) => {
494 await dispatch(loadUsersPanel());
495 dispatch(setBreadcrumbs([{ label: 'Users' }]));
498 export const loadComputeNodes = handleFirstTimeLoad(
499 async (dispatch: Dispatch<any>) => {
500 await dispatch(loadComputeNodesPanel());
503 export const loadApiClientAuthorizations = handleFirstTimeLoad(
504 async (dispatch: Dispatch<any>) => {
505 await dispatch(loadApiClientAuthorizationsPanel());
508 export const loadGroupsPanel = handleFirstTimeLoad(
509 (dispatch: Dispatch<any>) => {
510 dispatch(setGroupsBreadcrumbs());
511 dispatch(groupPanelActions.loadGroupsPanel());
515 export const loadGroupDetailsPanel = (groupUuid: string) =>
517 (dispatch: Dispatch<any>) => {
518 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
519 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
522 const finishLoadingProject = (project: GroupContentsResource | string) =>
523 async (dispatch: Dispatch<any>) => {
524 const uuid = typeof project === 'string' ? project : project.uuid;
525 dispatch(openProjectPanel(uuid));
526 dispatch(loadDetailsPanel(uuid));
527 if (typeof project !== 'string') {
528 dispatch(updateResources([project]));
532 const loadGroupContentsResource = async (params: {
535 services: ServiceRepository
537 const filters = new FilterBuilder()
538 .addEqual('uuid', params.uuid)
540 const { items } = await params.services.groupsService.contents(params.userUuid, {
545 const resource = items.shift();
546 let handler: GroupContentsHandler;
548 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
549 ? groupContentsHandlers.TRASHED(resource)
550 : groupContentsHandlers.OWNED(resource);
552 const kind = extractUuidKind(params.uuid);
553 let resource: GroupContentsResource;
554 if (kind === ResourceKind.COLLECTION) {
555 resource = await params.services.collectionService.get(params.uuid);
556 } else if (kind === ResourceKind.PROJECT) {
557 resource = await params.services.projectService.get(params.uuid);
559 resource = await params.services.containerRequestService.get(params.uuid);
561 handler = groupContentsHandlers.SHARED(resource);
563 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
564 groupContentsHandlers.match(handler, cases);
568 const groupContentsHandlersRecord = {
569 TRASHED: ofType<GroupContentsResource>(),
570 SHARED: ofType<GroupContentsResource>(),
571 OWNED: ofType<GroupContentsResource>(),
574 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
576 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;