ydb-embedded-ui 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +28 -0
  3. package/dist/HOCS/WithSearch/WithSearch.js +26 -0
  4. package/dist/HOCS/index.js +1 -0
  5. package/dist/assets/icons/bug.svg +1 -0
  6. package/dist/assets/icons/close.svg +1 -0
  7. package/dist/assets/icons/control-menu-button.svg +1 -0
  8. package/dist/assets/icons/databases.svg +3 -0
  9. package/dist/assets/icons/dots.svg +1 -0
  10. package/dist/assets/icons/server.svg +1 -0
  11. package/dist/assets/icons/settings-with-dot.svg +1 -0
  12. package/dist/assets/icons/settings.svg +1 -0
  13. package/dist/assets/icons/signIn.svg +1 -0
  14. package/dist/assets/icons/signOut.svg +1 -0
  15. package/dist/assets/icons/star.svg +1 -0
  16. package/dist/assets/icons/storage.svg +1 -0
  17. package/dist/assets/icons/support.svg +1 -0
  18. package/dist/assets/icons/user-check.svg +1 -0
  19. package/dist/assets/icons/user-secret.svg +1 -0
  20. package/dist/assets/icons/ydb.svg +4 -0
  21. package/dist/components/AsideNavigation/AsideHeader.scss +148 -0
  22. package/dist/components/AsideNavigation/AsideHeader.tsx +388 -0
  23. package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.scss +82 -0
  24. package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.tsx +138 -0
  25. package/dist/components/AsideNavigation/AsideHeaderFooterSlot/AsideHeaderFooterSlot.tsx +33 -0
  26. package/dist/components/AsideNavigation/AsideHeaderFooterSlot/SlotsContext.tsx +49 -0
  27. package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.scss +16 -0
  28. package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.tsx +37 -0
  29. package/dist/components/AsideNavigation/CompositeBar/CompositeBar.scss +108 -0
  30. package/dist/components/AsideNavigation/CompositeBar/CompositeBar.tsx +282 -0
  31. package/dist/components/AsideNavigation/Content/Content.tsx +35 -0
  32. package/dist/components/AsideNavigation/Drawer/Drawer.scss +76 -0
  33. package/dist/components/AsideNavigation/Drawer/Drawer.tsx +134 -0
  34. package/dist/components/AsideNavigation/Drawer/index.ts +1 -0
  35. package/dist/components/AsideNavigation/Logo/Logo.scss +44 -0
  36. package/dist/components/AsideNavigation/Logo/Logo.tsx +82 -0
  37. package/dist/components/AsideNavigation/Settings/README.md +92 -0
  38. package/dist/components/AsideNavigation/Settings/Settings.scss +113 -0
  39. package/dist/components/AsideNavigation/Settings/Settings.tsx +270 -0
  40. package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.scss +70 -0
  41. package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.tsx +141 -0
  42. package/dist/components/AsideNavigation/Settings/SettingsSearch/SettingsSearch.tsx +57 -0
  43. package/dist/components/AsideNavigation/Settings/collect-settings.ts +156 -0
  44. package/dist/components/AsideNavigation/Settings/filter-settings.ts +38 -0
  45. package/dist/components/AsideNavigation/Settings/helpers.ts +39 -0
  46. package/dist/components/AsideNavigation/Settings/i18n/en.json +5 -0
  47. package/dist/components/AsideNavigation/Settings/i18n/index.ts +11 -0
  48. package/dist/components/AsideNavigation/Settings/i18n/ru.json +5 -0
  49. package/dist/components/AsideNavigation/Settings/index.ts +1 -0
  50. package/dist/components/AsideNavigation/constants.ts +28 -0
  51. package/dist/components/AsideNavigation/helpers.ts +34 -0
  52. package/dist/components/AsideNavigation/i18n/en.json +4 -0
  53. package/dist/components/AsideNavigation/i18n/index.ts +11 -0
  54. package/dist/components/AsideNavigation/i18n/ru.json +4 -0
  55. package/dist/components/AsideNavigation/icons.ts +32 -0
  56. package/dist/components/AsideNavigation/types.ts +23 -0
  57. package/dist/components/Breadcrumbs/Breadcrumbs.js +25 -0
  58. package/dist/components/Breadcrumbs/Breadcrumbs.scss +4 -0
  59. package/dist/components/ClusterInfo/ClusterInfo.scss +65 -0
  60. package/dist/components/ClusterInfo/ClusterInfo.tsx +157 -0
  61. package/dist/components/Collapse/Collapse.js +84 -0
  62. package/dist/components/Collapse/Collapse.scss +70 -0
  63. package/dist/components/CriticalActionDialog/CriticalActionDialog.js +53 -0
  64. package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +31 -0
  65. package/dist/components/EmptyState/EmptyState.js +48 -0
  66. package/dist/components/EmptyState/EmptyState.scss +70 -0
  67. package/dist/components/EntityStatus/EntityStatus.js +96 -0
  68. package/dist/components/EntityStatus/EntityStatus.scss +81 -0
  69. package/dist/components/FullGroupViewer/FullGroupViewer.js +149 -0
  70. package/dist/components/FullGroupViewer/FullGroupViewer.scss +32 -0
  71. package/dist/components/FullNodeViewer/FullNodeViewer.js +108 -0
  72. package/dist/components/FullNodeViewer/FullNodeViewer.scss +78 -0
  73. package/dist/components/GroupTreeViewer/GroupTreeViewer.js +86 -0
  74. package/dist/components/GroupTreeViewer/GroupTreeViewer.scss +17 -0
  75. package/dist/components/GroupViewer/GroupViewer.js +100 -0
  76. package/dist/components/GroupViewer/GroupViewer.scss +41 -0
  77. package/dist/components/Hotkey/Hotkey.js +102 -0
  78. package/dist/components/Icon/Icon.js +26 -0
  79. package/dist/components/InfoViewer/InfoViewer.js +47 -0
  80. package/dist/components/InfoViewer/InfoViewer.scss +48 -0
  81. package/dist/components/InternalLink/InternalLink.js +15 -0
  82. package/dist/components/NodesViewer/NodesViewer.js +183 -0
  83. package/dist/components/NodesViewer/NodesViewer.scss +66 -0
  84. package/dist/components/PDiskViewer/PDiskViewer.js +80 -0
  85. package/dist/components/PDiskViewer/PDiskViewer.scss +40 -0
  86. package/dist/components/Pagination/Pagination.js +63 -0
  87. package/dist/components/Pagination/Pagination.scss +25 -0
  88. package/dist/components/PoolBar/PoolBar.js +52 -0
  89. package/dist/components/PoolBar/PoolBar.scss +40 -0
  90. package/dist/components/PoolUsage/PoolUsage.js +54 -0
  91. package/dist/components/PoolUsage/PoolUsage.scss +65 -0
  92. package/dist/components/PoolsGraph/PoolsGraph.js +33 -0
  93. package/dist/components/PoolsGraph/PoolsGraph.scss +3 -0
  94. package/dist/components/ProblemFilter/ProblemFilter.js +24 -0
  95. package/dist/components/ProgressViewer/ProgressViewer.js +92 -0
  96. package/dist/components/ProgressViewer/ProgressViewer.scss +84 -0
  97. package/dist/components/SplitPane/SplitPane.js +368 -0
  98. package/dist/components/SplitPane/SplitPane.scss +107 -0
  99. package/dist/components/SplitPane/index.js +3 -0
  100. package/dist/components/Tablet/Tablet.js +61 -0
  101. package/dist/components/Tablet/Tablet.scss +49 -0
  102. package/dist/components/TabletsStatistic/TabletsStatistic.js +58 -0
  103. package/dist/components/TabletsStatistic/TabletsStatistic.scss +41 -0
  104. package/dist/components/TabletsViewer/TabletsViewer.js +44 -0
  105. package/dist/components/TabletsViewer/TabletsViewer.scss +37 -0
  106. package/dist/components/Tag/Tag.js +14 -0
  107. package/dist/components/Tag/Tag.scss +17 -0
  108. package/dist/components/Tags/Tags.js +36 -0
  109. package/dist/components/Tags/Tags.scss +5 -0
  110. package/dist/components/TenantOverview/TenantOverview.js +148 -0
  111. package/dist/components/TenantOverview/TenantOverview.scss +75 -0
  112. package/dist/components/TreeView/TreeView.js +60 -0
  113. package/dist/components/TreeView/TreeView.scss +30 -0
  114. package/dist/components/TruncatedQuery/TruncatedQuery.js +26 -0
  115. package/dist/components/TruncatedQuery/TruncatedQuery.scss +12 -0
  116. package/dist/containers/App/App.js +67 -0
  117. package/dist/containers/App/App.scss +154 -0
  118. package/dist/containers/App/Content.js +109 -0
  119. package/dist/containers/App/TipPopup/TipPopup.js +66 -0
  120. package/dist/containers/App/TipPopup/TipPopup.scss +42 -0
  121. package/dist/containers/AppIcons/AppIcons.js +477 -0
  122. package/dist/containers/AsideNavigation/AsideNavigation.scss +43 -0
  123. package/dist/containers/AsideNavigation/AsideNavigation.tsx +228 -0
  124. package/dist/containers/Authentication/Authentication.scss +37 -0
  125. package/dist/containers/Authentication/Authentication.tsx +89 -0
  126. package/dist/containers/Cluster/Cluster.js +168 -0
  127. package/dist/containers/Cluster/Cluster.scss +52 -0
  128. package/dist/containers/Group/Group.js +97 -0
  129. package/dist/containers/Group/Group.scss +6 -0
  130. package/dist/containers/Header/Header.js +88 -0
  131. package/dist/containers/Header/Header.scss +72 -0
  132. package/dist/containers/Header/Host/Host.js +66 -0
  133. package/dist/containers/Header/Host/Host.scss +43 -0
  134. package/dist/containers/Heatmap/Heatmap.js +246 -0
  135. package/dist/containers/Heatmap/Heatmap.scss +94 -0
  136. package/dist/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js +167 -0
  137. package/dist/containers/Heatmap/Histogram/Histogram.js +108 -0
  138. package/dist/containers/Heatmap/Histogram/Histogram.scss +49 -0
  139. package/dist/containers/Heatmap/util.js +110 -0
  140. package/dist/containers/Node/Node.js +184 -0
  141. package/dist/containers/Node/Node.scss +34 -0
  142. package/dist/containers/Node/NodePages.js +13 -0
  143. package/dist/containers/Nodes/Nodes.js +193 -0
  144. package/dist/containers/Nodes/Nodes.scss +50 -0
  145. package/dist/containers/Pdisk/Pdisk.js +159 -0
  146. package/dist/containers/Pdisk/Pdisk.scss +40 -0
  147. package/dist/containers/Pool/Pool.js +169 -0
  148. package/dist/containers/Pool/Pool.scss +32 -0
  149. package/dist/containers/ReduxTooltip/ReduxTooltip.js +108 -0
  150. package/dist/containers/ReduxTooltip/ReduxTooltip.scss +67 -0
  151. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +81 -0
  152. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.tsx +56 -0
  153. package/dist/containers/StorageV2/Pdisk/Pdisk.scss +32 -0
  154. package/dist/containers/StorageV2/Pdisk/Pdisk.tsx +167 -0
  155. package/dist/containers/StorageV2/Storage.js +249 -0
  156. package/dist/containers/StorageV2/Storage.scss +57 -0
  157. package/dist/containers/StorageV2/StorageFilter/StorageFilter.js +39 -0
  158. package/dist/containers/StorageV2/StorageGroups/StorageGroups.scss +26 -0
  159. package/dist/containers/StorageV2/StorageGroups/StorageGroups.tsx +234 -0
  160. package/dist/containers/StorageV2/StorageNodes/StorageNodes.scss +30 -0
  161. package/dist/containers/StorageV2/StorageNodes/StorageNodes.tsx +135 -0
  162. package/dist/containers/StorageV2/Vdisk/Vdisk.js +250 -0
  163. package/dist/containers/StorageV2/Vdisk/Vdisk.scss +32 -0
  164. package/dist/containers/Tablet/Tablet.js +453 -0
  165. package/dist/containers/Tablet/Tablet.scss +88 -0
  166. package/dist/containers/Tablets/Tablets.js +306 -0
  167. package/dist/containers/Tablets/Tablets.scss +77 -0
  168. package/dist/containers/TabletsFilters/TabletsFilters.js +412 -0
  169. package/dist/containers/TabletsFilters/TabletsFilters.scss +104 -0
  170. package/dist/containers/Tenant/Acl/Acl.js +149 -0
  171. package/dist/containers/Tenant/Acl/Acl.scss +34 -0
  172. package/dist/containers/Tenant/Compute/Compute.js +110 -0
  173. package/dist/containers/Tenant/Compute/Compute.scss +6 -0
  174. package/dist/containers/Tenant/Describe/Describe.js +81 -0
  175. package/dist/containers/Tenant/Describe/Describe.scss +25 -0
  176. package/dist/containers/Tenant/Healthcheck/Healthcheck.js +116 -0
  177. package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +64 -0
  178. package/dist/containers/Tenant/Healthcheck/IssuesViewer/IssueViewer.scss +164 -0
  179. package/dist/containers/Tenant/Healthcheck/IssuesViewer/IssuesViewer.js +185 -0
  180. package/dist/containers/Tenant/Network/Network.js +341 -0
  181. package/dist/containers/Tenant/Network/Network.scss +145 -0
  182. package/dist/containers/Tenant/Network/NodeNetwork/NodeNetwork.js +71 -0
  183. package/dist/containers/Tenant/Network/NodeNetwork/NodeNetwork.scss +52 -0
  184. package/dist/containers/Tenant/Preview/Preview.js +169 -0
  185. package/dist/containers/Tenant/Preview/Preview.scss +20 -0
  186. package/dist/containers/Tenant/QueryEditor/QueryEditor.js +649 -0
  187. package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +71 -0
  188. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +168 -0
  189. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.scss +42 -0
  190. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +58 -0
  191. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.scss +24 -0
  192. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +171 -0
  193. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss +51 -0
  194. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.js +156 -0
  195. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.scss +82 -0
  196. package/dist/containers/Tenant/Schema/HotKeys/HotKeys.js +149 -0
  197. package/dist/containers/Tenant/Schema/HotKeys/HotKeys.scss +48 -0
  198. package/dist/containers/Tenant/Schema/Info/Info.js +84 -0
  199. package/dist/containers/Tenant/Schema/Info/Info.scss +3 -0
  200. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +67 -0
  201. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss +21 -0
  202. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +439 -0
  203. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +90 -0
  204. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.js +150 -0
  205. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.scss +41 -0
  206. package/dist/containers/Tenant/Schema/SchemaPages.js +56 -0
  207. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.js +115 -0
  208. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.scss +13 -0
  209. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +63 -0
  210. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.scss +28 -0
  211. package/dist/containers/Tenant/Tenant.js +199 -0
  212. package/dist/containers/Tenant/Tenant.scss +94 -0
  213. package/dist/containers/Tenant/TenantPages.js +35 -0
  214. package/dist/containers/Tenant/TopQueries/TopQueries.js +184 -0
  215. package/dist/containers/Tenant/TopQueries/TopQueries.scss +53 -0
  216. package/dist/containers/Tenant/TopShards/TopShards.js +171 -0
  217. package/dist/containers/Tenant/TopShards/TopShards.scss +23 -0
  218. package/dist/containers/Tenants/Tenants.js +375 -0
  219. package/dist/containers/Tenants/Tenants.scss +73 -0
  220. package/dist/containers/UserSettings/UserSettings.tsx +57 -0
  221. package/dist/containers/Vdisk/Vdisk.js +160 -0
  222. package/dist/containers/Vdisk/Vdisk.scss +40 -0
  223. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.js +528 -0
  224. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.scss +60 -0
  225. package/dist/contexts/HistoryContext.ts +6 -0
  226. package/dist/index.css +11 -0
  227. package/dist/index.js +28 -0
  228. package/dist/index.test.js +5 -0
  229. package/dist/react-app-env.d.ts +1 -0
  230. package/dist/reportWebVitals.js +13 -0
  231. package/dist/routes.js +40 -0
  232. package/dist/services/api.js +224 -0
  233. package/dist/setupTests.js +5 -0
  234. package/dist/store/index.js +61 -0
  235. package/dist/store/reducers/authentication.js +77 -0
  236. package/dist/store/reducers/cluster.js +52 -0
  237. package/dist/store/reducers/clusterInfo.js +48 -0
  238. package/dist/store/reducers/clusterNodes.js +70 -0
  239. package/dist/store/reducers/describe.js +45 -0
  240. package/dist/store/reducers/executeQuery.js +158 -0
  241. package/dist/store/reducers/executeTopQueries.js +69 -0
  242. package/dist/store/reducers/explainQuery.js +174 -0
  243. package/dist/store/reducers/group.js +49 -0
  244. package/dist/store/reducers/healthcheckInfo.js +45 -0
  245. package/dist/store/reducers/heatmap.js +105 -0
  246. package/dist/store/reducers/host.js +44 -0
  247. package/dist/store/reducers/hotKeys.js +57 -0
  248. package/dist/store/reducers/index.js +78 -0
  249. package/dist/store/reducers/network.js +45 -0
  250. package/dist/store/reducers/node.js +42 -0
  251. package/dist/store/reducers/nodes.js +58 -0
  252. package/dist/store/reducers/olapStats.js +74 -0
  253. package/dist/store/reducers/pdisk.js +51 -0
  254. package/dist/store/reducers/pool.js +42 -0
  255. package/dist/store/reducers/preview.js +73 -0
  256. package/dist/store/reducers/schema.js +95 -0
  257. package/dist/store/reducers/schemaAcl.js +44 -0
  258. package/dist/store/reducers/settings.js +76 -0
  259. package/dist/store/reducers/shardsWorkload.js +75 -0
  260. package/dist/store/reducers/storage.js +280 -0
  261. package/dist/store/reducers/tablet.js +94 -0
  262. package/dist/store/reducers/tablets.js +90 -0
  263. package/dist/store/reducers/tabletsFilters.js +126 -0
  264. package/dist/store/reducers/tenant.js +76 -0
  265. package/dist/store/reducers/tenants.js +61 -0
  266. package/dist/store/reducers/tooltip.js +64 -0
  267. package/dist/store/reducers/vdisk.js +49 -0
  268. package/dist/store/state-url-mapping.js +133 -0
  269. package/dist/store/utils.js +55 -0
  270. package/dist/styles/mixins.scss +254 -0
  271. package/dist/styles/react-treeview.scss +45 -0
  272. package/dist/types/assets.d.ts +12 -0
  273. package/dist/types/react-list.d.ts +4 -0
  274. package/dist/types/window.d.ts +33 -0
  275. package/dist/utils/actionsConstants.js +4 -0
  276. package/dist/utils/constants.js +126 -0
  277. package/dist/utils/getNodesColumns.js +156 -0
  278. package/dist/utils/i18n/i18n.ts +7 -0
  279. package/dist/utils/i18n/index.ts +1 -0
  280. package/dist/utils/index.js +136 -0
  281. package/dist/utils/monaco.js +69 -0
  282. package/dist/utils/prepareQueryExplain.ts +101 -0
  283. package/dist/utils/tooltip.js +197 -0
  284. package/dist/utils/utils.js +75 -0
  285. package/package.json +89 -0
