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,
36 setMyAccountBreadcrumbs,
37 setUserProfileBreadcrumbs,
38 } from 'store/breadcrumbs/breadcrumbs-actions';
39 import { navigateTo, navigateToRootProject } from 'store/navigation/navigation-action';
40 import { MoveToFormDialogData } from 'store/move-to-dialog/move-to-dialog';
41 import { ServiceRepository } from 'services/services';
42 import { getResource } from 'store/resources/resources';
43 import * as projectCreateActions from 'store/projects/project-create-actions';
44 import * as projectMoveActions from 'store/projects/project-move-actions';
45 import * as projectUpdateActions from 'store/projects/project-update-actions';
46 import * as collectionCreateActions from 'store/collections/collection-create-actions';
47 import * as collectionCopyActions from 'store/collections/collection-copy-actions';
48 import * as collectionMoveActions from 'store/collections/collection-move-actions';
49 import * as processesActions from 'store/processes/processes-actions';
50 import * as processMoveActions from 'store/processes/process-move-actions';
51 import * as processUpdateActions from 'store/processes/process-update-actions';
52 import * as processCopyActions from 'store/processes/process-copy-actions';
53 import { trashPanelColumns } from "views/trash-panel/trash-panel";
54 import { loadTrashPanel, trashPanelActions } from "store/trash-panel/trash-panel-action";
55 import { initProcessLogsPanel } from 'store/process-logs-panel/process-logs-panel-actions';
56 import { loadProcessPanel } from 'store/process-panel/process-panel-actions';
58 loadSharedWithMePanel,
59 sharedWithMePanelActions
60 } from 'store/shared-with-me-panel/shared-with-me-panel-actions';
61 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
62 import { loadWorkflowPanel, workflowPanelActions } from 'store/workflow-panel/workflow-panel-actions';
63 import { loadSshKeysPanel } from 'store/auth/auth-action-ssh';
64 import { loadLinkAccountPanel, linkAccountPanelActions } from 'store/link-account-panel/link-account-panel-actions';
65 import { loadSiteManagerPanel } from 'store/auth/auth-action-session';
66 import { workflowPanelColumns } from 'views/workflow-panel/workflow-panel-view';
67 import { progressIndicatorActions } from 'store/progress-indicator/progress-indicator-actions';
68 import { getProgressIndicator } from 'store/progress-indicator/progress-indicator-reducer';
69 import { extractUuidKind, ResourceKind } from 'models/resource';
70 import { FilterBuilder } from 'services/api/filter-builder';
71 import { GroupContentsResource } from 'services/groups-service/groups-service';
72 import { MatchCases, ofType, unionize, UnionOf } from 'common/unionize';
73 import { loadRunProcessPanel } from 'store/run-process-panel/run-process-panel-actions';
74 import { collectionPanelActions, loadCollectionPanel } from "store/collection-panel/collection-panel-action";
75 import { CollectionResource } from "models/collection";
77 loadSearchResultsPanel,
78 searchResultsPanelActions
79 } from 'store/search-results-panel/search-results-panel-actions';
80 import { searchResultsPanelColumns } from 'views/search-results-panel/search-results-panel-view';
81 import { loadVirtualMachinesPanel } from 'store/virtual-machines/virtual-machines-actions';
82 import { loadRepositoriesPanel } from 'store/repositories/repositories-actions';
83 import { loadKeepServicesPanel } from 'store/keep-services/keep-services-actions';
84 import { loadUsersPanel, userBindedActions } from 'store/users/users-actions';
85 import * as userProfilePanelActions from 'store/user-profile/user-profile-actions';
86 import { linkPanelActions, loadLinkPanel } from 'store/link-panel/link-panel-actions';
87 import { linkPanelColumns } from 'views/link-panel/link-panel-root';
88 import { userPanelColumns } from 'views/user-panel/user-panel';
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 { groupDetailsMembersPanelColumns, groupDetailsPermissionsPanelColumns } 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';
106 import { AdminMenuIcon } from 'components/icon/icon';
107 import { userProfileGroupsColumns } from 'views/user-profile-panel/user-profile-panel-root';
109 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
111 export const isWorkbenchLoading = (state: RootState) => {
112 const progress = getProgressIndicator(WORKBENCH_LOADING_SCREEN)(state.progressIndicator);
113 return progress ? progress.working : false;
116 export const handleFirstTimeLoad = (action: any) =>
117 async (dispatch: Dispatch<any>, getState: () => RootState) => {
119 await dispatch(action);
121 if (isWorkbenchLoading(getState())) {
122 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
127 export const loadWorkbench = () =>
128 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
129 dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
130 const { auth, router } = getState();
131 const { user } = auth;
133 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
134 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
135 dispatch(allProcessesPanelActions.SET_COLUMNS({ columns: allProcessesPanelColumns }));
136 dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns }));
137 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
138 dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
139 dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
140 dispatch(searchResultsPanelActions.SET_FETCH_MODE({ fetchMode: DataTableFetchMode.INFINITE }));
141 dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
142 dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
143 dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
144 dispatch(groupDetailsPanelActions.GroupMembersPanelActions.SET_COLUMNS({ columns: groupDetailsMembersPanelColumns }));
145 dispatch(groupDetailsPanelActions.GroupPermissionsPanelActions.SET_COLUMNS({ columns: groupDetailsPermissionsPanelColumns }));
146 dispatch(userProfilePanelActions.UserProfileGroupsActions.SET_COLUMNS({ columns: userProfileGroupsColumns }));
147 dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
148 dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
149 dispatch(collectionsContentAddressActions.SET_COLUMNS({ columns: collectionContentAddressPanelColumns }));
150 dispatch(subprocessPanelActions.SET_COLUMNS({ columns: subprocessPanelColumns }));
152 if (services.linkAccountService.getAccountToLink()) {
153 dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
156 dispatch<any>(initSidePanelTree());
157 if (router.location) {
158 const match = matchRootRoute(router.location.pathname);
160 dispatch<any>(navigateToRootProject);
164 dispatch(userIsNotAuthenticated);
168 export const loadFavorites = () =>
170 (dispatch: Dispatch) => {
171 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
172 dispatch<any>(loadFavoritePanel());
173 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
176 export const loadCollectionContentAddress = handleFirstTimeLoad(
177 async (dispatch: Dispatch<any>) => {
178 await dispatch(loadCollectionsContentAddressPanel());
181 export const loadTrash = () =>
183 (dispatch: Dispatch) => {
184 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
185 dispatch<any>(loadTrashPanel());
186 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.TRASH));
189 export const loadAllProcesses = () =>
191 (dispatch: Dispatch) => {
192 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.ALL_PROCESSES));
193 dispatch<any>(loadAllProcessesPanel());
194 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.ALL_PROCESSES));
198 export const loadProject = (uuid: string) =>
200 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
201 const userUuid = getUserUuid(getState());
202 dispatch(setIsProjectPanelTrashed(false));
206 if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
207 // Load another users home projects
208 dispatch(finishLoadingProject(uuid));
209 } else if (userUuid !== uuid) {
210 await dispatch(finishLoadingProject(uuid));
211 const match = await loadGroupContentsResource({ uuid, userUuid, services });
214 await dispatch(activateSidePanelTreeItem(uuid));
215 dispatch<any>(setSidePanelBreadcrumbs(uuid));
217 SHARED: async () => {
218 await dispatch(activateSidePanelTreeItem(uuid));
219 dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
221 TRASHED: async () => {
222 await dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
223 dispatch<any>(setTrashBreadcrumbs(uuid));
224 dispatch(setIsProjectPanelTrashed(true));
228 await dispatch(finishLoadingProject(userUuid));
229 await dispatch(activateSidePanelTreeItem(userUuid));
230 dispatch<any>(setSidePanelBreadcrumbs(userUuid));
234 export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
235 async (dispatch: Dispatch) => {
236 const newProject = await dispatch<any>(projectCreateActions.createProject(data));
238 dispatch(snackbarActions.OPEN_SNACKBAR({
239 message: "Project has been successfully created.",
241 kind: SnackbarKind.SUCCESS
243 await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
244 dispatch<any>(navigateTo(newProject.uuid));
248 export const moveProject = (data: MoveToFormDialogData) =>
249 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
251 const oldProject = getResource(data.uuid)(getState().resources);
252 const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
253 const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
255 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
257 await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
259 dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
262 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
266 export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
267 async (dispatch: Dispatch) => {
268 const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
269 if (updatedProject) {
270 dispatch(snackbarActions.OPEN_SNACKBAR({
271 message: "Project has been successfully updated.",
273 kind: SnackbarKind.SUCCESS
275 await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
276 dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
280 export const updateGroup = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
281 async (dispatch: Dispatch) => {
282 const updatedGroup = await dispatch<any>(groupPanelActions.updateGroup(data));
284 dispatch(snackbarActions.OPEN_SNACKBAR({
285 message: "Group has been successfully updated.",
287 kind: SnackbarKind.SUCCESS
289 await dispatch<any>(loadSidePanelTreeProjects(updatedGroup.ownerUuid));
290 dispatch<any>(reloadProjectMatchingUuid([updatedGroup.ownerUuid, updatedGroup.uuid]));
294 export const loadCollection = (uuid: string) =>
296 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
297 const userUuid = getUserUuid(getState());
299 // Clear collection files panel
300 dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() }));
301 const match = await loadGroupContentsResource({ uuid, userUuid, services });
303 OWNED: async collection => {
304 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
305 dispatch(updateResources([collection]));
306 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
307 dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
308 dispatch(loadCollectionPanel(collection.uuid));
310 SHARED: collection => {
311 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
312 dispatch(updateResources([collection]));
313 dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
314 dispatch(activateSidePanelTreeItem(collection.ownerUuid));
315 dispatch(loadCollectionPanel(collection.uuid));
317 TRASHED: collection => {
318 dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
319 dispatch(updateResources([collection]));
320 dispatch(setTrashBreadcrumbs(''));
321 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
322 dispatch(loadCollectionPanel(collection.uuid));
328 export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
329 async (dispatch: Dispatch) => {
330 const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
332 dispatch(snackbarActions.OPEN_SNACKBAR({
333 message: "Collection has been successfully created.",
335 kind: SnackbarKind.SUCCESS
337 dispatch<any>(updateResources([collection]));
338 dispatch<any>(navigateTo(collection.uuid));
342 export const copyCollection = (data: CopyFormDialogData) =>
343 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
345 const copyToProject = getResource(data.ownerUuid)(getState().resources);
346 const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
347 if (copyToProject && collection) {
348 dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
349 dispatch(snackbarActions.OPEN_SNACKBAR({
350 message: 'Collection has been copied.',
352 kind: SnackbarKind.SUCCESS,
353 link: collection.ownerUuid
357 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
361 export const moveCollection = (data: MoveToFormDialogData) =>
362 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
364 const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
365 dispatch<any>(updateResources([collection]));
366 dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
367 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
369 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
373 export const loadProcess = (uuid: string) =>
375 async (dispatch: Dispatch, getState: () => RootState) => {
376 dispatch<any>(loadProcessPanel(uuid));
377 const process = await dispatch<any>(processesActions.loadProcess(uuid));
378 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
379 dispatch<any>(setProcessBreadcrumbs(uuid));
380 dispatch<any>(loadDetailsPanel(uuid));
383 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
384 async (dispatch: Dispatch) => {
386 const process = await dispatch<any>(processUpdateActions.updateProcess(data));
388 dispatch(snackbarActions.OPEN_SNACKBAR({
389 message: "Process has been successfully updated.",
391 kind: SnackbarKind.SUCCESS
393 dispatch<any>(updateResources([process]));
394 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
397 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
401 export const moveProcess = (data: MoveToFormDialogData) =>
402 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
404 const process = await dispatch<any>(processMoveActions.moveProcess(data));
405 dispatch<any>(updateResources([process]));
406 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
407 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been moved.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
409 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
413 export const copyProcess = (data: CopyFormDialogData) =>
414 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
416 const process = await dispatch<any>(processCopyActions.copyProcess(data));
417 dispatch<any>(updateResources([process]));
418 dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
419 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process has been copied.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
421 dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
425 export const loadProcessLog = (uuid: string) =>
427 async (dispatch: Dispatch) => {
428 const process = await dispatch<any>(processesActions.loadProcess(uuid));
429 dispatch<any>(setProcessBreadcrumbs(uuid));
430 dispatch<any>(initProcessLogsPanel(uuid));
431 await dispatch<any>(activateSidePanelTreeItem(process.containerRequest.ownerUuid));
434 export const resourceIsNotLoaded = (uuid: string) =>
435 snackbarActions.OPEN_SNACKBAR({
436 message: `Resource identified by ${uuid} is not loaded.`,
437 kind: SnackbarKind.ERROR
440 export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
441 message: 'User is not authenticated',
442 kind: SnackbarKind.ERROR
445 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
446 message: 'Could not load user',
447 kind: SnackbarKind.ERROR
450 export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
451 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
452 const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
453 if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
454 dispatch<any>(loadProject(currentProjectPanelUuid));
458 export const loadSharedWithMe = handleFirstTimeLoad(async (dispatch: Dispatch) => {
459 dispatch<any>(loadSharedWithMePanel());
460 await dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
461 await dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
464 export const loadRunProcess = handleFirstTimeLoad(
465 async (dispatch: Dispatch) => {
466 await dispatch<any>(loadRunProcessPanel());
470 export const loadWorkflow = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
471 dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.WORKFLOWS));
472 await dispatch(loadWorkflowPanel());
473 dispatch(setSidePanelBreadcrumbs(SidePanelTreeCategory.WORKFLOWS));
476 export const loadPublicFavorites = () =>
478 (dispatch: Dispatch) => {
479 dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.PUBLIC_FAVORITES));
480 dispatch<any>(loadPublicFavoritePanel());
481 dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.PUBLIC_FAVORITES));
484 export const loadSearchResults = handleFirstTimeLoad(
485 async (dispatch: Dispatch<any>) => {
486 await dispatch(loadSearchResultsPanel());
489 export const loadLinks = handleFirstTimeLoad(
490 async (dispatch: Dispatch<any>) => {
491 await dispatch(loadLinkPanel());
494 export const loadVirtualMachines = handleFirstTimeLoad(
495 async (dispatch: Dispatch<any>) => {
496 await dispatch(loadVirtualMachinesPanel());
497 dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
500 export const loadVirtualMachinesAdmin = handleFirstTimeLoad(
501 async (dispatch: Dispatch<any>) => {
502 await dispatch(loadVirtualMachinesPanel());
503 dispatch(setBreadcrumbs([{ label: 'Virtual Machines Admin', icon: AdminMenuIcon }]));
506 export const loadRepositories = handleFirstTimeLoad(
507 async (dispatch: Dispatch<any>) => {
508 await dispatch(loadRepositoriesPanel());
509 dispatch(setBreadcrumbs([{ label: 'Repositories' }]));
512 export const loadSshKeys = handleFirstTimeLoad(
513 async (dispatch: Dispatch<any>) => {
514 await dispatch(loadSshKeysPanel());
517 export const loadSiteManager = handleFirstTimeLoad(
518 async (dispatch: Dispatch<any>) => {
519 await dispatch(loadSiteManagerPanel());
522 export const loadUserProfile = (userUuid?: string) =>
524 (dispatch: Dispatch<any>) => {
526 dispatch(setUserProfileBreadcrumbs(userUuid));
527 dispatch(userProfilePanelActions.loadUserProfilePanel(userUuid));
529 dispatch(setMyAccountBreadcrumbs());
530 dispatch(userProfilePanelActions.loadUserProfilePanel());
535 export const loadLinkAccount = handleFirstTimeLoad(
536 (dispatch: Dispatch<any>) => {
537 dispatch(loadLinkAccountPanel());
540 export const loadKeepServices = handleFirstTimeLoad(
541 async (dispatch: Dispatch<any>) => {
542 await dispatch(loadKeepServicesPanel());
545 export const loadUsers = handleFirstTimeLoad(
546 async (dispatch: Dispatch<any>) => {
547 await dispatch(loadUsersPanel());
548 dispatch(setUsersBreadcrumbs());
551 export const loadApiClientAuthorizations = handleFirstTimeLoad(
552 async (dispatch: Dispatch<any>) => {
553 await dispatch(loadApiClientAuthorizationsPanel());
556 export const loadGroupsPanel = handleFirstTimeLoad(
557 (dispatch: Dispatch<any>) => {
558 dispatch(setGroupsBreadcrumbs());
559 dispatch(groupPanelActions.loadGroupsPanel());
563 export const loadGroupDetailsPanel = (groupUuid: string) =>
565 (dispatch: Dispatch<any>) => {
566 dispatch(setGroupDetailsBreadcrumbs(groupUuid));
567 dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
570 const finishLoadingProject = (project: GroupContentsResource | string) =>
571 async (dispatch: Dispatch<any>) => {
572 const uuid = typeof project === 'string' ? project : project.uuid;
573 dispatch(openProjectPanel(uuid));
574 dispatch(loadDetailsPanel(uuid));
575 if (typeof project !== 'string') {
576 dispatch(updateResources([project]));
580 const loadGroupContentsResource = async (params: {
583 services: ServiceRepository
585 const filters = new FilterBuilder()
586 .addEqual('uuid', params.uuid)
588 const { items } = await params.services.groupsService.contents(params.userUuid, {
593 const resource = items.shift();
594 let handler: GroupContentsHandler;
596 handler = (resource.kind === ResourceKind.COLLECTION || resource.kind === ResourceKind.PROJECT) && resource.isTrashed
597 ? groupContentsHandlers.TRASHED(resource)
598 : groupContentsHandlers.OWNED(resource);
600 const kind = extractUuidKind(params.uuid);
601 let resource: GroupContentsResource;
602 if (kind === ResourceKind.COLLECTION) {
603 resource = await params.services.collectionService.get(params.uuid);
604 } else if (kind === ResourceKind.PROJECT) {
605 resource = await params.services.projectService.get(params.uuid);
607 resource = await params.services.containerRequestService.get(params.uuid);
609 handler = groupContentsHandlers.SHARED(resource);
611 return (cases: MatchCases<typeof groupContentsHandlersRecord, GroupContentsHandler, void>) =>
612 groupContentsHandlers.match(handler, cases);
616 const groupContentsHandlersRecord = {
617 TRASHED: ofType<GroupContentsResource>(),
618 SHARED: ofType<GroupContentsResource>(),
619 OWNED: ofType<GroupContentsResource>(),
622 const groupContentsHandlers = unionize(groupContentsHandlersRecord);
624 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;