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,388 @@
1
+ import React from 'react';
2
+ import block from 'bem-cn-lite';
3
+ import noop from 'lodash/noop';
4
+ import throttle from 'lodash/throttle';
5
+
6
+ import {Button, Icon} from '@yandex-cloud/uikit';
7
+
8
+ import {Drawer, DrawerItem} from './Drawer';
9
+ import {Logo, LogoProps} from './Logo/Logo';
10
+ import {CompositeBar} from './CompositeBar/CompositeBar';
11
+ import {AsideHeaderFooterItem} from './AsideHeaderFooterItem/AsideHeaderFooterItem';
12
+ import {Content, RenderContentType} from './Content/Content';
13
+ import {AsideHeaderMenuItem} from './types';
14
+ import {
15
+ ASIDE_HEADER_COLLAPSE_BUTTON_SIZE,
16
+ ASIDE_HEADER_COMPACT_WIDTH,
17
+ ASIDE_HEADER_EXPANDED_WIDTH,
18
+ AsideHeaderEvent,
19
+ AsideHeaderVisibleItem,
20
+ FooterItemIconView,
21
+ } from './constants';
22
+ import i18n from './i18n';
23
+ import {Lang} from 'utils/i18n';
24
+ import {getLocalData, setLocalData} from './helpers';
25
+ import {SetSlotsContext, SlotsProvider} from './AsideHeaderFooterSlot/SlotsContext';
26
+ import {SlotName} from './AsideHeaderFooterSlot/AsideHeaderFooterSlot';
27
+
28
+ import controlMenuButton from '../../assets/icons/control-menu-button.svg';
29
+
30
+ import './AsideHeader.scss';
31
+
32
+ const b = block('nv-aside-header');
33
+
34
+ export type {AsideHeaderMenuItem};
35
+
36
+ interface AsideHeaderGeneralProps
37
+ extends Pick<
38
+ LogoProps,
39
+ | 'onLogoIconClick'
40
+ | 'logoText'
41
+ | 'logoIcon'
42
+ | 'logoIconClassName'
43
+ | 'logoIconSize'
44
+ | 'logoTextSize'
45
+ | 'logoHref'
46
+ | 'logoWrapper'
47
+ > {
48
+ className?: string;
49
+ panelClassName?: string;
50
+ renderContent?: RenderContentType;
51
+ renderPanel?: () => React.ReactNode;
52
+ lang?: Lang;
53
+ renderFooter?: (data: {
54
+ size: number;
55
+ isCompact: boolean;
56
+ asideRef: React.RefObject<HTMLDivElement>;
57
+ }) => React.ReactNode;
58
+ onEvent?: (event: AsideHeaderEvent) => void;
59
+ settings?: React.ReactNode;
60
+ settingsIconWithBadge?: boolean;
61
+ onChangeCompact?: (compact: boolean) => void;
62
+ isCompact?: boolean;
63
+ initIsCompact?: boolean;
64
+ }
65
+
66
+ interface AsideHeaderDefaultProps {
67
+ menuItems: AsideHeaderMenuItem[];
68
+ panelVisible: boolean;
69
+ onClosePanel: () => void;
70
+ }
71
+
72
+ export interface AsideHeaderProps
73
+ extends AsideHeaderGeneralProps,
74
+ Partial<AsideHeaderDefaultProps> {}
75
+
76
+ type AsideHeaderInnerProps = AsideHeaderGeneralProps & AsideHeaderDefaultProps;
77
+
78
+ interface AsideHeaderState {
79
+ visibleItem: AsideHeaderVisibleItem | null;
80
+ isCompact: boolean;
81
+ isButtonVisible: boolean;
82
+ }
83
+
84
+ export {AsideHeaderFooterItem};
85
+
86
+ export {SlotName};
87
+
88
+ export class AsideHeader extends React.Component<AsideHeaderInnerProps, AsideHeaderState> {
89
+ static getDerivedStateFromProps(props: AsideHeaderInnerProps, state: AsideHeaderState) {
90
+ if (typeof props.isCompact !== 'undefined') {
91
+ const newState: Partial<AsideHeaderState> = {
92
+ isCompact: props.isCompact,
93
+ };
94
+ if ((!props.isCompact || !state.isCompact) && !state.isButtonVisible) {
95
+ newState.isButtonVisible = true;
96
+ }
97
+ return newState;
98
+ }
99
+ return null;
100
+ }
101
+
102
+ constructor(props: AsideHeaderInnerProps) {
103
+ super(props);
104
+
105
+ this.throttledPageMouseMove = throttle(this.onPageMouseMove, 300);
106
+
107
+ const isCompact =
108
+ typeof getLocalData()?.isCompact === 'boolean'
109
+ ? Boolean(getLocalData()?.isCompact)
110
+ : Boolean(props.initIsCompact);
111
+
112
+ this.state = {
113
+ visibleItem: null,
114
+ isCompact,
115
+ isButtonVisible: !isCompact,
116
+ };
117
+ }
118
+
119
+ componentDidUpdate(prevProps: AsideHeaderInnerProps, prevState: AsideHeaderState) {
120
+ if (!prevProps.panelVisible && this.props.panelVisible && this.state.visibleItem) {
121
+ this.setState({visibleItem: null});
122
+ }
123
+
124
+ if (
125
+ (prevState.visibleItem === AsideHeaderVisibleItem.Settings) !==
126
+ this.isVisibleItem(AsideHeaderVisibleItem.Settings)
127
+ ) {
128
+ this.props.onEvent?.(
129
+ this.isVisibleItem(AsideHeaderVisibleItem.Settings)
130
+ ? AsideHeaderEvent.SETTINGS_OPEN
131
+ : AsideHeaderEvent.SETTINGS_CLOSE,
132
+ );
133
+ }
134
+ }
135
+
136
+ render() {
137
+ const size = this.state.isCompact
138
+ ? ASIDE_HEADER_COMPACT_WIDTH
139
+ : ASIDE_HEADER_EXPANDED_WIDTH;
140
+
141
+ return (
142
+ <div className={b(null, this.props.className)}>
143
+ <div
144
+ className={b('pane-container')}
145
+ onMouseMove={(event) => {
146
+ if (!this.state.isCompact) {
147
+ return;
148
+ }
149
+ event.persist();
150
+ this.throttledPageMouseMove(event);
151
+ }}
152
+ >
153
+ {this.renderFirstPane(size)}
154
+ {this.renderSecondPane(size)}
155
+ </div>
156
+ </div>
157
+ );
158
+ }
159
+
160
+ static defaultProps: AsideHeaderDefaultProps = {
161
+ menuItems: [],
162
+ panelVisible: false,
163
+ onClosePanel: noop,
164
+ };
165
+
166
+ asideRef = React.createRef<HTMLDivElement>();
167
+
168
+ throttledPageMouseMove: (_event: React.MouseEvent<HTMLDivElement>) => void;
169
+
170
+ triggerEvent = (event: AsideHeaderEvent) => {
171
+ switch (event) {
172
+ case AsideHeaderEvent.SETTINGS_OPEN:
173
+ this.onSettingsToggle(true);
174
+ break;
175
+ }
176
+ };
177
+
178
+ private renderFirstPane = (size: number) => {
179
+ const {menuItems, panelVisible, renderPanel, panelClassName, settings} = this.props;
180
+ const {isCompact} = this.state;
181
+
182
+ return (
183
+ <SlotsProvider>
184
+ <div className={b('aside')} style={{width: size}}>
185
+ {this.renderCollapseButton()}
186
+ <div className={b('aside-popup-anchor')} ref={this.asideRef} />
187
+ <div className={b('aside-content')}>
188
+ <Logo
189
+ onLogoIconClick={this.props.onLogoIconClick}
190
+ logoWrapper={this.props.logoWrapper}
191
+ logoText={this.props.logoText}
192
+ logoIcon={this.props.logoIcon}
193
+ logoIconSize={this.props.logoIconSize}
194
+ logoTextSize={this.props.logoTextSize}
195
+ logoHref={this.props.logoHref}
196
+ logoIconClassName={this.props.logoIconClassName}
197
+ isCompact={isCompact}
198
+ />
199
+ <CompositeBar
200
+ items={menuItems}
201
+ isCompact={isCompact}
202
+ onClickItem={this.onCompositeBarClick}
203
+ />
204
+ {this.renderFooter(size)}
205
+ </div>
206
+ </div>
207
+ <Drawer
208
+ className={b('drawer')}
209
+ onVeilClick={this.onCloseDrawer}
210
+ onEscape={this.onCloseDrawer}
211
+ style={{left: size}}
212
+ >
213
+ <DrawerItem visible={panelVisible} className={b('panel', panelClassName)}>
214
+ {renderPanel?.()}
215
+ </DrawerItem>
216
+ <DrawerItem visible={this.isVisibleItem(AsideHeaderVisibleItem.Settings)}>
217
+ {settings}
218
+ </DrawerItem>
219
+ </Drawer>
220
+ </SlotsProvider>
221
+ );
222
+ };
223
+
224
+ private renderSecondPane = (size: number) => {
225
+ return (
226
+ <Content
227
+ size={size}
228
+ renderContent={this.props.renderContent}
229
+ className={b('content')}
230
+ />
231
+ );
232
+ };
233
+
234
+ private renderFooter = (size: number) => {
235
+ const {settings, settingsIconWithBadge} = this.props;
236
+ const {isCompact} = this.state;
237
+
238
+ return (
239
+ <SetSlotsContext.Consumer>
240
+ {(registerSlot) => {
241
+ if (!registerSlot) {
242
+ return null;
243
+ }
244
+ return (
245
+ <div className={b('footer')}>
246
+ {this.props.renderFooter?.({
247
+ size,
248
+ isCompact,
249
+ asideRef: this.asideRef,
250
+ })}
251
+ <div
252
+ ref={(node) => {
253
+ registerSlot(SlotName.Support, node);
254
+ }}
255
+ />
256
+ <div
257
+ ref={(node) => {
258
+ registerSlot(SlotName.BugReport, node);
259
+ }}
260
+ />
261
+ <div
262
+ ref={(node) => {
263
+ registerSlot(SlotName.Settings, node);
264
+ }}
265
+ >
266
+ {settings ? (
267
+ <AsideHeaderFooterItem
268
+ slot={SlotName.Settings}
269
+ view={
270
+ settingsIconWithBadge
271
+ ? FooterItemIconView.WithDot
272
+ : FooterItemIconView.Normal
273
+ }
274
+ text={i18n('switch_settings')}
275
+ isCompact={isCompact}
276
+ isCurrent={this.isVisibleItem(
277
+ AsideHeaderVisibleItem.Settings,
278
+ )}
279
+ onClick={() => this.onSettingsToggle()}
280
+ />
281
+ ) : null}
282
+ </div>
283
+ <div
284
+ ref={(node) => {
285
+ registerSlot(SlotName.User, node);
286
+ }}
287
+ />
288
+ </div>
289
+ );
290
+ }}
291
+ </SetSlotsContext.Consumer>
292
+ );
293
+ };
294
+
295
+ private renderCollapseButton = () => {
296
+ const {isCompact, isButtonVisible} = this.state;
297
+
298
+ const buttonVisibility = isButtonVisible ? 'visible' : 'hidden';
299
+
300
+ return (
301
+ <Button
302
+ className={b('collapse-button', {compact: isCompact})}
303
+ view="flat"
304
+ style={{visibility: buttonVisibility}}
305
+ onClick={this.onCollapseButtonClick}
306
+ >
307
+ <Icon
308
+ data={controlMenuButton}
309
+ className={b('collapse-icon')}
310
+ width="14"
311
+ height="14"
312
+ />
313
+ </Button>
314
+ );
315
+ };
316
+
317
+ private onCollapseButtonClick = () => {
318
+ const newIsCompact = !this.state.isCompact;
319
+
320
+ if (typeof this.props.isCompact === 'undefined') {
321
+ setLocalData({isCompact: newIsCompact});
322
+ this.setState({
323
+ isCompact: newIsCompact,
324
+ isButtonVisible: !newIsCompact,
325
+ });
326
+ } else {
327
+ this.setState({isButtonVisible: !newIsCompact});
328
+ }
329
+ if (this.props.onChangeCompact) {
330
+ this.props.onChangeCompact(newIsCompact);
331
+ }
332
+ };
333
+
334
+ private onCloseDrawer = () => {
335
+ this.setState({visibleItem: null});
336
+ this.props.onClosePanel?.();
337
+ };
338
+
339
+ private onSettingsToggle = (open?: boolean) => {
340
+ let visibleItem;
341
+
342
+ if (typeof open === 'undefined') {
343
+ visibleItem = this.getToggledVisibleItem(AsideHeaderVisibleItem.Settings);
344
+ } else {
345
+ visibleItem = open ? AsideHeaderVisibleItem.Settings : null;
346
+ }
347
+
348
+ this.setState({visibleItem});
349
+ if (this.props.panelVisible) {
350
+ this.props.onClosePanel?.();
351
+ }
352
+ };
353
+
354
+ private isVisibleItem = (item: AsideHeaderVisibleItem) => {
355
+ return item === this.state.visibleItem;
356
+ };
357
+
358
+ private getToggledVisibleItem = (item: AsideHeaderVisibleItem) => {
359
+ return !this.isVisibleItem(item) ? item : null;
360
+ };
361
+
362
+ private onPageMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {
363
+ const xPointerCoordinate = event.clientX;
364
+
365
+ const hoverArea = ASIDE_HEADER_COMPACT_WIDTH + ASIDE_HEADER_COLLAPSE_BUTTON_SIZE;
366
+
367
+ if (
368
+ !this.state.isButtonVisible &&
369
+ xPointerCoordinate <= hoverArea &&
370
+ xPointerCoordinate >= 0
371
+ ) {
372
+ this.setState({isButtonVisible: true});
373
+ return;
374
+ }
375
+
376
+ if (
377
+ this.state.isButtonVisible &&
378
+ (xPointerCoordinate > hoverArea || xPointerCoordinate < 0)
379
+ ) {
380
+ this.setState({isButtonVisible: false});
381
+ return;
382
+ }
383
+ };
384
+
385
+ private onCompositeBarClick = () => {
386
+ this.setState({visibleItem: null});
387
+ };
388
+ }
@@ -0,0 +1,82 @@
1
+ @mixin aside-header-popup-animation() {
2
+ &.popup2_theme_normal.popup2_direction_right-bottom.popup2_visible_yes {
3
+ /* stylelint-disable-next-line */
4
+ animation-name: popup2_theme_normal_bottom_visible;
5
+ }
6
+
7
+ &.popup2_theme_normal.popup2_direction_right-bottom {
8
+ /* stylelint-disable-next-line */
9
+ animation-name: popup2_theme_normal_bottom;
10
+ }
11
+ }
12
+
13
+ .nv-aside-header-footer-item {
14
+ $class: &;
15
+ display: flex;
16
+ overflow: hidden;
17
+ align-items: center;
18
+
19
+ width: 100%;
20
+ min-height: 40px;
21
+
22
+ &_current {
23
+ background-color: var(--yc-color-base-selection);
24
+ }
25
+
26
+ &:hover {
27
+ cursor: pointer;
28
+ }
29
+
30
+ &:not(&_current):hover {
31
+ background-color: var(--yc-color-base-simple-hover);
32
+ }
33
+
34
+ &__icon-place {
35
+ display: flex;
36
+ align-items: center;
37
+ flex-shrink: 0;
38
+ justify-content: center;
39
+
40
+ width: var(--nv-aside-header-min-width);
41
+ height: 100%;
42
+ }
43
+
44
+ &__text {
45
+ overflow: hidden;
46
+
47
+ width: 100%;
48
+
49
+ white-space: nowrap;
50
+ text-overflow: ellipsis;
51
+ }
52
+
53
+ &__icon-wrap {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+
58
+ width: 38px;
59
+ height: 38px;
60
+ }
61
+
62
+ #{$class} &__icon {
63
+ color: var(--yc-color-text-misc);
64
+ }
65
+
66
+ &__btn-icon {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+
71
+ width: 100%;
72
+ height: 100%;
73
+ }
74
+
75
+ &__popup {
76
+ @include aside-header-popup-animation();
77
+ }
78
+
79
+ @at-root .yc-list__item_active &:not(&_current) {
80
+ background-color: var(--yc-color-base-simple-hover);
81
+ }
82
+ }
@@ -0,0 +1,138 @@
1
+ import React from 'react';
2
+ import block from 'bem-cn-lite';
3
+ import {Icon, Popup, PopupPlacement, PopupProps} from '@yandex-cloud/uikit';
4
+
5
+ import {AsideHeaderTooltip} from '../AsideHeaderTooltip/AsideHeaderTooltip';
6
+ import {AsideHeaderFooterSlot, SlotName} from '../AsideHeaderFooterSlot/AsideHeaderFooterSlot';
7
+ import {ASIDE_HEADER_ICON_SIZE, FooterItemIconView} from '../constants';
8
+ import {footerItemIconMap, getFooterItemIcon} from '../icons';
9
+
10
+ import settingsIcon from '../../../assets/icons/settings.svg';
11
+
12
+ import './AsideHeaderFooterItem.scss';
13
+
14
+ const b = block('nv-aside-header-footer-item');
15
+
16
+ export const defaultAsideHeaderFooterPopupPlacement: PopupPlacement = ['right-end'];
17
+ export const defaultAsideHeaderFooterPopupOffset: NonNullable<PopupProps['offset']> = [-20, 8];
18
+
19
+ export interface AsideHeaderFooterItemProps {
20
+ onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
21
+ isCompact: boolean;
22
+ isCurrent?: boolean;
23
+ text: React.ReactNode;
24
+ tooltipText?: React.ReactNode;
25
+ enableTooltip?: boolean;
26
+ iconSize?: string | number;
27
+ slot?: SlotName;
28
+ view?: FooterItemIconView;
29
+ className?: string;
30
+ popupVisible?: boolean;
31
+ popupAnchor?: React.RefObject<HTMLElement>;
32
+ popupPlacement?: PopupPlacement;
33
+ popupOffset?: PopupProps['offset'];
34
+ renderPopupContent?: () => React.ReactNode;
35
+ onClosePopup?: () => void;
36
+ renderCustomIcon?: () => React.ReactNode;
37
+ }
38
+
39
+ export const AsideHeaderFooterItem: React.FC<AsideHeaderFooterItemProps> = ({
40
+ onClick,
41
+ isCompact,
42
+ isCurrent = false,
43
+ enableTooltip = true,
44
+ tooltipText,
45
+ text,
46
+ iconSize = ASIDE_HEADER_ICON_SIZE,
47
+ slot,
48
+ view,
49
+ className,
50
+ popupAnchor,
51
+ popupVisible = false,
52
+ popupPlacement = defaultAsideHeaderFooterPopupPlacement,
53
+ popupOffset = defaultAsideHeaderFooterPopupOffset,
54
+ onClosePopup,
55
+ renderPopupContent,
56
+ renderCustomIcon,
57
+ }) => {
58
+ const [tooltipAnchor, setTooltipAnchor] = React.useState<HTMLDivElement | null>(null);
59
+ const ref = React.useRef<HTMLDivElement>(null);
60
+
61
+ React.useEffect(() => {
62
+ if (!isCompact) {
63
+ setTooltipAnchor(null);
64
+ }
65
+ }, [isCompact]);
66
+
67
+ const icon = (slot && getFooterItemIcon(slot, view)) || settingsIcon;
68
+ let iconPlaceNode: React.ReactNode;
69
+
70
+ if (typeof renderCustomIcon === 'function') {
71
+ iconPlaceNode = renderCustomIcon();
72
+ } else {
73
+ const iconData = typeof icon === 'string' ? footerItemIconMap[icon as never] : icon;
74
+ iconPlaceNode = isCompact ? (
75
+ <React.Fragment>
76
+ <div
77
+ onMouseEnter={(event) => setTooltipAnchor(event.currentTarget)}
78
+ onMouseLeave={() => setTooltipAnchor(null)}
79
+ className={b('btn-icon', {current: isCurrent})}
80
+ >
81
+ <Icon data={iconData} size={iconSize} className={b('icon')} />
82
+ </div>
83
+ {enableTooltip && (
84
+ <AsideHeaderTooltip anchor={tooltipAnchor} text={tooltipText || text} />
85
+ )}
86
+ </React.Fragment>
87
+ ) : (
88
+ <div className={b('icon-wrap')}>
89
+ <Icon data={iconData} size={iconSize} className={b('icon')} />
90
+ </div>
91
+ );
92
+ }
93
+
94
+ const anchorRef = popupAnchor || ref;
95
+
96
+ const onClose = React.useCallback(
97
+ (event: MouseEvent | KeyboardEvent) => {
98
+ if (
99
+ event instanceof MouseEvent &&
100
+ event.target &&
101
+ ref.current?.contains(event.target as Node)
102
+ ) {
103
+ return;
104
+ }
105
+ onClosePopup?.();
106
+ },
107
+ [onClosePopup],
108
+ );
109
+
110
+ const contentNode = (
111
+ <React.Fragment>
112
+ <div
113
+ className={b({compact: isCompact, current: isCurrent}, className)}
114
+ onClick={onClick}
115
+ ref={ref}
116
+ >
117
+ <div className={b('icon-place')}>{iconPlaceNode}</div>
118
+ {!isCompact && <div className={b('text')}>{text}</div>}
119
+ </div>
120
+ <Popup
121
+ className={b('popup')}
122
+ open={popupVisible}
123
+ placement={popupPlacement}
124
+ offset={popupOffset}
125
+ anchorRef={anchorRef}
126
+ onClose={onClose}
127
+ >
128
+ {renderPopupContent?.()}
129
+ </Popup>
130
+ </React.Fragment>
131
+ );
132
+
133
+ return slot ? (
134
+ <AsideHeaderFooterSlot name={slot}>{contentNode}</AsideHeaderFooterSlot>
135
+ ) : (
136
+ contentNode
137
+ );
138
+ };
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import {useSlot} from './SlotsContext';
4
+
5
+ export enum SlotName {
6
+ Settings = 'settings',
7
+ User = 'user',
8
+ Support = 'support',
9
+ BugReport = 'bug-report',
10
+ }
11
+
12
+ interface AsideHeaderFooterSlotProps {
13
+ name: SlotName;
14
+ children: React.ReactNode;
15
+ slotRef?: React.Ref<HTMLElement>;
16
+ }
17
+
18
+ export function AsideHeaderFooterSlot({name, slotRef, children}: AsideHeaderFooterSlotProps) {
19
+ const slot = useSlot(name);
20
+
21
+ if (typeof slotRef === 'function') {
22
+ slotRef(slot || null);
23
+ } else if (slotRef) {
24
+ // @ts-ignore
25
+ slotRef.current = slot;
26
+ }
27
+
28
+ if (slot) {
29
+ return ReactDOM.createPortal(children, slot);
30
+ }
31
+
32
+ return null;
33
+ }
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import {SlotName} from './AsideHeaderFooterSlot';
3
+
4
+ type Slots = Partial<Record<SlotName, HTMLElement | null>>;
5
+
6
+ const SlotsContext = React.createContext<Slots | undefined>(undefined);
7
+ export const SetSlotsContext = React.createContext<
8
+ ((name: SlotName, node: HTMLElement | null) => void) | undefined
9
+ >(undefined);
10
+
11
+ export function SlotsProvider({children}: {children: React.ReactNode}) {
12
+ const [slots, setSlots] = React.useState<Slots>({});
13
+
14
+ const registerSlot = React.useCallback(
15
+ (name: SlotName, node: HTMLElement | null) => {
16
+ setSlots((prevSlots) => {
17
+ if (prevSlots[name] === node) {
18
+ return prevSlots;
19
+ }
20
+ return {
21
+ ...prevSlots,
22
+ [name]: node,
23
+ };
24
+ });
25
+ },
26
+ [setSlots],
27
+ );
28
+
29
+ return (
30
+ <SetSlotsContext.Provider value={registerSlot}>
31
+ <SlotsContext.Provider value={slots}>{children}</SlotsContext.Provider>
32
+ </SetSlotsContext.Provider>
33
+ );
34
+ }
35
+
36
+ function useSlotsValue() {
37
+ const slots = React.useContext(SlotsContext);
38
+
39
+ if (slots === undefined) {
40
+ throw new Error('useSlots must be used within a SlotsProvider');
41
+ }
42
+
43
+ return slots;
44
+ }
45
+
46
+ export function useSlot(name: SlotName) {
47
+ const slots = useSlotsValue();
48
+ return slots[name];
49
+ }
@@ -0,0 +1,16 @@
1
+ .nv-aside-header-tooltip {
2
+ &.yc-popup {
3
+ animation-name: none;
4
+
5
+ border: none;
6
+ box-shadow: none;
7
+ }
8
+
9
+ &__text {
10
+ padding: 6px 12px;
11
+
12
+ color: var(--yc-color-text-light-primary);
13
+ border-radius: 4px;
14
+ background-color: var(--yc-color-base-float-heavy);
15
+ }
16
+ }