ydb-embedded-ui 4.8.2 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/components/BasicNodeViewer/BasicNodeViewer.tsx +7 -4
  3. package/dist/components/EntityStatus/EntityStatus.js +3 -1
  4. package/dist/components/FormattedBytes/FormattedBytes.tsx +10 -0
  5. package/dist/components/FormattedBytes/utils.tsx +13 -0
  6. package/dist/components/FullNodeViewer/FullNodeViewer.tsx +73 -0
  7. package/dist/components/InfoViewer/formatters/table.ts +6 -5
  8. package/dist/components/NodeHostWrapper/NodeHostWrapper.tsx +2 -2
  9. package/dist/components/ProblemFilter/ProblemFilter.tsx +2 -2
  10. package/dist/components/SpeedMultiMeter/SpeedMultiMeter.tsx +4 -4
  11. package/dist/components/TruncatedQuery/{TruncatedQuery.js → TruncatedQuery.tsx} +10 -8
  12. package/dist/containers/AsideNavigation/AsideNavigation.tsx +6 -6
  13. package/dist/containers/Cluster/Cluster.tsx +10 -6
  14. package/dist/containers/Node/Node.tsx +3 -3
  15. package/dist/containers/Nodes/Nodes.tsx +3 -3
  16. package/dist/containers/Nodes/getNodesColumns.tsx +2 -2
  17. package/dist/containers/Storage/PDisk/PDisk.tsx +2 -7
  18. package/dist/containers/Storage/Storage.tsx +240 -0
  19. package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +59 -57
  20. package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +23 -25
  21. package/dist/containers/Storage/StorageTypeFilter/StorageTypeFilter.tsx +27 -0
  22. package/dist/containers/Storage/StorageVisibleEntityFilter/StorageVisibleEntityFilter.tsx +31 -0
  23. package/dist/containers/Storage/UsageFilter/UsageFilter.scss +1 -0
  24. package/dist/containers/Storage/UsageFilter/UsageFilter.tsx +17 -17
  25. package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +3 -3
  26. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +7 -4
  27. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss +0 -15
  28. package/dist/containers/Tenant/Diagnostics/TopQueries/TopQueries.tsx +10 -3
  29. package/dist/containers/Tenant/{Preview → Query/Preview}/Preview.scss +1 -1
  30. package/dist/containers/Tenant/Query/Preview/Preview.tsx +121 -0
  31. package/dist/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx +1 -1
  32. package/dist/containers/Tenant/Query/QueryEditor/QueryEditor.js +23 -51
  33. package/dist/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss +20 -15
  34. package/dist/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx +74 -27
  35. package/dist/containers/Tenant/Query/SavedQueries/SavedQueries.tsx +1 -1
  36. package/dist/containers/Tenant/Query/i18n/en.json +9 -2
  37. package/dist/containers/Tenant/Query/i18n/ru.json +9 -2
  38. package/dist/containers/Tenants/Tenants.tsx +269 -0
  39. package/dist/containers/UserSettings/i18n/en.json +1 -1
  40. package/dist/containers/UserSettings/i18n/ru.json +1 -1
  41. package/dist/services/api.ts +14 -16
  42. package/dist/store/reducers/executeQuery.ts +2 -3
  43. package/dist/store/reducers/explainQuery.ts +2 -2
  44. package/dist/store/reducers/index.ts +2 -2
  45. package/dist/store/reducers/{nodes.ts → nodes/nodes.ts} +33 -32
  46. package/dist/{types/store/nodes.ts → store/reducers/nodes/types.ts} +24 -27
  47. package/dist/store/reducers/partitions/types.ts +3 -3
  48. package/dist/store/reducers/settings/settings.ts +14 -4
  49. package/dist/store/reducers/settings/types.ts +3 -1
  50. package/dist/store/reducers/storage/constants.ts +10 -0
  51. package/dist/store/reducers/storage/selectors.ts +279 -0
  52. package/dist/store/reducers/storage/storage.ts +191 -0
  53. package/dist/store/reducers/storage/types.ts +92 -0
  54. package/dist/store/reducers/tenants/selectors.ts +46 -0
  55. package/dist/store/reducers/tenants/tenants.ts +21 -14
  56. package/dist/store/reducers/tenants/types.ts +20 -5
  57. package/dist/store/reducers/tenants/utils.ts +68 -0
  58. package/dist/types/additionalProps.ts +8 -0
  59. package/dist/types/api/storage.ts +1 -1
  60. package/dist/types/store/query.ts +5 -6
  61. package/dist/types/store/topic.ts +3 -3
  62. package/dist/utils/bytesParsers/__test__/formatBytes.test.ts +38 -0
  63. package/dist/utils/bytesParsers/convertBytesObjectToSpeed.ts +2 -2
  64. package/dist/utils/bytesParsers/formatBytes.ts +132 -0
  65. package/dist/utils/bytesParsers/i18n/en.json +1 -0
  66. package/dist/utils/bytesParsers/i18n/ru.json +1 -0
  67. package/dist/utils/bytesParsers/index.ts +1 -1
  68. package/dist/utils/constants.ts +1 -0
  69. package/dist/utils/index.js +5 -10
  70. package/dist/utils/nodes.ts +2 -2
  71. package/dist/utils/numeral.ts +8 -0
  72. package/dist/utils/query.ts +12 -0
  73. package/package.json +1 -1
  74. package/dist/components/FullNodeViewer/FullNodeViewer.js +0 -89
  75. package/dist/containers/Node/NodeOverview/NodeOverview.scss +0 -0
  76. package/dist/containers/Node/NodeOverview/NodeOverview.tsx +0 -21
  77. package/dist/containers/Storage/Storage.js +0 -372
  78. package/dist/containers/Tenant/Preview/Preview.js +0 -168
  79. package/dist/containers/Tenant/Query/QueryEditorControls/OldQueryEditorControls.tsx +0 -90
  80. package/dist/containers/Tenant/Query/QueryEditorControls/shared.ts +0 -18
  81. package/dist/containers/Tenants/Tenants.js +0 -363
  82. package/dist/store/reducers/storage.js +0 -438
  83. package/dist/utils/bytesParsers/formatBytesCustom.ts +0 -57
