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';
10 import { favoritePanelActions, loadFavoritePanel } from '~/store/favorite-panel/favorite-panel-action';
12 getProjectPanelCurrentUuid,
15 setIsProjectPanelTrashed
16 } from '~/store/project-panel/project-panel-action';
18 activateSidePanelTreeItem,
20 loadSidePanelTreeProjects,
22 } from '~/store/side-panel-tree/side-panel-tree-actions';
23 import { updateResources } from '~/store/resources/resources-actions';
24 import { projectPanelColumns } from '~/views/project-panel/project-panel';
25 import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
26 import { matchRootRoute } from '~/routes/routes';
29 setGroupDetailsBreadcrumbs,
31 setProcessBreadcrumbs,
32 setSharedWithMeBreadcrumbs,
33 setSidePanelBreadcrumbs,
35 } from '~/store/breadcrumbs/breadcrumbs-actions';
36 import { navigateTo } from '~/store/navigation/navigation-action';
37 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
38 import { ServiceRepository } from '~/services/services';
39 import { getResource } from '~/store/resources/resources';
40 import * as projectCreateActions from '~/store/projects/project-create-actions';
41 import * as projectMoveActions from '~/store/projects/project-move-actions';
42 import * as projectUpdateActions from '~/store/projects/project-update-actions';
43 import * as collectionCreateActions from '~/store/collections/collection-create-actions';
44 import * as collectionCopyActions from '~/store/collections/collection-copy-actions';
45 import * as collectionUpdateActions from '~/store/collections/collection-update-actions';
46 import * as collectionMoveActions from '~/store/collections/collection-move-actions';
47 import * as processesActions from '~/store/processes/processes-actions';
48 import * as processMoveActions from '~/store/processes/process-move-actions';
49 import * as processUpdateActions from '~/store/processes/process-update-actions';
50 import * as processCopyActions from '~/store/processes/process-copy-actions';
51 import { trashPanelColumns } from "~/views/trash-panel/trash-panel";
52 import { loadTrashPanel, trashPanelActions } from "~/store/trash-panel/trash-panel-action";
53 import { initProcessLogsPanel } from '~/store/process-logs-panel/process-logs-panel-actions';
54 import { loadProcessPanel } from '~/store/process-panel/process-panel-actions';
56 loadSharedWithMePanel,
57 sharedWithMePanelActions
58 } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
59 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
60 import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
61 import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh';
62 import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
63 import { loadLinkAccountPanel, linkAccountPanelActions } from '~/store/link-account-panel/link-account-panel-actions';
64 import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
65 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
66 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
67 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
68 import { extractUuidKind, ResourceKind } from '~/models/resource';
69 import { FilterBuilder } from '~/services/api/filter-builder';
70 import { GroupContentsResource } from '~/services/groups-service/groups-service';
71 import { MatchCases, ofType, unionize, UnionOf } from '~/common/unionize';
72 import { loadRunProcessPanel } from '~/store/run-process-panel/run-process-panel-actions';
73 import { collectionPanelActions, loadCollectionPanel } from "~/store/collection-panel/collection-panel-action";
74 import { CollectionResource } from "~/models/collection";
76 loadSearchResultsPanel,
77 searchResultsPanelActions
78 } from '~/store/search-results-panel/search-results-panel-actions';
79 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
80 import { loadVirtualMachinesPanel } from '~/store/virtual-machines/virtual-machines-actions';
81 import { loadRepositoriesPanel } from '~/store/repositories/repositories-actions';
82 import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
83 import { loadUsersPanel, userBindedActions } from '~/store/users/users-actions';
84 import { linkPanelActions, loadLinkPanel } from '~/store/link-panel/link-panel-actions';
85 import { computeNodesActions, loadComputeNodesPanel } from '~/store/compute-nodes/compute-nodes-actions';
86 import { linkPanelColumns } from '~/views/link-panel/link-panel-root';
87 import { userPanelColumns } from '~/views/user-panel/user-panel';
88 import { computeNodePanelColumns } from '~/views/compute-node-panel/compute-node-panel-root';
89 import { loadApiClientAuthorizationsPanel, apiClientAuthorizationsActions } from '~/store/api-client-authorizations/api-client-authorizations-actions';
90 import { apiClientAuthorizationPanelColumns } from '~/views/api-client-authorization-panel/api-client-authorization-panel-root';
91 import * as groupPanelActions from '~/store/groups-panel/groups-panel-actions';
92 import { groupsPanelColumns } from '~/views/groups-panel/groups-panel';
93 import * as groupDetailsPanelActions from '~/store/group-details-panel/group-details-panel-actions';
94 import { groupDetailsPanelColumns } from '~/views/group-details-panel/group-details-panel';
95 import { DataTableFetchMode } from "~/components/data-table/data-table";
96 import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action';
97 import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel';
98 import { loadCollectionsContentAddressPanel, collectionsContentAddressActions } from '~/store/collections-content-address-panel/collections-content-address-panel-actions';
99 import { collectionContentAddressPanelColumns } from '~/views/collection-content-address-panel/collection-content-address-panel';
101 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
103 export const isWorkbenchLoading = (state: RootState) => {
104 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
105 return progress ? progress.working : false;
108 const handleFirstTimeLoad = (action: any) =>
109 async (dispatch: Dispatch<any>, getState: () => RootState) => {
111 await dispatch(action);
113 if (isWorkbenchLoading(getState())) {
114 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
119 export const loadWorkbench = () =>
120 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
121 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
122 const { auth, router } = getState();
123 const { user } = auth;
125 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
126 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
127 dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns }));
128 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
129 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
130 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
131 dispatch(searchResultsPanelActions.SET_FETCH_MODE({ fetchMode: DataTableFetchMode.INFINITE }));
132 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
133 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
134 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
135 dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({ columns: groupDetailsPanelColumns }));
136 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
137 dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
138 dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
139 dispatch(collectionsContentAddressActions.SET_COLUMNS({ columns: collectionContentAddressPanelColumns }));
141 if (services.linkAccountService.getAccountToLink()) {
142 dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
145 dispatch<any>(initSidePanelTree());
146 if (router.location) {
147 const match = matchRootRoute(router.location.pathname);
149 dispatch<any>(navigateTo(user.uuid));
153 dispatch(userIsNotAuthenticated);
157 export const loadFavorites = () =>
159 (dispatch: Dispatch) => {
160 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
161 dispatch<any>(loadFavoritePanel());
162 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
165 export const loadCollectionContentAddress = handleFirstTimeLoad(
166 async (dispatch: Dispatch<any>) => {
167 await dispatch(loadCollectionsContentAddressPanel());
170 export const loadTrash = () =>
172 (dispatch: Dispatch) => {
173 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
174 dispatch<any>(loadTrashPanel());
175 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
178 export const loadProject = (uuid: string) =>
180 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
181 const userUuid = getUserUuid(getState());
182 dispatch(setIsProjectPanelTrashed(false));
184 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
185 // Load another users home projects
186 dispatch(finishLoadingProject(uuid));
187 } else if (userUuid !== uuid) {
188 const match = await loadGroupContentsResource({ uuid, userUuid, services });
190 OWNED: async project => {
191 await dispatch(activateSidePanelTreeItem(uuid));
192 dispatch<any>(setSidePanelBreadcrumbs(uuid));
193 dispatch(finishLoadingProject(project));
196 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
197 dispatch(activateSidePanelTreeItem(uuid));
198 dispatch(finishLoadingProject(project));
200 TRASHED: project => {
201 dispatch<any>(setTrashBreadcrumbs(uuid));
202 dispatch(setIsProjectPanelTrashed(true));
203 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
204 dispatch(finishLoadingProject(project));
208 await dispatch(activateSidePanelTreeItem(userUuid));
209 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
210 dispatch(finishLoadingProject(userUuid));
215 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
216 async (dispatch: Dispatch) => {
217 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
219 dispatch(snackbarActions.OPEN_SNACKBAR({
220 message: "Project has been successfully created.",
222 kind: SnackbarKind.SUCCESS
224 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
225 dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
229 export const moveProject = (data: MoveToFormDialogData) =>
230 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
232 const oldProject = getResource(data.uuid)(getState().resources);
233 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
234 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
236 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
238 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
240 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
243 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
247 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
248 async (dispatch: Dispatch) => {
249 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
250 if (updatedProject) {
251 dispatch(snackbarActions.OPEN_SNACKBAR({
252 message: "Project has been successfully updated.",
254 kind: SnackbarKind.SUCCESS
256 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
257 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
261 export const loadCollection = (uuid: string) =>
263 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
264 const userUuid = getUserUuid(getState());
266 const match = await loadGroupContentsResource({ uuid, userUuid, services });
268 OWNED: async collection => {
269 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
270 dispatch(updateResources([collection]));
271 await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
272 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
273 dispatch(loadCollectionPanel(collection.uuid));
275 SHARED: collection => {
276 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
277 dispatch(updateResources([collection]));
278 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
279 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
280 dispatch(loadCollectionPanel(collection.uuid));
282 TRASHED: collection => {
283 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
284 dispatch(updateResources([collection]));
285 dispatch(setTrashBreadcrumbs(''));
286 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
287 dispatch(loadCollectionPanel(collection.uuid));
294 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
295 async (dispatch: Dispatch) => {
296 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
298 dispatch(snackbarActions.OPEN_SNACKBAR({
299 message: "Collection has been successfully created.",
301 kind: SnackbarKind.SUCCESS
303 dispatch<any>(updateResources([collection]));
304 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
308 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
309 async (dispatch: Dispatch) => {
310 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
312 dispatch(snackbarActions.OPEN_SNACKBAR({
313 message: "Collection has been successfully updated.",
315 kind: SnackbarKind.SUCCESS
317 dispatch<any>(updateResources([collection]));
318 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
322 export const copyCollection = (data: CopyFormDialogData) =>
323 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
325 const copyToProject = getResource(data.ownerUuid)(getState().resources);
326 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
327 if (copyToProject && collection) {
328 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
329 dispatch(snackbarActions.OPEN_SNACKBAR({
330 message: 'Collection has been copied.',
332 kind: SnackbarKind.SUCCESS,
333 link: collection.ownerUuid
337 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
341 export const moveCollection = (data: MoveToFormDialogData) =>
342 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
344 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
345 dispatch<any>(updateResources([collection]));
346 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
347 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
349 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
353 export const loadProcess = (uuid: string) =>
355 async (dispatch: Dispatch, getState: () => RootState) => {
356 dispatch<any>(loadProcessPanel(uuid));
357 const process = await dispatch<any>(processesActions.loadProcess(uuid));
358 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
359 dispatch<any>(setProcessBreadcrumbs(uuid));
360 dispatch(loadDetailsPanel(uuid));
363 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
364 async (dispatch: Dispatch) => {
366 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
368 dispatch(snackbarActions.OPEN_SNACKBAR({
369 message: "Process has been successfully updated.",
371 kind: SnackbarKind.SUCCESS
373 dispatch<any>(updateResources([process]));
374 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
377 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
381 export const moveProcess = (data: MoveToFormDialogData) =>
382 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
384 const process = await dispatch<any>(processMoveActions.moveProcess(data));
385 dispatch<any>(updateResources([process]));
386 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
387 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
389 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
393 export const copyProcess = (data: CopyFormDialogData) =>
394 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
396 const process = await dispatch<any>(processCopyActions.copyProcess(data));
397 dispatch<any>(updateResources([process]));
398 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
399 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
401 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
405 export const loadProcessLog = (uuid: string) =>
407 async (dispatch: Dispatch) => {
408 const process = await dispatch<any>(processesActions.loadProcess(uuid));
409 dispatch<any>(setProcessBreadcrumbs(uuid));
410 dispatch<any>(initProcessLogsPanel(uuid));
411 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
414 export const resourceIsNotLoaded = (uuid: string) =>
415 snackbarActions.OPEN_SNACKBAR({
416 message: `Resource identified by ${uuid} is not loaded.`,
417 kind: SnackbarKind.ERROR
420 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
421 message: 'User is not authenticated',
422 kind: SnackbarKind.ERROR
425 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
426 message: 'Could not load user',
427 kind: SnackbarKind.ERROR
430 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
431 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
432 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
433 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
434 dispatch<any>(loadProject(currentProjectPanelUuid));
438 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
439 dispatch<any>(loadSharedWithMePanel());
440 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
441 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
444 export const loadRunProcess = handleFirstTimeLoad(
445 async (dispatch: Dispatch) => {
446 await dispatch<any>(loadRunProcessPanel());
450 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
451 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
452 await dispatch(loadWorkflowPanel());
453 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
456 export const loadPublicFavorites = () =>
458 (dispatch: Dispatch) => {
459 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES));
460 dispatch<any>(loadPublicFavoritePanel());
461 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES));
464 export const loadSearchResults = handleFirstTimeLoad(
465 async (dispatch: Dispatch<any>) => {
466 await dispatch(loadSearchResultsPanel());
469 export const loadLinks = handleFirstTimeLoad(
470 async (dispatch: Dispatch<any>) => {
471 await dispatch(loadLinkPanel());
474 export const loadVirtualMachines = handleFirstTimeLoad(
475 async (dispatch: Dispatch<any>) => {
476 await dispatch(loadVirtualMachinesPanel());
477 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
480 export const loadRepositories = handleFirstTimeLoad(
481 async (dispatch: Dispatch<any>) => {
482 await dispatch(loadRepositoriesPanel());
483 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
486 export const loadSshKeys = handleFirstTimeLoad(
487 async (dispatch: Dispatch<any>) => {
488 await dispatch(loadSshKeysPanel());
491 export const loadSiteManager = handleFirstTimeLoad(
492 async (dispatch: Dispatch<any>) => {
493 await dispatch(loadSiteManagerPanel());
496 export const loadMyAccount = handleFirstTimeLoad(
497 (dispatch: Dispatch<any>) => {
498 dispatch(loadMyAccountPanel());
501 export const loadLinkAccount = handleFirstTimeLoad(
502 (dispatch: Dispatch<any>) => {
503 dispatch(loadLinkAccountPanel());
506 export const loadKeepServices = handleFirstTimeLoad(
507 async (dispatch: Dispatch<any>) => {
508 await dispatch(loadKeepServicesPanel());
511 export const loadUsers = handleFirstTimeLoad(
512 async (dispatch: Dispatch<any>) => {
513 await dispatch(loadUsersPanel());
514 dispatch(setBreadcrumbs([{ label: 'Users' }]));
517 export const loadComputeNodes = handleFirstTimeLoad(
518 async (dispatch: Dispatch<any>) => {
519 await dispatch(loadComputeNodesPanel());
522 export const loadApiClientAuthorizations = handleFirstTimeLoad(
523 async (dispatch: Dispatch<any>) => {
524 await dispatch(loadApiClientAuthorizationsPanel());
527 export const loadGroupsPanel = handleFirstTimeLoad(
528 (dispatch: Dispatch<any>) => {
529 dispatch(setGroupsBreadcrumbs());
530 dispatch(groupPanelActions.loadGroupsPanel());
534 export const loadGroupDetailsPanel = (groupUuid: string) =>
536 (dispatch: Dispatch<any>) => {
537 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
538 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
541 const finishLoadingProject = (project: GroupContentsResource | string) =>
542 async (dispatch: Dispatch<any>) => {
543 const uuid = typeof project === 'string' ? project : project.uuid;
544 dispatch(openProjectPanel(uuid));
545 dispatch(loadDetailsPanel(uuid));
546 if (typeof project !== 'string') {
547 dispatch(updateResources([project]));
551 const loadGroupContentsResource = async (params: {
554 services: ServiceRepository
556 const filters = new FilterBuilder()
557 .addEqual('uuid', params.uuid)
559 const { items } = await params.services.groupsService.contents(params.userUuid, {
564 const resource = items.shift();
565 let handler: GroupContentsHandler;
567 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
568 ? groupContentsHandlers.TRASHED(resource)
569 : groupContentsHandlers.OWNED(resource);
571 const kind = extractUuidKind(params.uuid);
572 let resource: GroupContentsResource;
573 if (kind === ResourceKind.COLLECTION) {
574 resource = await params.services.collectionService.get(params.uuid);
575 } else if (kind === ResourceKind.PROJECT) {
576 resource = await params.services.projectService.get(params.uuid);
578 resource = await params.services.containerRequestService.get(params.uuid);
580 handler = groupContentsHandlers.SHARED(resource);
582 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
583 groupContentsHandlers.match(handler, cases);
587 const groupContentsHandlersRecord = {
588 TRASHED: ofType<GroupContentsResource>(),
589 SHARED: ofType<GroupContentsResource>(),
590 OWNED: ofType<GroupContentsResource>(),
593 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
595 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;