ydb-embedded-ui 3.4.1 → 3.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -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.scss +15 -0
- package/dist/containers/Storage/PDisk/PDisk.tsx +43 -13
- package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +2 -2
- package/dist/containers/Storage/StorageNodes/StorageNodes.scss +8 -2
- package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +3 -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/containers/Tenant/Diagnostics/Partitions/Partitions.tsx +9 -15
- package/dist/containers/Tenant/Diagnostics/Partitions/PartitionsWrapper.tsx +2 -0
- package/dist/store/reducers/storage.js +1 -0
- package/dist/store/reducers/topic.ts +13 -0
- package/dist/types/api/nodes.ts +1 -1
- package/dist/types/store/topic.ts +3 -2
- 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,23 @@
|
|
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
|
+
|
12
|
+
## [3.4.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.1...v3.4.2) (2023-03-03)
|
13
|
+
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* **Partitions:** add search to consumers filter ([95e4462](https://github.com/ydb-platform/ydb-embedded-ui/commit/95e446295cb2b2729daf0d0ef719e37c7c8e0d3c))
|
18
|
+
* **Partitions:** fix error on wrong consumer in query string ([44269fa](https://github.com/ydb-platform/ydb-embedded-ui/commit/44269fa9240fe31c9ef69e061c20d58b2b55fae3))
|
19
|
+
* **PDisk:** display vdisks donors ([8b39b01](https://github.com/ydb-platform/ydb-embedded-ui/commit/8b39b01e8bf62624e9e12ac0a329fda5d03cc8df))
|
20
|
+
|
3
21
|
## [3.4.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.0...v3.4.1) (2023-03-01)
|
4
22
|
|
5
23
|
|
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>
|
@@ -21,6 +21,21 @@
|
|
21
21
|
&__vdisks-item {
|
22
22
|
flex-basis: 5px;
|
23
23
|
flex-shrink: 0;
|
24
|
+
|
25
|
+
.stack__layer {
|
26
|
+
background: var(--yc-color-base-background);
|
27
|
+
|
28
|
+
.data-table__row:hover & {
|
29
|
+
background: var(--ydb-data-table-color-hover);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
&__donors-stack {
|
35
|
+
--ydb-stack-offset-x: 0px;
|
36
|
+
--ydb-stack-offset-y: -2px;
|
37
|
+
--ydb-stack-offset-x-hover: 0px;
|
38
|
+
--ydb-stack-offset-y-hover: -7px;
|
24
39
|
}
|
25
40
|
|
26
41
|
&__media-type {
|
@@ -2,6 +2,7 @@ import React, {useEffect, useState, useRef, useMemo} from 'react';
|
|
2
2
|
import cn from 'bem-cn-lite';
|
3
3
|
|
4
4
|
import {InternalLink} from '../../../components/InternalLink';
|
5
|
+
import {Stack} from '../../../components/Stack/Stack';
|
5
6
|
|
6
7
|
import routes, {createHref} from '../../../routes';
|
7
8
|
import {getVDisksForPDisk} from '../../../store/reducers/storage';
|
@@ -10,6 +11,7 @@ import {TVDiskStateInfo} from '../../../types/api/vdisk';
|
|
10
11
|
import {stringifyVdiskId} from '../../../utils';
|
11
12
|
import {useTypedSelector} from '../../../utils/hooks';
|
12
13
|
import {getPDiskType} from '../../../utils/pdisk';
|
14
|
+
import {isFullVDiskData} from '../../../utils/storage';
|
13
15
|
|
14
16
|
import {STRUCTURE} from '../../Node/NodePages';
|
15
17
|
|
@@ -109,19 +111,47 @@ export const PDisk = ({nodeId, data: rawData = {}}: PDiskProps) => {
|
|
109
111
|
|
110
112
|
return (
|
111
113
|
<div className={b('vdisks')}>
|
112
|
-
{vdisks.map((vdisk) =>
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
114
|
+
{vdisks.map((vdisk) => {
|
115
|
+
const donors = vdisk.Donors;
|
116
|
+
|
117
|
+
return (
|
118
|
+
<div
|
119
|
+
key={stringifyVdiskId(vdisk.VDiskId)}
|
120
|
+
className={b('vdisks-item')}
|
121
|
+
style={{
|
122
|
+
// 1 is small enough for empty disks to be of the minimum width
|
123
|
+
// but if all of them are empty, `flex-grow: 1` would size them evenly
|
124
|
+
flexGrow: Number(vdisk.AllocatedSize) || 1,
|
125
|
+
}}
|
126
|
+
>
|
127
|
+
{donors && donors.length ? (
|
128
|
+
<Stack
|
129
|
+
className={b('donors-stack')}
|
130
|
+
key={stringifyVdiskId(vdisk.VDiskId)}
|
131
|
+
>
|
132
|
+
<VDisk data={vdisk} compact />
|
133
|
+
{donors.map((donor) => {
|
134
|
+
const isFullData = isFullVDiskData(donor);
|
135
|
+
|
136
|
+
return (
|
137
|
+
<VDisk
|
138
|
+
compact
|
139
|
+
data={
|
140
|
+
isFullData ? donor : {...donor, DonorMode: true}
|
141
|
+
}
|
142
|
+
key={stringifyVdiskId(
|
143
|
+
isFullData ? donor.VDiskId : donor,
|
144
|
+
)}
|
145
|
+
/>
|
146
|
+
);
|
147
|
+
})}
|
148
|
+
</Stack>
|
149
|
+
) : (
|
150
|
+
<VDisk data={vdisk} compact />
|
151
|
+
)}
|
152
|
+
</div>
|
153
|
+
);
|
154
|
+
})}
|
125
155
|
</div>
|
126
156
|
);
|
127
157
|
};
|
@@ -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
|
@@ -1,8 +1,10 @@
|
|
1
1
|
.global-storage-nodes {
|
2
|
+
&__pdisks-column {
|
3
|
+
overflow: visible; // to enable stacked disks overflow the row
|
4
|
+
}
|
5
|
+
|
2
6
|
&__pdisks-wrapper {
|
3
7
|
display: flex;
|
4
|
-
overflow-x: auto;
|
5
|
-
overflow-y: hidden;
|
6
8
|
justify-content: left;
|
7
9
|
align-items: flex-end;
|
8
10
|
|
@@ -33,4 +35,8 @@
|
|
33
35
|
&__group-id {
|
34
36
|
font-weight: 500;
|
35
37
|
}
|
38
|
+
|
39
|
+
&__node_unavailable {
|
40
|
+
opacity: 0.6;
|
41
|
+
}
|
36
42
|
}
|
@@ -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';
|
@@ -128,6 +128,7 @@ function StorageNodes({
|
|
128
128
|
},
|
129
129
|
{
|
130
130
|
name: TableColumnsIds.PDisks,
|
131
|
+
className: b('pdisks-column'),
|
131
132
|
header: tableColumnsNames[TableColumnsIds.PDisks],
|
132
133
|
render: ({value, row}) => (
|
133
134
|
<div className={b('pdisks-wrapper')}>
|
@@ -189,6 +190,7 @@ function StorageNodes({
|
|
189
190
|
}}
|
190
191
|
initialSortOrder={setSortOrder(visibleEntities)}
|
191
192
|
emptyDataMessage={i18n('empty.default')}
|
193
|
+
rowClassName={(row) => b('node', {unavailable: isUnavailableNode(row)})}
|
192
194
|
/>
|
193
195
|
) : null;
|
194
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
|
+
};
|