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;
173 // console.log('PREJECTPANELCOLUMNS', projectPanelColumns);
175 projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns })
178 favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns })
181 allProcessesPanelActions.SET_COLUMNS({
182 columns: allProcessesPanelColumns,
186 publicFavoritePanelActions.SET_COLUMNS({
187 columns: publicFavoritePanelColumns,
190 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
192 sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns })
195 workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns })
198 searchResultsPanelActions.SET_FETCH_MODE({
199 fetchMode: DataTableFetchMode.INFINITE,
203 searchResultsPanelActions.SET_COLUMNS({
204 columns: searchResultsPanelColumns,
207 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
209 groupPanelActions.GroupsPanelActions.SET_COLUMNS({
210 columns: groupsPanelColumns,
214 groupDetailsPanelActions.GroupMembersPanelActions.SET_COLUMNS({
215 columns: groupDetailsMembersPanelColumns,
219 groupDetailsPanelActions.GroupPermissionsPanelActions.SET_COLUMNS({
220 columns: groupDetailsPermissionsPanelColumns,
224 userProfilePanelActions.UserProfileGroupsActions.SET_COLUMNS({
225 columns: userProfileGroupsColumns,
228 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
230 apiClientAuthorizationsActions.SET_COLUMNS({
231 columns: apiClientAuthorizationPanelColumns,
235 collectionsContentAddressActions.SET_COLUMNS({
236 columns: collectionContentAddressPanelColumns,
240 subprocessPanelActions.SET_COLUMNS({ columns: subprocessPanelColumns })
243 if (services.linkAccountService.getAccountToLink()) {
244 dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
247 dispatch<any>(initSidePanelTree());
248 if (router.location) {
249 const match = matchRootRoute(router.location.pathname);
251 dispatch<any>(navigateToRootProject);
255 dispatch(userIsNotAuthenticated);
259 export const loadFavorites = () =>
260 handleFirstTimeLoad((dispatch: Dispatch) => {
261 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
262 dispatch<any>(loadFavoritePanel());
263 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
266 export const loadCollectionContentAddress = handleFirstTimeLoad(
267 async (dispatch: Dispatch<any>) => {
268 await dispatch(loadCollectionsContentAddressPanel());
272 export const loadTrash = () =>
273 handleFirstTimeLoad((dispatch: Dispatch) => {
274 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
275 dispatch<any>(loadTrashPanel());
276 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
279 export const loadAllProcesses = () =>
280 handleFirstTimeLoad((dispatch: Dispatch) => {
282 activateSidePanelTreeItem(SidePanelTreeCategory.ALL_PROCESSES)
284 dispatch<any>(loadAllProcessesPanel());
285 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.ALL_PROCESSES));
288 export const loadProject = (uuid: string) =>
291 dispatch: Dispatch<any>,
292 getState: () => RootState,
293 services: ServiceRepository
295 const userUuid = getUserUuid(getState());
296 dispatch(setIsProjectPanelTrashed(false));
300 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
301 // Load another users home projects
302 dispatch(finishLoadingProject(uuid));
303 } else if (userUuid !== uuid) {
304 await dispatch(finishLoadingProject(uuid));
305 const match = await loadGroupContentsResource({
312 await dispatch(activateSidePanelTreeItem(uuid));
313 dispatch<any>(setSidePanelBreadcrumbs(uuid));
315 SHARED: async () => {
316 await dispatch(activateSidePanelTreeItem(uuid));
317 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
319 TRASHED: async () => {
321 activateSidePanelTreeItem(SidePanelTreeCategory.TRASH)
323 dispatch<any>(setTrashBreadcrumbs(uuid));
324 dispatch(setIsProjectPanelTrashed(true));
328 await dispatch(finishLoadingProject(userUuid));
329 await dispatch(activateSidePanelTreeItem(userUuid));
330 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
335 export const createProject =
336 (data: projectCreateActions.ProjectCreateFormDialogData) =>
337 async (dispatch: Dispatch) => {
338 const newProject = await dispatch<any>(
339 projectCreateActions.createProject(data)
343 snackbarActions.OPEN_SNACKBAR({
344 message: 'Project has been successfully created.',
346 kind: SnackbarKind.SUCCESS,
349 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
350 dispatch<any>(navigateTo(newProject.uuid));
354 export const moveProject =
355 (data: MoveToFormDialogData) =>
358 getState: () => RootState,
359 services: ServiceRepository
362 const oldProject = getResource(data.uuid)(getState().resources);
363 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
364 const movedProject = await dispatch<any>(
365 projectMoveActions.moveProject(data)
369 snackbarActions.OPEN_SNACKBAR({
370 message: 'Project has been moved',
372 kind: SnackbarKind.SUCCESS,
376 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
379 reloadProjectMatchingUuid([
381 movedProject.ownerUuid,
388 snackbarActions.OPEN_SNACKBAR({
391 kind: SnackbarKind.ERROR,
397 export const updateProject =
398 (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
399 async (dispatch: Dispatch) => {
400 const updatedProject = await dispatch<any>(
401 projectUpdateActions.updateProject(data)
403 if (updatedProject) {
405 snackbarActions.OPEN_SNACKBAR({
406 message: 'Project has been successfully updated.',
408 kind: SnackbarKind.SUCCESS,
411 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
413 reloadProjectMatchingUuid([
414 updatedProject.ownerUuid,
421 export const updateGroup =
422 (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
423 async (dispatch: Dispatch) => {
424 const updatedGroup = await dispatch<any>(
425 groupPanelActions.updateGroup(data)
429 snackbarActions.OPEN_SNACKBAR({
430 message: 'Group has been successfully updated.',
432 kind: SnackbarKind.SUCCESS,
435 await dispatch<any>(loadSidePanelTreeProjects(updatedGroup.ownerUuid));
437 reloadProjectMatchingUuid([updatedGroup.ownerUuid, updatedGroup.uuid])
442 export const loadCollection = (uuid: string) =>
445 dispatch: Dispatch<any>,
446 getState: () => RootState,
447 services: ServiceRepository
449 const userUuid = getUserUuid(getState());
451 const match = await loadGroupContentsResource({
457 OWNED: (collection) => {
459 collectionPanelActions.SET_COLLECTION(
460 collection as CollectionResource
463 dispatch(updateResources([collection]));
464 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
465 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
466 dispatch(loadCollectionPanel(collection.uuid));
468 SHARED: (collection) => {
470 collectionPanelActions.SET_COLLECTION(
471 collection as CollectionResource
474 dispatch(updateResources([collection]));
475 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
476 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
477 dispatch(loadCollectionPanel(collection.uuid));
479 TRASHED: (collection) => {
481 collectionPanelActions.SET_COLLECTION(
482 collection as CollectionResource
485 dispatch(updateResources([collection]));
486 dispatch(setTrashBreadcrumbs(''));
487 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
488 dispatch(loadCollectionPanel(collection.uuid));
495 export const createCollection =
496 (data: collectionCreateActions.CollectionCreateFormDialogData) =>
497 async (dispatch: Dispatch) => {
498 const collection = await dispatch<any>(
499 collectionCreateActions.createCollection(data)
503 snackbarActions.OPEN_SNACKBAR({
504 message: 'Collection has been successfully created.',
506 kind: SnackbarKind.SUCCESS,
509 dispatch<any>(updateResources([collection]));
510 dispatch<any>(navigateTo(collection.uuid));
514 export const copyCollection =
515 (data: CopyFormDialogData) =>
518 getState: () => RootState,
519 services: ServiceRepository
522 const copyToProject = getResource(data.ownerUuid)(getState().resources);
523 const collection = await dispatch<any>(
524 collectionCopyActions.copyCollection(data)
526 if (copyToProject && collection) {
527 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
529 snackbarActions.OPEN_SNACKBAR({
530 message: 'Collection has been copied.',
532 kind: SnackbarKind.SUCCESS,
533 link: collection.ownerUuid,
539 snackbarActions.OPEN_SNACKBAR({
542 kind: SnackbarKind.ERROR,
548 export const moveCollection =
549 (data: MoveToFormDialogData) =>
552 getState: () => RootState,
553 services: ServiceRepository
556 const collection = await dispatch<any>(
557 collectionMoveActions.moveCollection(data)
559 dispatch<any>(updateResources([collection]));
560 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
562 snackbarActions.OPEN_SNACKBAR({
563 message: 'Collection has been moved.',
565 kind: SnackbarKind.SUCCESS,
570 snackbarActions.OPEN_SNACKBAR({
573 kind: SnackbarKind.ERROR,
579 export const loadProcess = (uuid: string) =>
580 handleFirstTimeLoad(async (dispatch: Dispatch, getState: () => RootState) => {
581 dispatch<any>(loadProcessPanel(uuid));
582 const process = await dispatch<any>(processesActions.loadProcess(uuid));
584 activateSidePanelTreeItem(process.containerRequest.ownerUuid)
586 dispatch<any>(setProcessBreadcrumbs(uuid));
587 dispatch<any>(loadDetailsPanel(uuid));
590 export const updateProcess =
591 (data: processUpdateActions.ProcessUpdateFormDialogData) =>
592 async (dispatch: Dispatch) => {
594 const process = await dispatch<any>(
595 processUpdateActions.updateProcess(data)
599 snackbarActions.OPEN_SNACKBAR({
600 message: 'Process has been successfully updated.',
602 kind: SnackbarKind.SUCCESS,
605 dispatch<any>(updateResources([process]));
606 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
610 snackbarActions.OPEN_SNACKBAR({
613 kind: SnackbarKind.ERROR,
619 export const moveProcess =
620 (data: MoveToFormDialogData) =>
623 getState: () => RootState,
624 services: ServiceRepository
627 const process = await dispatch<any>(processMoveActions.moveProcess(data));
628 dispatch<any>(updateResources([process]));
629 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
631 snackbarActions.OPEN_SNACKBAR({
632 message: 'Process has been moved.',
634 kind: SnackbarKind.SUCCESS,
639 snackbarActions.OPEN_SNACKBAR({
642 kind: SnackbarKind.ERROR,
648 export const copyProcess =
649 (data: CopyFormDialogData) =>
652 getState: () => RootState,
653 services: ServiceRepository
656 const process = await dispatch<any>(processCopyActions.copyProcess(data));
657 dispatch<any>(updateResources([process]));
658 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
660 snackbarActions.OPEN_SNACKBAR({
661 message: 'Process has been copied.',
663 kind: SnackbarKind.SUCCESS,
668 snackbarActions.OPEN_SNACKBAR({
671 kind: SnackbarKind.ERROR,
677 export const resourceIsNotLoaded = (uuid: string) =>
678 snackbarActions.OPEN_SNACKBAR({
679 message: `Resource identified by ${uuid} is not loaded.`,
680 kind: SnackbarKind.ERROR,
683 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
684 message: 'User is not authenticated',
685 kind: SnackbarKind.ERROR,
688 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
689 message: 'Could not load user',
690 kind: SnackbarKind.ERROR,
693 export const reloadProjectMatchingUuid =
694 (matchingUuids: string[]) =>
697 getState: () => RootState,
698 services: ServiceRepository
700 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
702 currentProjectPanelUuid &&
703 matchingUuids.some((uuid) => uuid === currentProjectPanelUuid)
705 dispatch<any>(loadProject(currentProjectPanelUuid));
709 export const loadSharedWithMe = handleFirstTimeLoad(
710 async (dispatch: Dispatch) => {
711 dispatch<any>(loadSharedWithMePanel());
713 activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME)
716 setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME)
721 export const loadRunProcess = handleFirstTimeLoad(
722 async (dispatch: Dispatch) => {
723 await dispatch<any>(loadRunProcessPanel());
727 export const loadPublicFavorites = () =>
728 handleFirstTimeLoad((dispatch: Dispatch) => {
730 activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES)
732 dispatch<any>(loadPublicFavoritePanel());
734 setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES)
738 export const loadSearchResults = handleFirstTimeLoad(
739 async (dispatch: Dispatch<any>) => {
740 await dispatch(loadSearchResultsPanel());
744 export const loadLinks = handleFirstTimeLoad(
745 async (dispatch: Dispatch<any>) => {
746 await dispatch(loadLinkPanel());
750 export const loadVirtualMachines = handleFirstTimeLoad(
751 async (dispatch: Dispatch<any>) => {
752 await dispatch(loadVirtualMachinesPanel());
753 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
757 export const loadVirtualMachinesAdmin = handleFirstTimeLoad(
758 async (dispatch: Dispatch<any>) => {
759 await dispatch(loadVirtualMachinesPanel());
761 setBreadcrumbs([{ label: 'Virtual Machines Admin', icon: AdminMenuIcon }])
766 export const loadRepositories = handleFirstTimeLoad(
767 async (dispatch: Dispatch<any>) => {
768 await dispatch(loadRepositoriesPanel());
769 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
773 export const loadSshKeys = handleFirstTimeLoad(
774 async (dispatch: Dispatch<any>) => {
775 await dispatch(loadSshKeysPanel());
779 export const loadSiteManager = handleFirstTimeLoad(
780 async (dispatch: Dispatch<any>) => {
781 await dispatch(loadSiteManagerPanel());
785 export const loadUserProfile = (userUuid?: string) =>
786 handleFirstTimeLoad((dispatch: Dispatch<any>) => {
788 dispatch(setUserProfileBreadcrumbs(userUuid));
789 dispatch(userProfilePanelActions.loadUserProfilePanel(userUuid));
791 dispatch(setMyAccountBreadcrumbs());
792 dispatch(userProfilePanelActions.loadUserProfilePanel());
796 export const loadLinkAccount = handleFirstTimeLoad(
797 (dispatch: Dispatch<any>) => {
798 dispatch(loadLinkAccountPanel());
802 export const loadKeepServices = handleFirstTimeLoad(
803 async (dispatch: Dispatch<any>) => {
804 await dispatch(loadKeepServicesPanel());
808 export const loadUsers = handleFirstTimeLoad(
809 async (dispatch: Dispatch<any>) => {
810 await dispatch(loadUsersPanel());
811 dispatch(setUsersBreadcrumbs());
815 export const loadApiClientAuthorizations = handleFirstTimeLoad(
816 async (dispatch: Dispatch<any>) => {
817 await dispatch(loadApiClientAuthorizationsPanel());
821 export const loadGroupsPanel = handleFirstTimeLoad(
822 (dispatch: Dispatch<any>) => {
823 dispatch(setGroupsBreadcrumbs());
824 dispatch(groupPanelActions.loadGroupsPanel());
828 export const loadGroupDetailsPanel = (groupUuid: string) =>
829 handleFirstTimeLoad((dispatch: Dispatch<any>) => {
830 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
831 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
834 const finishLoadingProject =
835 (project: GroupContentsResource | string) =>
836 async (dispatch: Dispatch<any>) => {
837 const uuid = typeof project === 'string' ? project : project.uuid;
838 dispatch(openProjectPanel(uuid));
839 dispatch(loadDetailsPanel(uuid));
840 if (typeof project !== 'string') {
841 dispatch(updateResources([project]));
845 const loadGroupContentsResource = async (params: {
848 services: ServiceRepository;
850 const filters = new FilterBuilder()
851 .addEqual('uuid', params.uuid)
853 const { items } = await params.services.groupsService.contents(
861 const resource = items.shift();
862 let handler: GroupContentsHandler;
865 (resource.kind === ResourceKind.COLLECTION ||
866 resource.kind === ResourceKind.PROJECT) &&
868 ? groupContentsHandlers.TRASHED(resource)
869 : groupContentsHandlers.OWNED(resource);
871 const kind = extractUuidKind(params.uuid);
872 let resource: GroupContentsResource;
873 if (kind === ResourceKind.COLLECTION) {
874 resource = await params.services.collectionService.get(params.uuid);
875 } else if (kind === ResourceKind.PROJECT) {
876 resource = await params.services.projectService.get(params.uuid);
878 resource = await params.services.containerRequestService.get(params.uuid);
880 handler = groupContentsHandlers.SHARED(resource);
884 typeof groupContentsHandlersRecord,
885 GroupContentsHandler,
888 ) => groupContentsHandlers.match(handler, cases);
891 const groupContentsHandlersRecord = {
892 TRASHED: ofType<GroupContentsResource>(),
893 SHARED: ofType<GroupContentsResource>(),
894 OWNED: ofType<GroupContentsResource>(),
897 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
899 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;