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 { getUserUuid } from 'common/getuser';
8 import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
9 import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
13 } from 'store/favorite-panel/favorite-panel-action';
15 getProjectPanelCurrentUuid,
18 setIsProjectPanelTrashed,
19 } from 'store/project-panel/project-panel-action';
21 activateSidePanelTreeItem,
23 loadSidePanelTreeProjects,
24 SidePanelTreeCategory,
25 } from 'store/side-panel-tree/side-panel-tree-actions';
26 import { updateResources } from 'store/resources/resources-actions';
27 import { projectPanelColumns } from 'views/project-panel/project-panel';
28 import { favoritePanelColumns } from 'views/favorite-panel/favorite-panel';
29 import { matchRootRoute } from 'routes/routes';
32 setGroupDetailsBreadcrumbs,
34 setProcessBreadcrumbs,
35 setSharedWithMeBreadcrumbs,
36 setSidePanelBreadcrumbs,
39 setMyAccountBreadcrumbs,
40 setUserProfileBreadcrumbs,
41 } from 'store/breadcrumbs/breadcrumbs-actions';
44 navigateToRootProject,
45 } from 'store/navigation/navigation-action';
46 import { MoveToFormDialogData } from 'store/move-to-dialog/move-to-dialog';
47 import { ServiceRepository } from 'services/services';
48 import { getResource } from 'store/resources/resources';
49 import * as projectCreateActions from 'store/projects/project-create-actions';
50 import * as projectMoveActions from 'store/projects/project-move-actions';
51 import * as projectUpdateActions from 'store/projects/project-update-actions';
52 import * as collectionCreateActions from 'store/collections/collection-create-actions';
53 import * as collectionCopyActions from 'store/collections/collection-copy-actions';
54 import * as collectionMoveActions from 'store/collections/collection-move-actions';
55 import * as processesActions from 'store/processes/processes-actions';
56 import * as processMoveActions from 'store/processes/process-move-actions';
57 import * as processUpdateActions from 'store/processes/process-update-actions';
58 import * as processCopyActions from 'store/processes/process-copy-actions';
59 import { trashPanelColumns } from 'views/trash-panel/trash-panel';
63 } from 'store/trash-panel/trash-panel-action';
64 import { loadProcessPanel } from 'store/process-panel/process-panel-actions';
66 loadSharedWithMePanel,
67 sharedWithMePanelActions,
68 } from 'store/shared-with-me-panel/shared-with-me-panel-actions';
69 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
70 import { workflowPanelActions } from 'store/workflow-panel/workflow-panel-actions';
71 import { loadSshKeysPanel } from 'store/auth/auth-action-ssh';
74 linkAccountPanelActions,
75 } from 'store/link-account-panel/link-account-panel-actions';
76 import { loadSiteManagerPanel } from 'store/auth/auth-action-session';
77 import { workflowPanelColumns } from 'views/workflow-panel/workflow-panel-view';
78 import { progressIndicatorActions } from 'store/progress-indicator/progress-indicator-actions';
79 import { getProgressIndicator } from 'store/progress-indicator/progress-indicator-reducer';
80 import { extractUuidKind, ResourceKind } from 'models/resource';
81 import { FilterBuilder } from 'services/api/filter-builder';
82 import { GroupContentsResource } from 'services/groups-service/groups-service';
83 import { MatchCases, ofType, unionize, UnionOf } from 'common/unionize';
84 import { loadRunProcessPanel } from 'store/run-process-panel/run-process-panel-actions';
86 collectionPanelActions,
88 } from 'store/collection-panel/collection-panel-action';
89 import { CollectionResource } from 'models/collection';
91 loadSearchResultsPanel,
92 searchResultsPanelActions,
93 } from 'store/search-results-panel/search-results-panel-actions';
94 import { searchResultsPanelColumns } from 'views/search-results-panel/search-results-panel-view';
95 import { loadVirtualMachinesPanel } from 'store/virtual-machines/virtual-machines-actions';
96 import { loadRepositoriesPanel } from 'store/repositories/repositories-actions';
97 import { loadKeepServicesPanel } from 'store/keep-services/keep-services-actions';
98 import { loadUsersPanel, userBindedActions } from 'store/users/users-actions';
99 import * as userProfilePanelActions from 'store/user-profile/user-profile-actions';
103 } from 'store/link-panel/link-panel-actions';
104 import { linkPanelColumns } from 'views/link-panel/link-panel-root';
105 import { userPanelColumns } from 'views/user-panel/user-panel';
107 loadApiClientAuthorizationsPanel,
108 apiClientAuthorizationsActions,
109 } from 'store/api-client-authorizations/api-client-authorizations-actions';
110 import { apiClientAuthorizationPanelColumns } from 'views/api-client-authorization-panel/api-client-authorization-panel-root';
111 import * as groupPanelActions from 'store/groups-panel/groups-panel-actions';
112 import { groupsPanelColumns } from 'views/groups-panel/groups-panel';
113 import * as groupDetailsPanelActions from 'store/group-details-panel/group-details-panel-actions';
115 groupDetailsMembersPanelColumns,
116 groupDetailsPermissionsPanelColumns,
117 } from 'views/group-details-panel/group-details-panel';
118 import { DataTableFetchMode } from 'components/data-table/data-table';
120 loadPublicFavoritePanel,
121 publicFavoritePanelActions,
122 } from 'store/public-favorites-panel/public-favorites-action';
123 import { publicFavoritePanelColumns } from 'views/public-favorites-panel/public-favorites-panel';
125 loadCollectionsContentAddressPanel,
126 collectionsContentAddressActions,
127 } from 'store/collections-content-address-panel/collections-content-address-panel-actions';
128 import { collectionContentAddressPanelColumns } from 'views/collection-content-address-panel/collection-content-address-panel';
129 import { subprocessPanelActions } from 'store/subprocess-panel/subprocess-panel-actions';
130 import { subprocessPanelColumns } from 'views/subprocess-panel/subprocess-panel-root';
132 loadAllProcessesPanel,
133 allProcessesPanelActions,
134 } from '../all-processes-panel/all-processes-panel-action';
135 import { allProcessesPanelColumns } from 'views/all-processes-panel/all-processes-panel';
136 import { AdminMenuIcon } from 'components/icon/icon';
137 import { userProfileGroupsColumns } from 'views/user-profile-panel/user-profile-panel-root';
139 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
141 export const isWorkbenchLoading = (state: RootState) => {
142 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(
143 state.progressIndicator
145 return progress ? progress.working : false;
148 export const handleFirstTimeLoad =
150 async (dispatch: Dispatch<any>, getState: () => RootState) => {
152 await dispatch(action);
154 if (isWorkbenchLoading(getState())) {
156 progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN)
162 export const loadWorkbench =
166 getState: () => RootState,
167 services: ServiceRepository
169 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
170 const { auth, router } = getState();
171 const { user } = auth;
174 projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns })
177 favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns })
180 allProcessesPanelActions.SET_COLUMNS({
181 columns: allProcessesPanelColumns,
185 publicFavoritePanelActions.SET_COLUMNS({
186 columns: publicFavoritePanelColumns,
189 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
191 sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns })
194 workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns })
197 searchResultsPanelActions.SET_FETCH_MODE({
198 fetchMode: DataTableFetchMode.INFINITE,
202 searchResultsPanelActions.SET_COLUMNS({
203 columns: searchResultsPanelColumns,
206 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
208 groupPanelActions.GroupsPanelActions.SET_COLUMNS({
209 columns: groupsPanelColumns,
213 groupDetailsPanelActions.GroupMembersPanelActions.SET_COLUMNS({
214 columns: groupDetailsMembersPanelColumns,
218 groupDetailsPanelActions.GroupPermissionsPanelActions.SET_COLUMNS({
219 columns: groupDetailsPermissionsPanelColumns,
223 userProfilePanelActions.UserProfileGroupsActions.SET_COLUMNS({
224 columns: userProfileGroupsColumns,
227 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
229 apiClientAuthorizationsActions.SET_COLUMNS({
230 columns: apiClientAuthorizationPanelColumns,
234 collectionsContentAddressActions.SET_COLUMNS({
235 columns: collectionContentAddressPanelColumns,
239 subprocessPanelActions.SET_COLUMNS({ columns: subprocessPanelColumns })
242 if (services.linkAccountService.getAccountToLink()) {
243 dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
246 dispatch<any>(initSidePanelTree());
247 if (router.location) {
248 const match = matchRootRoute(router.location.pathname);
250 dispatch<any>(navigateToRootProject);
254 dispatch(userIsNotAuthenticated);
258 export const loadFavorites = () =>
259 handleFirstTimeLoad((dispatch: Dispatch) => {
260 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
261 dispatch<any>(loadFavoritePanel());
262 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
265 export const loadCollectionContentAddress = handleFirstTimeLoad(
266 async (dispatch: Dispatch<any>) => {
267 await dispatch(loadCollectionsContentAddressPanel());
271 export const loadTrash = () =>
272 handleFirstTimeLoad((dispatch: Dispatch) => {
273 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
274 dispatch<any>(loadTrashPanel());
275 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
278 export const loadAllProcesses = () =>
279 handleFirstTimeLoad((dispatch: Dispatch) => {
281 activateSidePanelTreeItem(SidePanelTreeCategory.ALL_PROCESSES)
283 dispatch<any>(loadAllProcessesPanel());
284 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.ALL_PROCESSES));
287 export const loadProject = (uuid: string) =>
290 dispatch: Dispatch<any>,
291 getState: () => RootState,
292 services: ServiceRepository
294 const userUuid = getUserUuid(getState());
295 dispatch(setIsProjectPanelTrashed(false));
299 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
300 // Load another users home projects
301 dispatch(finishLoadingProject(uuid));
302 } else if (userUuid !== uuid) {
303 await dispatch(finishLoadingProject(uuid));
304 const match = await loadGroupContentsResource({
311 await dispatch(activateSidePanelTreeItem(uuid));
312 dispatch<any>(setSidePanelBreadcrumbs(uuid));
314 SHARED: async () => {
315 await dispatch(activateSidePanelTreeItem(uuid));
316 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
318 TRASHED: async () => {
320 activateSidePanelTreeItem(SidePanelTreeCategory.TRASH)
322 dispatch<any>(setTrashBreadcrumbs(uuid));
323 dispatch(setIsProjectPanelTrashed(true));
327 await dispatch(finishLoadingProject(userUuid));
328 await dispatch(activateSidePanelTreeItem(userUuid));
329 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
334 export const createProject =
335 (data: projectCreateActions.ProjectCreateFormDialogData) =>
336 async (dispatch: Dispatch) => {
337 const newProject = await dispatch<any>(
338 projectCreateActions.createProject(data)
342 snackbarActions.OPEN_SNACKBAR({
343 message: 'Project has been successfully created.',
345 kind: SnackbarKind.SUCCESS,
348 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
349 dispatch<any>(navigateTo(newProject.uuid));
353 export const moveProject =
354 (data: MoveToFormDialogData) =>
357 getState: () => RootState,
358 services: ServiceRepository
361 const oldProject = getResource(data.uuid)(getState().resources);
362 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
363 const movedProject = await dispatch<any>(
364 projectMoveActions.moveProject(data)
368 snackbarActions.OPEN_SNACKBAR({
369 message: 'Project has been moved',
371 kind: SnackbarKind.SUCCESS,
375 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
378 reloadProjectMatchingUuid([
380 movedProject.ownerUuid,
387 snackbarActions.OPEN_SNACKBAR({
390 kind: SnackbarKind.ERROR,
396 export const updateProject =
397 (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
398 async (dispatch: Dispatch) => {
399 const updatedProject = await dispatch<any>(
400 projectUpdateActions.updateProject(data)
402 if (updatedProject) {
404 snackbarActions.OPEN_SNACKBAR({
405 message: 'Project has been successfully updated.',
407 kind: SnackbarKind.SUCCESS,
410 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
412 reloadProjectMatchingUuid([
413 updatedProject.ownerUuid,
420 export const updateGroup =
421 (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
422 async (dispatch: Dispatch) => {
423 const updatedGroup = await dispatch<any>(
424 groupPanelActions.updateGroup(data)
428 snackbarActions.OPEN_SNACKBAR({
429 message: 'Group has been successfully updated.',
431 kind: SnackbarKind.SUCCESS,
434 await dispatch<any>(loadSidePanelTreeProjects(updatedGroup.ownerUuid));
436 reloadProjectMatchingUuid([updatedGroup.ownerUuid, updatedGroup.uuid])
441 export const loadCollection = (uuid: string) =>
444 dispatch: Dispatch<any>,
445 getState: () => RootState,
446 services: ServiceRepository
448 const userUuid = getUserUuid(getState());
450 const match = await loadGroupContentsResource({
456 OWNED: (collection) => {
458 collectionPanelActions.SET_COLLECTION(
459 collection as CollectionResource
462 dispatch(updateResources([collection]));
463 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
464 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
465 dispatch(loadCollectionPanel(collection.uuid));
467 SHARED: (collection) => {
469 collectionPanelActions.SET_COLLECTION(
470 collection as CollectionResource
473 dispatch(updateResources([collection]));
474 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
475 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
476 dispatch(loadCollectionPanel(collection.uuid));
478 TRASHED: (collection) => {
480 collectionPanelActions.SET_COLLECTION(
481 collection as CollectionResource
484 dispatch(updateResources([collection]));
485 dispatch(setTrashBreadcrumbs(''));
486 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
487 dispatch(loadCollectionPanel(collection.uuid));
494 export const createCollection =
495 (data: collectionCreateActions.CollectionCreateFormDialogData) =>
496 async (dispatch: Dispatch) => {
497 const collection = await dispatch<any>(
498 collectionCreateActions.createCollection(data)
502 snackbarActions.OPEN_SNACKBAR({
503 message: 'Collection has been successfully created.',
505 kind: SnackbarKind.SUCCESS,
508 dispatch<any>(updateResources([collection]));
509 dispatch<any>(navigateTo(collection.uuid));
513 export const copyCollection =
514 (data: CopyFormDialogData) =>
517 getState: () => RootState,
518 services: ServiceRepository
521 const copyToProject = getResource(data.ownerUuid)(getState().resources);
522 const collection = await dispatch<any>(
523 collectionCopyActions.copyCollection(data)
525 if (copyToProject && collection) {
526 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
528 snackbarActions.OPEN_SNACKBAR({
529 message: 'Collection has been copied.',
531 kind: SnackbarKind.SUCCESS,
532 link: collection.ownerUuid,
538 snackbarActions.OPEN_SNACKBAR({
541 kind: SnackbarKind.ERROR,
547 export const moveCollection =
548 (data: MoveToFormDialogData) =>
551 getState: () => RootState,
552 services: ServiceRepository
555 const collection = await dispatch<any>(
556 collectionMoveActions.moveCollection(data)
558 dispatch<any>(updateResources([collection]));
559 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
561 snackbarActions.OPEN_SNACKBAR({
562 message: 'Collection has been moved.',
564 kind: SnackbarKind.SUCCESS,
569 snackbarActions.OPEN_SNACKBAR({
572 kind: SnackbarKind.ERROR,
578 export const loadProcess = (uuid: string) =>
579 handleFirstTimeLoad(async (dispatch: Dispatch, getState: () => RootState) => {
580 dispatch<any>(loadProcessPanel(uuid));
581 const process = await dispatch<any>(processesActions.loadProcess(uuid));
584 activateSidePanelTreeItem(process.containerRequest.ownerUuid)
586 dispatch<any>(setProcessBreadcrumbs(uuid));
587 dispatch<any>(loadDetailsPanel(uuid));
591 export const updateProcess =
592 (data: processUpdateActions.ProcessUpdateFormDialogData) =>
593 async (dispatch: Dispatch) => {
595 const process = await dispatch<any>(
596 processUpdateActions.updateProcess(data)
600 snackbarActions.OPEN_SNACKBAR({
601 message: 'Process has been successfully updated.',
603 kind: SnackbarKind.SUCCESS,
606 dispatch<any>(updateResources([process]));
607 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
611 snackbarActions.OPEN_SNACKBAR({
614 kind: SnackbarKind.ERROR,
620 export const moveProcess =
621 (data: MoveToFormDialogData) =>
624 getState: () => RootState,
625 services: ServiceRepository
628 const process = await dispatch<any>(processMoveActions.moveProcess(data));
629 dispatch<any>(updateResources([process]));
630 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
632 snackbarActions.OPEN_SNACKBAR({
633 message: 'Process has been moved.',
635 kind: SnackbarKind.SUCCESS,
640 snackbarActions.OPEN_SNACKBAR({
643 kind: SnackbarKind.ERROR,
649 export const copyProcess =
650 (data: CopyFormDialogData) =>
653 getState: () => RootState,
654 services: ServiceRepository
657 const process = await dispatch<any>(processCopyActions.copyProcess(data));
658 dispatch<any>(updateResources([process]));
659 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
661 snackbarActions.OPEN_SNACKBAR({
662 message: 'Process has been copied.',
664 kind: SnackbarKind.SUCCESS,
667 dispatch<any>(navigateTo(process.uuid));
670 snackbarActions.OPEN_SNACKBAR({
673 kind: SnackbarKind.ERROR,
679 export const resourceIsNotLoaded = (uuid: string) =>
680 snackbarActions.OPEN_SNACKBAR({
681 message: `Resource identified by ${uuid} is not loaded.`,
682 kind: SnackbarKind.ERROR,
685 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
686 message: 'User is not authenticated',
687 kind: SnackbarKind.ERROR,
690 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
691 message: 'Could not load user',
692 kind: SnackbarKind.ERROR,
695 export const reloadProjectMatchingUuid =
696 (matchingUuids: string[]) =>
699 getState: () => RootState,
700 services: ServiceRepository
702 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
704 currentProjectPanelUuid &&
705 matchingUuids.some((uuid) => uuid === currentProjectPanelUuid)
707 dispatch<any>(loadProject(currentProjectPanelUuid));
711 export const loadSharedWithMe = handleFirstTimeLoad(
712 async (dispatch: Dispatch) => {
713 dispatch<any>(loadSharedWithMePanel());
715 activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME)
718 setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME)
723 export const loadRunProcess = handleFirstTimeLoad(
724 async (dispatch: Dispatch) => {
725 await dispatch<any>(loadRunProcessPanel());
729 export const loadPublicFavorites = () =>
730 handleFirstTimeLoad((dispatch: Dispatch) => {
732 activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES)
734 dispatch<any>(loadPublicFavoritePanel());
736 setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES)
740 export const loadSearchResults = handleFirstTimeLoad(
741 async (dispatch: Dispatch<any>) => {
742 await dispatch(loadSearchResultsPanel());
746 export const loadLinks = handleFirstTimeLoad(
747 async (dispatch: Dispatch<any>) => {
748 await dispatch(loadLinkPanel());
752 export const loadVirtualMachines = handleFirstTimeLoad(
753 async (dispatch: Dispatch<any>) => {
754 await dispatch(loadVirtualMachinesPanel());
755 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
759 export const loadVirtualMachinesAdmin = handleFirstTimeLoad(
760 async (dispatch: Dispatch<any>) => {
761 await dispatch(loadVirtualMachinesPanel());
763 setBreadcrumbs([{ label: 'Virtual Machines Admin', icon: AdminMenuIcon }])
768 export const loadRepositories = handleFirstTimeLoad(
769 async (dispatch: Dispatch<any>) => {
770 await dispatch(loadRepositoriesPanel());
771 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
775 export const loadSshKeys = handleFirstTimeLoad(
776 async (dispatch: Dispatch<any>) => {
777 await dispatch(loadSshKeysPanel());
781 export const loadSiteManager = handleFirstTimeLoad(
782 async (dispatch: Dispatch<any>) => {
783 await dispatch(loadSiteManagerPanel());
787 export const loadUserProfile = (userUuid?: string) =>
788 handleFirstTimeLoad((dispatch: Dispatch<any>) => {
790 dispatch(setUserProfileBreadcrumbs(userUuid));
791 dispatch(userProfilePanelActions.loadUserProfilePanel(userUuid));
793 dispatch(setMyAccountBreadcrumbs());
794 dispatch(userProfilePanelActions.loadUserProfilePanel());
798 export const loadLinkAccount = handleFirstTimeLoad(
799 (dispatch: Dispatch<any>) => {
800 dispatch(loadLinkAccountPanel());
804 export const loadKeepServices = handleFirstTimeLoad(
805 async (dispatch: Dispatch<any>) => {
806 await dispatch(loadKeepServicesPanel());
810 export const loadUsers = handleFirstTimeLoad(
811 async (dispatch: Dispatch<any>) => {
812 await dispatch(loadUsersPanel());
813 dispatch(setUsersBreadcrumbs());
817 export const loadApiClientAuthorizations = handleFirstTimeLoad(
818 async (dispatch: Dispatch<any>) => {
819 await dispatch(loadApiClientAuthorizationsPanel());
823 export const loadGroupsPanel = handleFirstTimeLoad(
824 (dispatch: Dispatch<any>) => {
825 dispatch(setGroupsBreadcrumbs());
826 dispatch(groupPanelActions.loadGroupsPanel());
830 export const loadGroupDetailsPanel = (groupUuid: string) =>
831 handleFirstTimeLoad((dispatch: Dispatch<any>) => {
832 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
833 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
836 const finishLoadingProject =
837 (project: GroupContentsResource | string) =>
838 async (dispatch: Dispatch<any>) => {
839 const uuid = typeof project === 'string' ? project : project.uuid;
840 dispatch(openProjectPanel(uuid));
841 dispatch(loadDetailsPanel(uuid));
842 if (typeof project !== 'string') {
843 dispatch(updateResources([project]));
847 const loadGroupContentsResource = async (params: {
850 services: ServiceRepository;
852 const filters = new FilterBuilder()
853 .addEqual('uuid', params.uuid)
855 const { items } = await params.services.groupsService.contents(
863 const resource = items.shift();
864 let handler: GroupContentsHandler;
867 (resource.kind === ResourceKind.COLLECTION ||
868 resource.kind === ResourceKind.PROJECT) &&
870 ? groupContentsHandlers.TRASHED(resource)
871 : groupContentsHandlers.OWNED(resource);
873 const kind = extractUuidKind(params.uuid);
874 let resource: GroupContentsResource;
875 if (kind === ResourceKind.COLLECTION) {
876 resource = await params.services.collectionService.get(params.uuid);
877 } else if (kind === ResourceKind.PROJECT) {
878 resource = await params.services.projectService.get(params.uuid);
880 resource = await params.services.containerRequestService.get(params.uuid);
882 handler = groupContentsHandlers.SHARED(resource);
886 typeof groupContentsHandlersRecord,
887 GroupContentsHandler,
890 ) => groupContentsHandlers.match(handler, cases);
893 const groupContentsHandlersRecord = {
894 TRASHED: ofType<GroupContentsResource>(),
895 SHARED: ofType<GroupContentsResource>(),
896 OWNED: ofType<GroupContentsResource>(),
899 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
901 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;