@@ -1,372 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import {connect} from 'react-redux';
4
- import cn from 'bem-cn-lite';
5
- import DataTable from '@gravity-ui/react-data-table';
6
- import {RadioButton} from '@gravity-ui/uikit';
7
-
8
- import {Search} from '../../components/Search';
9
- import {UsageFilter} from './UsageFilter';
10
- import {AutoFetcher} from '../../utils/autofetcher';
11
- import {NodesUptimeFilterValues} from '../../utils/nodes';
12
- import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
13
- import {UptimeFilter} from '../../components/UptimeFIlter';
14
- import {AccessDenied} from '../../components/Errors/403';
15
- import {EntitiesCount} from '../../components/EntitiesCount';
16
-
17
- import {
18
- getStorageInfo,
19
- setInitialState,
20
- getFilteredEntities,
21
- VisibleEntities,
22
- setVisibleEntities,
23
- setStorageFilter,
24
- setUsageFilter,
25
- StorageTypes,
26
- setStorageType,
27
- setNodesUptimeFilter,
28
- setDataWasNotLoaded,
29
- VisibleEntitiesTitles,
30
- getStoragePoolsGroupsCount,
31
- getStorageNodesCount,
32
- getUsageFilterOptions,
33
- } from '../../store/reducers/storage';
34
- import {getNodesList, selectNodesMap} from '../../store/reducers/nodesList';
35
- import StorageGroups from './StorageGroups/StorageGroups';
36
- import StorageNodes from './StorageNodes/StorageNodes';
37
- import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
38
-
39
- import './Storage.scss';
40
-
41
- const b = cn('global-storage');
42
-
43
- const FILTER_OPTIONS = {
44
- Missing: 'missing',
45
- Space: 'space',
46
- };
47
-
48
- const tableSettings = {
49
- ...DEFAULT_TABLE_SETTINGS,
50
- defaultOrder: DataTable.DESCENDING,
51
- };
52
-
53
- class Storage extends React.Component {
54
- static propTypes = {
55
- loading: PropTypes.bool,
56
- error: PropTypes.object,
57
- wasLoaded: PropTypes.bool,
58
- autorefresh: PropTypes.bool,
59
- database: PropTypes.bool,
60
- getStorageInfo: PropTypes.func,
61
- setInitialState: PropTypes.func,
62
- flatListStorageEntities: PropTypes.array,
63
- groupsCount: PropTypes.object,
64
- nodesCount: PropTypes.object,
65
- setStorageFilter: PropTypes.func,
66
- setVisibleEntities: PropTypes.func,
67
- visibleEntities: PropTypes.string,
68
- tenant: PropTypes.string,
69
- nodeId: PropTypes.string,
70
- nodesUptimeFilter: PropTypes.string,
71
- setNodesUptimeFilter: PropTypes.func,
72
- setDataWasNotLoaded: PropTypes.func,
73
- additionalNodesInfo: PropTypes.object,
74
- };
75
-
76
- componentDidMount() {
77
- const {tenant, nodeId, setVisibleEntities, storageType, getNodesList} =
78
- this.props;
79
-
80
- this.autofetcher = new AutoFetcher();
81
- getNodesList();
82
- if (tenant || nodeId) {
83
- setVisibleEntities(VisibleEntities.All);
84
- this.getStorageInfo({
85
- filter: FILTER_OPTIONS.All,
86
- type: storageType,
87
- });
88
- } else {
89
- this.getStorageInfo({
90
- filter: FILTER_OPTIONS.Missing,
91
- type: storageType,
92
- });
93
- this.autofetcher.fetch(() =>
94
- this.getStorageInfo({
95
- filter: FILTER_OPTIONS.Missing,
96
- type: storageType,
97
- }),
98
- );
99
- }
100
- }
101
-
102
- componentDidUpdate(prevProps) {
103
- const {visibleEntities, storageType, autorefresh, database, tenant, setDataWasNotLoaded} =
104
- this.props;
105
-
106
- const startFetch = () => {
107
- this.getStorageInfo({
108
- filter: FILTER_OPTIONS[visibleEntities],
109
- type: storageType,
110
- });
111
- };
112
-
113
- const restartAutorefresh = () => {
114
- this.autofetcher.stop();
115
- this.autofetcher.start();
116
- this.autofetcher.fetch(() =>
117
- this.getStorageInfo({
118
- filter: FILTER_OPTIONS[visibleEntities],
119
- type: storageType,
120
- }),
121
- );
122
- };
123
-
124
- if (database && !autorefresh && prevProps.autorefresh) {
125
- this.autofetcher.stop();
126
- }
127
- if (database && autorefresh && !prevProps.autorefresh) {
128
- startFetch();
129
- restartAutorefresh();
130
- }
131
-
132
- if (
133
- storageType !== prevProps.storageType ||
134
- visibleEntities !== prevProps.visibleEntities
135
- ) {
136
- startFetch();
137
-
138
- if (!database || (database && autorefresh)) {
139
- restartAutorefresh();
140
- }
141
- }
142
-
143
- if (tenant !== prevProps.tenant) {
144
- setDataWasNotLoaded();
145
- startFetch();
146
- restartAutorefresh();
147
- }
148
- }
149
-
150
- componentWillUnmount() {
151
- this.autofetcher.stop();
152
- this.props.setInitialState();
153
- }
154
-
155
- getStorageInfo(data) {
156
- const {tenant, nodeId, getStorageInfo} = this.props;
157
-
158
- getStorageInfo(
159
- {
160
- tenant,
161
- nodeId,
162
- ...data,
163
- },
164
- {
165
- concurrentId: 'getStorageInfo',
166
- },
167
- );
168
- }
169
-
170
- renderLoader() {
171
- return <TableSkeleton className={b('loader')} />;
172
- }
173
-
174
- renderDataTable() {
175
- const {
176
- flatListStorageEntities,
177
- visibleEntities,
178
- nodesUptimeFilter,
179
- nodes,
180
- storageType,
181
- additionalNodesInfo,
182
- } = this.props;
183
-
184
- return (
185
- <div className={b('table-wrapper')}>
186
- {storageType === StorageTypes.groups && (
187
- <StorageGroups
188
- visibleEntities={visibleEntities}
189
- data={flatListStorageEntities}
190
- tableSettings={tableSettings}
191
- nodes={nodes}
192
- onShowAll={() => this.onGroupVisibilityChange(VisibleEntities.All)}
193
- />
194
- )}
195
- {storageType === StorageTypes.nodes && (
196
- <StorageNodes
197
- visibleEntities={visibleEntities}
198
- nodesUptimeFilter={nodesUptimeFilter}
199
- data={flatListStorageEntities}
200
- tableSettings={tableSettings}
201
- onShowAll={this.onShowAllNodes}
202
- additionalNodesInfo={additionalNodesInfo}
203
- />
204
- )}
205
- </div>
206
- );
207
- }
208
-
209
- onGroupVisibilityChange = (value) => {
210
- const {setVisibleEntities} = this.props;
211
- setVisibleEntities(value);
212
- };
213
-
214
- onStorageTypeChange = (value) => {
215
- const {setStorageType} = this.props;
216
- setStorageType(value);
217
- };
218
-
219
- onUptimeFilterChange = (value) => {
220
- this.props.setNodesUptimeFilter(value);
221
- };
222
-
223
- onShowAllNodes = () => {
224
- this.onGroupVisibilityChange(VisibleEntities.All);
225
- this.onUptimeFilterChange(NodesUptimeFilterValues.All);
226
- };
227
-
228
- renderEntitiesCount() {
229
- const {storageType, groupsCount, nodesCount, flatListStorageEntities, loading, wasLoaded} =
230
- this.props;
231
-
232
- const entityName = storageType === StorageTypes.groups ? 'Groups' : 'Nodes';
233
- const count = storageType === StorageTypes.groups ? groupsCount : nodesCount;
234
-
235
- return (
236
- <EntitiesCount
237
- label={entityName}
238
- loading={loading && !wasLoaded}
239
- total={count.total}
240
- current={flatListStorageEntities.length}
241
- />
242
- );
243
- }
244
-
245
- renderControls() {
246
- const {
247
- filter,
248
- setStorageFilter,
249
- visibleEntities,
250
- storageType,
251
- usageFilter,
252
- nodesUptimeFilter,
253
- setUsageFilter,
254
- usageFilterOptions,
255
- } = this.props;
256
-
257
- return (
258
- <div className={b('controls')}>
259
- <div className={b('search')}>
260
- <Search
261
- placeholder={
262
- storageType === StorageTypes.groups
263
- ? 'Group ID, Pool name'
264
- : 'Node ID, FQDN'
265
- }
266
- onChange={setStorageFilter}
267
- value={filter}
268
- />
269
- </div>
270
-
271
- <RadioButton value={storageType} onUpdate={this.onStorageTypeChange}>
272
- <RadioButton.Option value={StorageTypes.groups}>
273
- {StorageTypes.groups}
274
- </RadioButton.Option>
275
- <RadioButton.Option value={StorageTypes.nodes}>
276
- {StorageTypes.nodes}
277
- </RadioButton.Option>
278
- </RadioButton>
279
-
280
- <RadioButton value={visibleEntities} onUpdate={this.onGroupVisibilityChange}>
281
- <RadioButton.Option value={VisibleEntities.Missing}>
282
- {VisibleEntitiesTitles[VisibleEntities.Missing]}
283
- </RadioButton.Option>
284
- <RadioButton.Option value={VisibleEntities.Space}>
285
- {VisibleEntitiesTitles[VisibleEntities.Space]}
286
- </RadioButton.Option>
287
- <RadioButton.Option value={VisibleEntities.All}>
288
- {VisibleEntitiesTitles[VisibleEntities.All]}
289
- </RadioButton.Option>
290
- </RadioButton>
291
-
292
- {storageType === StorageTypes.nodes && (
293
- <UptimeFilter value={nodesUptimeFilter} onChange={this.onUptimeFilterChange} />
294
- )}
295
-
296
- {storageType === StorageTypes.groups && (
297
- <UsageFilter
298
- value={usageFilter}
299
- onChange={setUsageFilter}
300
- groups={usageFilterOptions}
301
- disabled={usageFilterOptions.length === 0}
302
- />
303
- )}
304
- {this.renderEntitiesCount()}
305
- </div>
306
- );
307
- }
308
-
309
- render() {
310
- const {loading, wasLoaded, error} = this.props;
311
- const showLoader = loading && !wasLoaded;
312
-
313
- if (error) {
314
- if (error.status === 403) {
315
- return <AccessDenied />;
316
- }
317
-
318
- return <div className={b()}>{error.statusText}</div>;
319
- }
320
-
321
- return (
322
- <div className={b()}>
323
- {this.renderControls()}
324
- {showLoader ? this.renderLoader() : this.renderDataTable()}
325
- </div>
326
- );
327
- }
328
- }
329
-
330
- function mapStateToProps(state) {
331
- const {
332
- loading,
333
- wasLoaded,
334
- error,
335
- visible: visibleEntities,
336
- type: storageType,
337
- filter,
338
- usageFilter,
339
- nodesUptimeFilter,
340
- } = state.storage;
341
-
342
- return {
343
- flatListStorageEntities: getFilteredEntities(state),
344
- groupsCount: getStoragePoolsGroupsCount(state),
345
- autorefresh: state.schema.autorefresh,
346
- nodes: selectNodesMap(state),
347
- nodesCount: getStorageNodesCount(state),
348
- loading,
349
- wasLoaded,
350
- error,
351
- visibleEntities,
352
- storageType,
353
- filter,
354
- usageFilter,
355
- nodesUptimeFilter,
356
- usageFilterOptions: getUsageFilterOptions(state),
357
- };
358
- }
359
-
360
- const mapDispatchToProps = {
361
- getStorageInfo,
362
- setInitialState,
363
- setStorageFilter,
364
- setUsageFilter,
365
- setVisibleEntities: setVisibleEntities,
366
- setNodesUptimeFilter,
367
- getNodesList,
368
- setStorageType,
369
- setDataWasNotLoaded,
370
- };
371
-
372
- export default connect(mapStateToProps, mapDispatchToProps)(Storage);
@@ -1,168 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import {connect} from 'react-redux';
4
- import cn from 'bem-cn-lite';
5
-
6
- import {Loader, Button} from '@gravity-ui/uikit';
7
-
8
- import {Icon} from '../../../components/Icon';
9
- import Fullscreen from '../../../components/Fullscreen/Fullscreen';
10
- import {QueryResultTable} from '../../../components/QueryResultTable';
11
-
12
- import {sendQuery, setQueryOptions} from '../../../store/reducers/preview';
13
- import {prepareQueryError} from '../../../utils/query';
14
-
15
- import {isTableType} from '../utils/schema';
16
- import {AutoFetcher} from '../../../utils/autofetcher';
17
- import EnableFullscreenButton from '../../../components/EnableFullscreenButton/EnableFullscreenButton';
18
- import {setShowPreview} from '../../../store/reducers/schema/schema';
19
-
20
- import './Preview.scss';
21
-
22
- const b = cn('kv-preview');
23
-
24
- class Preview extends React.Component {
25
- static propTypes = {
26
- sendQuery: PropTypes.func,
27
- database: PropTypes.string,
28
- table: PropTypes.string,
29
- error: PropTypes.string,
30
- data: PropTypes.array,
31
- loading: PropTypes.bool,
32
- type: PropTypes.string,
33
- partCount: PropTypes.string,
34
- };
35
-
36
- autofetcher;
37
-
38
- componentDidMount() {
39
- this.sendQueryForPreview();
40
- this.autofetcher = new AutoFetcher();
41
- if (this.props.autorefresh) {
42
- this.autofetcher.start();
43
- this.autofetcher.fetch(() => this.sendQueryForPreview());
44
- }
45
- }
46
-
47
- componentDidUpdate(prevProps) {
48
- const {table, autorefresh, setQueryOptions} = this.props;
49
-
50
- if (prevProps.table !== table) {
51
- this.sendQueryForPreview();
52
- setQueryOptions({
53
- wasLoaded: false,
54
- data: undefined,
55
- });
56
- }
57
-
58
- if (autorefresh && !prevProps.autorefresh) {
59
- this.sendQueryForPreview();
60
- this.autofetcher.start();
61
- this.autofetcher.fetch(() => this.sendQueryForPreview());
62
- }
63
- if (!autorefresh && prevProps.autorefresh) {
64
- this.autofetcher.stop();
65
- }
66
- }
67
-
68
- componentWillUnmount() {
69
- this.autofetcher.stop();
70
- }
71
-
72
- sendQueryForPreview = () => {
73
- const {sendQuery, database, table, type} = this.props;
74
-
75
- if (!isTableType(type)) {
76
- return;
77
- }
78
-
79
- const query = `--!syntax_v1\nselect * from \`${table}\` limit 32`;
80
- sendQuery({
81
- query,
82
- database: database,
83
- action: 'execute-scan',
84
- path: table,
85
- });
86
- };
87
-
88
- onClosePreview = () => {
89
- this.props.setShowPreview(false);
90
- };
91
-
92
- renderHeader = () => {
93
- const {currentSchemaPath, error} = this.props;
94
- return (
95
- <div className={b('header')}>
96
- <div className={b('title')}>
97
- Preview <div className={b('table-name')}>{currentSchemaPath}</div>
98
- </div>
99
- <div className={b('controls-left')}>
100
- <EnableFullscreenButton disabled={Boolean(error)} />
101
- <Button
102
- view="flat-secondary"
103
- onClick={this.onClosePreview}
104
- title="Close preview"
105
- >
106
- <Icon name="close" viewBox={'0 0 16 16'} width={16} height={16} />
107
- </Button>
108
- </div>
109
- </div>
110
- );
111
- };
112
-
113
- render() {
114
- const {error, loading, data, type, wasLoaded, isFullscreen} = this.props;
115
-
116
- if (loading && !wasLoaded) {
117
- return (
118
- <div className={b('loader-container')}>
119
- <Loader size="m" />
120
- </div>
121
- );
122
- }
123
-
124
- let message;
125
-
126
- if (!isTableType(type)) {
127
- message = <div className={b('message-container')}>Not available</div>;
128
- } else if (error) {
129
- message = <div className={b('message-container')}>{prepareQueryError(error)}</div>;
130
- }
131
-
132
- const content = message ?? (
133
- <div className={b('result')}>
134
- <QueryResultTable data={data.result} columns={data.columns} />
135
- </div>
136
- );
137
-
138
- return (
139
- <div className={b()}>
140
- {this.renderHeader()}
141
- {isFullscreen ? <Fullscreen>{content}</Fullscreen> : content}
142
- </div>
143
- );
144
- }
145
- }
146
-
147
- const mapStateToProps = (state) => {
148
- const {data = {}, loading, error, wasLoaded} = state.preview;
149
- const {autorefresh, currentSchemaPath} = state.schema;
150
-
151
- return {
152
- data,
153
- loading,
154
- error,
155
- autorefresh,
156
- wasLoaded,
157
- currentSchemaPath,
158
- isFullscreen: state.fullscreen,
159
- };
160
- };
161
-
162
- const mapDispatchToProps = {
163
- sendQuery,
164
- setQueryOptions,
165
- setShowPreview,
166
- };
167
-
168
- export default connect(mapStateToProps, mapDispatchToProps)(Preview);
@@ -1,90 +0,0 @@
1
- import {Button, DropdownMenu} from '@gravity-ui/uikit';
2
- import {useMemo} from 'react';
3
-
4
- import {QueryModes} from '../../../../types/store/query';
5
- import {Icon} from '../../../../components/Icon';
6
-
7
- import SaveQuery from '../SaveQuery/SaveQuery';
8
-
9
- import {QueryEditorControlsProps, b} from './shared';
10
-
11
- import './QueryEditorControls.scss';
12
-
13
- type OldQueryModes = QueryModes.script | QueryModes.scan;
14
-
15
- export const QueryModeSelectorTitles = {
16
- [QueryModes.script]: 'Script',
17
- [QueryModes.scan]: 'Scan',
18
- } as const;
19
-
20
- export const OldQueryEditorControls = ({
21
- onRunButtonClick,
22
- runIsLoading,
23
- onExplainButtonClick,
24
- explainIsLoading,
25
- onSaveQueryClick,
26
- savedQueries,
27
- disabled,
28
- onUpdateQueryMode,
29
- queryMode,
30
- }: QueryEditorControlsProps) => {
31
- const runModeSelectorMenuItems = useMemo(() => {
32
- return Object.entries(QueryModeSelectorTitles).map(([mode, title]) => {
33
- return {
34
- text: `Run ${title}`,
35
- action: () => {
36
- onUpdateQueryMode(mode as OldQueryModes);
37
- },
38
- };
39
- });
40
- }, [onUpdateQueryMode]);
41
-
42
- return (
43
- <div className={b()}>
44
- <div className={b('left')}>
45
- <div className={b('run')}>
46
- <Button
47
- onClick={() => onRunButtonClick(queryMode)}
48
- view="action"
49
- pin="round-brick"
50
- disabled={disabled}
51
- loading={runIsLoading}
52
- >
53
- <Icon name="startPlay" viewBox="0 0 16 16" width={16} height={16} />
54
- {`Run ${QueryModeSelectorTitles[queryMode as OldQueryModes]}`}
55
- </Button>
56
- <DropdownMenu
57
- items={runModeSelectorMenuItems}
58
- popupProps={{className: b('select-query-action-popup')}}
59
- switcher={
60
- <Button
61
- view="action"
62
- pin="brick-round"
63
- disabled={disabled}
64
- loading={runIsLoading}
65
- className={b('select-query-action')}
66
- >
67
- <Icon name="chevron-down" width={16} height={16} />
68
- </Button>
69
- }
70
- />
71
- </div>
72
- <Button
73
- onClick={() => {
74
- // Without defined query mode it sends 'explain' action
75
- onExplainButtonClick();
76
- }}
77
- disabled={disabled}
78
- loading={explainIsLoading}
79
- >
80
- Explain
81
- </Button>
82
- </div>
83
- <SaveQuery
84
- savedQueries={savedQueries}
85
- onSaveQuery={onSaveQueryClick}
86
- saveButtonDisabled={disabled}
87
- />
88
- </div>
89
- );
90
- };
@@ -1,18 +0,0 @@
1
- import block from 'bem-cn-lite';
2
-
3
- import type {QueryModes} from '../../../../types/store/query';
4
-
5
- export const b = block('ydb-query-editor-controls');
6
-
7
- export interface QueryEditorControlsProps {
8
- onRunButtonClick: (mode?: QueryModes) => void;
9
- runIsLoading: boolean;
10
- onExplainButtonClick: (mode?: QueryModes) => void;
11
- explainIsLoading: boolean;
12
- onSaveQueryClick: (queryName: string) => void;
13
- savedQueries: unknown;
14
- disabled: boolean;
15
- onUpdateQueryMode: (mode: QueryModes) => void;
16
- queryMode: QueryModes;
17
- enableQueryModesForExplain: boolean;
18
- }