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,412 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {connect} from 'react-redux';
4
+ import cn from 'bem-cn-lite';
5
+ import qs from 'qs';
6
+ import _ from 'lodash';
7
+
8
+ import {Loader, Progress} from '@yandex-cloud/uikit';
9
+ import {Select} from '@yandex-cloud/uikit/build/esm/components/unstable/Select';
10
+ import ReactList from 'react-list';
11
+
12
+ import Tablet from '../../components/Tablet/Tablet';
13
+
14
+ import {COLORS_PRIORITY, TABLET_COLOR_TO_STATES, TABLETS_STATES} from '../../utils/constants';
15
+ import {showTooltip, hideTooltip} from '../../store/reducers/tooltip';
16
+ import {
17
+ getTabletsInfo,
18
+ clearWasLoadingFlag,
19
+ setStateFilter,
20
+ setTypeFilter,
21
+ getFilteredTablets,
22
+ getTablets,
23
+ } from '../../store/reducers/tabletsFilters';
24
+
25
+ import './TabletsFilters.scss';
26
+
27
+ // чтобы при очень маленьком проценте все равно были видны проблемные места, установим минимальный процент в 3
28
+ const minOverallPercentValue = 3;
29
+
30
+ const b = cn('tablets-filters');
31
+
32
+ class TabletsFilters extends React.Component {
33
+ static propTypes = {
34
+ wasLoaded: PropTypes.bool,
35
+ loading: PropTypes.bool,
36
+ showTooltip: PropTypes.func,
37
+ hideTooltip: PropTypes.func,
38
+ getTabletsInfo: PropTypes.func,
39
+ timeoutForRequest: PropTypes.number,
40
+ path: PropTypes.string,
41
+ clearWasLoadingFlag: PropTypes.func,
42
+ nodes: PropTypes.array,
43
+ tablets: PropTypes.array,
44
+ filteredTablets: PropTypes.array,
45
+ setStateFilter: PropTypes.func,
46
+ setTypeFilter: PropTypes.func,
47
+ stateFilter: PropTypes.array,
48
+ typeFilter: PropTypes.array,
49
+ error: PropTypes.oneOf([PropTypes.string, PropTypes.object]),
50
+ };
51
+
52
+ static renderLoader() {
53
+ return (
54
+ <div className={'loader'}>
55
+ <Loader size="l" />
56
+ </div>
57
+ );
58
+ }
59
+
60
+ static parseNodes = (nodes) => {
61
+ if (Array.isArray(nodes)) {
62
+ return nodes.map(Number).filter(Number.isInteger);
63
+ }
64
+ };
65
+
66
+ static getStateFiltersFromColor = (color) => {
67
+ return TABLET_COLOR_TO_STATES[color] || [color];
68
+ };
69
+
70
+ static CONTROL_WIDTH = 220;
71
+ static POPUP_WIDTH = 300;
72
+
73
+ state = {
74
+ nodeFilter: [],
75
+ tenantPath: '',
76
+ };
77
+
78
+ reloadDescriptor = -1;
79
+
80
+ componentDidMount() {
81
+ const {setStateFilter, setTypeFilter} = this.props;
82
+
83
+ const queryParams = qs.parse(this.props.location.search, {
84
+ ignoreQueryPrefix: true,
85
+ });
86
+ const {nodeIds, type, path, state} = queryParams;
87
+ const nodes = TabletsFilters.parseNodes(nodeIds);
88
+ const stateFilter = TabletsFilters.getStateFiltersFromColor(state);
89
+
90
+ setStateFilter(stateFilter);
91
+ setTypeFilter([type]);
92
+
93
+ this.setState({nodeFilter: nodes, tenantPath: path}, () => {
94
+ this.makeRequest();
95
+ });
96
+ }
97
+
98
+ componentDidUpdate(prevProps) {
99
+ const {loading, error} = this.props;
100
+ if (!error && prevProps.path && this.props.path && prevProps.path !== this.props.path) {
101
+ this.props.clearWasLoadingFlag();
102
+ this.getTablets();
103
+ }
104
+
105
+ if (!error && !loading && this.reloadDescriptor === -1) {
106
+ this.getTablets();
107
+ }
108
+ }
109
+
110
+ componentWillUnmount() {
111
+ clearInterval(this.reloadDescriptor);
112
+ }
113
+
114
+ makeRequest = () => {
115
+ const {nodeFilter, tenantPath} = this.state;
116
+
117
+ this.props.getTabletsInfo({nodes: nodeFilter, path: [tenantPath]});
118
+ };
119
+
120
+ getTablets = () => {
121
+ const {timeoutForRequest} = this.props;
122
+ clearInterval(this.reloadDescriptor);
123
+ this.reloadDescriptor = setTimeout(() => {
124
+ this.makeRequest();
125
+ this.reloadDescriptor = -1;
126
+ }, timeoutForRequest);
127
+ };
128
+
129
+ handleNodeFilterChange = (nodeFilter) => {
130
+ this.setState({nodeFilter}, () => {
131
+ this.props.clearWasLoadingFlag();
132
+ this.makeRequest();
133
+ });
134
+ };
135
+
136
+ handleStateFilterChange = (stateFilter) => {
137
+ const {setStateFilter} = this.props;
138
+ setStateFilter(stateFilter);
139
+ };
140
+
141
+ handleTypeFilterChange = (typeFilter) => {
142
+ const {setTypeFilter} = this.props;
143
+ setTypeFilter(typeFilter);
144
+ };
145
+
146
+ renderTablet = (index, key) => {
147
+ const {filteredTablets, hideTooltip, showTooltip, size} = this.props;
148
+
149
+ return (
150
+ <Tablet
151
+ onMouseLeave={hideTooltip}
152
+ onMouseEnter={showTooltip}
153
+ tablet={filteredTablets[index]}
154
+ key={key}
155
+ size={size}
156
+ className={b('tablet')}
157
+ />
158
+ );
159
+ };
160
+
161
+ renderOverall = (tablets) => {
162
+ const {hideTooltip, showTooltip} = this.props;
163
+ const tabletsCount = tablets.length;
164
+
165
+ const substractPercentsFromMaxPercents = (statesForOverallProgress, substractValue) => {
166
+ Object.keys(statesForOverallProgress).some((key) => {
167
+ if (statesForOverallProgress[key] > 10) {
168
+ statesForOverallProgress[key] -= minOverallPercentValue - substractValue;
169
+ return true;
170
+ }
171
+ return false;
172
+ });
173
+ };
174
+
175
+ // определим, сколько таблеток какого цвета имеется в tablets
176
+ const statesForOverallProgress = tablets.reduce((acc, tablet) => {
177
+ const color = tablet.Overall.toLowerCase();
178
+ if (!acc[color]) {
179
+ acc[color] = 1;
180
+ } else {
181
+ acc[color]++;
182
+ }
183
+
184
+ return acc;
185
+ }, {});
186
+
187
+ const tooltipData = [];
188
+
189
+ // подсчитаем, сколько процентов составляет каждый цвет в statesForOverallProgress и заодно сгенерируем информацию для тултипа
190
+ Object.keys(statesForOverallProgress).forEach((key) => {
191
+ const percents = (statesForOverallProgress[key] / tabletsCount) * 100;
192
+ const value = statesForOverallProgress[key];
193
+ statesForOverallProgress[key] = percents;
194
+ tooltipData.push({color: key, percents, value, total: tablets.length});
195
+ });
196
+
197
+ // заменим все проценты, значения которых меньше 3 на тройку
198
+ Object.keys(statesForOverallProgress).forEach((key) => {
199
+ if (statesForOverallProgress[key] < minOverallPercentValue) {
200
+ substractPercentsFromMaxPercents(
201
+ statesForOverallProgress,
202
+ statesForOverallProgress[key],
203
+ );
204
+ statesForOverallProgress[key] = minOverallPercentValue;
205
+ }
206
+ });
207
+
208
+ const memoryProgress = 100;
209
+ const stack = Object.keys(statesForOverallProgress).map((key) => ({
210
+ color: `var(--color-status-${key}-solid-70)`,
211
+ colorKey: key,
212
+ value: statesForOverallProgress[key],
213
+ }));
214
+
215
+ // сортируем наш stack, чтобы цвета были в порядке "зеленый, оранжевый, желтый, красный, черный"
216
+ stack.sort((a, b) => COLORS_PRIORITY[b.colorKey] - COLORS_PRIORITY[a.colorKey]);
217
+
218
+ return (
219
+ <div className={b('row', {overall: true})}>
220
+ <span className={b('label', {overall: true})}>Overall</span>
221
+ <div
222
+ onMouseLeave={hideTooltip}
223
+ onMouseEnter={(e) => showTooltip(e.target, tooltipData, 'tabletsOverall')}
224
+ >
225
+ <Progress value={memoryProgress} stack={stack} />
226
+ </div>
227
+ </div>
228
+ );
229
+ };
230
+
231
+ renderContent = () => {
232
+ const {nodeFilter, tenantPath} = this.state;
233
+ const {tablets, filteredTablets, nodes, stateFilter, typeFilter, error} = this.props;
234
+
235
+ const states = TABLETS_STATES.map((item) => ({value: item, content: item}));
236
+ const types = Array.from(new Set(...[_.map(tablets, (tblt) => tblt.Type)])).map((item) => ({
237
+ value: item,
238
+ content: item,
239
+ }));
240
+
241
+ const nodesForSelect = _.map(nodes, (node) => ({
242
+ content: node.Id,
243
+ value: node.Id,
244
+ meta: node.Host,
245
+ }));
246
+
247
+ return (
248
+ <div className={b()}>
249
+ {/* {this.renderOverall(tablets)} */}
250
+
251
+ <div className={b('tenant')}>
252
+ <span className={b('label')}>Database: </span> {tenantPath}
253
+ </div>
254
+ <MemoizedFilters
255
+ nodesForSelect={nodesForSelect}
256
+ nodeFilter={nodeFilter}
257
+ onChangeNodes={this.handleNodeFilterChange}
258
+ states={states}
259
+ stateFilter={stateFilter}
260
+ onChangeStates={this.handleStateFilterChange}
261
+ types={types}
262
+ typeFilter={typeFilter}
263
+ onChangeTypes={this.handleTypeFilterChange}
264
+ />
265
+
266
+ {error && <div className="error">{error}</div>}
267
+
268
+ {filteredTablets.length > 0 ? (
269
+ <div className={b('items')}>
270
+ <ReactList
271
+ itemRenderer={this.renderTablet}
272
+ length={filteredTablets.length}
273
+ type="uniform"
274
+ />
275
+ </div>
276
+ ) : (
277
+ !error && <div className={b('empty-message')}>no tablets</div>
278
+ )}
279
+ </div>
280
+ );
281
+ };
282
+
283
+ render() {
284
+ const {loading, wasLoaded, error} = this.props;
285
+
286
+ if (loading && !wasLoaded) {
287
+ return TabletsFilters.renderLoader();
288
+ } else if (error && typeof error === 'object') {
289
+ return <div>{error.statusText}</div>;
290
+ } else {
291
+ return this.renderContent();
292
+ }
293
+ }
294
+ }
295
+
296
+ const Filters = ({
297
+ nodesForSelect,
298
+ nodeFilter,
299
+ onChangeNodes,
300
+
301
+ states,
302
+ stateFilter,
303
+ onChangeStates,
304
+
305
+ types,
306
+ typeFilter,
307
+ onChangeTypes,
308
+ }) => {
309
+ return (
310
+ <div className={b('filters')}>
311
+ <div className={b('filter-wrapper')}>
312
+ <Select
313
+ multiple
314
+ label="Node ID"
315
+ showApply
316
+ showItemMeta
317
+ width={TabletsFilters.CONTROL_WIDTH}
318
+ popupWidth={TabletsFilters.POPUP_WIDTH}
319
+ placeholder="All"
320
+ options={nodesForSelect}
321
+ value={nodeFilter}
322
+ onUpdate={onChangeNodes}
323
+ renderOption={(option) => {
324
+ return (
325
+ <div className={b('node')}>
326
+ <div>{option.content}</div>
327
+ <div className={b('node-meta')}>{option.meta}</div>
328
+ </div>
329
+ );
330
+ }}
331
+ getOptionHeight={() => 40}
332
+ />
333
+ </div>
334
+
335
+ <div className={b('filter-wrapper')}>
336
+ <Select
337
+ multiple
338
+ label="multiple"
339
+ showApply
340
+ width={TabletsFilters.CONTROL_WIDTH}
341
+ placeholder="All"
342
+ options={states}
343
+ value={stateFilter}
344
+ onUpdate={onChangeStates}
345
+ />
346
+ </div>
347
+
348
+ <div className={b('filter-wrapper')}>
349
+ <Select
350
+ multiple
351
+ label="Types"
352
+ showApply
353
+ width={TabletsFilters.CONTROL_WIDTH}
354
+ placeholder="All"
355
+ options={types}
356
+ value={typeFilter}
357
+ onUpdate={onChangeTypes}
358
+ />
359
+ </div>
360
+ </div>
361
+ );
362
+ };
363
+
364
+ Filters.propTypes = {
365
+ nodesForSelect: PropTypes.array,
366
+ nodeFilter: PropTypes.array,
367
+ onChangeNodes: PropTypes.func,
368
+
369
+ states: PropTypes.array,
370
+ stateFilter: PropTypes.array,
371
+ onChangeStates: PropTypes.func,
372
+
373
+ types: PropTypes.array,
374
+ typeFilter: PropTypes.array,
375
+ onChangeTypes: PropTypes.func,
376
+ };
377
+
378
+ const MemoizedFilters = React.memo(Filters, (prevProps, nextProps) => {
379
+ return (
380
+ _.isEqual(prevProps.nodeFilter, nextProps.nodeFilter) &&
381
+ _.isEqual(prevProps.stateFilter, nextProps.stateFilter) &&
382
+ _.isEqual(prevProps.typeFilter, nextProps.typeFilter)
383
+ );
384
+ });
385
+
386
+ const mapStateToProps = (state) => {
387
+ const {nodes, wasLoaded, loading, timeoutForRequest, stateFilter, typeFilter, error} =
388
+ state.tabletsFilters;
389
+
390
+ return {
391
+ tablets: getTablets(state),
392
+ filteredTablets: getFilteredTablets(state),
393
+ nodes,
394
+ timeoutForRequest,
395
+ wasLoaded,
396
+ loading,
397
+ stateFilter,
398
+ typeFilter,
399
+ error,
400
+ };
401
+ };
402
+
403
+ const mapDispatchToProps = {
404
+ getTabletsInfo,
405
+ hideTooltip,
406
+ showTooltip,
407
+ clearWasLoadingFlag,
408
+ setStateFilter,
409
+ setTypeFilter,
410
+ };
411
+
412
+ export default connect(mapStateToProps, mapDispatchToProps)(TabletsFilters);
@@ -0,0 +1,104 @@
1
+ @import '../../styles/mixins';
2
+
3
+ .tablets-filters {
4
+ @include flex-container();
5
+ overflow: auto;
6
+ max-height: 400px;
7
+ // max-width: 400px;
8
+
9
+ &__node {
10
+ font-size: var(--yc-text-body-font-size);
11
+ line-height: var(--yc-text-body-line-height);
12
+ display: flex;
13
+ flex-direction: column;
14
+ }
15
+
16
+ &__node-meta {
17
+ color: var(--yc-color-text-secondary);
18
+ }
19
+
20
+ &__row {
21
+ display: flex;
22
+ align-items: center;
23
+
24
+ &_overall {
25
+ margin: 15px 20px;
26
+
27
+ .yc-progress {
28
+ width: 300px;
29
+ margin: 0;
30
+ }
31
+ }
32
+ }
33
+
34
+ &__label {
35
+ font-size: var(--yc-text-body2-font-size);
36
+ line-height: var(--yc-text-body2-line-height);
37
+ font-weight: 500;
38
+ text-transform: uppercase;
39
+ margin-right: 16px;
40
+
41
+ &_overall {
42
+ margin-right: 15px;
43
+ }
44
+ }
45
+
46
+ &__items {
47
+ display: flex;
48
+ flex-wrap: wrap;
49
+ flex: 1 1 auto;
50
+ overflow: auto;
51
+ padding: 5px 20px;
52
+ }
53
+
54
+ &__items-wrapper {
55
+ overflow: auto;
56
+ }
57
+
58
+ &__filters {
59
+ display: flex;
60
+ align-items: center;
61
+ margin: 10px 0;
62
+ padding: 0 20px;
63
+ }
64
+
65
+ &__filter-label {
66
+ margin-right: 15px;
67
+ white-space: nowrap;
68
+ }
69
+
70
+ &__filter-wrapper {
71
+ display: flex;
72
+ align-items: center;
73
+ margin-right: 15px;
74
+ }
75
+
76
+ &__filter-control {
77
+ margin-right: 10px;
78
+ min-width: 100px;
79
+ max-width: 200px;
80
+
81
+ &:last-child {
82
+ margin-right: 0;
83
+ }
84
+ }
85
+
86
+ &__tablet {
87
+ margin-bottom: 2px;
88
+ }
89
+
90
+ &__empty-message {
91
+ display: flex;
92
+ justify-content: center;
93
+ }
94
+
95
+ &__tenant {
96
+ padding: 20px 20px 10px 20px;
97
+ }
98
+
99
+ .tablet {
100
+ display: inline-block;
101
+ text-align: center;
102
+ line-height: 18px;
103
+ }
104
+ }
@@ -0,0 +1,149 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cn from 'bem-cn-lite';
4
+ import _ from 'lodash';
5
+ import {connect} from 'react-redux';
6
+ import {Loader} from '@yandex-cloud/uikit';
7
+ import DataTable from '@yandex-cloud/react-data-table';
8
+
9
+ import './Acl.scss';
10
+
11
+ const b = cn('kv-acl');
12
+
13
+ const TABLE_SETTINGS = {
14
+ displayIndices: false,
15
+ syncHeadOnResize: true,
16
+ stickyHead: DataTable.MOVING,
17
+ };
18
+ const COLUMN_WIDTH = 140;
19
+ const COLUMNS = [
20
+ {
21
+ name: 'AccessType',
22
+ header: 'Access Type',
23
+ sortable: false,
24
+ width: COLUMN_WIDTH,
25
+ },
26
+ {
27
+ name: 'AccessRights',
28
+ header: 'Access Rights',
29
+ render: ({value}) => {
30
+ return _.map(value, (item, index) => {
31
+ return <div key={index}>{item}</div>;
32
+ });
33
+ },
34
+ width: COLUMN_WIDTH,
35
+ sortable: false,
36
+ },
37
+ {
38
+ name: 'Subject',
39
+ sortable: false,
40
+ // eslint-disable-next-line react/display-name
41
+ render: ({value}) => {
42
+ return Acl.prepareLogin(value);
43
+ },
44
+ width: COLUMN_WIDTH,
45
+ },
46
+ {
47
+ name: 'InheritanceType',
48
+ header: 'Inheritance Type',
49
+ render: ({value}) => {
50
+ return _.map(value, (item, index) => {
51
+ return <div key={index}>{item}</div>;
52
+ });
53
+ },
54
+ width: COLUMN_WIDTH,
55
+ sortable: false,
56
+ },
57
+ ];
58
+
59
+ class Acl extends React.Component {
60
+ static propTypes = {
61
+ error: PropTypes.string,
62
+ acl: PropTypes.array,
63
+ loading: PropTypes.bool,
64
+ };
65
+
66
+ static prepareLogin = (value) => {
67
+ if (value && value.endsWith('@staff') && !value.startsWith('svc_')) {
68
+ const login = value.split('@')[0];
69
+ return login;
70
+ }
71
+
72
+ return value;
73
+ };
74
+
75
+ renderTable = () => {
76
+ const {acl} = this.props;
77
+
78
+ if (!acl) {
79
+ return null;
80
+ }
81
+
82
+ return <DataTable columns={COLUMNS} data={acl} settings={TABLE_SETTINGS} />;
83
+ };
84
+
85
+ renderOwner = () => {
86
+ const {owner} = this.props;
87
+
88
+ if (!owner) {
89
+ return null;
90
+ }
91
+
92
+ return (
93
+ <div className={b('owner-container')}>
94
+ <span className={b('owner-label')}>Owner: </span>
95
+ {Acl.prepareLogin(owner)}
96
+ </div>
97
+ );
98
+ };
99
+ renderResult = () => {
100
+ return (
101
+ <React.Fragment>
102
+ {this.renderOwner()}
103
+ {this.renderTable()}
104
+ </React.Fragment>
105
+ );
106
+ };
107
+
108
+ render() {
109
+ const {error, loading, acl, owner, wasLoaded} = this.props;
110
+
111
+ if (loading && !wasLoaded) {
112
+ return (
113
+ <div className={b('loader-container')}>
114
+ <Loader size="m" />
115
+ </div>
116
+ );
117
+ }
118
+
119
+ if (error && !error.isCancelled) {
120
+ const message = (error.data || error).slice(0, 100);
121
+
122
+ return <div className={b('message-container')}>{message}</div>;
123
+ }
124
+
125
+ if (!loading && !acl && !owner) {
126
+ return <div className={b('message-container')}>Empty</div>;
127
+ }
128
+
129
+ return (
130
+ <div className={b()}>
131
+ <div className={b('result')}>{this.renderResult()}</div>
132
+ </div>
133
+ );
134
+ }
135
+ }
136
+
137
+ const mapStateToProps = (state) => {
138
+ const {loading, error, acl, owner, wasLoaded} = state.schemaAcl;
139
+
140
+ return {
141
+ acl,
142
+ owner,
143
+ loading,
144
+ error,
145
+ wasLoaded,
146
+ };
147
+ };
148
+
149
+ export default connect(mapStateToProps)(Acl);
@@ -0,0 +1,34 @@
1
+ @import '../../../styles/mixins.scss';
2
+
3
+ .kv-acl {
4
+ &__message-container {
5
+ padding: 15px 0;
6
+ }
7
+
8
+ &__loader-container {
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ height: 100%;
13
+ }
14
+
15
+ @include query-data-table;
16
+
17
+ &__owner-container {
18
+ margin: 10px;
19
+
20
+ .yc-staff-card {
21
+ display: inline-block;
22
+ }
23
+ }
24
+
25
+ &__text {
26
+ font-size: var(--yc-text-body-font-size);
27
+ line-height: var(--yc-text-body-line-height);
28
+ color: var(--yc-color-text-primary);
29
+
30
+ &::first-letter {
31
+ color: var(--yc-color-text-danger);
32
+ }
33
+ }
34
+ }