ydb-embedded-ui 0.1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -3
  4. package/dist/assets/icons/cluster.svg +1 -0
  5. package/dist/assets/icons/hide.svg +1 -0
  6. package/dist/assets/icons/show.svg +1 -0
  7. package/dist/assets/icons/user-check.svg +1 -1
  8. package/dist/assets/icons/user-secret.svg +1 -1
  9. package/dist/components/AsideNavigation/AsideHeader.scss +1 -2
  10. package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.scss +7 -7
  11. package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.scss +2 -2
  12. package/dist/components/AsideNavigation/CompositeBar/CompositeBar.scss +6 -6
  13. package/dist/components/AsideNavigation/Drawer/Drawer.scss +5 -5
  14. package/dist/components/AsideNavigation/Logo/Logo.scss +3 -4
  15. package/dist/components/AsideNavigation/Settings/Settings.scss +27 -12
  16. package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.scss +14 -6
  17. package/dist/components/Breadcrumbs/Breadcrumbs.scss +2 -1
  18. package/dist/components/ClusterInfo/ClusterInfo.scss +19 -12
  19. package/dist/components/ClusterInfo/ClusterInfo.tsx +110 -10
  20. package/dist/components/CopyToClipboard/CopyToClipboard.tsx +39 -0
  21. package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +5 -4
  22. package/dist/components/Divider/Divider.scss +7 -0
  23. package/dist/components/Divider/Divider.tsx +11 -0
  24. package/dist/components/EmptyState/EmptyState.scss +14 -10
  25. package/dist/components/EnableFullscreenButton/EnableFullscreenButton.tsx +22 -0
  26. package/dist/components/EntityStatus/EntityStatus.js +5 -3
  27. package/dist/components/EntityStatus/EntityStatus.scss +35 -13
  28. package/dist/components/FullGroupViewer/FullGroupViewer.js +2 -4
  29. package/dist/components/FullGroupViewer/FullGroupViewer.scss +6 -3
  30. package/dist/components/FullNodeViewer/FullNodeViewer.scss +19 -11
  31. package/dist/components/Fullscreen/Fullscreen.scss +28 -0
  32. package/dist/components/Fullscreen/Fullscreen.tsx +81 -0
  33. package/dist/components/GroupTreeViewer/GroupTreeViewer.scss +1 -0
  34. package/dist/components/GroupViewer/GroupViewer.scss +8 -4
  35. package/dist/components/Icon/Icon.js +2 -0
  36. package/dist/components/InfoViewer/InfoViewer.scss +22 -16
  37. package/dist/components/NodesViewer/NodesViewer.js +25 -35
  38. package/dist/components/NodesViewer/NodesViewer.scss +15 -11
  39. package/dist/components/PDiskViewer/PDiskViewer.scss +10 -4
  40. package/dist/components/Pagination/Pagination.scss +6 -3
  41. package/dist/components/PoolBar/PoolBar.scss +14 -10
  42. package/dist/components/PoolUsage/PoolUsage.scss +17 -9
  43. package/dist/components/ProgressViewer/ProgressViewer.js +1 -1
  44. package/dist/components/ProgressViewer/ProgressViewer.scss +28 -18
  45. package/dist/components/QueryExecutionStatus/QueryExecutionStatus.scss +14 -0
  46. package/dist/components/QueryExecutionStatus/QueryExecutionStatus.tsx +29 -0
  47. package/dist/components/SplitPane/SplitPane.scss +33 -40
  48. package/dist/components/SplitPane/SplitPane.tsx +94 -0
  49. package/dist/components/Tablet/Tablet.scss +9 -6
  50. package/dist/components/TabletsOverall/TabletsOverall.scss +19 -0
  51. package/dist/components/TabletsOverall/TabletsOverall.tsx +105 -0
  52. package/dist/components/TabletsStatistic/TabletsStatistic.scss +24 -18
  53. package/dist/components/TabletsViewer/TabletsViewer.scss +12 -9
  54. package/dist/components/Tag/Tag.scss +6 -4
  55. package/dist/components/Tags/Tags.scss +1 -1
  56. package/dist/components/TreeView/TreeView.js +1 -1
  57. package/dist/components/TreeView/TreeView.scss +9 -0
  58. package/dist/components/TruncatedQuery/TruncatedQuery.scss +4 -3
  59. package/dist/containers/App/App.js +1 -0
  60. package/dist/containers/App/App.scss +50 -31
  61. package/dist/containers/App/Content.js +2 -2
  62. package/dist/containers/App/NodesTable.scss +25 -0
  63. package/dist/containers/App/TipPopup/TipPopup.scss +10 -6
  64. package/dist/containers/AppIcons/AppIcons.js +46 -22
  65. package/dist/containers/AsideNavigation/AsideNavigation.scss +1 -1
  66. package/dist/containers/AsideNavigation/AsideNavigation.tsx +12 -5
  67. package/dist/containers/Authentication/Authentication.scss +63 -14
  68. package/dist/containers/Authentication/Authentication.tsx +42 -9
  69. package/dist/containers/Cluster/Cluster.scss +5 -3
  70. package/dist/containers/Cluster/Cluster.tsx +49 -0
  71. package/dist/containers/Group/Group.scss +1 -1
  72. package/dist/containers/Header/Header.scss +15 -59
  73. package/dist/containers/Header/Header.tsx +75 -0
  74. package/dist/containers/Header/Host/Host.scss +10 -3
  75. package/dist/containers/Heatmap/Heatmap.js +1 -1
  76. package/dist/containers/Heatmap/Heatmap.scss +16 -7
  77. package/dist/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js +3 -3
  78. package/dist/containers/Heatmap/Histogram/Histogram.scss +21 -9
  79. package/dist/containers/Node/Node.js +1 -1
  80. package/dist/containers/Node/Node.scss +6 -4
  81. package/dist/containers/Nodes/Nodes.js +28 -27
  82. package/dist/containers/Nodes/Nodes.scss +5 -17
  83. package/dist/containers/Pdisk/Pdisk.scss +6 -4
  84. package/dist/containers/Pool/Pool.scss +7 -4
  85. package/dist/containers/ReduxTooltip/ReduxTooltip.scss +5 -1
  86. package/dist/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.scss +77 -0
  87. package/dist/containers/{StorageV2 → Storage}/DiskStateProgressBar/DiskStateProgressBar.tsx +1 -1
  88. package/dist/containers/{StorageV2 → Storage}/Pdisk/Pdisk.scss +6 -4
  89. package/dist/containers/{StorageV2 → Storage}/Pdisk/Pdisk.tsx +1 -2
  90. package/dist/containers/{StorageV2 → Storage}/Storage.js +72 -34
  91. package/dist/containers/{StorageV2 → Storage}/Storage.scss +12 -14
  92. package/dist/containers/{StorageV2 → Storage}/StorageFilter/StorageFilter.js +1 -9
  93. package/dist/containers/{StorageV2 → Storage}/StorageGroups/StorageGroups.scss +2 -0
  94. package/dist/containers/{StorageV2 → Storage}/StorageGroups/StorageGroups.tsx +1 -1
  95. package/dist/containers/{StorageV2 → Storage}/StorageNodes/StorageNodes.scss +2 -0
  96. package/dist/containers/{StorageV2 → Storage}/StorageNodes/StorageNodes.tsx +1 -1
  97. package/dist/containers/{StorageV2 → Storage}/Vdisk/Vdisk.js +0 -0
  98. package/dist/containers/{StorageV2 → Storage}/Vdisk/Vdisk.scss +6 -4
  99. package/dist/containers/Tablet/Tablet.scss +13 -9
  100. package/dist/containers/Tablets/Tablets.js +21 -90
  101. package/dist/containers/Tablets/Tablets.scss +9 -35
  102. package/dist/containers/TabletsFilters/TabletsFilters.js +2 -75
  103. package/dist/containers/TabletsFilters/TabletsFilters.scss +15 -35
  104. package/dist/containers/Tenant/Acl/Acl.js +54 -47
  105. package/dist/containers/Tenant/Acl/Acl.scss +15 -4
  106. package/dist/containers/Tenant/{Compute → Diagnostics/Compute}/Compute.js +35 -12
  107. package/dist/containers/Tenant/Diagnostics/Compute/Compute.scss +14 -0
  108. package/dist/containers/Tenant/{Describe → Diagnostics/Describe}/Describe.js +50 -1
  109. package/dist/containers/Tenant/{Describe → Diagnostics/Describe}/Describe.scss +5 -3
  110. package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.scss +27 -0
  111. package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.tsx +88 -0
  112. package/dist/containers/Tenant/Diagnostics/Diagnostics.scss +50 -0
  113. package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +208 -0
  114. package/dist/containers/Tenant/Diagnostics/DiagnosticsPages.ts +75 -0
  115. package/dist/containers/Tenant/Diagnostics/Healthcheck/Healthcheck.js +191 -0
  116. package/dist/containers/Tenant/Diagnostics/Healthcheck/Healthcheck.scss +79 -0
  117. package/dist/containers/Tenant/{Healthcheck → Diagnostics/Healthcheck}/IssuesViewer/IssueViewer.scss +25 -13
  118. package/dist/containers/Tenant/{Healthcheck → Diagnostics/Healthcheck}/IssuesViewer/IssuesViewer.js +2 -2
  119. package/dist/containers/Tenant/{Schema → Diagnostics}/HotKeys/HotKeys.js +14 -8
  120. package/dist/containers/Tenant/{Schema → Diagnostics}/HotKeys/HotKeys.scss +7 -5
  121. package/dist/containers/Tenant/{Network → Diagnostics/Network}/Network.js +39 -9
  122. package/dist/containers/Tenant/{Network → Diagnostics/Network}/Network.scss +35 -36
  123. package/dist/containers/Tenant/{Network → Diagnostics/Network}/NodeNetwork/NodeNetwork.js +0 -0
  124. package/dist/containers/Tenant/{Network → Diagnostics/Network}/NodeNetwork/NodeNetwork.scss +11 -9
  125. package/dist/containers/Tenant/Diagnostics/Overview/Overview.scss +13 -0
  126. package/dist/containers/Tenant/Diagnostics/Overview/Overview.tsx +123 -0
  127. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +200 -0
  128. package/dist/{components → containers/Tenant/Diagnostics}/TenantOverview/TenantOverview.scss +24 -17
  129. package/dist/containers/Tenant/{TopQueries → Diagnostics/TopQueries}/TopQueries.js +32 -30
  130. package/dist/containers/Tenant/{TopQueries → Diagnostics/TopQueries}/TopQueries.scss +10 -9
  131. package/dist/containers/Tenant/{TopShards → Diagnostics/TopShards}/TopShards.js +25 -29
  132. package/dist/containers/Tenant/{TopShards → Diagnostics/TopShards}/TopShards.scss +1 -13
  133. package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.scss +38 -0
  134. package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.tsx +104 -0
  135. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.scss +175 -0
  136. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +319 -0
  137. package/dist/containers/Tenant/Preview/Preview.js +50 -12
  138. package/dist/containers/Tenant/Preview/Preview.scss +45 -3
  139. package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.scss +85 -0
  140. package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.tsx +95 -0
  141. package/dist/containers/Tenant/QueryEditor/QueryEditor.js +319 -268
  142. package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +47 -18
  143. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +190 -75
  144. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.scss +47 -11
  145. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +89 -20
  146. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.scss +60 -6
  147. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +10 -23
  148. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss +15 -7
  149. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.js +7 -3
  150. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.scss +28 -17
  151. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +7 -7
  152. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss +1 -11
  153. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.js +37 -17
  154. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.scss +33 -12
  155. package/dist/containers/Tenant/Schema/SchemaNodeActions/SchemaNodeActions.scss +17 -0
  156. package/dist/containers/Tenant/Schema/SchemaNodeActions/SchemaNodeActions.tsx +125 -0
  157. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.js +5 -4
  158. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.scss +6 -2
  159. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +53 -34
  160. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.scss +1 -22
  161. package/dist/containers/Tenant/Tenant.scss +3 -32
  162. package/dist/containers/Tenant/Tenant.tsx +161 -0
  163. package/dist/containers/Tenant/TenantPages.tsx +48 -0
  164. package/dist/containers/Tenant/utils/ToggleButton.scss +26 -0
  165. package/dist/containers/Tenant/utils/paneVisibilityToggleHelpers.tsx +126 -0
  166. package/dist/containers/Tenants/Tenants.js +41 -55
  167. package/dist/containers/Tenants/Tenants.scss +4 -17
  168. package/dist/containers/UserSettings/UserSettings.tsx +0 -2
  169. package/dist/containers/Vdisk/Vdisk.scss +6 -4
  170. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.js +1 -1
  171. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.scss +5 -5
  172. package/dist/{routes.js → routes.ts} +14 -4
  173. package/dist/store/reducers/clusterNodes.js +1 -1
  174. package/dist/store/reducers/executeQuery.js +36 -2
  175. package/dist/store/reducers/fullscreen.ts +31 -0
  176. package/dist/store/reducers/header.ts +23 -0
  177. package/dist/store/reducers/hotKeys.js +1 -1
  178. package/dist/store/reducers/index.js +6 -0
  179. package/dist/store/reducers/saveQuery.ts +33 -0
  180. package/dist/store/reducers/schema.js +14 -0
  181. package/dist/store/reducers/shardsWorkload.js +1 -1
  182. package/dist/store/state-url-mapping.js +1 -1
  183. package/dist/store/utils.js +2 -6
  184. package/dist/styles/mixins.scss +49 -34
  185. package/dist/utils/autofetcher.ts +51 -0
  186. package/dist/utils/constants.js +26 -7
  187. package/dist/utils/createToast.tsx +23 -0
  188. package/dist/utils/getNodesColumns.js +25 -28
  189. package/dist/utils/index.js +6 -2
  190. package/package.json +8 -4
  191. package/dist/components/SplitPane/SplitPane.js +0 -368
  192. package/dist/components/TenantOverview/TenantOverview.js +0 -148
  193. package/dist/containers/Cluster/Cluster.js +0 -168
  194. package/dist/containers/Header/Header.js +0 -88
  195. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +0 -81
  196. package/dist/containers/Tenant/Compute/Compute.scss +0 -6
  197. package/dist/containers/Tenant/Healthcheck/Healthcheck.js +0 -116
  198. package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +0 -64
  199. package/dist/containers/Tenant/Schema/Info/Info.js +0 -84
  200. package/dist/containers/Tenant/Schema/Info/Info.scss +0 -3
  201. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +0 -439
  202. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +0 -90
  203. package/dist/containers/Tenant/Schema/SchemaPages.js +0 -56
  204. package/dist/containers/Tenant/Tenant.js +0 -199
  205. package/dist/containers/Tenant/TenantPages.js +0 -35
