ydb-embedded-ui 3.4.2 → 3.4.4
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 +16 -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 +17 -10
- 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/containers/Tenant/Diagnostics/Diagnostics.tsx +2 -1
- package/dist/containers/Tenant/Diagnostics/DiagnosticsPages.ts +4 -4
- 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,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.4.4](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.3...v3.4.4) (2023-03-22)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* **Diagnostics:** display nodes tab for not db entities ([a542dbc](https://github.com/ydb-platform/ydb-embedded-ui/commit/a542dbc23d01138a5c1a4126cfc1836a1543b68c))
|
9
|
+
|
10
|
+
## [3.4.3](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.2...v3.4.3) (2023-03-17)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* add opacity to unavailable nodes ([8b82c78](https://github.com/ydb-platform/ydb-embedded-ui/commit/8b82c78f0b6bed536ca23c63b78b141b29afc4a8))
|
16
|
+
* **Tablet:** add error check ([49f13cf](https://github.com/ydb-platform/ydb-embedded-ui/commit/49f13cf0cff2d6dad59b8f6a4c2885966bf3450a))
|
17
|
+
* **VDisk:** fix typo ([1528d03](https://github.com/ydb-platform/ydb-embedded-ui/commit/1528d03531f482e438e0bdb6c761be236822fc27))
|
18
|
+
|
3
19
|
## [3.4.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v3.4.1...v3.4.2) (2023-03-03)
|
4
20
|
|
5
21
|
|
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';
|
@@ -4,10 +4,11 @@ import {useDispatch} from 'react-redux';
|
|
4
4
|
|
5
5
|
import DataTable from '@gravity-ui/react-data-table';
|
6
6
|
|
7
|
+
import type {EPathType} from '../../types/api/schema';
|
8
|
+
|
7
9
|
import {AccessDenied} from '../../components/Errors/403';
|
8
10
|
import {Illustration} from '../../components/Illustration';
|
9
11
|
import {Loader} from '../../components/Loader';
|
10
|
-
|
11
12
|
import {Search} from '../../components/Search';
|
12
13
|
import {ProblemFilter} from '../../components/ProblemFilter';
|
13
14
|
import {UptimeFilter} from '../../components/UptimeFIlter';
|
@@ -21,7 +22,7 @@ import {
|
|
21
22
|
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
|
22
23
|
} from '../../utils/constants';
|
23
24
|
import {useAutofetcher, useTypedSelector} from '../../utils/hooks';
|
24
|
-
import {NodesUptimeFilterValues} from '../../utils/nodes';
|
25
|
+
import {isUnavailableNode, NodesUptimeFilterValues} from '../../utils/nodes';
|
25
26
|
|
26
27
|
import {setHeader} from '../../store/reducers/header';
|
27
28
|
import {
|
@@ -35,6 +36,8 @@ import {
|
|
35
36
|
import {changeFilter, getSettingValue} from '../../store/reducers/settings';
|
36
37
|
import {hideTooltip, showTooltip} from '../../store/reducers/tooltip';
|
37
38
|
|
39
|
+
import {isDatabaseEntityType} from '../Tenant/utils/schema';
|
40
|
+
|
38
41
|
import {getNodesColumns} from './getNodesColumns';
|
39
42
|
|
40
43
|
import './Nodes.scss';
|
@@ -48,22 +51,23 @@ interface IAdditionalNodesInfo extends Record<string, unknown> {
|
|
48
51
|
}
|
49
52
|
|
50
53
|
interface NodesProps {
|
51
|
-
|
54
|
+
path?: string;
|
55
|
+
type?: EPathType;
|
52
56
|
className?: string;
|
53
57
|
additionalNodesInfo?: IAdditionalNodesInfo;
|
54
58
|
}
|
55
59
|
|
56
|
-
export const Nodes = ({
|
60
|
+
export const Nodes = ({path, type, className, additionalNodesInfo = {}}: NodesProps) => {
|
57
61
|
const dispatch = useDispatch();
|
58
62
|
|
59
|
-
const isClusterNodes = !
|
63
|
+
const isClusterNodes = !path;
|
60
64
|
|
61
65
|
// Since Nodes component is used in several places,
|
62
66
|
// we need to reset filters, searchValue and loading state
|
63
67
|
// in nodes reducer when path changes
|
64
68
|
useEffect(() => {
|
65
69
|
dispatch(resetNodesState());
|
66
|
-
}, [dispatch,
|
70
|
+
}, [dispatch, path]);
|
67
71
|
|
68
72
|
const {wasLoaded, loading, error, nodesUptimeFilter, searchValue, totalNodes} =
|
69
73
|
useTypedSelector((state) => state.nodes);
|
@@ -77,12 +81,14 @@ export const Nodes = ({tenantPath, className, additionalNodesInfo = {}}: NodesPr
|
|
77
81
|
);
|
78
82
|
|
79
83
|
const fetchNodes = useCallback(() => {
|
80
|
-
|
81
|
-
|
84
|
+
// For not DB entities we always use /compute endpoint instead of /nodes
|
85
|
+
// since /nodes can return data only for tenants
|
86
|
+
if (path && (!JSON.parse(useNodesEndpoint) || !isDatabaseEntityType(type))) {
|
87
|
+
dispatch(getComputeNodes(path));
|
82
88
|
} else {
|
83
|
-
dispatch(getNodes({tenant:
|
89
|
+
dispatch(getNodes({tenant: path}));
|
84
90
|
}
|
85
|
-
}, [dispatch,
|
91
|
+
}, [dispatch, path, type, useNodesEndpoint]);
|
86
92
|
|
87
93
|
useAutofetcher(fetchNodes, [fetchNodes], isClusterNodes ? true : autorefresh);
|
88
94
|
|
@@ -166,6 +172,7 @@ export const Nodes = ({tenantPath, className, additionalNodesInfo = {}}: NodesPr
|
|
166
172
|
order: DataTable.ASCENDING,
|
167
173
|
}}
|
168
174
|
emptyDataMessage={i18n('empty.default')}
|
175
|
+
rowClassName={(row) => b('node', {unavailable: isUnavailableNode(row)})}
|
169
176
|
/>
|
170
177
|
</div>
|
171
178
|
</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';
|