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';
100 import { subprocessPanelActions } from '~/store/subprocess-panel/subprocess-panel-actions';
101 import { subprocessPanelColumns } from '~/views/subprocess-panel/subprocess-panel-root';
102 import { loadAllProcessesPanel, allProcessesPanelActions } from '../all-processes-panel/all-processes-panel-action';
103 import { allProcessesPanelColumns } from '~/views/all-processes-panel/all-processes-panel';
104 import { collectionPanelFilesAction } from '../collection-panel/collection-panel-files/collection-panel-files-actions';
105 import { createTree } from '~/models/tree';
107 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
109 export const isWorkbenchLoading = (state: RootState) => {
110 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
111 return progress ? progress.working : false;
114 const handleFirstTimeLoad = (action: any) =>
115 async (dispatch: Dispatch<any>, getState: () => RootState) => {
117 await dispatch(action);
119 if (isWorkbenchLoading(getState())) {
120 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
125 export const loadWorkbench = () =>
126 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
127 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
128 const { auth, router } = getState();
129 const { user } = auth;
131 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
132 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
133 dispatch(allProcessesPanelActions.SET_COLUMNS({ columns: allProcessesPanelColumns }));
134 dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns }));
135 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
136 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
137 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
138 dispatch(searchResultsPanelActions.SET_FETCH_MODE({ fetchMode: DataTableFetchMode.INFINITE }));
139 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
140 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
141 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
142 dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({ columns: groupDetailsPanelColumns }));
143 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
144 dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
145 dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
146 dispatch(collectionsContentAddressActions.SET_COLUMNS({ columns: collectionContentAddressPanelColumns }));
147 dispatch(subprocessPanelActions.SET_COLUMNS({ columns: subprocessPanelColumns }));
149 if (services.linkAccountService.getAccountToLink()) {
150 dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
153 dispatch<any>(initSidePanelTree());
154 if (router.location) {
155 const match = matchRootRoute(router.location.pathname);
157 dispatch<any>(navigateTo(user.uuid));
161 dispatch(userIsNotAuthenticated);
165 export const loadFavorites = () =>
167 (dispatch: Dispatch) => {
168 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
169 dispatch<any>(loadFavoritePanel());
170 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
173 export const loadCollectionContentAddress = handleFirstTimeLoad(
174 async (dispatch: Dispatch<any>) => {
175 await dispatch(loadCollectionsContentAddressPanel());
178 export const loadTrash = () =>
180 (dispatch: Dispatch) => {
181 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
182 dispatch<any>(loadTrashPanel());
183 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
186 export const loadAllProcesses = () =>
188 (dispatch: Dispatch) => {
189 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.ALL_PROCESSES));
190 dispatch<any>(loadAllProcessesPanel());
191 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.ALL_PROCESSES));
195 export const loadProject = (uuid: string) =>
197 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
198 const userUuid = getUserUuid(getState());
199 dispatch(setIsProjectPanelTrashed(false));
201 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
202 // Load another users home projects
203 dispatch(finishLoadingProject(uuid));
204 } else if (userUuid !== uuid) {
205 const match = await loadGroupContentsResource({ uuid, userUuid, services });
207 OWNED: async project => {
208 await dispatch(activateSidePanelTreeItem(uuid));
209 dispatch<any>(setSidePanelBreadcrumbs(uuid));
210 dispatch(finishLoadingProject(project));
213 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
214 dispatch(activateSidePanelTreeItem(uuid));
215 dispatch(finishLoadingProject(project));
217 TRASHED: project => {
218 dispatch<any>(setTrashBreadcrumbs(uuid));
219 dispatch(setIsProjectPanelTrashed(true));
220 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
221 dispatch(finishLoadingProject(project));
225 await dispatch(activateSidePanelTreeItem(userUuid));
226 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
227 dispatch(finishLoadingProject(userUuid));
232 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
233 async (dispatch: Dispatch) => {
234 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
236 dispatch(snackbarActions.OPEN_SNACKBAR({
237 message: "Project has been successfully created.",
239 kind: SnackbarKind.SUCCESS
241 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
242 dispatch<any>(navigateTo(newProject.uuid));
246 export const moveProject = (data: MoveToFormDialogData) =>
247 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
249 const oldProject = getResource(data.uuid)(getState().resources);
250 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
251 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
253 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
255 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
257 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
260 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
264 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
265 async (dispatch: Dispatch) => {
266 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
267 if (updatedProject) {
268 dispatch(snackbarActions.OPEN_SNACKBAR({
269 message: "Project has been successfully updated.",
271 kind: SnackbarKind.SUCCESS
273 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
274 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
278 export const loadCollection = (uuid: string) =>
280 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
281 const userUuid = getUserUuid(getState());
283 // Clear collection files panel
284 dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() }));
285 const match = await loadGroupContentsResource({ uuid, userUuid, services });
287 OWNED: async collection => {
288 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
289 dispatch(updateResources([collection]));
290 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
291 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
292 dispatch(loadCollectionPanel(collection.uuid));
294 SHARED: collection => {
295 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
296 dispatch(updateResources([collection]));
297 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
298 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
299 dispatch(loadCollectionPanel(collection.uuid));
301 TRASHED: collection => {
302 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
303 dispatch(updateResources([collection]));
304 dispatch(setTrashBreadcrumbs(''));
305 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
306 dispatch(loadCollectionPanel(collection.uuid));
312 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
313 async (dispatch: Dispatch) => {
314 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
316 dispatch(snackbarActions.OPEN_SNACKBAR({
317 message: "Collection has been successfully created.",
319 kind: SnackbarKind.SUCCESS
321 dispatch<any>(updateResources([collection]));
322 dispatch<any>(navigateTo(collection.uuid));
326 export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
327 async (dispatch: Dispatch) => {
329 const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
331 dispatch(snackbarActions.OPEN_SNACKBAR({
332 message: "Collection has been successfully updated.",
334 kind: SnackbarKind.SUCCESS
336 dispatch<any>(updateResources([collection]));
337 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
340 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors.join(''), hideDuration: 2000, kind: SnackbarKind.ERROR }));
344 export const copyCollection = (data: CopyFormDialogData) =>
345 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
347 const copyToProject = getResource(data.ownerUuid)(getState().resources);
348 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
349 if (copyToProject && collection) {
350 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
351 dispatch(snackbarActions.OPEN_SNACKBAR({
352 message: 'Collection has been copied.',
354 kind: SnackbarKind.SUCCESS,
355 link: collection.ownerUuid
359 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
363 export const moveCollection = (data: MoveToFormDialogData) =>
364 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
366 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
367 dispatch<any>(updateResources([collection]));
368 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
369 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
371 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
375 export const loadProcess = (uuid: string) =>
377 async (dispatch: Dispatch, getState: () => RootState) => {
378 dispatch<any>(loadProcessPanel(uuid));
379 const process = await dispatch<any>(processesActions.loadProcess(uuid));
380 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
381 dispatch<any>(setProcessBreadcrumbs(uuid));
382 dispatch(loadDetailsPanel(uuid));
385 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
386 async (dispatch: Dispatch) => {
388 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
390 dispatch(snackbarActions.OPEN_SNACKBAR({
391 message: "Process has been successfully updated.",
393 kind: SnackbarKind.SUCCESS
395 dispatch<any>(updateResources([process]));
396 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
399 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
403 export const moveProcess = (data: MoveToFormDialogData) =>
404 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
406 const process = await dispatch<any>(processMoveActions.moveProcess(data));
407 dispatch<any>(updateResources([process]));
408 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
409 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
411 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
415 export const copyProcess = (data: CopyFormDialogData) =>
416 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
418 const process = await dispatch<any>(processCopyActions.copyProcess(data));
419 dispatch<any>(updateResources([process]));
420 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
421 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
423 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
427 export const loadProcessLog = (uuid: string) =>
429 async (dispatch: Dispatch) => {
430 const process = await dispatch<any>(processesActions.loadProcess(uuid));
431 dispatch<any>(setProcessBreadcrumbs(uuid));
432 dispatch<any>(initProcessLogsPanel(uuid));
433 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
436 export const resourceIsNotLoaded = (uuid: string) =>
437 snackbarActions.OPEN_SNACKBAR({
438 message: `Resource identified by ${uuid} is not loaded.`,
439 kind: SnackbarKind.ERROR
442 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
443 message: 'User is not authenticated',
444 kind: SnackbarKind.ERROR
447 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
448 message: 'Could not load user',
449 kind: SnackbarKind.ERROR
452 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
453 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
454 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
455 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
456 dispatch<any>(loadProject(currentProjectPanelUuid));
460 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
461 dispatch<any>(loadSharedWithMePanel());
462 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
463 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
466 export const loadRunProcess = handleFirstTimeLoad(
467 async (dispatch: Dispatch) => {
468 await dispatch<any>(loadRunProcessPanel());
472 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
473 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
474 await dispatch(loadWorkflowPanel());
475 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
478 export const loadPublicFavorites = () =>
480 (dispatch: Dispatch) => {
481 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES));
482 dispatch<any>(loadPublicFavoritePanel());
483 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES));
486 export const loadSearchResults = handleFirstTimeLoad(
487 async (dispatch: Dispatch<any>) => {
488 await dispatch(loadSearchResultsPanel());
491 export const loadLinks = handleFirstTimeLoad(
492 async (dispatch: Dispatch<any>) => {
493 await dispatch(loadLinkPanel());
496 export const loadVirtualMachines = handleFirstTimeLoad(
497 async (dispatch: Dispatch<any>) => {
498 await dispatch(loadVirtualMachinesPanel());
499 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
502 export const loadRepositories = handleFirstTimeLoad(
503 async (dispatch: Dispatch<any>) => {
504 await dispatch(loadRepositoriesPanel());
505 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
508 export const loadSshKeys = handleFirstTimeLoad(
509 async (dispatch: Dispatch<any>) => {
510 await dispatch(loadSshKeysPanel());
513 export const loadSiteManager = handleFirstTimeLoad(
514 async (dispatch: Dispatch<any>) => {
515 await dispatch(loadSiteManagerPanel());
518 export const loadMyAccount = handleFirstTimeLoad(
519 (dispatch: Dispatch<any>) => {
520 dispatch(loadMyAccountPanel());
523 export const loadLinkAccount = handleFirstTimeLoad(
524 (dispatch: Dispatch<any>) => {
525 dispatch(loadLinkAccountPanel());
528 export const loadKeepServices = handleFirstTimeLoad(
529 async (dispatch: Dispatch<any>) => {
530 await dispatch(loadKeepServicesPanel());
533 export const loadUsers = handleFirstTimeLoad(
534 async (dispatch: Dispatch<any>) => {
535 await dispatch(loadUsersPanel());
536 dispatch(setBreadcrumbs([{ label: 'Users' }]));
539 export const loadComputeNodes = handleFirstTimeLoad(
540 async (dispatch: Dispatch<any>) => {
541 await dispatch(loadComputeNodesPanel());
544 export const loadApiClientAuthorizations = handleFirstTimeLoad(
545 async (dispatch: Dispatch<any>) => {
546 await dispatch(loadApiClientAuthorizationsPanel());
549 export const loadGroupsPanel = handleFirstTimeLoad(
550 (dispatch: Dispatch<any>) => {
551 dispatch(setGroupsBreadcrumbs());
552 dispatch(groupPanelActions.loadGroupsPanel());
556 export const loadGroupDetailsPanel = (groupUuid: string) =>
558 (dispatch: Dispatch<any>) => {
559 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
560 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
563 const finishLoadingProject = (project: GroupContentsResource | string) =>
564 async (dispatch: Dispatch<any>) => {
565 const uuid = typeof project === 'string' ? project : project.uuid;
566 dispatch(openProjectPanel(uuid));
567 dispatch(loadDetailsPanel(uuid));
568 if (typeof project !== 'string') {
569 dispatch(updateResources([project]));
573 const loadGroupContentsResource = async (params: {
576 services: ServiceRepository
578 const filters = new FilterBuilder()
579 .addEqual('uuid', params.uuid)
581 const { items } = await params.services.groupsService.contents(params.userUuid, {
586 const resource = items.shift();
587 let handler: GroupContentsHandler;
589 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
590 ? groupContentsHandlers.TRASHED(resource)
591 : groupContentsHandlers.OWNED(resource);
593 const kind = extractUuidKind(params.uuid);
594 let resource: GroupContentsResource;
595 if (kind === ResourceKind.COLLECTION) {
596 resource = await params.services.collectionService.get(params.uuid);
597 } else if (kind === ResourceKind.PROJECT) {
598 resource = await params.services.projectService.get(params.uuid);
600 resource = await params.services.containerRequestService.get(params.uuid);
602 handler = groupContentsHandlers.SHARED(resource);
604 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
605 groupContentsHandlers.match(handler, cases);
609 const groupContentsHandlersRecord = {
610 TRASHED: ofType<GroupContentsResource>(),
611 SHARED: ofType<GroupContentsResource>(),
612 OWNED: ofType<GroupContentsResource>(),
615 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
617 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;