ydb-embedded-ui 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +2 -2
  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 +165 -0
  136. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +310 -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 +94 -0
  141. package/dist/containers/Tenant/QueryEditor/QueryEditor.js +291 -264
  142. package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +47 -18
  143. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +132 -32
  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/fullscreen.ts +31 -0
  175. package/dist/store/reducers/header.ts +23 -0
  176. package/dist/store/reducers/hotKeys.js +1 -1
  177. package/dist/store/reducers/index.js +6 -0
  178. package/dist/store/reducers/saveQuery.ts +33 -0
  179. package/dist/store/reducers/schema.js +14 -0
  180. package/dist/store/reducers/shardsWorkload.js +1 -1
  181. package/dist/store/state-url-mapping.js +1 -1
  182. package/dist/store/utils.js +2 -6
  183. package/dist/styles/mixins.scss +49 -34
  184. package/dist/utils/autofetcher.ts +51 -0
  185. package/dist/utils/constants.js +25 -7
  186. package/dist/utils/createToast.tsx +23 -0
  187. package/dist/utils/getNodesColumns.js +25 -28
  188. package/dist/utils/index.js +6 -2
  189. package/package.json +8 -4
  190. package/dist/components/SplitPane/SplitPane.js +0 -368
  191. package/dist/components/TenantOverview/TenantOverview.js +0 -148
  192. package/dist/containers/Cluster/Cluster.js +0 -168
  193. package/dist/containers/Header/Header.js +0 -88
  194. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +0 -81
  195. package/dist/containers/Tenant/Compute/Compute.scss +0 -6
  196. package/dist/containers/Tenant/Healthcheck/Healthcheck.js +0 -116
  197. package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +0 -64
  198. package/dist/containers/Tenant/Schema/Info/Info.js +0 -84
  199. package/dist/containers/Tenant/Schema/Info/Info.scss +0 -3
  200. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +0 -439
  201. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +0 -90
  202. package/dist/containers/Tenant/Schema/SchemaPages.js +0 -56
  203. package/dist/containers/Tenant/Tenant.js +0 -199
  204. package/dist/containers/Tenant/TenantPages.js +0 -35
@@ -1,11 +1,11 @@
1
- import React, {useState, useMemo, useRef} from 'react';
1
+ import React, {useState, useRef} from 'react';
2
2
  import _ from 'lodash';
3
3
  import cn from 'bem-cn-lite';
4
- import {useSelector} from 'react-redux';
4
+ import {useDispatch, useSelector} from 'react-redux';
5
5
  import {Dialog, DropdownMenu, Popup, TextInput, Button} from '@yandex-cloud/uikit';
6
6
 
7
- import SavedQueries from '../SavedQueries/SavedQueries';
8
7
  import Icon from '../../../../components/Icon/Icon';
8
+ import {setQueryNameToEdit} from '../../../../store/reducers/saveQuery';
9
9
 
10
10
  import './SaveQuery.scss';
11
11
 
@@ -14,27 +14,21 @@ const b = cn('kv-save-query');
14
14
  const EMBEDDED_VERSION_WARNING =
15
15
  'Please be aware: after cookies delete your saved queries will be lost.';
16
16
 