@@ -0,0 +1,71 @@
1
+ @import '../../../styles/mixins.scss';
2
+
3
+ .query-editor {
4
+ display: flex;
5
+ flex-direction: column;
6
+ flex: 1 1 auto;
7
+ height: 100%;
8
+ position: relative;
9
+
10
+ & .yc-button__text {
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ }
15
+
16
+ &__monaco {
17
+ display: flex;
18
+ width: 100%;
19
+ height: 100%;
20
+ position: relative;
21
+ }
22
+
23
+ &__monaco-wrapper {
24
+ width: 100%;
25
+ height: 100%;
26
+ min-height: 0;
27
+ }
28
+
29
+ &__pane-wrapper {
30
+ display: flex;
31
+ flex-direction: column;
32
+ height: 100%;
33
+ width: 100%;
34
+ }
35
+
36
+ &__controls {
37
+ display: flex;
38
+ align-items: flex-end;
39
+ padding: 10px 0;
40
+ border-bottom: 1px solid var(--yc-color-line-generic);
41
+ min-height: 28px;
42
+
43
+ & > * {
44
+ margin-right: 16px;
45
+ }
46
+ }
47
+
48
+ &__control-run {
49
+ display: flex;
50
+ align-items: center;
51
+ }
52
+
53
+ &__run-switcher {
54
+ margin-left: 1px;
55
+ }
56
+
57
+ &__history-controls {
58
+ display: flex;
59
+ align-items: center;
60
+ }
61
+
62
+ &__history-label {
63
+ margin-right: 8px;
64
+ }
65
+
66
+ @include query-data-table;
67
+
68
+ &__cell {
69
+ @include cell-container;
70
+ }
71
+ }
@@ -0,0 +1,168 @@
1
+ import React, {useEffect, useState, useMemo} from 'react';
2
+ import cn from 'bem-cn-lite';
3
+ import MonacoEditor from 'react-monaco-editor';
4
+ import {Loader, Tabs} from '@yandex-cloud/uikit';
5
+ import JSONTree from 'react-json-inspector';
6
+ import {LANGUAGE_S_EXPRESSION_ID} from '../../../../utils/monaco';
7
+
8
+ import './QueryExplain.scss';
9
+ import {
10
+ TopologyWrapper,
11
+ CompactTopologyWrapper,
12
+ TextOverflow,
13
+ getYdbPlanNodeShape,
14
+ } from '@yandex-cloud/paranoid';
15
+ import {renderExplainNode} from '../../../../utils';
16
+ import {explainVersions} from '../../../../store/reducers/explainQuery';
17
+
18
+ const b = cn('kv-query-explain');
19
+
20
+ const DARK_COLORS = {
21
+ success: 'rgba(59,201,53,0.75)',
22
+ error: '#bf3230',
23
+ warning: '#cc6810',
24
+ mute: 'rgba(255,255,255,0.15)',
25
+ stroke: 'rgba(255,255,255,0.17)',
26
+ fill: '#313037',
27
+ nodeFill: '#3b3a41',
28
+ nodeShadow: 'rgba(0,0,0,0.2)',
29
+ titleColor: 'rgba(255,255,255,0.7)',
30
+ textColor: 'rgba(255,255,255,0.55)',
31
+ buttonBorderColor: 'rgba(255,255,255,0.07)',
32
+ };
33
+
34
+ const EDITOR_OPTIONS = {
35
+ automaticLayout: true,
36
+ selectOnLineNumbers: true,
37
+ readOnly: true,
38
+ minimap: {
39
+ enabled: false,
40
+ },
41
+ wrappingIndent: 'indent',
42
+ };
43
+
44
+ const TabsIds = {
45
+ schema: 'schema',
46
+ json: 'json',
47
+ ast: 'ast',
48
+ };
49
+
50
+ const tabsItems = [
51
+ {id: TabsIds.schema, title: 'Schema'},
52
+ {id: TabsIds.json, title: 'JSON'},
53
+ {id: TabsIds.ast, title: 'AST'},
54
+ ];
55
+
56
+ function QueryExplain(props) {
57
+ const [activeTab, setActiveTab] = useState(TabsIds.schema);
58
+
59
+ const {explain = {}, theme} = props;
60
+ const {links, nodes, version, graphDepth} = explain;
61
+
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
+ useEffect(() => {
98
+ if (!props.ast && activeTab === TabsIds.ast) {
99
+ props.astQuery();
100
+ }
101
+ }, [activeTab]);
102
+
103
+ const onSelectTab = (tabId) => {
104
+ setActiveTab(tabId);
105
+ };
106
+
107
+ const renderTextExplain = () => {
108
+ return (
109
+ <JSONTree
110
+ data={props.explain?.pristine}
111
+ isExpanded={() => true}
112
+ className={b('inspector')}
113
+ searchOptions={{
114
+ debounceTime: 300,
115
+ }}
116
+ />
117
+ );
118
+ };
119
+
120
+ const renderAstExplain = () => {
121
+ return props.loadingAst ? (
122
+ <div className={b('loader')}>
123
+ <Loader size="m" />
124
+ </div>
125
+ ) : (
126
+ <div className={b('ast')}>
127
+ <MonacoEditor
128
+ language={LANGUAGE_S_EXPRESSION_ID}
129
+ value={props.ast}
130
+ options={EDITOR_OPTIONS}
131
+ wrappingIndent="indent"
132
+ />
133
+ </div>
134
+ );
135
+ };
136
+
137
+ const renderGraph = () => {
138
+ const graphHeight = `${Math.max(graphDepth * 100, 200)}px`;
139
+ 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>
148
+ );
149
+ };
150
+
151
+ return (
152
+ <React.Fragment>
153
+ <div className={b('tabs-wrapper')}>
154
+ <Tabs
155
+ items={tabsItems}
156
+ onSelectTab={onSelectTab}
157
+ activeTab={activeTab}
158
+ className={b('tabs')}
159
+ />
160
+ </div>
161
+ {activeTab === TabsIds.json && renderTextExplain()}
162
+ {activeTab === TabsIds.ast && renderAstExplain()}
163
+ {activeTab === TabsIds.schema && renderGraph()}
164
+ </React.Fragment>
165
+ );
166
+ }
167
+
168
+ export default QueryExplain;
@@ -0,0 +1,42 @@
1
+ @import '../../../../styles/mixins.scss';
2
+
3
+ .kv-query-explain {
4
+ &__tabs {
5
+ background-color: var(--yc-color-base-background);
6
+ }
7
+ &__tabs-wrapper {
8
+ position: sticky;
9
+ top: 0;
10
+ background-color: var(--yc-color-base-background);
11
+ padding-bottom: 20px;
12
+ z-index: 2;
13
+ }
14
+ &__explain-canvas-container {
15
+ margin-bottom: 20px;
16
+ overflow-y: auto;
17
+ &_hidden {
18
+ display: none;
19
+ }
20
+ }
21
+ &__inspector {
22
+ @include json-tree-styles();
23
+ overflow-y: auto;
24
+ &
25
+ .json-inspector__leaf.json-inspector__leaf_root.json-inspector__leaf_expanded.json-inspector__leaf_composite {
26
+ max-width: calc(100% - 50px);
27
+ }
28
+ }
29
+
30
+ &__ast {
31
+ margin: 20px 0;
32
+ white-space: pre-wrap;
33
+ height: 100%;
34
+ }
35
+ &__loader {
36
+ width: 100%;
37
+ margin-top: 20px;
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ }
42
+ }
@@ -0,0 +1,58 @@
1
+ import React, {useState} from 'react';
2
+ import cn from 'bem-cn-lite';
3
+ import {Tabs} from '@yandex-cloud/uikit';
4
+ import JSONTree from 'react-json-inspector';
5
+
6
+ import './QueryResult.scss';
7
+
8
+ const b = cn('kv-query-result');
9
+
10
+ const TabsIds = {
11
+ result: 'result',
12
+ stats: 'stats',
13
+ };
14
+
15
+ const tabsItems = [
16
+ {id: TabsIds.result, title: 'Result'},
17
+ {id: TabsIds.stats, title: 'Stats'},
18
+ ];
19
+
20
+ function QueryResult(props) {
21
+ const [activeTab, setActiveTab] = useState(TabsIds.result);
22
+
23
+ const onSelectTab = (tabId) => {
24
+ setActiveTab(tabId);
25
+ };
26
+
27
+ const renderStats = () => {
28
+ return (
29
+ <JSONTree
30
+ data={props.stats}
31
+ isExpanded={() => true}
32
+ className={b('inspector')}
33
+ searchOptions={{
34
+ debounceTime: 300,
35
+ }}
36
+ />
37
+ );
38
+ };
39
+
40
+ return (
41
+ <React.Fragment>
42
+ {props.stats && (
43
+ <Tabs
44
+ items={tabsItems}
45
+ onSelectTab={onSelectTab}
46
+ activeTab={activeTab}
47
+ className={b('tabs')}
48
+ />
49
+ )}
50
+ <div className={b('result')}>
51
+ {activeTab === TabsIds.result && props.result}
52
+ {activeTab === TabsIds.stats && renderStats()}
53
+ </div>
54
+ </React.Fragment>
55
+ );
56
+ }
57
+
58
+ export default QueryResult;
@@ -0,0 +1,24 @@
1
+ @import '../../../../styles/mixins.scss';
2
+
3
+ .kv-query-result {
4
+ &__result {
5
+ overflow: auto;
6
+ margin-top: 20px;
7
+ display: flex;
8
+ flex-direction: column;
9
+ flex-grow: 1;
10
+ & .data-table__table-wrapper {
11
+ padding-bottom: 0;
12
+ }
13
+ }
14
+ &__tabs {
15
+ position: sticky;
16
+ top: 0;
17
+ background-color: var(--yc-color-base-background);
18
+ z-index: 2;
19
+ }
20
+ &__inspector {
21
+ @include json-tree-styles();
22
+ max-width: calc(100% - 50px);
23
+ }
24
+ }
@@ -0,0 +1,171 @@
1
+ import React, {useState, useMemo, useRef} from 'react';
2
+ import _ from 'lodash';
3
+ import cn from 'bem-cn-lite';
4
+ import {useSelector} from 'react-redux';
5
+ import {Dialog, DropdownMenu, Popup, TextInput, Button} from '@yandex-cloud/uikit';
6
+
7
+ import SavedQueries from '../SavedQueries/SavedQueries';
8
+ import Icon from '../../../../components/Icon/Icon';
9
+
10
+ import './SaveQuery.scss';
11
+
12
+ const b = cn('kv-save-query');
13
+
14
+ const EMBEDDED_VERSION_WARNING =
15
+ 'Please be aware: after cookies delete your saved queries will be lost.';
16
+
17
+ function SaveQuery({
18
+ savedQueries,
19
+ onSaveQuery,
20
+ saveButtonDisabled,
21
+ changeUserInput,
22
+ onDeleteQuery,
23
+ }) {
24
+ const singleClusterMode = useSelector((state) => state.singleClusterMode);
25
+ const [isDialogVisible, setIsDialogVisible] = useState(false);
26
+ const [isEmbeddedWarningVisible, setIsEmbeddedWarningVisible] = useState(false);
27
+ const [queryName, setQueryName] = useState('');
28
+ const [validationError, setValidationError] = useState(null);
29
+ const [queryNameToEdit, setQueryNameToEdit] = useState(null);
30
+
31
+ const warningRef = useRef();
32
+
33
+ const hasSavedQueries = useMemo(() => savedQueries && savedQueries.length > 0, [savedQueries]);
34
+
35
+ const onSaveQueryClick = () => {
36
+ setIsDialogVisible(true);
37
+ setQueryNameToEdit(null);
38
+ };
39
+
40
+ const onCloseDialog = () => {
41
+ setIsDialogVisible(false);
42
+ setQueryName('');
43
+ setValidationError(null);
44
+ };
45
+
46
+ const onQueryNameChange = (value) => {
47
+ setQueryName(value);
48
+ setValidationError(validateQueryName(value));
49
+ };
50
+
51
+ const onEmbeddedWarningOpen = () => {
52
+ setIsEmbeddedWarningVisible(true);
53
+ };
54
+ const onEmbeddedWarningClose = () => {
55
+ setIsEmbeddedWarningVisible(false);
56
+ };
57
+
58
+ const validateQueryName = (value) => {
59
+ if (_.some(savedQueries, (q) => q.name.toLowerCase() === value.trim().toLowerCase())) {
60
+ return 'This name already exists';
61
+ }
62
+ return null;
63
+ };
64
+
65
+ const onSaveClick = () => {
66
+ if (queryName && !validationError) {
67
+ onSaveQuery(queryName);
68
+ }
69
+ onCloseDialog();
70
+ };
71
+
72
+ const onEditQueryClick = () => {
73
+ onSaveQuery(queryNameToEdit);
74
+ setQueryNameToEdit(null);
75
+ };
76
+
77
+ const renderDialog = () => {
78
+ return (
79
+ <Dialog open={isDialogVisible} hasCloseButton={false} size="s" onClose={onCloseDialog}>
80
+ <Dialog.Header caption="Save query" />
81
+ <Dialog.Body className={b('dialog-body')}>
82
+ <span className={b('field-title', 'required')}>Query name</span>
83
+ <div className={b('control-wrapper')}>
84
+ <TextInput
85
+ placeholder="Enter query name"
86
+ text={queryName}
87
+ onUpdate={onQueryNameChange}
88
+ hasClear
89
+ />
90
+ <span className={b('error')}>{validationError}</span>
91
+ </div>
92
+ </Dialog.Body>
93
+ <Dialog.Footer
94
+ textButtonApply="Save"
95
+ textButtonCancel="Cancel"
96
+ onClickButtonCancel={onCloseDialog}
97
+ onClickButtonApply={onSaveClick}
98
+ propsButtonApply={{
99
+ disabled: !queryName || Boolean(validationError),
100
+ }}
101
+ />
102
+ </Dialog>
103
+ );
104
+ };
105
+
106
+ const renderSaveButton = (onClick) => {
107
+ return (
108
+ <Button onClick={onClick} disabled={saveButtonDisabled}>
109
+ Save query
110
+ </Button>
111
+ );
112
+ };
113
+
114
+ const renderSaveDropdownMenu = () => {
115
+ const items = [
116
+ {
117
+ action: onSaveQueryClick,
118
+ text: 'Save as new',
119
+ },
120
+ {
121
+ action: onEditQueryClick,
122
+ text: 'Edit existing',
123
+ },
124
+ ];
125
+ return (
126
+ <DropdownMenu items={items} switcher={renderSaveButton()} popupPlacement={['top']} />
127
+ );
128
+ };
129
+
130
+ const renderEmbeddedVersionWarning = () => {
131
+ return (
132
+ <React.Fragment>
133
+ <Popup
134
+ className={b('embedded-popup')}
135
+ anchorRef={warningRef}
136
+ placement={['top']}
137
+ open={isEmbeddedWarningVisible}
138
+ hasArrow
139
+ >
140
+ {EMBEDDED_VERSION_WARNING}
141
+ </Popup>
142
+ <div
143
+ className={b('embedded-tooltip')}
144
+ ref={warningRef}
145
+ onMouseEnter={onEmbeddedWarningOpen}
146
+ onMouseLeave={onEmbeddedWarningClose}
147
+ >
148
+ <Icon name="question" height={18} width={18} viewBox="0 0 24 24" />
149
+ </div>
150
+ </React.Fragment>
151
+ );
152
+ };
153
+
154
+ return (
155
+ <React.Fragment>
156
+ {queryNameToEdit ? renderSaveDropdownMenu() : renderSaveButton(onSaveQueryClick)}
157
+ {isDialogVisible && renderDialog()}
158
+ {hasSavedQueries && (
159
+ <SavedQueries
160
+ savedQueries={savedQueries}
161
+ changeUserInput={changeUserInput}
162
+ onDeleteQuery={onDeleteQuery}
163
+ setQueryNameToEdit={setQueryNameToEdit}
164
+ />
165
+ )}
166
+ {singleClusterMode && renderEmbeddedVersionWarning()}
167
+ </React.Fragment>
168
+ );
169
+ }
170
+
171
+ export default SaveQuery;
@@ -0,0 +1,51 @@
1
+ @import '../../../../styles/mixins.scss';
2
+
3
+ .kv-save-query {
4
+ &__dialog-body {
5
+ display: flex;
6
+ align-items: flex-start;
7
+ }
8
+ &__field-title {
9
+ @include body2-typography();
10
+ line-height: 32px;
11
+ font-weight: 500;
12
+ white-space: nowrap;
13
+ margin-right: 12px;
14
+ &.required {
15
+ &::after {
16
+ content: '*';
17
+ color: var(--yc-color-text-danger);
18
+ }
19
+ }
20
+ }
21
+ &__control-wrapper {
22
+ flex-grow: 1;
23
+ display: flex;
24
+ flex-direction: column;
25
+ }
26
+ &__error {
27
+ display: inline-block;
28
+ height: 17px;
29
+ color: var(--yc-color-text-danger);
30
+ }
31
+ &__embedded-tooltip {
32
+ height: 100%;
33
+ display: flex;
34
+ align-items: center;
35
+ color: var(--yc-color-text-secondary);
36
+ margin-left: -10px;
37
+ &:hover {
38
+ cursor: pointer;
39
+ color: var(--yc-color-text-complementary);
40
+ }
41
+ }
42
+
43
+ &__embedded-popup {
44
+ padding: 10px;
45
+ border-radius: 5px;
46
+ max-width: 150px !important;
47
+ &::before {
48
+ border-radius: 5px;
49
+ }
50
+ }
51
+ }