17782: Fixes almost all tests (4 left) mostly by fixing namespace-type imports.
[arvados-workbench2.git] / src / views / compute-node-panel / compute-node-panel-root.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { ShareMeIcon } from 'components/icon/icon';
7 import { DataExplorer } from 'views-components/data-explorer/data-explorer';
8 import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view';
9 import { COMPUTE_NODE_PANEL_ID } from 'store/compute-nodes/compute-nodes-actions';
10 import { DataColumns } from 'components/data-table/data-table';
11 import { SortDirection } from 'components/data-table/data-column';
12 import { createTree } from 'models/tree';
13 import {
14     ComputeNodeInfo, ComputeNodeDomain, ComputeNodeHostname, ComputeNodeJobUuid,
15     ComputeNodeFirstPingAt, ComputeNodeLastPingAt, ComputeNodeIpAddress, CommonUuid
16 } from 'views-components/data-explorer/renderers';
17 import { ResourcesState } from 'store/resources/resources';
18
19 export enum ComputeNodePanelColumnNames {
20     INFO = 'Info',
21     UUID = 'UUID',
22     DOMAIN = 'Domain',
23     FIRST_PING_AT = 'First ping at',
24     HOSTNAME = 'Hostname',
25     IP_ADDRESS = 'IP Address',
26     JOB = 'Job',
27     LAST_PING_AT = 'Last ping at'
28 }
29
30 export const computeNodePanelColumns: DataColumns<string> = [
31     {
32         name: ComputeNodePanelColumnNames.INFO,
33         selected: true,
34         configurable: true,
35         filters: createTree(),
36         render: uuid => <ComputeNodeInfo uuid={uuid} />
37     },
38     {
39         name: ComputeNodePanelColumnNames.UUID,
40         selected: true,
41         configurable: true,
42         sortDirection: SortDirection.NONE,
43         filters: createTree(),
44         render: uuid => <CommonUuid uuid={uuid} />
45     },
46     {
47         name: ComputeNodePanelColumnNames.DOMAIN,
48         selected: true,
49         configurable: true,
50         filters: createTree(),
51         render: uuid => <ComputeNodeDomain uuid={uuid} />
52     },
53     {
54         name: ComputeNodePanelColumnNames.FIRST_PING_AT,
55         selected: true,
56         configurable: true,
57         filters: createTree(),
58         render: uuid => <ComputeNodeFirstPingAt uuid={uuid} />
59     },
60     {
61         name: ComputeNodePanelColumnNames.HOSTNAME,
62         selected: true,
63         configurable: true,
64         filters: createTree(),
65         render: uuid => <ComputeNodeHostname uuid={uuid} />
66     },
67     {
68         name: ComputeNodePanelColumnNames.IP_ADDRESS,
69         selected: true,
70         configurable: true,
71         filters: createTree(),
72         render: uuid => <ComputeNodeIpAddress uuid={uuid} />
73     },
74     {
75         name: ComputeNodePanelColumnNames.JOB,
76         selected: true,
77         configurable: true,
78         filters: createTree(),
79         render: uuid => <ComputeNodeJobUuid uuid={uuid} />
80     },
81     {
82         name: ComputeNodePanelColumnNames.LAST_PING_AT,
83         selected: true,
84         configurable: true,
85         filters: createTree(),
86         render: uuid => <ComputeNodeLastPingAt uuid={uuid} />
87     }
88 ];
89
90 const DEFAULT_MESSAGE = 'Your compute node list is empty.';
91
92 export interface ComputeNodePanelRootActionProps {
93     onItemClick: (item: string) => void;
94     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
95     onItemDoubleClick: (item: string) => void;
96 }
97
98 export interface ComputeNodePanelRootDataProps {
99     resources: ResourcesState;
100 }
101
102 type ComputeNodePanelRootProps = ComputeNodePanelRootActionProps & ComputeNodePanelRootDataProps;
103
104 export const ComputeNodePanelRoot = (props: ComputeNodePanelRootProps) => {
105     return <DataExplorer
106         id={COMPUTE_NODE_PANEL_ID}
107         onRowClick={props.onItemClick}
108         onRowDoubleClick={props.onItemDoubleClick}
109         onContextMenu={props.onContextMenu}
110         contextMenuColumn={true}
111         hideColumnSelector
112         hideSearchInput
113         dataTableDefaultView={
114             <DataTableDefaultView
115                 icon={ShareMeIcon}
116                 messages={[DEFAULT_MESSAGE]} />
117         } />;
118 };