17
- function SaveQuery({
18
- savedQueries,
19
- onSaveQuery,
20
- saveButtonDisabled,
21
- changeUserInput,
22
- onDeleteQuery,
23
- }) {
17
+ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
24
18
  const singleClusterMode = useSelector((state) => state.singleClusterMode);
25
19
  const [isDialogVisible, setIsDialogVisible] = useState(false);
26
20
  const [isEmbeddedWarningVisible, setIsEmbeddedWarningVisible] = useState(false);
27
21
  const [queryName, setQueryName] = useState('');
28
22
  const [validationError, setValidationError] = useState(null);
29
- const [queryNameToEdit, setQueryNameToEdit] = useState(null);
30
23
 
31
- const warningRef = useRef();
24
+ const queryNameToEdit = useSelector((state) => state.saveQuery);
25
+ const dispatch = useDispatch();
32
26
 
33
- const hasSavedQueries = useMemo(() => savedQueries && savedQueries.length > 0, [savedQueries]);
27
+ const warningRef = useRef();
34
28
 
35
29
  const onSaveQueryClick = () => {
36
30
  setIsDialogVisible(true);
37
- setQueryNameToEdit(null);
31
+ dispatch(setQueryNameToEdit(null));
38
32
  };
39
33
 
40
34
  const onCloseDialog = () => {
@@ -71,7 +65,7 @@ function SaveQuery({
71
65
 
72
66
  const onEditQueryClick = () => {
73
67
  onSaveQuery(queryNameToEdit);
74
- setQueryNameToEdit(null);
68
+ dispatch(setQueryNameToEdit(null));
75
69
  };
76
70
 
77
71
  const renderDialog = () => {
@@ -155,14 +149,7 @@ function SaveQuery({
155
149
  <React.Fragment>
156
150
  {queryNameToEdit ? renderSaveDropdownMenu() : renderSaveButton(onSaveQueryClick)}
157
151
  {isDialogVisible && renderDialog()}
158
- {hasSavedQueries && (
159
- <SavedQueries
160
- savedQueries={savedQueries}
161
- changeUserInput={changeUserInput}
162
- onDeleteQuery={onDeleteQuery}
163
- setQueryNameToEdit={setQueryNameToEdit}
164
- />
165
- )}
152
+
166
153
  {singleClusterMode && renderEmbeddedVersionWarning()}
167
154
  </React.Fragment>
168
155
  );
@@ -6,44 +6,52 @@
6
6
  align-items: flex-start;
7
7
  }
8
8
  &__field-title {
9
- @include body2-typography();
10
- line-height: 32px;
9
+ margin-right: 12px;
10
+
11
11
  font-weight: 500;
12
+ line-height: 32px;
12
13
  white-space: nowrap;
13
- margin-right: 12px;
14
+ @include body2-typography();
14
15
  &.required {
15
16
  &::after {
16
17
  content: '*';
18
+
17
19
  color: var(--yc-color-text-danger);
18
20
  }
19
21
  }
20
22
  }
21
23
  &__control-wrapper {
22
- flex-grow: 1;
23
24
  display: flex;
25
+ flex-grow: 1;
24
26
  flex-direction: column;
25
27
  }
26
28
  &__error {
27
29
  display: inline-block;
30
+
28
31
  height: 17px;
32
+
29
33
  color: var(--yc-color-text-danger);
30
34
  }
31
35
  &__embedded-tooltip {
32
- height: 100%;
33
36
  display: flex;
34
37
  align-items: center;
35
- color: var(--yc-color-text-secondary);
38
+
39
+ height: 100%;
36
40
  margin-left: -10px;
41
+
42
+ color: var(--yc-color-text-secondary);
37
43
  &:hover {
38
44
  cursor: pointer;
45
+
39
46
  color: var(--yc-color-text-complementary);
40
47
  }
41
48
  }
42
49
 
43
50
  &__embedded-popup {
51
+ max-width: 150px !important;
44
52
  padding: 10px;
53
+
45
54
  border-radius: 5px;
46
- max-width: 150px !important;
47
55
  &::before {
48
56
  border-radius: 5px;
49
57
  }
@@ -6,17 +6,21 @@ import {Dialog, Popup, Button} from '@yandex-cloud/uikit';
6
6
  import TruncatedQuery from '../../../../components/TruncatedQuery/TruncatedQuery';
7
7
  import Icon from '../../../../components/Icon/Icon';
8
8
  import './SavedQueries.scss';
9
+ import {setQueryNameToEdit} from '../../../../store/reducers/saveQuery';
10
+ import {useDispatch} from 'react-redux';
9
11
 
10
12
  const b = cn('saved-queries');
11
13
 
12
14
  const MAX_QUERY_HEIGHT = 3;
13
15
 
14
- function SavedQueries({savedQueries, changeUserInput, onDeleteQuery, setQueryNameToEdit}) {
16
+ function SavedQueries({savedQueries, changeUserInput, onDeleteQuery}) {
15
17
  const [isSavedQueriesVisible, setIsSavedQueriesVisible] = useState(false);
16
18
  const [isDeleteDialogVisible, setIsDeleteDialogVisible] = useState(false);
17
19
  const [queryNameToDelete, setQueryNameToDelete] = useState(null);
18
20
 
19
21
  const [popupForceRender, setPopupForceRender] = useState(null);
22
+
23
+ const dispatch = useDispatch();
20
24
  const anchor = useRef(null);
21
25
 
22
26
  const onShowSavedQueriesClick = () => {
@@ -30,7 +34,7 @@ function SavedQueries({savedQueries, changeUserInput, onDeleteQuery, setQueryNam
30
34
  const onSavedQueryClick = (queryText, queryName) => {
31
35
  return () => {
32
36
  changeUserInput({input: queryText});
33
- setQueryNameToEdit(queryName);
37
+ dispatch(setQueryNameToEdit(queryName));
34
38
  setIsSavedQueriesVisible(false);
35
39
  };
36
40
  };
@@ -89,7 +93,7 @@ function SavedQueries({savedQueries, changeUserInput, onDeleteQuery, setQueryNam
89
93
  className={b('popup-wrapper')}
90
94
  anchorRef={anchor}
91
95
  open={isSavedQueriesVisible}
92
- placement={['top']}
96
+ placement={['bottom-end']}
93
97
  onClose={onCloseSavedQueries}
94
98
  >
95
99
  <div className={b()}>
@@ -2,32 +2,38 @@ $popup-width: 700px;
2
2
 
3
3
  .saved-queries {
4
4
  $block: &;
5
- padding: 12px 16px 12px;
5
+ padding: 12px 16px;
6
6
  &__popup-wrapper {
7
- border-radius: 4px;
7
+ overflow: hidden;
8
+
8
9
  width: $popup-width;
9
10
  max-width: $popup-width !important;
10
- // max-height: 70vh;
11
- overflow: hidden;
11
+
12
+ border-radius: 4px;
12
13
  :nth-child(2) {
13
- max-height: 70vh;
14
14
  overflow-y: auto;
15
+
16
+ max-height: 50vh;
15
17
  }
16
18
 
17
19
  &::before {
18
- border-radius: 4px;
19
20
  width: $popup-width;
21
+
22
+ border-radius: 4px;
20
23
  }
21
24
  }
22
25
  &__saved-queries-row {
23
26
  display: flex;
24
27
  align-items: center;
28
+
25
29
  padding: 8px 5px;
30
+
26
31
  border-bottom: 1px solid var(--yc-color-line-generic);
27
32
  &:hover {
33
+ cursor: pointer;
34
+
28
35
  color: var(--yc-color-text-link-hover);
29
36
  background: var(--yc-color-base-simple-hover);
30
- cursor: pointer;
31
37
  #{$block}__query-controls {
32
38
  display: flex;
33
39
  }
@@ -35,29 +41,32 @@ $popup-width: 700px;
35
41
  &_header {
36
42
  font-weight: 500;
37
43
  &:hover {
44
+ cursor: auto;
45
+
38
46
  color: var(--yc-color-text-primary);
39
47
  background: var(--yc-color-base-background);
40
- cursor: auto;
41
48
  }
42
49
  }
43
50
  }
44
51
  &__query-name {
45
- margin-right: 8px;
46
- flex-basis: 90px;
52
+ overflow: hidden;
53
+ flex: 0 0 90px;
54
+
47
55
  max-width: 90px;
48
- flex-shrink: 0;
49
- flex-grow: 0;
56
+ margin-right: 8px;
57
+
58
+ font-weight: 500;
50
59
  white-space: pre-wrap;
51
- overflow: hidden;
52
60
  text-overflow: ellipsis;
53
- font-weight: 500;
54
61
  }
55
62
  &__query-body {
63
+ overflow: hidden;
56
64
  flex-grow: 1;
65
+
66
+ max-width: 75%;
67
+
57
68
  white-space: pre;
58
69
  text-overflow: ellipsis;
59
- overflow: hidden;
60
- max-width: 75%;
61
70
  &_header {
62
71
  display: flex;
63
72
  justify-content: center;
@@ -68,9 +77,11 @@ $popup-width: 700px;
68
77
  }
69
78
  &__control-button {
70
79
  display: flex;
71
- align-items: center;
72
80
  justify-content: center;
81
+ align-items: center;
82
+
73
83
  width: 24px;
84
+
74
85
  color: var(--yc-color-text-hint);
75
86
  &:hover {
76
87
  color: var(--yc-color-text-secondary);
@@ -7,7 +7,7 @@ import {formatCPU, formatBytes} from '../../../../utils';
7
7
 
8
8
  import InfoViewer from '../../../../components/InfoViewer/InfoViewer';
9
9
 
10
- const b = cn('schema-viewer');
10
+ const b = cn('schema-info-viewer');
11
11
 
12
12
  class SchemaInfoViewer extends React.Component {
13
13
  static propTypes = {
@@ -26,7 +26,8 @@ class SchemaInfoViewer extends React.Component {
26
26
  const {data} = this.props;
27
27
 
28
28
  if (data) {
29
- const {TableStats = {}, TabletMetrics = {}} = data.PathDescription;
29
+ const {PathDescription = {}} = data;
30
+ const {TableStats = {}, TabletMetrics = {}} = PathDescription;
30
31
  const tableStatsInfo =
31
32
  TableStats &&
32
33
  Object.keys(TableStats).map((key) => ({
@@ -49,11 +50,10 @@ class SchemaInfoViewer extends React.Component {
49
50
  return (
50
51
  <div className={b()}>
51
52
  <div className={b('item')}>
52
- {Boolean(infoLength) && (
53
- <>
54
- <div className={b('title')}>General</div>
55
- <InfoViewer info={generalInfo}></InfoViewer>
56
- </>
53
+ {infoLength ? (
54
+ <InfoViewer info={generalInfo}></InfoViewer>
55
+ ) : (
56
+ <div>Empty</div>
57
57
  )}
58
58
  </div>
59
59
  </div>
@@ -1,5 +1,4 @@
1
- .schema-viewer {
2
- padding: 20px;
1
+ .schema-info-viewer {
3
2
  overflow: auto;
4
3
 
5
4
  &__item {
@@ -9,13 +8,4 @@
9
8
  grid-template-columns: minmax(max-content, 280px);
10
9
  }
11
10
  }
12
-
13
- &__title {
14
- margin: 0;
15
- color: var(--yc-color-text-primary);
16
- font-size: var(--yc-text-body2-font-size);
17
- font-weight: 500;
18
- line-height: var(--yc-text-body2-line-height);
19
- margin-bottom: 15px;
20
- }
21
11
  }
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
3
2
  import {connect} from 'react-redux';
4
3
  import PropTypes from 'prop-types';
5
4
  import cn from 'bem-cn-lite';
@@ -13,15 +12,16 @@ import {getDescribe} from '../../../../store/reducers/describe';
13
12
  import {getSchemaAcl} from '../../../../store/reducers/schemaAcl';
14
13
 
15
14
  import './SchemaNode.scss';
15
+ import SchemaNodeActions from '../SchemaNodeActions/SchemaNodeActions';
16
+ import {isTableType} from '../../Tenant';
16
17
 
17
18
  const b = cn('schema-node');
18
19
 
19
- export const FOLDERS_TYPE = [
20
- 'EPathTypeDir',
21
- 'EPathTypeSubDomain',
22
- 'EPathTypeExtSubDomain',
23
- 'EPathTypeOlapStore',
24
- ];
20
+ export const SUBDOMAIN_FOLDER_TYPE = 'EPathTypeSubDomain';
21
+ export const TABLE_TYPE = 'EPathTypeTable';
22
+ export const OLAP_TABLE_TYPE = 'EPathTypeOlapTable';
23
+
24
+ export const FOLDERS_TYPE = ['EPathTypeDir', 'EPathTypeExtSubDomain', 'EPathTypeOlapStore'];
25
25
 
26
26
  class SchemaNode extends React.Component {
27
27
  static propTypes = {
@@ -30,10 +30,12 @@ class SchemaNode extends React.Component {
30
30
  getSchema: PropTypes.func.isRequired,
31
31
  setCurrentSchemaPath: PropTypes.func,
32
32
  currentSchemaPath: PropTypes.string,
33
+ isRoot: PropTypes.bool,
33
34
  };
34
35
 
35
36
  state = {
36
37
  collapsed: true,
38
+ active: false,
37
39
  };
38
40
 
39
41
  schemaNodeRef = React.createRef();
@@ -42,7 +44,7 @@ class SchemaNode extends React.Component {
42
44
  const {currentSchemaPath, isRoot} = this.props;
43
45
  const schemaPath = this.getSchemaPath();
44
46
 
45
- if (schemaPath === currentSchemaPath) {
47
+ if (schemaPath === currentSchemaPath && !this.state.active) {
46
48
  this.addActiveClass();
47
49
  }
48
50
 
@@ -56,6 +58,15 @@ class SchemaNode extends React.Component {
56
58
  }
57
59
  }
58
60
 
61
+ componentDidUpdate() {
62
+ const {currentSchemaPath} = this.props;
63
+ const schemaPath = this.getSchemaPath();
64
+
65
+ if (schemaPath === currentSchemaPath && !this.state.active) {
66
+ this.addActiveClass();
67
+ }
68
+ }
69
+
59
70
  getSchemaPath = () => {
60
71
  const {data, fullPath, isRoot} = this.props;
61
72
 
@@ -67,15 +78,18 @@ class SchemaNode extends React.Component {
67
78
  };
68
79
 
69
80
  setIcon = (data) => {
81
+ const viewBox = '0 0 16 16';
70
82
  const {collapsed} = this.state;
71
83
  if (FOLDERS_TYPE.indexOf(data.PathType) !== -1) {
72
84
  return collapsed ? (
73
- <Icon name="folder" viewBox="0 0 13 10" width={14} height={14} />
85
+ <Icon name="folder" viewBox={viewBox} width={16} height={16} />
74
86
  ) : (
75
- <Icon name="openFolder" viewBox="0 0 13 10" width={14} height={14} />
87
+ <Icon name="openFolder" viewBox={viewBox} width={16} height={16} />
76
88
  );
77
- } else if (data.PathType === 'EPathTypeTable' || data.PathType === 'EPathTypeOlapTable') {
78
- return <Icon name="table" viewBox="0 0 13 10" width={14} height={14} />;
89
+ } else if (data.PathType === TABLE_TYPE || data.PathType === OLAP_TABLE_TYPE) {
90
+ return <Icon name="table" viewBox={viewBox} width={16} height={16} />;
91
+ } else if (data.PathType === SUBDOMAIN_FOLDER_TYPE) {
92
+ return <Icon name="subdomain" viewBox={viewBox} width={16} height={16} />;
79
93
  }
80
94
  };
81
95
 
@@ -85,9 +99,9 @@ class SchemaNode extends React.Component {
85
99
  if (currentActiveSchemaNode) {
86
100
  currentActiveSchemaNode.classList.remove(activeClass);
87
101
  }
88
- // eslint-disable-next-line react/no-find-dom-node
89
- const activeNode = ReactDOM.findDOMNode(this);
102
+ const activeNode = this.schemaNodeRef.current;
90
103
  if (activeNode) {
104
+ this.setState({active: true});
91
105
  activeNode.classList.add(activeClass);
92
106
  }
93
107
  };
@@ -105,18 +119,23 @@ class SchemaNode extends React.Component {
105
119
  };
106
120
 
107
121
  render() {
108
- const {data, fullPath, isRoot = false} = this.props;
122
+ const {data, fullPath, isRoot = false, currentSchemaPath, currentItem = {}} = this.props;
109
123
  const {collapsed} = this.state;
110
124
 
111
125
  if (!data) {
112
126
  return null;
113
127
  }
128
+ const currentPathType = currentItem.PathDescription?.Self?.PathType;
129
+ const type = isTableType(currentPathType);
114
130
 
115
- const hasArrow = data.PathType !== 'EPathTypeTable';
131
+ const hasArrow = data.PathType !== TABLE_TYPE;
116
132
  const label = (
117
133
  <div className={b('label')}>
118
134
  {this.setIcon(data)}
119
- <div className={b('name')}>{data.Name}</div>
135
+ <div className={b('name-wrapper')}>
136
+ <div className={b('name')}>{data.Name}</div>
137
+ <SchemaNodeActions name={currentSchemaPath} isTableType={type} />
138
+ </div>
120
139
  </div>
121
140
  );
122
141
  return (
@@ -137,6 +156,7 @@ class SchemaNode extends React.Component {
137
156
  function mapStateToProps(state) {
138
157
  return {
139
158
  currentSchemaPath: state.schema.currentSchemaPath,
159
+ currentItem: state.schema.currentSchema,
140
160
  };
141
161
  }
142
162
 
@@ -3,39 +3,60 @@
3
3
  align-items: center;
4
4
 
5
5
  .tree-view_item {
6
- padding: 5px 0;
7
- margin: 0;
8
6
  flex-wrap: wrap;
7
+
8
+ margin: 0;
9
+ padding: 5px 0;
9
10
  }
10
11
 
11
12
  .tree-view_children {
12
- padding-left: 15px;
13
13
  margin: 0;
14
+ padding-left: 15px;
14
15
  }
15
16
 
16
17
  &__label {
17
18
  display: flex;
18
- align-items: center;
19
19
  overflow: hidden;
20
- cursor: pointer;
21
- padding: 0 5px;
22
- border-radius: 3px;
20
+ align-items: center;
21
+
22
+ width: 100%;
23
23
  height: 20px;
24
+ padding: 0 5px;
25
+
26
+ cursor: pointer;
24
27
 
25
- &:hover {
26
- background-color: var(--yc-color-base-info-hover);
28
+ & > svg {
29
+ color: var(--yc-color-text-hint);
27
30
  }
28
31
  }
29
32
 
30
- &_active > .tree-view > .tree-view_item &__label {
33
+ &_active > .tree-view > .tree-view_item {
34
+ font-weight: 600;
35
+
31
36
  background-color: var(--yc-color-base-info);
32
37
  }
33
38
 
39
+ &__name-wrapper {
40
+ display: inline-flex;
41
+ justify-content: space-between;
42
+
43
+ width: 100%;
44
+ }
45
+
34
46
  &__name {
35
47
  display: inline;
36
- text-overflow: ellipsis;
37
- white-space: nowrap;
38
48
  overflow: hidden;
49
+
39
50
  margin-left: 6px;
51
+
52
+ white-space: nowrap;
53
+ text-overflow: ellipsis;
54
+ }
55
+ }
56
+
57
+ .tree-view_item {
58
+ border-bottom: 1px solid var(--yc-color-line-generic);
59
+ &:hover {
60
+ background-color: var(--yc-color-base-simple-hover);
40
61
  }
41
62
  }
@@ -0,0 +1,17 @@
1
+ .kv-schema-node-actions {
2
+ visibility: hidden;
3
+
4
+ &__popup {
5
+ .yc-menu__list-item {
6
+ line-height: 36px;
7
+ }
8
+ }
9
+ }
10
+
11
+ .tree-view_item {
12
+ &:hover {
13
+ .kv-schema-node-actions {
14
+ visibility: visible;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,125 @@
1
+ import {useDispatch} from 'react-redux';
2
+ import {useHistory} from 'react-router';
3
+ import cn from 'bem-cn-lite';
4
+ import {DropdownMenu} from '@yandex-cloud/uikit';
5
+ import qs from 'qs';
6
+
7
+ import {changeUserInput} from '../../../../store/reducers/executeQuery';
8
+ import {setShowPreview} from '../../../../store/reducers/schema';
9
+ import routes, {createHref} from '../../../../routes';
10
+
11
+ import './SchemaNodeActions.scss';
12
+ import {TenantGeneralTabsIds, TenantTabsGroups} from '../../TenantPages';
13
+ import createToast from '../../../../utils/createToast';
14
+
15
+ const b = cn('kv-schema-node-actions');
16
+
17
+ const createTableTemplate = (path: string) => {
18
+ return `CREATE TABLE \`${path}/my_table\`
19
+ (
20
+ \`id\` Uint64,
21
+ \`name\` String,
22
+ PRIMARY KEY (\`id\`)
23
+ );`;
24
+ };
25
+
26
+ const alterTableTemplate = (path: string) => {
27
+ return `ALTER TABLE \`${path}\`
28
+ ADD COLUMN is_deleted Bool;`;
29
+ };
30
+ const selectQueryTemplate = (path: string) => {
31
+ return `SELECT \`id\`, \`name\`
32
+ FROM \`${path}\`
33
+ ORDER BY \`id\`
34
+ LIMIT 10;`;
35
+ };
36
+ const upsertQueryTemplate = (path: string) => {
37
+ return `UPSERT INTO \`${path}\`
38
+ ( \`id\`, \`name\` )
39
+ VALUES ( );`;
40
+ };
41
+
42
+ interface SchemaNodeActionsProps {
43
+ name: string;
44
+ isTableType: boolean;
45
+ }
46
+
47
+ function SchemaNodeActions({name, isTableType}: SchemaNodeActionsProps) {
48
+ const dispatch = useDispatch();
49
+ const history = useHistory();
50
+
51
+ const queryParams = qs.parse(location.search, {
52
+ ignoreQueryPrefix: true,
53
+ });
54
+
55
+ const onCreateTableClick = () => {
56
+ dispatch(changeUserInput({input: createTableTemplate(name)}));
57
+ };
58
+
59
+ const onAlterTableClick = () => {
60
+ dispatch(changeUserInput({input: alterTableTemplate(name)}));
61
+ };
62
+
63
+ const onSelectQueryClick = () => {
64
+ dispatch(changeUserInput({input: selectQueryTemplate(name)}));
65
+ };
66
+
67
+ const onUpsertQueryClick = () => {
68
+ dispatch(changeUserInput({input: upsertQueryTemplate(name)}));
69
+ };
70
+
71
+ const onCopyPathClick = () => {
72
+ navigator.clipboard
73
+ .writeText(name)
74
+ .then(() => {
75
+ createToast({
76
+ name: 'Copied',
77
+ title: 'Path was copied to clipboard successfully',
78
+ type: 'success',
79
+ });
80
+ })
81
+ .catch(() => {
82
+ createToast({
83
+ name: 'Not copied',
84
+ title: 'Path was not copied to clipboard successfully',
85
+ type: 'error',
86
+ });
87
+ });
88
+ };
89
+
90
+ const onOpenPreviewClick = () => {
91
+ dispatch(setShowPreview(true));
92
+ history.push(
93
+ createHref(routes.tenant, undefined, {
94
+ ...queryParams,
95
+ [TenantTabsGroups.general]: TenantGeneralTabsIds.query,
96
+ }),
97
+ );
98
+ };
99
+
100
+ const copyItem = {text: 'Copy path', action: onCopyPathClick};
101
+
102
+ const tableItems = [
103
+ [{text: 'Open preview', action: onOpenPreviewClick}, copyItem],
104
+ [
105
+ {text: 'Alter table', action: onAlterTableClick},
106
+ {text: 'Select query', action: onSelectQueryClick},
107
+ {text: 'Upsert query', action: onUpsertQueryClick},
108
+ ],
109
+ ];
110
+
111
+ const catalogItems = [[copyItem], [{text: 'Create table', action: onCreateTableClick}]];
112
+
113
+ const items = isTableType ? tableItems : catalogItems;
114
+
115
+ return (
116
+ <DropdownMenu
117
+ items={items}
118
+ switcherWrapperClassName={b()}
119
+ popupClassName={b('popup')}
120
+ popupPlacement={['bottom-end']}
121
+ />
122
+ );
123
+ }
124
+
125
+ export default SchemaNodeActions;