ydb-embedded-ui 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +31 -10
- package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +1 -1
- package/dist/components/CriticalActionDialog/{CriticalActionDialog.js → CriticalActionDialog.tsx} +21 -16
- package/dist/components/CriticalActionDialog/index.ts +1 -0
- package/dist/containers/App/Content.js +1 -1
- package/dist/containers/Nodes/Nodes.scss +4 -0
- package/dist/containers/Nodes/Nodes.tsx +2 -1
- package/dist/containers/Storage/PDisk/PDisk.tsx +9 -4
- package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +2 -2
- package/dist/containers/Storage/StorageNodes/StorageNodes.scss +4 -0
- package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +2 -1
- package/dist/containers/Storage/VDisk/VDisk.tsx +2 -2
- package/dist/containers/Storage/VDiskPopup/VDiskPopup.tsx +2 -2
- package/dist/containers/Tablet/Tablet.tsx +121 -0
- package/dist/containers/Tablet/TabletControls/TabletControls.tsx +159 -0
- package/dist/containers/Tablet/TabletControls/index.ts +1 -0
- package/dist/containers/Tablet/TabletInfo/TabletInfo.tsx +80 -0
- package/dist/containers/Tablet/TabletInfo/index.ts +1 -0
- package/dist/containers/Tablet/TabletTable/TabletTable.tsx +59 -0
- package/dist/containers/Tablet/TabletTable/index.ts +1 -0
- package/dist/containers/Tablet/i18n/en.json +10 -0
- package/dist/containers/Tablet/i18n/index.ts +11 -0
- package/dist/containers/Tablet/i18n/ru.json +10 -0
- package/dist/containers/Tablet/index.ts +1 -0
- package/dist/store/reducers/storage.js +1 -0
- package/dist/types/api/nodes.ts +1 -1
- package/dist/utils/nodes.ts +7 -0
- package/dist/utils/storage.ts +1 -1
- package/package.json +5 -2
- package/dist/containers/Tablet/Tablet.js +0 -448
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.4.3](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.2...v3.4.3) (2023-03-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* add opacity to unavailable nodes ([8b82c78](https://github.com/ydb-platform/ydb-embedded-ui/commit/8b82c78f0b6bed536ca23c63b78b141b29afc4a8))
|
9
|
+
* **Tablet:** add error check ([49f13cf](https://github.com/ydb-platform/ydb-embedded-ui/commit/49f13cf0cff2d6dad59b8f6a4c2885966bf3450a))
|
10
|
+
* **VDisk:** fix typo ([1528d03](https://github.com/ydb-platform/ydb-embedded-ui/commit/1528d03531f482e438e0bdb6c761be236822fc27))
|
11
|
+
|
3
12
|
## [3.4.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.1...v3.4.2) (2023-03-03)
|
4
13
|
|
5
14
|
|
package/README.md
CHANGED
@@ -2,22 +2,42 @@
|
|
2
2
|
|
3
3
|
Local viewer for YDB clusters
|
4
4
|
|
5
|
-
##
|
5
|
+
## Development
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
1) Run on a machine with Docker installed:
|
7
|
+
1. Run on a machine with Docker installed:
|
10
8
|
```
|
11
9
|
docker pull cr.yandex/yc/yandex-docker-local-ydb
|
12
10
|
docker run --hostname localhost -e YDB_ALLOW_ORIGIN="http://localhost:3000" -dp 2135:2135 -dp 8765:8765 cr.yandex/yc/yandex-docker-local-ydb
|
13
11
|
```
|
14
|
-
2
|
15
|
-
3
|
12
|
+
2. Run the frontend app in the development mode, via invoking `npm run dev`
|
13
|
+
3. Open [http://localhost:3000](http://localhost:3000) to view it in the browser. The page will reload if you make edits.\
|
16
14
|
You will also see any lint errors in the console.
|
17
15
|
|
18
16
|
For API reference, open Swagger UI on http://localhost:8765/viewer/api/.
|
19
17
|
|
20
|
-
|
18
|
+
## E2E Tests
|
19
|
+
|
20
|
+
For e2e tests we use `@playwright/tests`. Tests configuration is in `playwright.config.ts`. Tests are set up in `tests` dir.
|
21
|
+
|
22
|
+
### Commands
|
23
|
+
|
24
|
+
Install all Playwright dependencies and chromium to run tests.
|
25
|
+
|
26
|
+
```
|
27
|
+
npm run test:e2e:install
|
28
|
+
```
|
29
|
+
|
30
|
+
Run tests. If `PLAYWRIGHT_BASE_URL` is provided, tests run on this url, otherwise Playwright `webServer` is started with `npm run dev` on `http://localhost:3000` and all tests run there.
|
31
|
+
|
32
|
+
```
|
33
|
+
npm run test:e2e
|
34
|
+
```
|
35
|
+
|
36
|
+
### CI
|
37
|
+
|
38
|
+
E2E tests are run in CI in `e2e_tests` job. Tests run on Playwright `webServer` (it is started with `npm run dev`), `webServer` uses docker container `cr.yandex/yc/yandex-docker-local-ydb` as backend.
|
39
|
+
|
40
|
+
## Making a production bundle.
|
21
41
|
|
22
42
|
Base command `npm run build` builds the app for production to the `build` folder.\
|
23
43
|
It correctly bundles React in production mode and optimizes the build for the best performance.
|
@@ -25,6 +45,7 @@ It correctly bundles React in production mode and optimizes the build for the be
|
|
25
45
|
The build is minified and the filenames include the hashes.
|
26
46
|
|
27
47
|
To test production bundle with latest YDB backend release, do the following:
|
28
|
-
|
29
|
-
|
30
|
-
|
48
|
+
|
49
|
+
1. Build a production bundle with a few tweaks for embedded version: `npm run build:embedded`.
|
50
|
+
2. Invoke `docker run -it --hostname localhost -dp 2135:2135 -p 8765:8765 -v ~/projects/ydb-embedded-ui/build:/ydb_data/node_1/contentmonitoring cr.yandex/yc/yandex-docker-local-ydb:latest`
|
51
|
+
3. Open [embedded YDB UI](http://localhost:8765/monitoring) to view it in the browser.
|
package/dist/components/CriticalActionDialog/{CriticalActionDialog.js → CriticalActionDialog.tsx}
RENAMED
@@ -1,22 +1,34 @@
|
|
1
|
-
import {useState} from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
1
|
+
import {FormEvent, useState} from 'react';
|
3
2
|
import cn from 'bem-cn-lite';
|
4
3
|
import {Dialog} from '@gravity-ui/uikit';
|
4
|
+
|
5
5
|
import {Icon} from '../Icon';
|
6
6
|
|
7
7
|
import './CriticalActionDialog.scss';
|
8
8
|
|
9
|
-
const b = cn('
|
9
|
+
const b = cn('ydb-critical-dialog');
|
10
|
+
|
11
|
+
interface CriticalActionDialogProps {
|
12
|
+
visible: boolean;
|
13
|
+
text: string;
|
14
|
+
onClose: VoidFunction;
|
15
|
+
onConfirm: () => Promise<unknown>;
|
16
|
+
}
|
10
17
|
|
11
|
-
export
|
12
|
-
|
18
|
+
export const CriticalActionDialog = ({
|
19
|
+
visible,
|
20
|
+
text,
|
21
|
+
onClose,
|
22
|
+
onConfirm,
|
23
|
+
}: CriticalActionDialogProps) => {
|
24
|
+
const [isLoading, setIsLoading] = useState(false);
|
13
25
|
|
14
|
-
const onSubmit = (e) => {
|
26
|
+
const onSubmit = async (e: FormEvent) => {
|
15
27
|
e.preventDefault();
|
16
|
-
|
28
|
+
setIsLoading(true);
|
17
29
|
|
18
30
|
return onConfirm().then(() => {
|
19
|
-
|
31
|
+
setIsLoading(false);
|
20
32
|
onClose();
|
21
33
|
});
|
22
34
|
};
|
@@ -32,7 +44,7 @@ export default function CriticalActionDialog({visible, onClose, onConfirm, text}
|
|
32
44
|
</Dialog.Body>
|
33
45
|
|
34
46
|
<Dialog.Footer
|
35
|
-
|
47
|
+
loading={isLoading}
|
36
48
|
preset="default"
|
37
49
|
textButtonApply="Confirm"
|
38
50
|
textButtonCancel="Cancel"
|
@@ -43,11 +55,4 @@ export default function CriticalActionDialog({visible, onClose, onConfirm, text}
|
|
43
55
|
</form>
|
44
56
|
</Dialog>
|
45
57
|
);
|
46
|
-
}
|
47
|
-
|
48
|
-
CriticalActionDialog.propTypes = {
|
49
|
-
visible: PropTypes.bool,
|
50
|
-
onClose: PropTypes.func,
|
51
|
-
onConfirm: PropTypes.func,
|
52
|
-
text: PropTypes.string,
|
53
58
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './CriticalActionDialog';
|
@@ -13,7 +13,7 @@ import Node from '../Node/Node';
|
|
13
13
|
import Pdisk from '../Pdisk/Pdisk';
|
14
14
|
import Group from '../Group/Group';
|
15
15
|
import Pool from '../Pool/Pool';
|
16
|
-
import Tablet from '../Tablet
|
16
|
+
import {Tablet} from '../Tablet';
|
17
17
|
import TabletsFilters from '../TabletsFilters/TabletsFilters';
|
18
18
|
import ReduxTooltip from '../ReduxTooltip/ReduxTooltip';
|
19
19
|
import Header from '../Header/Header';
|
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
|
22
22
|
} from '../../utils/constants';
|
23
23
|
import {useAutofetcher, useTypedSelector} from '../../utils/hooks';
|
24
|
-
import {NodesUptimeFilterValues} from '../../utils/nodes';
|
24
|
+
import {isUnavailableNode, NodesUptimeFilterValues} from '../../utils/nodes';
|
25
25
|
|
26
26
|
import {setHeader} from '../../store/reducers/header';
|
27
27
|
import {
|
@@ -166,6 +166,7 @@ export const Nodes = ({tenantPath, className, additionalNodesInfo = {}}: NodesPr
|
|
166
166
|
order: DataTable.ASCENDING,
|
167
167
|
}}
|
168
168
|
emptyDataMessage={i18n('empty.default')}
|
169
|
+
rowClassName={(row) => b('node', {unavailable: isUnavailableNode(row)})}
|
169
170
|
/>
|
170
171
|
</div>
|
171
172
|
</div>
|
@@ -11,7 +11,7 @@ import {TVDiskStateInfo} from '../../../types/api/vdisk';
|
|
11
11
|
import {stringifyVdiskId} from '../../../utils';
|
12
12
|
import {useTypedSelector} from '../../../utils/hooks';
|
13
13
|
import {getPDiskType} from '../../../utils/pdisk';
|
14
|
-
import {
|
14
|
+
import {isFullVDiskData} from '../../../utils/storage';
|
15
15
|
|
16
16
|
import {STRUCTURE} from '../../Node/NodePages';
|
17
17
|
|
@@ -125,15 +125,20 @@ export const PDisk = ({nodeId, data: rawData = {}}: PDiskProps) => {
|
|
125
125
|
}}
|
126
126
|
>
|
127
127
|
{donors && donors.length ? (
|
128
|
-
<Stack
|
128
|
+
<Stack
|
129
|
+
className={b('donors-stack')}
|
130
|
+
key={stringifyVdiskId(vdisk.VDiskId)}
|
131
|
+
>
|
129
132
|
<VDisk data={vdisk} compact />
|
130
133
|
{donors.map((donor) => {
|
131
|
-
const isFullData =
|
134
|
+
const isFullData = isFullVDiskData(donor);
|
132
135
|
|
133
136
|
return (
|
134
137
|
<VDisk
|
135
138
|
compact
|
136
|
-
data={
|
139
|
+
data={
|
140
|
+
isFullData ? donor : {...donor, DonorMode: true}
|
141
|
+
}
|
137
142
|
key={stringifyVdiskId(
|
138
143
|
isFullData ? donor.VDiskId : donor,
|
139
144
|
)}
|
@@ -16,7 +16,7 @@ import {VisibleEntities} from '../../../store/reducers/storage';
|
|
16
16
|
import {bytesToGB, bytesToSpeed} from '../../../utils/utils';
|
17
17
|
//@ts-ignore
|
18
18
|
import {stringifyVdiskId} from '../../../utils';
|
19
|
-
import {getUsage,
|
19
|
+
import {getUsage, isFullVDiskData} from '../../../utils/storage';
|
20
20
|
|
21
21
|
import {EmptyFilter} from '../EmptyFilter/EmptyFilter';
|
22
22
|
import {VDisk} from '../VDisk';
|
@@ -267,7 +267,7 @@ function StorageGroups({
|
|
267
267
|
nodes={nodes}
|
268
268
|
/>
|
269
269
|
{donors.map((donor) => {
|
270
|
-
const isFullData =
|
270
|
+
const isFullData = isFullVDiskData(donor);
|
271
271
|
|
272
272
|
return (
|
273
273
|
<VDisk
|
@@ -5,7 +5,7 @@ import DataTable, {Column, Settings, SortOrder} from '@gravity-ui/react-data-tab
|
|
5
5
|
import {Popover, PopoverBehavior} from '@gravity-ui/uikit';
|
6
6
|
|
7
7
|
import {VisibleEntities} from '../../../store/reducers/storage';
|
8
|
-
import {NodesUptimeFilterValues} from '../../../utils/nodes';
|
8
|
+
import {isUnavailableNode, NodesUptimeFilterValues} from '../../../utils/nodes';
|
9
9
|
|
10
10
|
import {EmptyFilter} from '../EmptyFilter/EmptyFilter';
|
11
11
|
import {PDisk} from '../PDisk';
|
@@ -190,6 +190,7 @@ function StorageNodes({
|
|
190
190
|
}}
|
191
191
|
initialSortOrder={setSortOrder(visibleEntities)}
|
192
192
|
emptyDataMessage={i18n('empty.default')}
|
193
|
+
rowClassName={(row) => b('node', {unavailable: isUnavailableNode(row)})}
|
193
194
|
/>
|
194
195
|
) : null;
|
195
196
|
}
|
@@ -7,7 +7,7 @@ import routes, {createHref} from '../../../routes';
|
|
7
7
|
import {EFlag} from '../../../types/api/enums';
|
8
8
|
import {EVDiskState, TVDiskStateInfo} from '../../../types/api/vdisk';
|
9
9
|
import {stringifyVdiskId} from '../../../utils';
|
10
|
-
import {
|
10
|
+
import {isFullVDiskData} from '../../../utils/storage';
|
11
11
|
|
12
12
|
import {STRUCTURE} from '../../Node/NodePages';
|
13
13
|
|
@@ -55,7 +55,7 @@ interface VDiskProps {
|
|
55
55
|
}
|
56
56
|
|
57
57
|
export const VDisk = ({data = {}, poolName, nodes, compact}: VDiskProps) => {
|
58
|
-
const isFullData =
|
58
|
+
const isFullData = isFullVDiskData(data);
|
59
59
|
|
60
60
|
const [severity, setSeverity] = useState(
|
61
61
|
getStateSeverity(isFullData ? data.VDiskState : undefined),
|
@@ -9,7 +9,7 @@ import {EFlag} from '../../../types/api/enums';
|
|
9
9
|
import type {TVDiskStateInfo} from '../../../types/api/vdisk';
|
10
10
|
import {stringifyVdiskId} from '../../../utils';
|
11
11
|
import {bytesToGB, bytesToSpeed} from '../../../utils/utils';
|
12
|
-
import {
|
12
|
+
import {isFullVDiskData} from '../../../utils/storage';
|
13
13
|
|
14
14
|
import type {IUnavailableDonor} from '../utils/types';
|
15
15
|
|
@@ -132,7 +132,7 @@ interface VDiskPopupProps extends PopupProps {
|
|
132
132
|
}
|
133
133
|
|
134
134
|
export const VDiskPopup = ({data, poolName, nodes, ...props}: VDiskPopupProps) => {
|
135
|
-
const isFullData =
|
135
|
+
const isFullData = isFullVDiskData(data);
|
136
136
|
|
137
137
|
const vdiskInfo = useMemo(
|
138
138
|
() =>
|
@@ -0,0 +1,121 @@
|
|
1
|
+
import {useCallback, useEffect, useRef} from 'react';
|
2
|
+
import {useParams} from 'react-router';
|
3
|
+
import {useDispatch} from 'react-redux';
|
4
|
+
import cn from 'bem-cn-lite';
|
5
|
+
import {Link as ExternalLink} from '@gravity-ui/uikit';
|
6
|
+
|
7
|
+
import {backend} from '../../store';
|
8
|
+
import {getTablet, getTabletDescribe} from '../../store/reducers/tablet';
|
9
|
+
import {useAutofetcher, useTypedSelector} from '../../utils/hooks';
|
10
|
+
import '../../services/api';
|
11
|
+
|
12
|
+
import EntityStatus from '../../components/EntityStatus/EntityStatus';
|
13
|
+
import {ResponseError} from '../../components/Errors/ResponseError';
|
14
|
+
import {Tag} from '../../components/Tag';
|
15
|
+
import {Icon} from '../../components/Icon';
|
16
|
+
import {EmptyState} from '../../components/EmptyState';
|
17
|
+
import {Loader} from '../../components/Loader';
|
18
|
+
|
19
|
+
import {TabletTable} from './TabletTable';
|
20
|
+
import {TabletInfo} from './TabletInfo';
|
21
|
+
import {TabletControls} from './TabletControls';
|
22
|
+
|
23
|
+
import i18n from './i18n';
|
24
|
+
|
25
|
+
import './Tablet.scss';
|
26
|
+
|
27
|
+
export const b = cn('tablet-page');
|
28
|
+
|
29
|
+
export const Tablet = () => {
|
30
|
+
const isFirstDataFetchRef = useRef(true);
|
31
|
+
|
32
|
+
const dispatch = useDispatch();
|
33
|
+
|
34
|
+
const params = useParams<{id: string}>();
|
35
|
+
const {id} = params;
|
36
|
+
|
37
|
+
const {
|
38
|
+
data: tablet = {},
|
39
|
+
loading,
|
40
|
+
id: tabletId,
|
41
|
+
history = [],
|
42
|
+
tenantPath,
|
43
|
+
error,
|
44
|
+
} = useTypedSelector((state) => state.tablet);
|
45
|
+
|
46
|
+
useEffect(() => {
|
47
|
+
if (isFirstDataFetchRef.current && tablet && tablet.TenantId) {
|
48
|
+
dispatch(getTabletDescribe(tablet.TenantId));
|
49
|
+
isFirstDataFetchRef.current = false;
|
50
|
+
}
|
51
|
+
}, [dispatch, tablet]);
|
52
|
+
|
53
|
+
const fetchData = useCallback(() => {
|
54
|
+
dispatch(getTablet(id));
|
55
|
+
}, [dispatch, id]);
|
56
|
+
|
57
|
+
useAutofetcher(fetchData, [fetchData], true);
|
58
|
+
|
59
|
+
const renderExternalLinks = (link: {name: string; path: string}, index: number) => {
|
60
|
+
return (
|
61
|
+
<li key={index} className={b('link', {external: true})}>
|
62
|
+
<ExternalLink href={`${backend}${link.path}`} target="_blank">
|
63
|
+
{link.name}
|
64
|
+
</ExternalLink>
|
65
|
+
</li>
|
66
|
+
);
|
67
|
+
};
|
68
|
+
|
69
|
+
if (loading && id !== tabletId && isFirstDataFetchRef.current) {
|
70
|
+
return <Loader size="l" />;
|
71
|
+
}
|
72
|
+
|
73
|
+
if (error) {
|
74
|
+
return <ResponseError error={error} />;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!tablet || !Object.keys(tablet).length) {
|
78
|
+
return (
|
79
|
+
<div className={b('placeholder')}>
|
80
|
+
<EmptyState title={i18n('emptyState')} />
|
81
|
+
</div>
|
82
|
+
);
|
83
|
+
}
|
84
|
+
|
85
|
+
const {TabletId, Overall, Leader} = tablet;
|
86
|
+
|
87
|
+
const externalLinks = [
|
88
|
+
{
|
89
|
+
name: 'Internal viewer - tablet',
|
90
|
+
path: `/tablets?TabletID=${TabletId}`,
|
91
|
+
},
|
92
|
+
];
|
93
|
+
|
94
|
+
return (
|
95
|
+
<div className={b()}>
|
96
|
+
<div className={b('pane-wrapper')}>
|
97
|
+
<div className={b('left-pane')}>
|
98
|
+
<ul className={b('links')}>{externalLinks.map(renderExternalLinks)}</ul>
|
99
|
+
<div className={b('row', {header: true})}>
|
100
|
+
<span className={b('title')}>{i18n('tablet.header')}</span>
|
101
|
+
<EntityStatus status={Overall} name={TabletId} />
|
102
|
+
<a
|
103
|
+
rel="noopener noreferrer"
|
104
|
+
className={b('link', {external: true})}
|
105
|
+
href={`${backend}/tablets?TabletID=${TabletId}`}
|
106
|
+
target="_blank"
|
107
|
+
>
|
108
|
+
<Icon name="external" />
|
109
|
+
</a>
|
110
|
+
{Leader && <Tag text="Leader" type="blue" />}
|
111
|
+
</div>
|
112
|
+
<TabletInfo tablet={tablet} tenantPath={tenantPath} />
|
113
|
+
<TabletControls tablet={tablet} />
|
114
|
+
</div>
|
115
|
+
<div className={b('rigth-pane')}>
|
116
|
+
<TabletTable history={history} />
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
);
|
121
|
+
};
|
@@ -0,0 +1,159 @@
|
|
1
|
+
import {useEffect, useState} from 'react';
|
2
|
+
import {Button} from '@gravity-ui/uikit';
|
3
|
+
|
4
|
+
import {ETabletState, TTabletStateInfo} from '../../../types/api/tablet';
|
5
|
+
import {CriticalActionDialog} from '../../../components/CriticalActionDialog';
|
6
|
+
|
7
|
+
import i18n from '../i18n';
|
8
|
+
import {b} from '../Tablet';
|
9
|
+
|
10
|
+
enum EVisibleDialogType {
|
11
|
+
'kill' = 'kill',
|
12
|
+
'stop' = 'kill',
|
13
|
+
'resume' = 'kill',
|
14
|
+
}
|
15
|
+
|
16
|
+
type VisibleDialogType = EVisibleDialogType | null;
|
17
|
+
|
18
|
+
interface TabletControlsProps {
|
19
|
+
tablet: TTabletStateInfo;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const TabletControls = ({tablet}: TabletControlsProps) => {
|
23
|
+
const {TabletId, HiveId} = tablet;
|
24
|
+
|
25
|
+
const [isDialogVisible, setIsDialogVisible] = useState(false);
|
26
|
+
const [visibleDialogType, setVisibleDialogType] = useState<VisibleDialogType>(null);
|
27
|
+
const [isTabletActionsDisabled, setIsTabletActionsDisabled] = useState(false);
|
28
|
+
|
29
|
+
// Enable controls after data update
|
30
|
+
useEffect(() => {
|
31
|
+
setIsTabletActionsDisabled(false);
|
32
|
+
}, [tablet]);
|
33
|
+
|
34
|
+
const makeShowDialog = (type: VisibleDialogType) => () => {
|
35
|
+
setIsDialogVisible(true);
|
36
|
+
setVisibleDialogType(type);
|
37
|
+
};
|
38
|
+
|
39
|
+
const showKillDialog = makeShowDialog(EVisibleDialogType.kill);
|
40
|
+
const showStopDialog = makeShowDialog(EVisibleDialogType.stop);
|
41
|
+
const showResumeDialog = makeShowDialog(EVisibleDialogType.resume);
|
42
|
+
|
43
|
+
const hideDialog = () => {
|
44
|
+
setIsDialogVisible(false);
|
45
|
+
setVisibleDialogType(null);
|
46
|
+
};
|
47
|
+
|
48
|
+
const _onKillClick = () => {
|
49
|
+
setIsTabletActionsDisabled(true);
|
50
|
+
return window.api.killTablet(TabletId);
|
51
|
+
};
|
52
|
+
const _onStopClick = () => {
|
53
|
+
setIsTabletActionsDisabled(true);
|
54
|
+
return window.api.stopTablet(TabletId, HiveId);
|
55
|
+
};
|
56
|
+
const _onResumeClick = () => {
|
57
|
+
setIsTabletActionsDisabled(true);
|
58
|
+
return window.api.resumeTablet(TabletId, HiveId);
|
59
|
+
};
|
60
|
+
|
61
|
+
const hasHiveId = () => {
|
62
|
+
return HiveId && HiveId !== '0';
|
63
|
+
};
|
64
|
+
|
65
|
+
const isDisabledResume = () => {
|
66
|
+
if (isTabletActionsDisabled) {
|
67
|
+
return true;
|
68
|
+
}
|
69
|
+
|
70
|
+
return tablet.State !== ETabletState.Stopped && tablet.State !== ETabletState.Dead;
|
71
|
+
};
|
72
|
+
|
73
|
+
const isDisabledKill = () => {
|
74
|
+
return isTabletActionsDisabled;
|
75
|
+
};
|
76
|
+
|
77
|
+
const isDisabledStop = () => {
|
78
|
+
if (isTabletActionsDisabled) {
|
79
|
+
return true;
|
80
|
+
}
|
81
|
+
|
82
|
+
return tablet.State === ETabletState.Stopped || tablet.State === ETabletState.Deleted;
|
83
|
+
};
|
84
|
+
|
85
|
+
const renderDialog = () => {
|
86
|
+
if (!isDialogVisible) {
|
87
|
+
return null;
|
88
|
+
}
|
89
|
+
|
90
|
+
switch (visibleDialogType) {
|
91
|
+
case EVisibleDialogType.kill: {
|
92
|
+
return (
|
93
|
+
<CriticalActionDialog
|
94
|
+
visible={isDialogVisible}
|
95
|
+
text={i18n('dialog.kill')}
|
96
|
+
onClose={hideDialog}
|
97
|
+
onConfirm={_onKillClick}
|
98
|
+
/>
|
99
|
+
);
|
100
|
+
}
|
101
|
+
case EVisibleDialogType.stop: {
|
102
|
+
return (
|
103
|
+
<CriticalActionDialog
|
104
|
+
visible={isDialogVisible}
|
105
|
+
text={i18n('dialog.stop')}
|
106
|
+
onClose={hideDialog}
|
107
|
+
onConfirm={_onStopClick}
|
108
|
+
/>
|
109
|
+
);
|
110
|
+
}
|
111
|
+
case EVisibleDialogType.resume: {
|
112
|
+
return (
|
113
|
+
<CriticalActionDialog
|
114
|
+
visible={isDialogVisible}
|
115
|
+
text={i18n('dialog.resume')}
|
116
|
+
onClose={hideDialog}
|
117
|
+
onConfirm={_onResumeClick}
|
118
|
+
/>
|
119
|
+
);
|
120
|
+
}
|
121
|
+
default:
|
122
|
+
return null;
|
123
|
+
}
|
124
|
+
};
|
125
|
+
|
126
|
+
return (
|
127
|
+
<div className={b('controls')}>
|
128
|
+
<Button
|
129
|
+
onClick={showKillDialog}
|
130
|
+
view="action"
|
131
|
+
disabled={isDisabledKill()}
|
132
|
+
className={b('control')}
|
133
|
+
>
|
134
|
+
{i18n('controls.kill')}
|
135
|
+
</Button>
|
136
|
+
{hasHiveId() ? (
|
137
|
+
<>
|
138
|
+
<Button
|
139
|
+
onClick={showStopDialog}
|
140
|
+
view="action"
|
141
|
+
disabled={isDisabledStop()}
|
142
|
+
className={b('control')}
|
143
|
+
>
|
144
|
+
{i18n('controls.stop')}
|
145
|
+
</Button>
|
146
|
+
<Button
|
147
|
+
onClick={showResumeDialog}
|
148
|
+
view="action"
|
149
|
+
disabled={isDisabledResume()}
|
150
|
+
className={b('control')}
|
151
|
+
>
|
152
|
+
{i18n('controls.resume')}
|
153
|
+
</Button>
|
154
|
+
</>
|
155
|
+
) : null}
|
156
|
+
{renderDialog()}
|
157
|
+
</div>
|
158
|
+
);
|
159
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './TabletControls';
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import {Link} from 'react-router-dom';
|
2
|
+
|
3
|
+
import {Link as UIKitLink} from '@gravity-ui/uikit';
|
4
|
+
|
5
|
+
import {ETabletState, TTabletStateInfo} from '../../../types/api/tablet';
|
6
|
+
import {InfoViewer, InfoViewerItem} from '../../../components/InfoViewer';
|
7
|
+
import routes, {createHref} from '../../../routes';
|
8
|
+
import {calcUptime} from '../../../utils';
|
9
|
+
import {getDefaultNodePath} from '../../Node/NodePages';
|
10
|
+
|
11
|
+
import {b} from '../Tablet';
|
12
|
+
|
13
|
+
interface TabletInfoProps {
|
14
|
+
tablet: TTabletStateInfo;
|
15
|
+
tenantPath: string;
|
16
|
+
}
|
17
|
+
|
18
|
+
export const TabletInfo = ({tablet, tenantPath}: TabletInfoProps) => {
|
19
|
+
const {
|
20
|
+
ChangeTime,
|
21
|
+
Generation,
|
22
|
+
FollowerId,
|
23
|
+
NodeId,
|
24
|
+
HiveId,
|
25
|
+
State,
|
26
|
+
Type,
|
27
|
+
TenantId: {SchemeShard} = {},
|
28
|
+
} = tablet;
|
29
|
+
|
30
|
+
const hasHiveId = HiveId && HiveId !== '0';
|
31
|
+
const hasUptime = State === ETabletState.Active;
|
32
|
+
|
33
|
+
const tabletInfo: InfoViewerItem[] = [{label: 'Database', value: tenantPath}];
|
34
|
+
|
35
|
+
if (hasHiveId) {
|
36
|
+
tabletInfo.push({
|
37
|
+
label: 'HiveId',
|
38
|
+
value: (
|
39
|
+
<UIKitLink href={createHref(routes.tablet, {id: HiveId})} target="_blank">
|
40
|
+
{HiveId}
|
41
|
+
</UIKitLink>
|
42
|
+
),
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
if (SchemeShard) {
|
47
|
+
tabletInfo.push({
|
48
|
+
label: 'SchemeShard',
|
49
|
+
value: (
|
50
|
+
<UIKitLink href={createHref(routes.tablet, {id: SchemeShard})} target="_blank">
|
51
|
+
{SchemeShard}
|
52
|
+
</UIKitLink>
|
53
|
+
),
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
57
|
+
tabletInfo.push({label: 'Type', value: Type}, {label: 'State', value: State});
|
58
|
+
|
59
|
+
if (hasUptime) {
|
60
|
+
tabletInfo.push({label: 'Uptime', value: calcUptime(ChangeTime)});
|
61
|
+
}
|
62
|
+
|
63
|
+
tabletInfo.push(
|
64
|
+
{label: 'Generation', value: Generation},
|
65
|
+
{
|
66
|
+
label: 'Node',
|
67
|
+
value: (
|
68
|
+
<Link className={b('link')} to={getDefaultNodePath(String(NodeId))}>
|
69
|
+
{NodeId}
|
70
|
+
</Link>
|
71
|
+
),
|
72
|
+
},
|
73
|
+
);
|
74
|
+
|
75
|
+
if (FollowerId) {
|
76
|
+
tabletInfo.push({label: 'Follower', value: FollowerId});
|
77
|
+
}
|
78
|
+
|
79
|
+
return <InfoViewer info={tabletInfo} />;
|
80
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './TabletInfo';
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import DataTable, {Column} from '@gravity-ui/react-data-table';
|
2
|
+
|
3
|
+
import type {ITabletPreparedHistoryItem} from '../../../types/store/tablet';
|
4
|
+
import {calcUptime} from '../../../utils';
|
5
|
+
|
6
|
+
const columns: Column<ITabletPreparedHistoryItem>[] = [
|
7
|
+
{
|
8
|
+
name: 'Generation',
|
9
|
+
align: DataTable.RIGHT,
|
10
|
+
render: ({row}) => row.generation,
|
11
|
+
},
|
12
|
+
{
|
13
|
+
name: 'Node ID',
|
14
|
+
align: DataTable.RIGHT,
|
15
|
+
sortable: false,
|
16
|
+
render: ({row}) => row.nodeId,
|
17
|
+
},
|
18
|
+
{
|
19
|
+
name: 'Change time',
|
20
|
+
align: DataTable.RIGHT,
|
21
|
+
sortable: false,
|
22
|
+
render: ({row}) => calcUptime(row.changeTime),
|
23
|
+
},
|
24
|
+
{
|
25
|
+
name: 'State',
|
26
|
+
sortable: false,
|
27
|
+
render: ({row}) => row.state,
|
28
|
+
},
|
29
|
+
{
|
30
|
+
name: 'Follower ID',
|
31
|
+
sortable: false,
|
32
|
+
render: ({row}) => {
|
33
|
+
return row.leader ? 'leader' : row.followerId;
|
34
|
+
},
|
35
|
+
},
|
36
|
+
];
|
37
|
+
|
38
|
+
const TABLE_SETTINGS = {
|
39
|
+
displayIndices: false,
|
40
|
+
};
|
41
|
+
|
42
|
+
interface TabletTableProps {
|
43
|
+
history: ITabletPreparedHistoryItem[];
|
44
|
+
}
|
45
|
+
|
46
|
+
export const TabletTable = ({history}: TabletTableProps) => {
|
47
|
+
return (
|
48
|
+
<DataTable
|
49
|
+
theme="yandex-cloud"
|
50
|
+
data={history}
|
51
|
+
columns={columns}
|
52
|
+
settings={TABLE_SETTINGS}
|
53
|
+
initialSortOrder={{
|
54
|
+
columnId: 'Generation',
|
55
|
+
order: DataTable.DESCENDING,
|
56
|
+
}}
|
57
|
+
/>
|
58
|
+
);
|
59
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './TabletTable';
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"tablet.header": "Tablet",
|
3
|
+
"controls.kill": "Restart",
|
4
|
+
"controls.stop": "Stop",
|
5
|
+
"controls.resume": "Resume",
|
6
|
+
"dialog.kill": "The tablet will be restarted. Do you want to proceed?",
|
7
|
+
"dialog.stop": "The tablet will be stopped. Do you want to proceed?",
|
8
|
+
"dialog.resume": "The tablet will be resumed. Do you want to proceed?",
|
9
|
+
"emptyState": "The tablet was not found"
|
10
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import {i18n, Lang} from '../../../utils/i18n';
|
2
|
+
|
3
|
+
import en from './en.json';
|
4
|
+
import ru from './ru.json';
|
5
|
+
|
6
|
+
const COMPONENT = 'ydb-tablet-page';
|
7
|
+
|
8
|
+
i18n.registerKeyset(Lang.En, COMPONENT, en);
|
9
|
+
i18n.registerKeyset(Lang.Ru, COMPONENT, ru);
|
10
|
+
|
11
|
+
export default i18n.keyset(COMPONENT);
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"tablet.header": "Таблетка",
|
3
|
+
"controls.kill": "Перезапустить",
|
4
|
+
"controls.stop": "Остановить",
|
5
|
+
"controls.resume": "Запустить",
|
6
|
+
"dialog.kill": "Таблетка будет перезапущена. Вы хотите продолжить?",
|
7
|
+
"dialog.stop": "Таблетка будет остановлена. Вы хотите продолжить?",
|
8
|
+
"dialog.resume": "Таблетка будет запущена. Вы хотите продолжить?",
|
9
|
+
"emptyState": "Таблетка не найдена"
|
10
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './Tablet';
|
@@ -313,6 +313,7 @@ export const getFlatListStorageNodes = createSelector([getStorageNodes], (storag
|
|
313
313
|
}).length;
|
314
314
|
return {
|
315
315
|
NodeId: node.NodeId,
|
316
|
+
SystemState: systemState.SystemState,
|
316
317
|
FQDN: systemState.Host,
|
317
318
|
DataCenter: systemState.DataCenter,
|
318
319
|
Rack: systemState.Rack,
|
package/dist/types/api/nodes.ts
CHANGED
package/dist/utils/nodes.ts
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
import type {TSystemStateInfo} from '../types/api/nodes';
|
2
|
+
import type {INodesPreparedEntity} from '../types/store/nodes';
|
3
|
+
import {EFlag} from '../types/api/enums';
|
4
|
+
|
1
5
|
export enum NodesUptimeFilterValues {
|
2
6
|
'All' = 'All',
|
3
7
|
'SmallUptime' = 'SmallUptime',
|
@@ -7,3 +11,6 @@ export const NodesUptimeFilterTitles = {
|
|
7
11
|
[NodesUptimeFilterValues.All]: 'All',
|
8
12
|
[NodesUptimeFilterValues.SmallUptime]: 'Uptime < 1h',
|
9
13
|
};
|
14
|
+
|
15
|
+
export const isUnavailableNode = (node: INodesPreparedEntity | TSystemStateInfo) =>
|
16
|
+
!node.SystemState || node.SystemState === EFlag.Grey;
|
package/dist/utils/storage.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type {TVSlotId, TVDiskStateInfo} from '../types/api/vdisk';
|
2
2
|
import type {IStoragePoolGroup} from '../types/store/storage';
|
3
3
|
|
4
|
-
export const
|
4
|
+
export const isFullVDiskData = (disk: TVDiskStateInfo | TVSlotId): disk is TVDiskStateInfo =>
|
5
5
|
'VDiskId' in disk;
|
6
6
|
|
7
7
|
export const getUsage = (data: IStoragePoolGroup, step = 1) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ydb-embedded-ui",
|
3
|
-
"version": "3.4.
|
3
|
+
"version": "3.4.3",
|
4
4
|
"files": [
|
5
5
|
"dist"
|
6
6
|
],
|
@@ -53,7 +53,9 @@
|
|
53
53
|
"eject": "react-scripts eject",
|
54
54
|
"prepublishOnly": "npm run package",
|
55
55
|
"typecheck": "tsc --noEmit",
|
56
|
-
"prepare": "husky install"
|
56
|
+
"prepare": "husky install",
|
57
|
+
"test:e2e:install": "npx playwright install --with-deps chromium",
|
58
|
+
"test:e2e": "npx playwright test --config=playwright.config.ts"
|
57
59
|
},
|
58
60
|
"lint-staged": {
|
59
61
|
"*.{scss}": [
|
@@ -104,6 +106,7 @@
|
|
104
106
|
"@gravity-ui/stylelint-config": "^1.0.1",
|
105
107
|
"@gravity-ui/tsconfig": "^1.0.0",
|
106
108
|
"@gravity-ui/uikit": "^3.20.2",
|
109
|
+
"@playwright/test": "^1.31.1",
|
107
110
|
"@testing-library/jest-dom": "^5.15.0",
|
108
111
|
"@testing-library/react": "^11.2.7",
|
109
112
|
"@testing-library/user-event": "^12.8.3",
|
@@ -1,448 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import {connect} from 'react-redux';
|
4
|
-
import {Link} from 'react-router-dom';
|
5
|
-
import cn from 'bem-cn-lite';
|
6
|
-
import _ from 'lodash';
|
7
|
-
|
8
|
-
import {calcUptime} from '../../utils';
|
9
|
-
import {backend} from '../../store';
|
10
|
-
import {getTablet, getTabletDescribe} from '../../store/reducers/tablet';
|
11
|
-
import '../../services/api';
|
12
|
-
|
13
|
-
import InfoViewer from '../../components/InfoViewer/InfoViewer';
|
14
|
-
import EntityStatus from '../../components/EntityStatus/EntityStatus';
|
15
|
-
import {Tag} from '../../components/Tag';
|
16
|
-
import {Icon} from '../../components/Icon';
|
17
|
-
import {EmptyState} from '../../components/EmptyState';
|
18
|
-
import {Link as ExternalLink, Button, Loader} from '@gravity-ui/uikit';
|
19
|
-
import DataTable from '@gravity-ui/react-data-table';
|
20
|
-
import CriticalActionDialog from '../../components/CriticalActionDialog/CriticalActionDialog';
|
21
|
-
import routes, {createHref} from '../../routes';
|
22
|
-
import {getDefaultNodePath} from '../Node/NodePages';
|
23
|
-
|
24
|
-
import './Tablet.scss';
|
25
|
-
|
26
|
-
const b = cn('tablet-page');
|
27
|
-
|
28
|
-
const TABLE_SETTINGS = {
|
29
|
-
displayIndices: false,
|
30
|
-
};
|
31
|
-
|
32
|
-
const CLUSTERS_COLUMNS = [
|
33
|
-
{
|
34
|
-
name: 'generation',
|
35
|
-
header: 'Generation',
|
36
|
-
align: DataTable.RIGHT,
|
37
|
-
},
|
38
|
-
{
|
39
|
-
name: 'nodeId',
|
40
|
-
header: 'Node ID',
|
41
|
-
align: DataTable.RIGHT,
|
42
|
-
sortable: false,
|
43
|
-
},
|
44
|
-
{
|
45
|
-
name: 'changeTime',
|
46
|
-
header: 'Change time',
|
47
|
-
align: DataTable.RIGHT,
|
48
|
-
sortable: false,
|
49
|
-
render: ({value}) => calcUptime(value),
|
50
|
-
},
|
51
|
-
{
|
52
|
-
name: 'state',
|
53
|
-
header: 'State',
|
54
|
-
sortable: false,
|
55
|
-
},
|
56
|
-
{
|
57
|
-
name: 'follower_id',
|
58
|
-
header: 'Follower ID',
|
59
|
-
sortable: false,
|
60
|
-
render: ({row}) => {
|
61
|
-
return row.leader ? 'leader' : row.followerId;
|
62
|
-
},
|
63
|
-
},
|
64
|
-
];
|
65
|
-
|
66
|
-
class Tablet extends React.Component {
|
67
|
-
static propTypes = {
|
68
|
-
id: PropTypes.string,
|
69
|
-
tablet: PropTypes.object,
|
70
|
-
loading: PropTypes.bool,
|
71
|
-
getTablet: PropTypes.func,
|
72
|
-
getTabletDescribe: PropTypes.func,
|
73
|
-
tenantPath: PropTypes.string,
|
74
|
-
tabletId: PropTypes.string,
|
75
|
-
};
|
76
|
-
|
77
|
-
componentDidMount() {
|
78
|
-
this.fetchTabletInfo();
|
79
|
-
}
|
80
|
-
|
81
|
-
componentDidUpdate(prevProps) {
|
82
|
-
const {version} = this.props;
|
83
|
-
|
84
|
-
if (version && !prevProps.version) {
|
85
|
-
this.fetchTabletInfo();
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
componentWillUnmount() {
|
90
|
-
if (this.fetcher) {
|
91
|
-
clearInterval(this.fetcher);
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
state = {
|
96
|
-
typeVisibleDialog: null,
|
97
|
-
dialogVisible: false,
|
98
|
-
isFirstFetchData: true,
|
99
|
-
tenantPath: '-',
|
100
|
-
disableTabletActions: false,
|
101
|
-
};
|
102
|
-
|
103
|
-
makeShowDialog = (type) => () => this.setState({dialogVisible: true, typeVisibleDialog: type});
|
104
|
-
showKillDialog = this.makeShowDialog('kill');
|
105
|
-
showStopDialog = this.makeShowDialog('stop');
|
106
|
-
showResumeDialog = this.makeShowDialog('resume');
|
107
|
-
hideDialog = () => this.setState({dialogVisible: false, typeVisibleDialog: null});
|
108
|
-
|
109
|
-
fetchTabletInfo = () => {
|
110
|
-
const {version, id} = this.props;
|
111
|
-
const {isFirstFetchData} = this.state;
|
112
|
-
|
113
|
-
if (version && this.isValidVersion()) {
|
114
|
-
this.props.getTablet(id).then(({tabletData}) => {
|
115
|
-
if (isFirstFetchData && tabletData.TenantId) {
|
116
|
-
this.props.getTabletDescribe(tabletData.TenantId);
|
117
|
-
}
|
118
|
-
|
119
|
-
this.setState({isFirstFetchData: false});
|
120
|
-
});
|
121
|
-
|
122
|
-
if (this.fetcher) {
|
123
|
-
clearInterval(this.fetcher);
|
124
|
-
this.fetcher = null;
|
125
|
-
}
|
126
|
-
|
127
|
-
this.fetcher = setInterval(() => {
|
128
|
-
this.props.getTablet(id).then(() => {
|
129
|
-
this.setState({disableTabletActions: false});
|
130
|
-
});
|
131
|
-
}, 10000);
|
132
|
-
}
|
133
|
-
};
|
134
|
-
|
135
|
-
isValidVersion = () => {
|
136
|
-
const {version} = this.props;
|
137
|
-
|
138
|
-
if (/\d+.stable-19-6$/.exec(version)) {
|
139
|
-
return false;
|
140
|
-
} else if (/\d+.stable-29/.exec(version)) {
|
141
|
-
return false;
|
142
|
-
}
|
143
|
-
|
144
|
-
return true;
|
145
|
-
};
|
146
|
-
renderLoader() {
|
147
|
-
return (
|
148
|
-
<div className={'loader'}>
|
149
|
-
<Loader size="l" />
|
150
|
-
</div>
|
151
|
-
);
|
152
|
-
}
|
153
|
-
renderPlaceholder() {
|
154
|
-
return (
|
155
|
-
<div className={b('placeholder')}>
|
156
|
-
<EmptyState title="The tablet was not found" />
|
157
|
-
</div>
|
158
|
-
);
|
159
|
-
}
|
160
|
-
renderExternalLinks = (link, index) => {
|
161
|
-
return (
|
162
|
-
<li key={index} className={b('link', {external: true})}>
|
163
|
-
<ExternalLink href={`${backend}${link.path}`} target="_blank">
|
164
|
-
{link.name}
|
165
|
-
</ExternalLink>
|
166
|
-
</li>
|
167
|
-
);
|
168
|
-
};
|
169
|
-
_onKillClick = () => {
|
170
|
-
const {TabletId: id} = this.props.tablet;
|
171
|
-
|
172
|
-
this.setState({disableTabletActions: true});
|
173
|
-
|
174
|
-
return window.api.killTablet(id);
|
175
|
-
};
|
176
|
-
_onStopClick = () => {
|
177
|
-
const {TabletId: id, HiveId: hiveId} = this.props.tablet;
|
178
|
-
|
179
|
-
this.setState({disableTabletActions: true});
|
180
|
-
|
181
|
-
return window.api.stopTablet(id, hiveId);
|
182
|
-
};
|
183
|
-
_onResumeClick = () => {
|
184
|
-
const {TabletId: id, HiveId: hiveId} = this.props.tablet;
|
185
|
-
|
186
|
-
this.setState({disableTabletActions: true});
|
187
|
-
|
188
|
-
return window.api.resumeTablet(id, hiveId);
|
189
|
-
};
|
190
|
-
renderDialog = () => {
|
191
|
-
const {dialogVisible, typeVisibleDialog} = this.state;
|
192
|
-
|
193
|
-
if (!dialogVisible) {
|
194
|
-
return null;
|
195
|
-
}
|
196
|
-
|
197
|
-
switch (typeVisibleDialog) {
|
198
|
-
case 'kill': {
|
199
|
-
return (
|
200
|
-
<CriticalActionDialog
|
201
|
-
visible={dialogVisible}
|
202
|
-
text="The tablet will be restarted. Do you want to proceed?"
|
203
|
-
onClose={this.hideDialog}
|
204
|
-
onConfirm={this._onKillClick}
|
205
|
-
/>
|
206
|
-
);
|
207
|
-
}
|
208
|
-
case 'stop': {
|
209
|
-
return (
|
210
|
-
<CriticalActionDialog
|
211
|
-
visible={dialogVisible}
|
212
|
-
text="The tablet will be stopped. Do you want to proceed?"
|
213
|
-
onClose={this.hideDialog}
|
214
|
-
onConfirm={this._onStopClick}
|
215
|
-
/>
|
216
|
-
);
|
217
|
-
}
|
218
|
-
case 'resume': {
|
219
|
-
return (
|
220
|
-
<CriticalActionDialog
|
221
|
-
visible={dialogVisible}
|
222
|
-
text="The tablet will be resumed. Do you want to proceed?"
|
223
|
-
onClose={this.hideDialog}
|
224
|
-
onConfirm={this._onResumeClick}
|
225
|
-
/>
|
226
|
-
);
|
227
|
-
}
|
228
|
-
default:
|
229
|
-
return null;
|
230
|
-
}
|
231
|
-
};
|
232
|
-
|
233
|
-
hasUptime = () => {
|
234
|
-
const {tablet} = this.props;
|
235
|
-
|
236
|
-
return tablet.State === 'Active';
|
237
|
-
};
|
238
|
-
|
239
|
-
hasHiveId = () => {
|
240
|
-
const {tablet} = this.props;
|
241
|
-
const {HiveId} = tablet;
|
242
|
-
|
243
|
-
return HiveId && HiveId !== '0';
|
244
|
-
};
|
245
|
-
|
246
|
-
getSchemeShard = () => {
|
247
|
-
const {tablet} = this.props;
|
248
|
-
|
249
|
-
return _.get(tablet, 'TenantId.SchemeShard');
|
250
|
-
};
|
251
|
-
|
252
|
-
isDisabledResume = () => {
|
253
|
-
const {tablet} = this.props;
|
254
|
-
const {disableTabletActions} = this.state;
|
255
|
-
|
256
|
-
if (disableTabletActions) {
|
257
|
-
return true;
|
258
|
-
}
|
259
|
-
|
260
|
-
return tablet.State !== 'Stopped' && tablet.State !== 'Dead';
|
261
|
-
};
|
262
|
-
|
263
|
-
isDisabledKill = () => {
|
264
|
-
const {disableTabletActions} = this.state;
|
265
|
-
|
266
|
-
return disableTabletActions;
|
267
|
-
};
|
268
|
-
|
269
|
-
isDisabledStop = () => {
|
270
|
-
const {tablet} = this.props;
|
271
|
-
const {disableTabletActions} = this.state;
|
272
|
-
|
273
|
-
if (disableTabletActions) {
|
274
|
-
return true;
|
275
|
-
}
|
276
|
-
|
277
|
-
return tablet.State === 'Stopped' || tablet.State === 'Deleted';
|
278
|
-
};
|
279
|
-
|
280
|
-
renderTablet = () => {
|
281
|
-
const {tablet, tenantPath} = this.props;
|
282
|
-
const {TabletId: id} = tablet;
|
283
|
-
const schemeShard = this.getSchemeShard();
|
284
|
-
|
285
|
-
const tabletInfo = [
|
286
|
-
{label: 'Database', value: tenantPath},
|
287
|
-
this.hasHiveId()
|
288
|
-
? {
|
289
|
-
label: 'HiveId',
|
290
|
-
value: (
|
291
|
-
<ExternalLink
|
292
|
-
href={createHref(routes.tablet, {id: tablet.HiveId})}
|
293
|
-
target="_blank"
|
294
|
-
>
|
295
|
-
{tablet.HiveId}
|
296
|
-
</ExternalLink>
|
297
|
-
),
|
298
|
-
}
|
299
|
-
: null,
|
300
|
-
schemeShard
|
301
|
-
? {
|
302
|
-
label: 'SchemeShard',
|
303
|
-
value: (
|
304
|
-
<ExternalLink
|
305
|
-
href={createHref(routes.tablet, {id: schemeShard})}
|
306
|
-
target="_blank"
|
307
|
-
>
|
308
|
-
{schemeShard}
|
309
|
-
</ExternalLink>
|
310
|
-
),
|
311
|
-
}
|
312
|
-
: null,
|
313
|
-
{label: 'Type', value: tablet.Type},
|
314
|
-
{label: 'State', value: tablet.State},
|
315
|
-
this.hasUptime() ? {label: 'Uptime', value: calcUptime(tablet.ChangeTime)} : null,
|
316
|
-
{label: 'Generation', value: tablet.Generation},
|
317
|
-
{
|
318
|
-
label: 'Node',
|
319
|
-
value: (
|
320
|
-
<Link className={b('link')} to={getDefaultNodePath(String(tablet.NodeId))}>
|
321
|
-
{tablet.NodeId}
|
322
|
-
</Link>
|
323
|
-
),
|
324
|
-
},
|
325
|
-
].filter(Boolean);
|
326
|
-
|
327
|
-
if (tablet.SlaveId || tablet.FollowerId) {
|
328
|
-
tabletInfo.push({label: 'Follower', value: tablet.SlaveId || tablet.FollowerId});
|
329
|
-
}
|
330
|
-
|
331
|
-
const externalLinks = [
|
332
|
-
{
|
333
|
-
name: 'Internal viewer - tablet',
|
334
|
-
path: `/tablets?TabletID=${id}`,
|
335
|
-
},
|
336
|
-
];
|
337
|
-
|
338
|
-
return (
|
339
|
-
<div className={b()}>
|
340
|
-
<div className={b('pane-wrapper')}>
|
341
|
-
<div className={b('left-pane')}>
|
342
|
-
<ul className={b('links')}>
|
343
|
-
{externalLinks.map(this.renderExternalLinks)}
|
344
|
-
</ul>
|
345
|
-
<div className={b('row', {header: true})}>
|
346
|
-
<span className={b('title')}>Tablet</span>
|
347
|
-
<EntityStatus status={tablet.Overall} name={tablet.TabletId} />
|
348
|
-
<a
|
349
|
-
rel="noopener noreferrer"
|
350
|
-
className={b('link', {external: true})}
|
351
|
-
href={`${backend}/tablets?TabletID=${tablet.TabletId}`}
|
352
|
-
target="_blank"
|
353
|
-
>
|
354
|
-
<Icon name="external" />
|
355
|
-
</a>
|
356
|
-
{(tablet.Master || tablet.Leader) && <Tag text="Leader" type="blue" />}
|
357
|
-
</div>
|
358
|
-
<InfoViewer info={tabletInfo} />
|
359
|
-
<div className={b('controls')}>
|
360
|
-
<Button
|
361
|
-
onClick={this.showKillDialog}
|
362
|
-
view="action"
|
363
|
-
disabled={this.isDisabledKill()}
|
364
|
-
className={b('control')}
|
365
|
-
>
|
366
|
-
Restart
|
367
|
-
</Button>
|
368
|
-
{this.hasHiveId() ? (
|
369
|
-
<React.Fragment>
|
370
|
-
<Button
|
371
|
-
onClick={this.showStopDialog}
|
372
|
-
view="action"
|
373
|
-
disabled={this.isDisabledStop()}
|
374
|
-
className={b('control')}
|
375
|
-
>
|
376
|
-
Stop
|
377
|
-
</Button>
|
378
|
-
<Button
|
379
|
-
onClick={this.showResumeDialog}
|
380
|
-
view="action"
|
381
|
-
disabled={this.isDisabledResume()}
|
382
|
-
className={b('control')}
|
383
|
-
>
|
384
|
-
Resume
|
385
|
-
</Button>
|
386
|
-
</React.Fragment>
|
387
|
-
) : null}
|
388
|
-
</div>
|
389
|
-
</div>
|
390
|
-
<div className={b('rigth-pane')}>
|
391
|
-
<DataTable
|
392
|
-
data={this.props.history}
|
393
|
-
columns={CLUSTERS_COLUMNS}
|
394
|
-
settings={TABLE_SETTINGS}
|
395
|
-
initialSortOrder={{
|
396
|
-
columnId: 'generation',
|
397
|
-
order: DataTable.DESCENDING,
|
398
|
-
}}
|
399
|
-
/>
|
400
|
-
</div>
|
401
|
-
</div>
|
402
|
-
{this.renderDialog()}
|
403
|
-
</div>
|
404
|
-
);
|
405
|
-
};
|
406
|
-
|
407
|
-
renderContent = () => {
|
408
|
-
const {tablet} = this.props;
|
409
|
-
return tablet && Object.keys(tablet).length
|
410
|
-
? this.renderTablet()
|
411
|
-
: this.renderPlaceholder();
|
412
|
-
};
|
413
|
-
render() {
|
414
|
-
const {loading, tabletId, id} = this.props;
|
415
|
-
const {isFirstFetchData} = this.state;
|
416
|
-
|
417
|
-
if (this.isValidVersion()) {
|
418
|
-
return loading && id !== tabletId && isFirstFetchData
|
419
|
-
? this.renderLoader()
|
420
|
-
: this.renderContent();
|
421
|
-
}
|
422
|
-
|
423
|
-
return null;
|
424
|
-
}
|
425
|
-
}
|
426
|
-
|
427
|
-
const mapStateToProps = (state, ownProps) => {
|
428
|
-
const {data: tablet = {}, loading, id: tabletId, history = [], tenantPath} = state.tablet;
|
429
|
-
const {id} = ownProps.match.params;
|
430
|
-
const {data: host} = state.host;
|
431
|
-
|
432
|
-
return {
|
433
|
-
tablet,
|
434
|
-
loading,
|
435
|
-
id,
|
436
|
-
tabletId,
|
437
|
-
history,
|
438
|
-
version: host.Version,
|
439
|
-
tenantPath,
|
440
|
-
};
|
441
|
-
};
|
442
|
-
|
443
|
-
const mapDispatchToProps = {
|
444
|
-
getTablet,
|
445
|
-
getTabletDescribe,
|
446
|
-
};
|
447
|
-
|
448
|
-
export default connect(mapStateToProps, mapDispatchToProps)(Tablet);
|