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 { 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 { navigateTo } 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 { loadLinkAccountPanel, linkAccountPanelActions } from '~/store/link-account-panel/link-account-panel-actions';
63 import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
64 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
65 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
66 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
67 import { extractUuidKind, ResourceKind } from '~/models/resource';
68 import { FilterBuilder } from '~/services/api/filter-builder';
69 import { GroupContentsResource } from '~/services/groups-service/groups-service';
70 import { MatchCases, ofType, unionize, UnionOf } from '~/common/unionize';
71 import { loadRunProcessPanel } from '~/store/run-process-panel/run-process-panel-actions';
72 import { collectionPanelActions, loadCollectionPanel } 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";
95 import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action';
96 import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel';
97 import { loadCollectionsContentAddressPanel, collectionsContentAddressActions } from '~/store/collections-content-address-panel/collections-content-address-panel-actions';
98 import { collectionContentAddressPanelColumns } from '~/views/collection-content-address-panel/collection-content-address-panel';
100 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
102 export const isWorkbenchLoading = (state: RootState) => {
103 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
104 return progress ? progress.working : false;
107 const handleFirstTimeLoad = (action: any) =>
108 async (dispatch: Dispatch<any>, getState: () => RootState) => {
110 await dispatch(action);
112 if (isWorkbenchLoading(getState())) {
113 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
118 export const loadWorkbench = () =>
119 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
120 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
121 const { auth, router } = getState();
122 const { user } = auth;
124 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
125 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
126 dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns }));
127 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
128 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
129 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
130 dispatch(searchResultsPanelActions.SET_FETCH_MODE({ fetchMode: DataTableFetchMode.INFINITE }));
131 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
132 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
133 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
134 dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({ columns: groupDetailsPanelColumns }));
135 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
136 dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
137 dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
138 dispatch(collectionsContentAddressActions.SET_COLUMNS({ columns: collectionContentAddressPanelColumns }));
140 if (services.linkAccountService.getAccountToLink()) {
141 dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
144 dispatch<any>(initSidePanelTree());
145 if (router.location) {
146 const match = matchRootRoute(router.location.pathname);
148 dispatch<any>(navigateTo(user.uuid));
152 dispatch(userIsNotAuthenticated);
156 export const loadFavorites = () =>
158 (dispatch: Dispatch) => {
159 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
160 dispatch<any>(loadFavoritePanel());
161 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
164 export const loadCollectionContentAddress = handleFirstTimeLoad(
165 async (dispatch: Dispatch<any>) => {
166 await dispatch(loadCollectionsContentAddressPanel());
169 export const loadTrash = () =>
171 (dispatch: Dispatch) => {
172 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
173 dispatch<any>(loadTrashPanel());
174 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
177 export const loadProject = (uuid: string) =>
179 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
180 const userUuid = services.authService.getUuid();
181 dispatch(setIsProjectPanelTrashed(false));
183 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
184 // Load another users home projects
185 dispatch(finishLoadingProject(uuid));
186 } else if (userUuid !== uuid) {
187 const match = await loadGroupContentsResource({ uuid, userUuid, services });
189 OWNED: async project => {
190 await dispatch(activateSidePanelTreeItem(uuid));
191 dispatch<any>(setSidePanelBreadcrumbs(uuid));
192 dispatch(finishLoadingProject(project));
195 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
196 dispatch(activateSidePanelTreeItem(uuid));
197 dispatch(finishLoadingProject(project));
199 TRASHED: project => {
200 dispatch<any>(setTrashBreadcrumbs(uuid));
201 dispatch(setIsProjectPanelTrashed(true));
202 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
203 dispatch(finishLoadingProject(project));
207 await dispatch(activateSidePanelTreeItem(userUuid));
208 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
209 dispatch(finishLoadingProject(userUuid));
214 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
215 async (dispatch: Dispatch) => {
216 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
218 dispatch(snackbarActions.OPEN_SNACKBAR({
219 message: "Project has been successfully created.",
221 kind: SnackbarKind.SUCCESS
223 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
224 dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
228 export const moveProject = (data: MoveToFormDialogData) =>
229 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
231 const oldProject = getResource(data.uuid)(getState().resources);
232 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
233 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
235 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
237 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
239 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
242 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
246 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
247 async (dispatch: Dispatch) => {
248 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
249 if (updatedProject) {
250 dispatch(snackbarActions.OPEN_SNACKBAR({
251 message: "Project has been successfully updated.",
253 kind: SnackbarKind.SUCCESS
255 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
256 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
260 export const loadCollection = (uuid: string) =>
262 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
263 const userUuid = services.authService.getUuid();
265 const match = await loadGroupContentsResource({ uuid, userUuid, services });
267 OWNED: async collection => {
268 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
269 dispatch(updateResources([collection]));
270 await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
271 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
272 dispatch(loadCollectionPanel(collection.uuid));
274 SHARED: collection => {
275 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
276 dispatch(updateResources([collection]));
277 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
278 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
279 dispatch(loadCollectionPanel(collection.uuid));
281 TRASHED: collection => {
282 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
283 dispatch(updateResources([collection]));
284 dispatch(setTrashBreadcrumbs(''));
285 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
286 dispatch(loadCollectionPanel(collection.uuid));
293 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
294 async (dispatch: Dispatch) => {
295 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
297 dispatch(snackbarActions.OPEN_SNACKBAR({
298 message: "Collection has been successfully created.",
300 kind: SnackbarKind.SUCCESS
302 dispatch<any>(updateResources([collection]));
303 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
307 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
308 async (dispatch: Dispatch) => {
309 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
311 dispatch(snackbarActions.OPEN_SNACKBAR({
312 message: "Collection has been successfully updated.",
314 kind: SnackbarKind.SUCCESS
316 dispatch<any>(updateResources([collection]));
317 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
321 export const copyCollection = (data: CopyFormDialogData) =>
322 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
324 const copyToProject = getResource(data.ownerUuid)(getState().resources);
325 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
326 if (copyToProject && collection) {
327 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
328 dispatch(snackbarActions.OPEN_SNACKBAR({
329 message: 'Collection has been copied.',
331 kind: SnackbarKind.SUCCESS,
332 link: collection.ownerUuid
336 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
340 export const moveCollection = (data: MoveToFormDialogData) =>
341 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
343 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
344 dispatch<any>(updateResources([collection]));
345 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
346 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
348 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
352 export const loadProcess = (uuid: string) =>
354 async (dispatch: Dispatch, getState: () => RootState) => {
355 dispatch<any>(loadProcessPanel(uuid));
356 const process = await dispatch<any>(processesActions.loadProcess(uuid));
357 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
358 dispatch<any>(setProcessBreadcrumbs(uuid));
359 dispatch(loadDetailsPanel(uuid));
362 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
363 async (dispatch: Dispatch) => {
365 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
367 dispatch(snackbarActions.OPEN_SNACKBAR({
368 message: "Process has been successfully updated.",
370 kind: SnackbarKind.SUCCESS
372 dispatch<any>(updateResources([process]));
373 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
376 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
380 export const moveProcess = (data: MoveToFormDialogData) =>
381 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
383 const process = await dispatch<any>(processMoveActions.moveProcess(data));
384 dispatch<any>(updateResources([process]));
385 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
386 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
388 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
392 export const copyProcess = (data: CopyFormDialogData) =>
393 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
395 const process = await dispatch<any>(processCopyActions.copyProcess(data));
396 dispatch<any>(updateResources([process]));
397 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
398 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
400 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
404 export const loadProcessLog = (uuid: string) =>
406 async (dispatch: Dispatch) => {
407 const process = await dispatch<any>(processesActions.loadProcess(uuid));
408 dispatch<any>(setProcessBreadcrumbs(uuid));
409 dispatch<any>(initProcessLogsPanel(uuid));
410 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
413 export const resourceIsNotLoaded = (uuid: string) =>
414 snackbarActions.OPEN_SNACKBAR({
415 message: `Resource identified by ${uuid} is not loaded.`,
416 kind: SnackbarKind.ERROR
419 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
420 message: 'User is not authenticated',
421 kind: SnackbarKind.ERROR
424 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
425 message: 'Could not load user',
426 kind: SnackbarKind.ERROR
429 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
430 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
431 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
432 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
433 dispatch<any>(loadProject(currentProjectPanelUuid));
437 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
438 dispatch<any>(loadSharedWithMePanel());
439 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
440 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
443 export const loadRunProcess = handleFirstTimeLoad(
444 async (dispatch: Dispatch) => {
445 await dispatch<any>(loadRunProcessPanel());
449 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
450 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
451 await dispatch(loadWorkflowPanel());
452 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
455 export const loadPublicFavorites = () =>
457 (dispatch: Dispatch) => {
458 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES));
459 dispatch<any>(loadPublicFavoritePanel());
460 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES));
463 export const loadSearchResults = handleFirstTimeLoad(
464 async (dispatch: Dispatch<any>) => {
465 await dispatch(loadSearchResultsPanel());
468 export const loadLinks = handleFirstTimeLoad(
469 async (dispatch: Dispatch<any>) => {
470 await dispatch(loadLinkPanel());
473 export const loadVirtualMachines = handleFirstTimeLoad(
474 async (dispatch: Dispatch<any>) => {
475 await dispatch(loadVirtualMachinesPanel());
476 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
479 export const loadRepositories = handleFirstTimeLoad(
480 async (dispatch: Dispatch<any>) => {
481 await dispatch(loadRepositoriesPanel());
482 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
485 export const loadSshKeys = handleFirstTimeLoad(
486 async (dispatch: Dispatch<any>) => {
487 await dispatch(loadSshKeysPanel());
490 export const loadSiteManager = handleFirstTimeLoad(
491 async (dispatch: Dispatch<any>) => {
492 await dispatch(loadSiteManagerPanel());
495 export const loadMyAccount = handleFirstTimeLoad(
496 (dispatch: Dispatch<any>) => {
497 dispatch(loadMyAccountPanel());
500 export const loadLinkAccount = handleFirstTimeLoad(
501 (dispatch: Dispatch<any>) => {
502 dispatch(loadLinkAccountPanel());
505 export const loadKeepServices = handleFirstTimeLoad(
506 async (dispatch: Dispatch<any>) => {
507 await dispatch(loadKeepServicesPanel());
510 export const loadUsers = handleFirstTimeLoad(
511 async (dispatch: Dispatch<any>) => {
512 await dispatch(loadUsersPanel());
513 dispatch(setBreadcrumbs([{ label: 'Users' }]));
516 export const loadComputeNodes = handleFirstTimeLoad(
517 async (dispatch: Dispatch<any>) => {
518 await dispatch(loadComputeNodesPanel());
521 export const loadApiClientAuthorizations = handleFirstTimeLoad(
522 async (dispatch: Dispatch<any>) => {
523 await dispatch(loadApiClientAuthorizationsPanel());
526 export const loadGroupsPanel = handleFirstTimeLoad(
527 (dispatch: Dispatch<any>) => {
528 dispatch(setGroupsBreadcrumbs());
529 dispatch(groupPanelActions.loadGroupsPanel());
533 export const loadGroupDetailsPanel = (groupUuid: string) =>
535 (dispatch: Dispatch<any>) => {
536 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
537 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
540 const finishLoadingProject = (project: GroupContentsResource | string) =>
541 async (dispatch: Dispatch<any>) => {
542 const uuid = typeof project === 'string' ? project : project.uuid;
543 dispatch(openProjectPanel(uuid));
544 dispatch(loadDetailsPanel(uuid));
545 if (typeof project !== 'string') {
546 dispatch(updateResources([project]));
550 const loadGroupContentsResource = async (params: {
553 services: ServiceRepository
555 const filters = new FilterBuilder()
556 .addEqual('uuid', params.uuid)
558 const { items } = await params.services.groupsService.contents(params.userUuid, {
563 const resource = items.shift();
564 let handler: GroupContentsHandler;
566 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
567 ? groupContentsHandlers.TRASHED(resource)
568 : groupContentsHandlers.OWNED(resource);
570 const kind = extractUuidKind(params.uuid);
571 let resource: GroupContentsResource;
572 if (kind === ResourceKind.COLLECTION) {
573 resource = await params.services.collectionService.get(params.uuid);
574 } else if (kind === ResourceKind.PROJECT) {
575 resource = await params.services.projectService.get(params.uuid);
577 resource = await params.services.containerRequestService.get(params.uuid);
579 handler = groupContentsHandlers.SHARED(resource);
581 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
582 groupContentsHandlers.match(handler, cases);
586 const groupContentsHandlersRecord = {
587 TRASHED: ofType<GroupContentsResource>(),
588 SHARED: ofType<GroupContentsResource>(),
589 OWNED: ofType<GroupContentsResource>(),
592 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
594 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;