@@ -1,11 +1,15 @@
1
1
  @import '../../../styles/mixins.scss';
2
2
 
3
3
  .query-editor {
4
+ position: relative;
5
+
4
6
  display: flex;
5
- flex-direction: column;
6
7
  flex: 1 1 auto;
7
- height: 100%;
8
- position: relative;
8
+ flex-direction: column;
9
+
10
+ height: calc(100% - 56px);
11
+
12
+ @include query-data-table;
9
13
 
10
14
  & .yc-button__text {
11
15
  display: flex;
@@ -14,44 +18,69 @@
14
18
  }
15
19
 
16
20
  &__monaco {
21
+ position: relative;
22
+
17
23
  display: flex;
24
+
18
25
  width: 100%;
19
26
  height: 100%;
20
- position: relative;
27
+ padding-top: 9px;
21
28
  }
22
29
 
23
30
  &__monaco-wrapper {
24
31
  width: 100%;
25
- height: 100%;
32
+ height: calc(100% - 49px);
26
33
  min-height: 0;
27
34
  }
28
35
 
29
36
  &__pane-wrapper {
37
+ z-index: 2;
38
+
30
39
  display: flex;
31
40
  flex-direction: column;
32
- height: 100%;
33
- width: 100%;
41
+
42
+ background-color: var(--yc-color-base-background);
43
+ }
44
+
45
+ &__upper-controls {
46
+ position: absolute;
47
+ top: -38px;
48
+ right: 16px;
49
+
50
+ display: flex;
51
+ gap: 12px;
52
+
53
+ justify-content: flex-end;
54
+ align-items: center;
34
55
  }
35
56
 
36
57
  &__controls {
37
58
  display: flex;
59
+ flex: 0 0 40px;
38
60
  align-items: flex-end;
39
- padding: 10px 0;
40
- border-bottom: 1px solid var(--yc-color-line-generic);
41
- min-height: 28px;
42
61
 
43
- & > * {
44
- margin-right: 16px;
45
- }
62
+ min-height: 40px;
63
+ padding: 5px 20px;
64
+
65
+ border-top: 1px solid var(--yc-color-line-generic);
66
+ border-bottom: 1px solid var(--yc-color-line-generic);
67
+ background-color: var(--yc-color-base-background);
68
+ gap: 12px;
46
69
  }
47
70
 
48
71
  &__control-run {
49
72
  display: flex;
50
73
  align-items: center;
51
- }
74
+ .yc-select__option-text {
75
+ display: none;
76
+ }
52
77
 
53
- &__run-switcher {
54
- margin-left: 1px;
78
+ .yc-button__text {
79
+ display: flex;
80
+ justify-content: center;
81
+ align-items: center;
82
+ gap: 8px;
83
+ }
55
84
  }
56
85
 
57
86
  &__history-controls {
@@ -61,9 +90,9 @@
61
90
 
62
91
  &__history-label {
63
92
  margin-right: 8px;
64
- }
65
93
 
66
- @include query-data-table;
94
+ color: var(--yc-color-text-secondary);
95
+ }
67
96
 
68
97
  &__cell {
69
98
  @include cell-container;
@@ -1,19 +1,27 @@
1
- import React, {useEffect, useState, useMemo} from 'react';
1
+ import React, {useEffect, useState} from 'react';
2
2
  import cn from 'bem-cn-lite';
3
3
  import MonacoEditor from 'react-monaco-editor';
4
- import {Loader, Tabs} from '@yandex-cloud/uikit';
4
+ import {Loader, RadioButton} from '@yandex-cloud/uikit';
5
5
  import JSONTree from 'react-json-inspector';
6
6
  import {LANGUAGE_S_EXPRESSION_ID} from '../../../../utils/monaco';
7
-
8
- import './QueryExplain.scss';
9
7
  import {
10
- TopologyWrapper,
11
- CompactTopologyWrapper,
12
8
  TextOverflow,
13
9
  getYdbPlanNodeShape,
10
+ getCompactTopology,
11
+ getTopology,
14
12
  } from '@yandex-cloud/paranoid';
15
13
  import {renderExplainNode} from '../../../../utils';
16
14
  import {explainVersions} from '../../../../store/reducers/explainQuery';
15
+ import QueryExecutionStatus from '../../../../components/QueryExecutionStatus/QueryExecutionStatus';
16
+ import Divider from '../../../../components/Divider/Divider';
17
+ import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';
18
+ import {PaneVisibilityToggleButtons} from '../../utils/paneVisibilityToggleHelpers';
19
+ import Fullscreen from '../../../../components/Fullscreen/Fullscreen';
20
+
21
+ import 'react-json-inspector/json-inspector.css';
22
+ import './QueryExplain.scss';
23
+ import {useDispatch, useSelector} from 'react-redux';
24
+ import {disableFullscreen} from '../../../../store/reducers/fullscreen';
17
25
 
18
26
  const b = cn('kv-query-explain');
19
27
 
@@ -41,71 +49,98 @@ const EDITOR_OPTIONS = {
41
49
  wrappingIndent: 'indent',
42
50
  };
43
51
 
44
- const TabsIds = {
52
+ const ExplainOptionIds = {
45
53
  schema: 'schema',
46
54
  json: 'json',
47
55
  ast: 'ast',
48
56
  };
49
57
 
50
- const tabsItems = [
51
- {id: TabsIds.schema, title: 'Schema'},
52
- {id: TabsIds.json, title: 'JSON'},
53
- {id: TabsIds.ast, title: 'AST'},
58
+ const explainOptions = [
59
+ {value: ExplainOptionIds.schema, content: 'Schema'},
60
+ {value: ExplainOptionIds.json, content: 'JSON'},
61
+ {value: ExplainOptionIds.ast, content: 'AST'},
54
62
  ];
55
63
 
64
+ function GraphRoot(props) {
65
+ let paranoid;
66
+ useEffect(() => {
67
+ const {data, opts, shapes, version} = props;
68
+ if (version === explainVersions.v2) {
69
+ paranoid = getTopology('graphRoot', props.data, opts, shapes);
70
+ paranoid.render();
71
+ } else if (version === explainVersions.v1) {
72
+ paranoid = getCompactTopology('graphRoot', data, opts);
73
+ paranoid.renderCompactTopology();
74
+ }
75
+ }, []);
76
+
77
+ useEffect(() => {
78
+ const graphRoot = document.getElementById('graphRoot');
79
+
80
+ if (!graphRoot) {
81
+ throw new Error("Can't find element with id #graphRoot");
82
+ }
83
+
84
+ graphRoot.innerHTML = '';
85
+
86
+ const {data, opts} = props;
87
+ paranoid = getCompactTopology('graphRoot', data, opts);
88
+ paranoid.renderCompactTopology();
89
+ }, [props.opts.colors]);
90
+
91
+ useEffect(() => {
92
+ paranoid.updateData(props.data);
93
+ }, [props.data]);
94
+
95
+ return <div id="graphRoot" style={{height: '100vh'}} />;
96
+ }
97
+
56
98
  function QueryExplain(props) {
57
- const [activeTab, setActiveTab] = useState(TabsIds.schema);
99
+ const dispatch = useDispatch();
100
+ const [activeOption, setActiveOption] = useState(ExplainOptionIds.schema);
101
+
102
+ const isFullscreen = useSelector((state) => state.fullscreen);
103
+
104
+ useEffect(() => {
105
+ return () => {
106
+ dispatch(disableFullscreen());
107
+ };
108
+ }, []);
58
109
 
59
110
  const {explain = {}, theme} = props;
60
111
  const {links, nodes, version, graphDepth} = explain;
61
112
 
62
- const graph = useMemo(() => {
63
- if (links && nodes) {
64
- if (version === explainVersions.v2) {
65
- return (
66
- <TopologyWrapper
67
- data={{links, nodes}}
68
- opts={{
69
- renderNodeTitle: renderExplainNode,
70
- textOverflow: TextOverflow.Normal,
71
- colors: theme === 'dark' ? DARK_COLORS : {},
72
- initialZoomFitsCanvas: true,
73
- }}
74
- shapes={{
75
- node: getYdbPlanNodeShape,
76
- }}
77
- />
78
- );
79
- } else if (version === explainVersions.v1) {
80
- return (
81
- <CompactTopologyWrapper
82
- data={{links, nodes}}
83
- opts={{
84
- renderNodeTitle: renderExplainNode,
85
- textOverflow: TextOverflow.Normal,
86
- colors: theme === 'dark' ? DARK_COLORS : {},
87
- initialZoomFitsCanvas: true,
88
- }}
89
- />
90
- );
91
- }
92
- return 'The explanation format of the query is not supported';
93
- }
94
- return null;
95
- }, [links, nodes, theme, version]);
96
-
97
113
  useEffect(() => {
98
- if (!props.ast && activeTab === TabsIds.ast) {
114
+ if (!props.ast && activeOption === ExplainOptionIds.ast) {
99
115
  props.astQuery();
100
116
  }
101
- }, [activeTab]);
117
+ }, [activeOption]);
102
118
 
103
- const onSelectTab = (tabId) => {
104
- setActiveTab(tabId);
119
+ const onSelectOption = (tabId) => {
120
+ setActiveOption(tabId);
105
121
  };
106
122
 
107
- const renderTextExplain = () => {
123
+ const renderLoader = () => {
108
124
  return (
125
+ <div className={b('loader')}>
126
+ <Loader size="m" />
127
+ </div>
128
+ );
129
+ };
130
+
131
+ const renderStub = () => {
132
+ const {explain} = props;
133
+ if (!explain) {
134
+ return 'Explain of query is empty';
135
+ }
136
+ if (!explain.nodes.length) {
137
+ return 'There is no explanation for the request';
138
+ }
139
+ return null;
140
+ };
141
+
142
+ const renderTextExplain = () => {
143
+ const content = (
109
144
  <JSONTree
110
145
  data={props.explain?.pristine}
111
146
  isExpanded={() => true}
@@ -115,14 +150,24 @@ function QueryExplain(props) {
115
150
  }}
116
151
  />
117
152
  );
153
+ return (
154
+ <React.Fragment>
155
+ {content}
156
+ {renderStub()}
157
+ {isFullscreen && (
158
+ <Fullscreen>
159
+ <div className={b('inspector', {fullscreen: true})}>{content}</div>
160
+ </Fullscreen>
161
+ )}
162
+ </React.Fragment>
163
+ );
118
164
  };
119
165
 
120
166
  const renderAstExplain = () => {
121
- return props.loadingAst ? (
122
- <div className={b('loader')}>
123
- <Loader size="m" />
124
- </div>
125
- ) : (
167
+ if (!props.ast) {
168
+ return 'There is no AST explanation for the request';
169
+ }
170
+ const content = (
126
171
  <div className={b('ast')}>
127
172
  <MonacoEditor
128
173
  language={LANGUAGE_S_EXPRESSION_ID}
@@ -132,35 +177,105 @@ function QueryExplain(props) {
132
177
  />
133
178
  </div>
134
179
  );
180
+ return (
181
+ <React.Fragment>
182
+ {content}
183
+ {isFullscreen && <Fullscreen>{content}</Fullscreen>}
184
+ </React.Fragment>
185
+ );
135
186
  };
136
187
 
137
188
  const renderGraph = () => {
138
189
  const graphHeight = `${Math.max(graphDepth * 100, 200)}px`;
190
+
191
+ const content =
192
+ links && nodes && nodes.length ? (
193
+ <div
194
+ className={b('explain-canvas-container', {
195
+ hidden: activeOption !== ExplainOptionIds.schema,
196
+ })}
197
+ style={{
198
+ height: isFullscreen ? '100%' : graphHeight,
199
+ minHeight: graphHeight,
200
+ width: '100%',
201
+ }}
202
+ >
203
+ <GraphRoot
204
+ version={version}
205
+ data={{links, nodes}}
206
+ opts={{
207
+ renderNodeTitle: renderExplainNode,
208
+ textOverflow: TextOverflow.Normal,
209
+ colors: theme === 'dark' ? DARK_COLORS : {},
210
+ initialZoomFitsCanvas: true,
211
+ }}
212
+ shapes={{
213
+ node: getYdbPlanNodeShape,
214
+ }}
215
+ />
216
+ </div>
217
+ ) : null;
139
218
  return (
140
- <div
141
- className={b('explain-canvas-container', {
142
- hidden: activeTab !== TabsIds.schema,
143
- })}
144
- style={{height: graphHeight, minHeight: graphHeight}}
145
- >
146
- {graph}
147
- </div>
219
+ <React.Fragment>
220
+ {!isFullscreen && content}
221
+ {isFullscreen && <Fullscreen>{content}</Fullscreen>}
222
+ {renderStub()}
223
+ </React.Fragment>
148
224
  );
149
225
  };
150
226
 
227
+ const renderContent = () => {
228
+ const {error, loading, loadingAst} = props;
229
+ if (loading || loadingAst) {
230
+ return renderLoader();
231
+ }
232
+
233
+ if (error) {
234
+ return error.data ? error.data : error;
235
+ }
236
+
237
+ switch (activeOption) {
238
+ case ExplainOptionIds.json: {
239
+ return renderTextExplain();
240
+ }
241
+ case ExplainOptionIds.ast: {
242
+ return renderAstExplain();
243
+ }
244
+ case ExplainOptionIds.schema: {
245
+ return renderGraph();
246
+ }
247
+ default:
248
+ return null;
249
+ }
250
+ };
251
+
151
252
  return (
152
253
  <React.Fragment>
153
- <div className={b('tabs-wrapper')}>
154
- <Tabs
155
- items={tabsItems}
156
- onSelectTab={onSelectTab}
157
- activeTab={activeTab}
158
- className={b('tabs')}
159
- />
254
+ <div className={b('controls')}>
255
+ <div className={b('controls-right')}>
256
+ <QueryExecutionStatus hasError={Boolean(props.error)} />
257
+ {!props.error && (
258
+ <React.Fragment>
259
+ <Divider />
260
+ <RadioButton
261
+ options={explainOptions}
262
+ value={activeOption}
263
+ onUpdate={onSelectOption}
264
+ />
265
+ </React.Fragment>
266
+ )}
267
+ </div>
268
+ <div className={b('controls-left')}>
269
+ <EnableFullscreenButton disabled={Boolean(props.error)} />
270
+ <PaneVisibilityToggleButtons
271
+ onCollapse={props.onCollapseResults}
272
+ onExpand={props.onExpandResults}
273
+ isCollapsed={props.isResultsCollapsed}
274
+ initialDirection="bottom"
275
+ />
276
+ </div>
160
277
  </div>
161
- {activeTab === TabsIds.json && renderTextExplain()}
162
- {activeTab === TabsIds.ast && renderAstExplain()}
163
- {activeTab === TabsIds.schema && renderGraph()}
278
+ <div className={b('result')}>{renderContent()}</div>
164
279
  </React.Fragment>
165
280
  );
166
281
  }
@@ -1,42 +1,78 @@
1
1
  @import '../../../../styles/mixins.scss';
2
2
 
3
3
  .kv-query-explain {
4
- &__tabs {
5
- background-color: var(--yc-color-base-background);
4
+ &__result {
5
+ display: flex;
6
+ overflow: auto;
7
+ flex-grow: 1;
8
+ flex-direction: column;
9
+
10
+ margin-top: 20px;
11
+ padding: 0px 8px;
6
12
  }
7
- &__tabs-wrapper {
13
+ &__controls {
8
14
  position: sticky;
15
+ z-index: 2;
9
16
  top: 0;
17
+
18
+ display: flex;
19
+ justify-content: space-between;
20
+ align-items: center;
21
+
22
+ padding: 12px 20px;
23
+
24
+ border-bottom: 1px solid var(--yc-color-line-generic);
10
25
  background-color: var(--yc-color-base-background);
11
- padding-bottom: 20px;
12
- z-index: 2;
26
+ }
27
+ &__controls-right {
28
+ display: flex;
29
+ gap: 12px;
30
+
31
+ height: 100%;
32
+ }
33
+ &__controls-left {
34
+ display: flex;
35
+ gap: 4px;
36
+ .yc-button__text {
37
+ margin: 0 6px;
38
+ }
13
39
  }
14
40
  &__explain-canvas-container {
15
- margin-bottom: 20px;
16
41
  overflow-y: auto;
42
+
43
+ margin-bottom: 20px;
17
44
  &_hidden {
18
45
  display: none;
19
46
  }
20
47
  }
21
48
  &__inspector {
22
- @include json-tree-styles();
23
49
  overflow-y: auto;
50
+
51
+ width: 100%;
52
+ @include json-tree-styles();
24
53
  &
25
54
  .json-inspector__leaf.json-inspector__leaf_root.json-inspector__leaf_expanded.json-inspector__leaf_composite {
26
55
  max-width: calc(100% - 50px);
27
56
  }
57
+
58
+ &_fullscreen {
59
+ padding: 10px;
60
+ }
28
61
  }
29
62
 
30
63
  &__ast {
64
+ width: 100%;
65
+ height: 100%;
31
66
  margin: 20px 0;
67
+
32
68
  white-space: pre-wrap;
33
- height: 100%;
34
69
  }
35
70
  &__loader {
36
- width: 100%;
37
- margin-top: 20px;
38
71
  display: flex;
39
- align-items: center;
40
72
  justify-content: center;
73
+ align-items: center;
74
+
75
+ width: 100%;
76
+ margin-top: 20px;
41
77
  }
42
78
  }
@@ -1,31 +1,61 @@
1
- import React, {useState} from 'react';
1
+ import React, {useEffect, useState} from 'react';
2
+ import {useDispatch, useSelector} from 'react-redux';
2
3
  import cn from 'bem-cn-lite';
3
- import {Tabs} from '@yandex-cloud/uikit';
4
+ import {RadioButton} from '@yandex-cloud/uikit';
4
5
  import JSONTree from 'react-json-inspector';
5
6
 
7
+ import CopyToClipboard from '../../../../components/CopyToClipboard/CopyToClipboard';
8
+ import Divider from '../../../../components/Divider/Divider';
9
+ import Fullscreen from '../../../../components/Fullscreen/Fullscreen';
10
+ import {disableFullscreen} from '../../../../store/reducers/fullscreen';
11
+
6
12
  import './QueryResult.scss';
13
+ import {PaneVisibilityToggleButtons} from '../../utils/paneVisibilityToggleHelpers';
14
+ import QueryExecutionStatus from '../../../../components/QueryExecutionStatus/QueryExecutionStatus';
15
+ import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';
7
16
 
8
17
  const b = cn('kv-query-result');
9
18
 
10
- const TabsIds = {
19
+ const resultOptionsIds = {
11
20
  result: 'result',
12
21
  stats: 'stats',
13
22
  };
14
23
 
15
- const tabsItems = [
16
- {id: TabsIds.result, title: 'Result'},
17
- {id: TabsIds.stats, title: 'Stats'},
24
+ const resultOptions = [
25
+ {value: resultOptionsIds.result, content: 'Result'},
26
+ {value: resultOptionsIds.stats, content: 'Stats'},
18
27
  ];
19
28
 
20
29
  function QueryResult(props) {
21
- const [activeTab, setActiveTab] = useState(TabsIds.result);
30
+ const [activeSection, setActiveSection] = useState(resultOptionsIds.result);
31
+ const isFullscreen = useSelector((state) => state.fullscreen);
32
+ const dispatch = useDispatch();
33
+
34
+ useEffect(() => {
35
+ return () => {
36
+ dispatch(disableFullscreen());
37
+ };
38
+ }, []);
22
39
 
23
- const onSelectTab = (tabId) => {
24
- setActiveTab(tabId);
40
+ const onSelectSection = (value) => {
41
+ setActiveSection(value);
25
42
  };
26
43
 
27
- const renderStats = () => {
44
+ const renderClipboardButton = () => {
45
+ const {textResults, copyDisabled} = props;
46
+
28
47
  return (
48
+ <CopyToClipboard
49
+ text={textResults}
50
+ title="Copy results"
51
+ toastText="Results were copied to clipboard successfully"
52
+ disabled={copyDisabled}
53
+ />
54
+ );
55
+ };
56
+
57
+ const renderStats = () => {
58
+ const content = (
29
59
  <JSONTree
30
60
  data={props.stats}
31
61
  isExpanded={() => true}
@@ -35,21 +65,60 @@ function QueryResult(props) {
35
65
  }}
36
66
  />
37
67
  );
68
+ return (
69
+ <React.Fragment>
70
+ {content}
71
+ {isFullscreen && (
72
+ <Fullscreen>
73
+ <div className={b('inspector', {fullscreen: true})}>{content}</div>
74
+ </Fullscreen>
75
+ )}
76
+ </React.Fragment>
77
+ );
78
+ };
79
+
80
+ const renderResult = () => {
81
+ const {result} = props;
82
+
83
+ return (
84
+ <React.Fragment>
85
+ {result}
86
+ {isFullscreen && <Fullscreen><div className={b('result', {fullscreen: true})}>{result}</div></Fullscreen>}
87
+ </React.Fragment>
88
+ );
38
89
  };
39
90
 
40
91
  return (
41
92
  <React.Fragment>
42
- {props.stats && (
43
- <Tabs
44
- items={tabsItems}
45
- onSelectTab={onSelectTab}
46
- activeTab={activeTab}
47
- className={b('tabs')}
48
- />
49
- )}
93
+ <div className={b('controls')}>
94
+ <div className={b('controls-right')}>
95
+ <QueryExecutionStatus hasError={Boolean(props.error)} />
96
+
97
+ {props.stats && !props.error && (
98
+ <React.Fragment>
99
+ <Divider />
100
+ <RadioButton
101
+ options={resultOptions}
102
+ value={activeSection}
103
+ onUpdate={onSelectSection}
104
+ />
105
+ </React.Fragment>
106
+ )}
107
+ </div>
108
+ <div className={b('controls-left')}>
109
+ {renderClipboardButton()}
110
+ <EnableFullscreenButton disabled={Boolean(props.error)}/>
111
+ <PaneVisibilityToggleButtons
112
+ onCollapse={props.onCollapseResults}
113
+ onExpand={props.onExpandResults}
114
+ isCollapsed={props.isResultsCollapsed}
115
+ initialDirection="bottom"
116
+ />
117
+ </div>
118
+ </div>
50
119
  <div className={b('result')}>
51
- {activeTab === TabsIds.result && props.result}
52
- {activeTab === TabsIds.stats && renderStats()}
120
+ {activeSection === resultOptionsIds.result && renderResult()}
121
+ {activeSection === resultOptionsIds.stats && renderStats()}
53
122
  </div>
54
123
  </React.Fragment>
55
124
  );