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,228 @@
1
+ import React, {useState} from 'react';
2
+ import {useHistory} from 'react-router-dom';
3
+ import cn from 'bem-cn-lite';
4
+ import {useLocation} from 'react-router';
5
+ import {connect} from 'react-redux';
6
+
7
+ import {
8
+ AsideHeader,
9
+ AsideHeaderFooterItem,
10
+ AsideHeaderMenuItem,
11
+ SlotName,
12
+ } from '../../components/AsideNavigation/AsideHeader';
13
+ import {Icon, Button} from '@yandex-cloud/uikit';
14
+ import signOutIcon from '../../assets/icons/signOut.svg';
15
+ import signInIcon from '../../assets/icons/signIn.svg';
16
+
17
+ import databaseIcon from '../../assets/icons/server.svg';
18
+
19
+ import storageIcon from '../../assets/icons/storage.svg';
20
+ import ydbLogoIcon from '../../assets/icons/ydb.svg';
21
+ import databasesIcon from '../../assets/icons/databases.svg';
22
+ import userSecret from '../../assets/icons/user-secret.svg';
23
+ import userChecked from '../../assets/icons/user-check.svg';
24
+ //@ts-ignore
25
+ import UserSettings from '../UserSettings/UserSettings';
26
+ //@ts-ignore
27
+ import routes, {createHref} from '../../routes';
28
+ import {CLUSTER_PAGES} from '../Cluster/Cluster';
29
+
30
+ //@ts-ignore
31
+ import {logout, setIsNotAuthenticated} from '../../store/reducers/authentication';
32
+
33
+ import './AsideNavigation.scss';
34
+
35
+ const b = cn('kv-navigation');
36
+ interface MenuItem {
37
+ id: string;
38
+ title: string;
39
+ icon: SVGIconData;
40
+ iconSize: string | number;
41
+ location: string;
42
+ locationKeys?: string[];
43
+ }
44
+
45
+ interface YbdInternalUserProps {
46
+ ydbUser?: string;
47
+ logout: VoidFunction;
48
+ setIsNotAuthenticated: VoidFunction;
49
+ }
50
+
51
+ function YbdInternalUser({ydbUser, logout, setIsNotAuthenticated}: YbdInternalUserProps) {
52
+ return (
53
+ <div className={b('internal-user')}>
54
+ <div className={b('user-info-wrapper')}>
55
+ <div className={b('ydb-internal-user-title')}>YDB user</div>
56
+ {ydbUser && <div className={b('username')}>{ydbUser}</div>}
57
+ </div>
58
+ {ydbUser ? (
59
+ <Button view="flat-secondary" onClick={logout} title="logout">
60
+ <Icon data={signOutIcon} size={16} />
61
+ </Button>
62
+ ) : (
63
+ <Button view="flat-secondary" onClick={setIsNotAuthenticated} title="login">
64
+ <Icon data={signInIcon} size={16} />
65
+ </Button>
66
+ )}
67
+ </div>
68
+ );
69
+ }
70
+
71
+ interface YdbUserDropdownProps {
72
+ isCompact: boolean;
73
+ ydbUser: {
74
+ login?: string;
75
+ logout: VoidFunction;
76
+ setIsNotAuthenticated: VoidFunction;
77
+ };
78
+ popupAnchor: React.RefObject<HTMLDivElement>;
79
+ }
80
+
81
+ function YdbUserDropdown({isCompact, popupAnchor, ydbUser}: YdbUserDropdownProps) {
82
+ const [isUserDropdownVisible, setIsUserDropdownVisible] = useState(false);
83
+ const iconDate = ydbUser?.login ? userChecked : userSecret;
84
+ return (
85
+ <AsideHeaderFooterItem
86
+ isCurrent={isUserDropdownVisible}
87
+ slot={SlotName.User}
88
+ renderCustomIcon={() => <Icon data={iconDate} size={22} className={b('user-icon')} />}
89
+ text={ydbUser?.login ?? 'Account'}
90
+ isCompact={isCompact}
91
+ popupAnchor={popupAnchor}
92
+ popupVisible={isUserDropdownVisible}
93
+ onClick={() => setIsUserDropdownVisible(true)}
94
+ onClosePopup={() => setIsUserDropdownVisible(false)}
95
+ renderPopupContent={() => (
96
+ <div className={b('ydb-user-wrapper')}>
97
+ <YbdInternalUser
98
+ ydbUser={ydbUser.login}
99
+ logout={ydbUser.logout}
100
+ setIsNotAuthenticated={ydbUser.setIsNotAuthenticated}
101
+ />
102
+ </div>
103
+ )}
104
+ />
105
+ );
106
+ }
107
+
108
+ interface AsideNavigationProps {
109
+ children: React.ReactNode;
110
+ ydbUser: string;
111
+ logout: VoidFunction;
112
+ setIsNotAuthenticated: VoidFunction;
113
+ }
114
+
115
+ const items: MenuItem[] = [
116
+ {
117
+ id: CLUSTER_PAGES.tenants.id,
118
+ title: 'Databases',
119
+ icon: databasesIcon,
120
+ iconSize: 20,
121
+ location: createHref(routes.cluster, {
122
+ activeTab: CLUSTER_PAGES.tenants.id,
123
+ }),
124
+ locationKeys: ['/tenant'],
125
+ },
126
+ {
127
+ id: CLUSTER_PAGES.nodes.id,
128
+ title: 'Nodes',
129
+ icon: databaseIcon,
130
+ iconSize: 20,
131
+ location: createHref(routes.cluster, {activeTab: CLUSTER_PAGES.nodes.id}),
132
+ locationKeys: ['/node'],
133
+ },
134
+ {
135
+ id: CLUSTER_PAGES.storage.id,
136
+ title: 'Storage',
137
+ icon: storageIcon,
138
+ iconSize: 20,
139
+ location: createHref(routes.cluster, {
140
+ activeTab: CLUSTER_PAGES.storage.id,
141
+ }),
142
+ locationKeys: ['/storage'],
143
+ },
144
+ ];
145
+
146
+ function AsideNavigation(props: AsideNavigationProps) {
147
+ const location = useLocation();
148
+ const history = useHistory();
149
+
150
+ const menuItems: AsideHeaderMenuItem[] = React.useMemo(() => {
151
+ const {pathname} = location;
152
+ const isClusterPage = pathname === '/cluster';
153
+ const menuItems: AsideHeaderMenuItem[] = items.map((item) => {
154
+ const locationKeysCoincidence = item.locationKeys?.filter((key) =>
155
+ pathname.startsWith(key),
156
+ );
157
+ let current =
158
+ (locationKeysCoincidence && locationKeysCoincidence.length > 0) ||
159
+ item.location.startsWith(pathname);
160
+ if (isClusterPage && item.id !== CLUSTER_PAGES.tenants.id) {
161
+ current = false;
162
+ }
163
+ return {
164
+ id: item.id,
165
+ title: item.title,
166
+ icon: item.icon,
167
+ iconSize: item.iconSize,
168
+ current,
169
+ onItemClick: () => {
170
+ history.push(item.location);
171
+ },
172
+ };
173
+ });
174
+ return menuItems;
175
+ }, [location, history]);
176
+
177
+ return (
178
+ <React.Fragment>
179
+ <AsideHeader
180
+ logoText="YDB"
181
+ logoIcon={ydbLogoIcon}
182
+ onLogoIconClick={() => history.push('/')}
183
+ menuItems={menuItems}
184
+ settings={<UserSettings />}
185
+ className={b()}
186
+ renderContent={() => props.children}
187
+ renderFooter={({isCompact, asideRef}) => (
188
+ <React.Fragment>
189
+ <AsideHeaderFooterItem
190
+ slot={SlotName.Support}
191
+ iconSize={24}
192
+ text="Documentation"
193
+ isCompact={isCompact}
194
+ onClick={() => {
195
+ window.open('http://ydb.tech/docs', '_blank', 'noreferrer');
196
+ }}
197
+ />
198
+
199
+ <YdbUserDropdown
200
+ isCompact={isCompact}
201
+ popupAnchor={asideRef}
202
+ ydbUser={{
203
+ login: props.ydbUser,
204
+ logout: props.logout,
205
+ setIsNotAuthenticated: props.setIsNotAuthenticated,
206
+ }}
207
+ />
208
+ </React.Fragment>
209
+ )}
210
+ />
211
+ </React.Fragment>
212
+ );
213
+ }
214
+
215
+ const mapStateToProps = (state: any) => {
216
+ const {user: ydbUser} = state.authentication;
217
+
218
+ return {
219
+ ydbUser,
220
+ };
221
+ };
222
+
223
+ const mapDispatchToProps = {
224
+ logout,
225
+ setIsNotAuthenticated,
226
+ };
227
+
228
+ export default connect(mapStateToProps, mapDispatchToProps)(AsideNavigation);
@@ -0,0 +1,37 @@
1
+ .authentication {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+
6
+ height: 100%;
7
+
8
+ &__form-wrapper {
9
+ display: flex;
10
+ align-items: center;
11
+ flex-direction: column;
12
+ flex-shrink: 0;
13
+ justify-content: center;
14
+
15
+ width: 50%;
16
+ min-width: 320px;
17
+ height: 50%;
18
+ min-height: 170px;
19
+
20
+ border-radius: 5px;
21
+ background-color: var(--yc-color-base-info);
22
+ box-shadow: 0px 1px 5px var(--yc-color-sfx-shadow);
23
+ }
24
+
25
+ &__field-wrapper {
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: space-between;
29
+
30
+ width: 250px;
31
+ margin-bottom: 10px;
32
+
33
+ &:last-child {
34
+ margin-bottom: 16px;
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,89 @@
1
+ import {KeyboardEvent, useEffect, useState} from 'react';
2
+ import cn from 'bem-cn-lite';
3
+ import {connect} from 'react-redux';
4
+ import {Button, TextInput} from '@yandex-cloud/uikit';
5
+ //@ts-ignore
6
+ import {authenticate} from '../../store/reducers/authentication';
7
+
8
+ import './Authentication.scss';
9
+
10
+ const b = cn('authentication');
11
+
12
+ function Authentication({authenticate, error}: any) {
13
+ const [login, setLogin] = useState('');
14
+ const [pass, setPass] = useState('');
15
+ const [loginError, setLoginError] = useState('');
16
+ const [passwordError, setPasswordError] = useState('');
17
+
18
+ useEffect(() => {
19
+ if (error?.data?.error?.includes('user')) {
20
+ setLoginError(error.data.error);
21
+ }
22
+ if (error?.data?.error?.includes('password')) {
23
+ setPasswordError(error.data.error);
24
+ }
25
+ }, [error]);
26
+
27
+ const onLoginUpdate = (value: string) => {
28
+ setLogin(value);
29
+ setLoginError('');
30
+ };
31
+
32
+ const onPassUpdate = (value: string) => {
33
+ setPass(value);
34
+ setPasswordError('');
35
+ };
36
+
37
+ const onLoginClick = () => {
38
+ authenticate(login, pass);
39
+ };
40
+
41
+ const onEnterClick = (e: KeyboardEvent<HTMLInputElement>) => {
42
+ if (e.keyCode === 13) {
43
+ onLoginClick();
44
+ }
45
+ };
46
+
47
+ return (
48
+ <section className={b()}>
49
+ <div className={b('form-wrapper')}>
50
+ <h2>Please sign in:</h2>
51
+ <div className={b('field-wrapper')}>
52
+ <TextInput
53
+ value={login}
54
+ onUpdate={onLoginUpdate}
55
+ placeholder={'Username'}
56
+ error={loginError}
57
+ />
58
+ </div>
59
+ <div className={b('field-wrapper')}>
60
+ <TextInput
61
+ value={pass}
62
+ onUpdate={onPassUpdate}
63
+ type="password"
64
+ placeholder={'Password'}
65
+ error={passwordError}
66
+ onKeyDown={onEnterClick}
67
+ />
68
+ </div>
69
+ <div className={b('field-wrapper')}>
70
+ <Button view="action" onClick={onLoginClick} width="max">
71
+ Let me in!
72
+ </Button>
73
+ </div>
74
+ </div>
75
+ </section>
76
+ );
77
+ }
78
+
79
+ function mapStateToProps(state: any) {
80
+ return {
81
+ error: state.authentication.error,
82
+ };
83
+ }
84
+
85
+ const mapDispatchToProps = {
86
+ authenticate,
87
+ };
88
+
89
+ export default connect(mapStateToProps, mapDispatchToProps)(Authentication);
@@ -0,0 +1,168 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {connect} from 'react-redux';
4
+ import cn from 'bem-cn-lite';
5
+
6
+ import {getClusterInfo} from '../../store/reducers/cluster';
7
+ import {clusterName} from '../../store';
8
+ import {hideTooltip, showTooltip} from '../../store/reducers/tooltip';
9
+
10
+ import {Loader} from '@yandex-cloud/uikit';
11
+ import ClusterInfo from '../../components/ClusterInfo/ClusterInfo';
12
+ import Tenants from '../Tenants/Tenants';
13
+ import Nodes from '../Nodes/Nodes';
14
+ import Storage from '../StorageV2/Storage';
15
+
16
+ import './Cluster.scss';
17
+
18
+ const b = cn('cluster');
19
+
20
+ export const CLUSTER_PAGES = {
21
+ tenants: {id: 'tenants', name: 'Databases'},
22
+ nodes: {id: 'nodes', name: 'Nodes'},
23
+ storage: {id: 'storage', name: 'Storage'},
24
+ };
25
+
26
+ export class AutoFetcher {
27
+ constructor() {
28
+ this.timeout = AutoFetcher.DEFAULT_TIMEOUT;
29
+ this.active = true;
30
+ this.timer = undefined;
31
+ }
32
+ static DEFAULT_TIMEOUT = 30000;
33
+ static MIN_TIMEOUT = 30000;
34
+ wait(ms) {
35
+ return new Promise((resolve) => {
36
+ this.timer = setTimeout(resolve, ms);
37
+ return;
38
+ });
39
+ }
40
+ async fetch(request) {
41
+ if (!this.active) {
42
+ return;
43
+ }
44
+
45
+ await this.wait(this.timeout);
46
+
47
+ if (this.active) {
48
+ const startTs = Date.now();
49
+ await request();
50
+ const finishTs = Date.now();
51
+
52
+ const responseTime = finishTs - startTs;
53
+ const nextTimeout =
54
+ responseTime > AutoFetcher.MIN_TIMEOUT ? responseTime : AutoFetcher.MIN_TIMEOUT;
55
+ this.timeout = nextTimeout;
56
+
57
+ this.fetch(request);
58
+ } else {
59
+ return;
60
+ }
61
+ }
62
+ stop() {
63
+ clearTimeout(this.timer);
64
+ this.active = false;
65
+ }
66
+ start() {
67
+ this.active = true;
68
+ }
69
+ }
70
+
71
+ class Cluster extends React.Component {
72
+ static propTypes = {
73
+ activeTab: PropTypes.string,
74
+ getClusterInfo: PropTypes.func,
75
+ cluster: PropTypes.object,
76
+ error: PropTypes.object,
77
+ loading: PropTypes.bool,
78
+ wasLoaded: PropTypes.bool,
79
+ showTooltip: PropTypes.func,
80
+ hideTooltip: PropTypes.func,
81
+ additionalClusterInfo: PropTypes.array,
82
+ additionalTenantsInfo: PropTypes.object,
83
+ additionalNodesInfo: PropTypes.object,
84
+ };
85
+ componentDidMount() {
86
+ this.props.getClusterInfo(clusterName);
87
+ this.autofetcher = new AutoFetcher();
88
+ this.autofetcher.fetch(() => this.props.getClusterInfo(clusterName));
89
+ }
90
+ componentDidCatch(error, info) {
91
+ console.log(error);
92
+ console.log(info);
93
+ }
94
+ componentWillUnmount() {
95
+ this.autofetcher.stop();
96
+ }
97
+ renderLoader() {
98
+ return (
99
+ <div className="loader">
100
+ <Loader size="l" />
101
+ </div>
102
+ );
103
+ }
104
+ renderTabContent() {
105
+ const {activeTab} = this.props;
106
+ switch (activeTab) {
107
+ case CLUSTER_PAGES.tenants.id: {
108
+ return <Tenants {...this.props} />;
109
+ }
110
+ case CLUSTER_PAGES.nodes.id: {
111
+ return <Nodes {...this.props} />;
112
+ }
113
+ case CLUSTER_PAGES.storage.id: {
114
+ return <Storage {...this.props} />;
115
+ }
116
+ default: {
117
+ return null;
118
+ }
119
+ }
120
+ }
121
+ renderContent = () => {
122
+ const {cluster} = this.props;
123
+
124
+ return (
125
+ <div className={b()}>
126
+ <ClusterInfo
127
+ cluster={cluster}
128
+ showTooltip={this.props.showTooltip}
129
+ hideTooltip={this.props.hideTooltip}
130
+ additionalInfo={this.props.additionalClusterInfo}
131
+ />
132
+ {this.renderTabContent()}
133
+ </div>
134
+ );
135
+ };
136
+
137
+ render() {
138
+ const {error, loading, wasLoaded} = this.props;
139
+
140
+ if (loading && !wasLoaded) {
141
+ return this.renderLoader();
142
+ } else if (error) {
143
+ return <div>{error.statusText}</div>;
144
+ }
145
+ return this.renderContent();
146
+ }
147
+ }
148
+
149
+ const mapStateToProps = (state, ownProps) => {
150
+ const {data: cluster, loading, error, wasLoaded} = state.cluster;
151
+ const {activeTab = CLUSTER_PAGES.tenants.id} = ownProps.match.params;
152
+
153
+ return {
154
+ activeTab,
155
+ cluster,
156
+ loading,
157
+ wasLoaded,
158
+ error,
159
+ };
160
+ };
161
+
162
+ const mapDispatchToProps = {
163
+ getClusterInfo,
164
+ hideTooltip,
165
+ showTooltip,
166
+ };
167
+
168
+ export default connect(mapStateToProps, mapDispatchToProps)(Cluster);
@@ -0,0 +1,52 @@
1
+ @import '../../styles/mixins.scss';
2
+
3
+ .cluster {
4
+ @include flex-container();
5
+ padding: 0 20px;
6
+ overflow: auto;
7
+
8
+ &__tab {
9
+ text-decoration: none;
10
+
11
+ &:first-letter {
12
+ text-transform: uppercase;
13
+ }
14
+ }
15
+
16
+ &__format-label {
17
+ margin-right: 15px;
18
+ }
19
+
20
+ &__title {
21
+ text-align: center;
22
+ }
23
+
24
+ &__tooltip {
25
+ animation: none !important;
26
+ }
27
+
28
+ &__search {
29
+ width: 255px;
30
+ margin: 0 15px 0 0;
31
+ }
32
+
33
+ &__tablets {
34
+ padding: 0 !important;
35
+
36
+ .tablets-viewer__grid {
37
+ grid-template-columns: 125px;
38
+ }
39
+ }
40
+
41
+ &__controls {
42
+ display: flex;
43
+ justify-content: space-between;
44
+ margin: 17px 0;
45
+ }
46
+
47
+ &__table-wrapper {
48
+ display: flex;
49
+ flex-direction: column;
50
+ flex: 1 1 auto;
51
+ }
52
+ }
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cn from 'bem-cn-lite';
4
+ import {connect} from 'react-redux';
5
+ import {getGroupInfo, clearStore} from '../../store/reducers/group';
6
+ import FullGroupViewer from '../../components/FullGroupViewer/FullGroupViewer';
7
+ import {Loader} from '@yandex-cloud/uikit';
8
+ import {GROUP_AUTO_RELOAD_INTERVAL} from '../../utils/constants';
9
+ import './Group.scss';
10
+
11
+ const b = cn('group');
12
+
13
+ class Group extends React.Component {
14
+ static renderLoader() {
15
+ return (
16
+ <div className={'loader'}>
17
+ <Loader size="l" />
18
+ </div>
19
+ );
20
+ }
21
+
22
+ static propTypes = {
23
+ className: PropTypes.string,
24
+ loading: PropTypes.bool,
25
+ wasLoaded: PropTypes.bool,
26
+ error: PropTypes.bool,
27
+ getGroupInfo: PropTypes.func,
28
+ clearStore: PropTypes.func,
29
+ group: PropTypes.object,
30
+ location: PropTypes.object,
31
+ match: PropTypes.object,
32
+ };
33
+
34
+ static defaultProps = {
35
+ className: '',
36
+ };
37
+
38
+ componentDidMount() {
39
+ const {id} = this.props.match.params;
40
+ this.props.getGroupInfo(id);
41
+ this.reloadDescriptor = setInterval(
42
+ () => this.props.getGroupInfo(id),
43
+ GROUP_AUTO_RELOAD_INTERVAL,
44
+ );
45
+ }
46
+
47
+ componentWillUnmount() {
48
+ this.props.clearStore();
49
+ clearInterval(this.reloadDescriptor);
50
+ }
51
+
52
+ renderContent = () => {
53
+ const {className, group} = this.props;
54
+ return (
55
+ <div className={`${b()} ${className}`}>
56
+ <FullGroupViewer group={group} />
57
+ </div>
58
+ );
59
+ };
60
+
61
+ render() {
62
+ const {loading, wasLoaded, error, group} = this.props;
63
+
64
+ if (loading && !wasLoaded) {
65
+ return Group.renderLoader();
66
+ } else if (error) {
67
+ return <div>{error.statusText}</div>;
68
+ } else if (group) {
69
+ return this.renderContent();
70
+ } else {
71
+ return <div className="error">no data</div>;
72
+ }
73
+ }
74
+ }
75
+
76
+ const mapStateToProps = (state) => {
77
+ const {data, wasLoaded, loading, error} = state.group;
78
+
79
+ let group;
80
+ if (data) {
81
+ group = data.StoragePools[0].Groups[0];
82
+ }
83
+
84
+ return {
85
+ group,
86
+ wasLoaded,
87
+ loading,
88
+ error,
89
+ };
90
+ };
91
+
92
+ const mapDispatchToProps = {
93
+ getGroupInfo,
94
+ clearStore,
95
+ };
96
+
97
+ export default connect(mapStateToProps, mapDispatchToProps)(Group);
@@ -0,0 +1,6 @@
1
+ @import '../../styles/mixins';
2
+
3
+ .group {
4
+ @include flex-container();
5
+ overflow: auto;
6
+ }