X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e5e090c801a015f04c04327a176faf54ba3650b7..5df95741b820e18db893c8ce1fac67b921b7fafc:/src/store/compute-nodes/compute-nodes-actions.ts diff --git a/src/store/compute-nodes/compute-nodes-actions.ts b/src/store/compute-nodes/compute-nodes-actions.ts index 659b1e8674..7a76c1296b 100644 --- a/src/store/compute-nodes/compute-nodes-actions.ts +++ b/src/store/compute-nodes/compute-nodes-actions.ts @@ -3,21 +3,18 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from "redux"; -import { unionize, ofType, UnionOf } from "~/common/unionize"; import { RootState } from '~/store/store'; import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions'; -import { ServiceRepository } from "~/services/services"; -import { NodeResource } from '~/models/node'; import { dialogActions } from '~/store/dialog/dialog-actions'; -import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import {snackbarActions, SnackbarKind} from '~/store/snackbar/snackbar-actions'; import { navigateToRootProject } from '~/store/navigation/navigation-action'; +import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action'; +import { getResource } from '~/store/resources/resources'; +import { ServiceRepository } from "~/services/services"; +import { NodeResource } from '~/models/node'; -export const computeNodesActions = unionize({ - SET_COMPUTE_NODES: ofType(), - REMOVE_COMPUTE_NODE: ofType() -}); - -export type ComputeNodesActions = UnionOf; +export const COMPUTE_NODE_PANEL_ID = "computeNodeId"; +export const computeNodesActions = bindDataExplorerActions(COMPUTE_NODE_PANEL_ID); export const COMPUTE_NODE_REMOVE_DIALOG = 'computeNodeRemoveDialog'; export const COMPUTE_NODE_ATTRIBUTES_DIALOG = 'computeNodeAttributesDialog'; @@ -28,20 +25,20 @@ export const loadComputeNodesPanel = () => if (user && user.isAdmin) { try { dispatch(setBreadcrumbs([{ label: 'Compute Nodes' }])); - const response = await services.nodeService.list(); - dispatch(computeNodesActions.SET_COMPUTE_NODES(response.items)); + dispatch(computeNodesActions.REQUEST_ITEMS()); } catch (e) { return; } } else { dispatch(navigateToRootProject); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000 })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000, kind: SnackbarKind.ERROR })); } }; export const openComputeNodeAttributesDialog = (uuid: string) => (dispatch: Dispatch, getState: () => RootState) => { - const computeNode = getState().computeNodes.find(node => node.uuid === uuid); + const { resources } = getState(); + const computeNode = getResource(uuid)(resources); dispatch(dialogActions.OPEN_DIALOG({ id: COMPUTE_NODE_ATTRIBUTES_DIALOG, data: { computeNode } })); }; @@ -60,11 +57,11 @@ export const openComputeNodeRemoveDialog = (uuid: string) => export const removeComputeNode = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...', kind: SnackbarKind.INFO })); try { await services.nodeService.delete(uuid); - dispatch(computeNodesActions.REMOVE_COMPUTE_NODE(uuid)); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Compute node has been successfully removed.', hideDuration: 2000 })); + dispatch(computeNodesActions.REQUEST_ITEMS()); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Compute node has been successfully removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); } catch (e) { return; }