ydb-embedded-ui 0.1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -3
  4. package/dist/assets/icons/cluster.svg +1 -0
  5. package/dist/assets/icons/hide.svg +1 -0
  6. package/dist/assets/icons/show.svg +1 -0
  7. package/dist/assets/icons/user-check.svg +1 -1
  8. package/dist/assets/icons/user-secret.svg +1 -1
  9. package/dist/components/AsideNavigation/AsideHeader.scss +1 -2
  10. package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.scss +7 -7
  11. package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.scss +2 -2
  12. package/dist/components/AsideNavigation/CompositeBar/CompositeBar.scss +6 -6
  13. package/dist/components/AsideNavigation/Drawer/Drawer.scss +5 -5
  14. package/dist/components/AsideNavigation/Logo/Logo.scss +3 -4
  15. package/dist/components/AsideNavigation/Settings/Settings.scss +27 -12
  16. package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.scss +14 -6
  17. package/dist/components/Breadcrumbs/Breadcrumbs.scss +2 -1
  18. package/dist/components/ClusterInfo/ClusterInfo.scss +19 -12
  19. package/dist/components/ClusterInfo/ClusterInfo.tsx +110 -10
  20. package/dist/components/CopyToClipboard/CopyToClipboard.tsx +39 -0
  21. package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +5 -4
  22. package/dist/components/Divider/Divider.scss +7 -0
  23. package/dist/components/Divider/Divider.tsx +11 -0
  24. package/dist/components/EmptyState/EmptyState.scss +14 -10
  25. package/dist/components/EnableFullscreenButton/EnableFullscreenButton.tsx +22 -0
  26. package/dist/components/EntityStatus/EntityStatus.js +5 -3
  27. package/dist/components/EntityStatus/EntityStatus.scss +35 -13
  28. package/dist/components/FullGroupViewer/FullGroupViewer.js +2 -4
  29. package/dist/components/FullGroupViewer/FullGroupViewer.scss +6 -3
  30. package/dist/components/FullNodeViewer/FullNodeViewer.scss +19 -11
  31. package/dist/components/Fullscreen/Fullscreen.scss +28 -0
  32. package/dist/components/Fullscreen/Fullscreen.tsx +81 -0
  33. package/dist/components/GroupTreeViewer/GroupTreeViewer.scss +1 -0
  34. package/dist/components/GroupViewer/GroupViewer.scss +8 -4
  35. package/dist/components/Icon/Icon.js +2 -0
  36. package/dist/components/InfoViewer/InfoViewer.scss +22 -16
  37. package/dist/components/NodesViewer/NodesViewer.js +25 -35
  38. package/dist/components/NodesViewer/NodesViewer.scss +15 -11
  39. package/dist/components/PDiskViewer/PDiskViewer.scss +10 -4
  40. package/dist/components/Pagination/Pagination.scss +6 -3
  41. package/dist/components/PoolBar/PoolBar.scss +14 -10
  42. package/dist/components/PoolUsage/PoolUsage.scss +17 -9
  43. package/dist/components/ProgressViewer/ProgressViewer.js +1 -1
  44. package/dist/components/ProgressViewer/ProgressViewer.scss +28 -18
  45. package/dist/components/QueryExecutionStatus/QueryExecutionStatus.scss +14 -0
  46. package/dist/components/QueryExecutionStatus/QueryExecutionStatus.tsx +29 -0
  47. package/dist/components/SplitPane/SplitPane.scss +33 -40
  48. package/dist/components/SplitPane/SplitPane.tsx +94 -0
  49. package/dist/components/Tablet/Tablet.scss +9 -6
  50. package/dist/components/TabletsOverall/TabletsOverall.scss +19 -0
  51. package/dist/components/TabletsOverall/TabletsOverall.tsx +105 -0
  52. package/dist/components/TabletsStatistic/TabletsStatistic.scss +24 -18
  53. package/dist/components/TabletsViewer/TabletsViewer.scss +12 -9
  54. package/dist/components/Tag/Tag.scss +6 -4
  55. package/dist/components/Tags/Tags.scss +1 -1
  56. package/dist/components/TreeView/TreeView.js +1 -1
  57. package/dist/components/TreeView/TreeView.scss +9 -0
  58. package/dist/components/TruncatedQuery/TruncatedQuery.scss +4 -3
  59. package/dist/containers/App/App.js +1 -0
  60. package/dist/containers/App/App.scss +50 -31
  61. package/dist/containers/App/Content.js +2 -2
  62. package/dist/containers/App/NodesTable.scss +25 -0
  63. package/dist/containers/App/TipPopup/TipPopup.scss +10 -6
  64. package/dist/containers/AppIcons/AppIcons.js +46 -22
  65. package/dist/containers/AsideNavigation/AsideNavigation.scss +1 -1
  66. package/dist/containers/AsideNavigation/AsideNavigation.tsx +12 -5
  67. package/dist/containers/Authentication/Authentication.scss +63 -14
  68. package/dist/containers/Authentication/Authentication.tsx +42 -9
  69. package/dist/containers/Cluster/Cluster.scss +5 -3
  70. package/dist/containers/Cluster/Cluster.tsx +49 -0
  71. package/dist/containers/Group/Group.scss +1 -1
  72. package/dist/containers/Header/Header.scss +15 -59
  73. package/dist/containers/Header/Header.tsx +75 -0
  74. package/dist/containers/Header/Host/Host.scss +10 -3
  75. package/dist/containers/Heatmap/Heatmap.js +1 -1
  76. package/dist/containers/Heatmap/Heatmap.scss +16 -7
  77. package/dist/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js +3 -3
  78. package/dist/containers/Heatmap/Histogram/Histogram.scss +21 -9
  79. package/dist/containers/Node/Node.js +1 -1
  80. package/dist/containers/Node/Node.scss +6 -4
  81. package/dist/containers/Nodes/Nodes.js +28 -27
  82. package/dist/containers/Nodes/Nodes.scss +5 -17
  83. package/dist/containers/Pdisk/Pdisk.scss +6 -4
  84. package/dist/containers/Pool/Pool.scss +7 -4
  85. package/dist/containers/ReduxTooltip/ReduxTooltip.scss +5 -1
  86. package/dist/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.scss +77 -0
  87. package/dist/containers/{StorageV2 → Storage}/DiskStateProgressBar/DiskStateProgressBar.tsx +1 -1
  88. package/dist/containers/{StorageV2 → Storage}/Pdisk/Pdisk.scss +6 -4
  89. package/dist/containers/{StorageV2 → Storage}/Pdisk/Pdisk.tsx +1 -2
  90. package/dist/containers/{StorageV2 → Storage}/Storage.js +72 -34
  91. package/dist/containers/{StorageV2 → Storage}/Storage.scss +12 -14
  92. package/dist/containers/{StorageV2 → Storage}/StorageFilter/StorageFilter.js +1 -9
  93. package/dist/containers/{StorageV2 → Storage}/StorageGroups/StorageGroups.scss +2 -0
  94. package/dist/containers/{StorageV2 → Storage}/StorageGroups/StorageGroups.tsx +1 -1
  95. package/dist/containers/{StorageV2 → Storage}/StorageNodes/StorageNodes.scss +2 -0
  96. package/dist/containers/{StorageV2 → Storage}/StorageNodes/StorageNodes.tsx +1 -1
  97. package/dist/containers/{StorageV2 → Storage}/Vdisk/Vdisk.js +0 -0
  98. package/dist/containers/{StorageV2 → Storage}/Vdisk/Vdisk.scss +6 -4
  99. package/dist/containers/Tablet/Tablet.scss +13 -9
  100. package/dist/containers/Tablets/Tablets.js +21 -90
  101. package/dist/containers/Tablets/Tablets.scss +9 -35
  102. package/dist/containers/TabletsFilters/TabletsFilters.js +2 -75
  103. package/dist/containers/TabletsFilters/TabletsFilters.scss +15 -35
  104. package/dist/containers/Tenant/Acl/Acl.js +54 -47
  105. package/dist/containers/Tenant/Acl/Acl.scss +15 -4
  106. package/dist/containers/Tenant/{Compute → Diagnostics/Compute}/Compute.js +35 -12
  107. package/dist/containers/Tenant/Diagnostics/Compute/Compute.scss +14 -0
  108. package/dist/containers/Tenant/{Describe → Diagnostics/Describe}/Describe.js +50 -1
  109. package/dist/containers/Tenant/{Describe → Diagnostics/Describe}/Describe.scss +5 -3
  110. package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.scss +27 -0
  111. package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.tsx +88 -0
  112. package/dist/containers/Tenant/Diagnostics/Diagnostics.scss +50 -0
  113. package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +208 -0
  114. package/dist/containers/Tenant/Diagnostics/DiagnosticsPages.ts +75 -0
  115. package/dist/containers/Tenant/Diagnostics/Healthcheck/Healthcheck.js +191 -0
  116. package/dist/containers/Tenant/Diagnostics/Healthcheck/Healthcheck.scss +79 -0
  117. package/dist/containers/Tenant/{Healthcheck → Diagnostics/Healthcheck}/IssuesViewer/IssueViewer.scss +25 -13
  118. package/dist/containers/Tenant/{Healthcheck → Diagnostics/Healthcheck}/IssuesViewer/IssuesViewer.js +2 -2
  119. package/dist/containers/Tenant/{Schema → Diagnostics}/HotKeys/HotKeys.js +14 -8
  120. package/dist/containers/Tenant/{Schema → Diagnostics}/HotKeys/HotKeys.scss +7 -5
  121. package/dist/containers/Tenant/{Network → Diagnostics/Network}/Network.js +39 -9
  122. package/dist/containers/Tenant/{Network → Diagnostics/Network}/Network.scss +35 -36
  123. package/dist/containers/Tenant/{Network → Diagnostics/Network}/NodeNetwork/NodeNetwork.js +0 -0
  124. package/dist/containers/Tenant/{Network → Diagnostics/Network}/NodeNetwork/NodeNetwork.scss +11 -9
  125. package/dist/containers/Tenant/Diagnostics/Overview/Overview.scss +13 -0
  126. package/dist/containers/Tenant/Diagnostics/Overview/Overview.tsx +123 -0
  127. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +200 -0
  128. package/dist/{components → containers/Tenant/Diagnostics}/TenantOverview/TenantOverview.scss +24 -17
  129. package/dist/containers/Tenant/{TopQueries → Diagnostics/TopQueries}/TopQueries.js +32 -30
  130. package/dist/containers/Tenant/{TopQueries → Diagnostics/TopQueries}/TopQueries.scss +10 -9
  131. package/dist/containers/Tenant/{TopShards → Diagnostics/TopShards}/TopShards.js +25 -29
  132. package/dist/containers/Tenant/{TopShards → Diagnostics/TopShards}/TopShards.scss +1 -13
  133. package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.scss +38 -0
  134. package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.tsx +104 -0
  135. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.scss +175 -0
  136. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +319 -0
  137. package/dist/containers/Tenant/Preview/Preview.js +50 -12
  138. package/dist/containers/Tenant/Preview/Preview.scss +45 -3
  139. package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.scss +85 -0
  140. package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.tsx +95 -0
  141. package/dist/containers/Tenant/QueryEditor/QueryEditor.js +319 -268
  142. package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +47 -18
  143. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +190 -75
  144. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.scss +47 -11
  145. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +89 -20
  146. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.scss +60 -6
  147. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +10 -23
  148. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss +15 -7
  149. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.js +7 -3
  150. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.scss +28 -17
  151. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +7 -7
  152. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss +1 -11
  153. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.js +37 -17
  154. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.scss +33 -12
  155. package/dist/containers/Tenant/Schema/SchemaNodeActions/SchemaNodeActions.scss +17 -0
  156. package/dist/containers/Tenant/Schema/SchemaNodeActions/SchemaNodeActions.tsx +125 -0
  157. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.js +5 -4
  158. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.scss +6 -2
  159. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +53 -34
  160. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.scss +1 -22
  161. package/dist/containers/Tenant/Tenant.scss +3 -32
  162. package/dist/containers/Tenant/Tenant.tsx +161 -0
  163. package/dist/containers/Tenant/TenantPages.tsx +48 -0
  164. package/dist/containers/Tenant/utils/ToggleButton.scss +26 -0
  165. package/dist/containers/Tenant/utils/paneVisibilityToggleHelpers.tsx +126 -0
  166. package/dist/containers/Tenants/Tenants.js +41 -55
  167. package/dist/containers/Tenants/Tenants.scss +4 -17
  168. package/dist/containers/UserSettings/UserSettings.tsx +0 -2
  169. package/dist/containers/Vdisk/Vdisk.scss +6 -4
  170. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.js +1 -1
  171. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.scss +5 -5
  172. package/dist/{routes.js → routes.ts} +14 -4
  173. package/dist/store/reducers/clusterNodes.js +1 -1
  174. package/dist/store/reducers/executeQuery.js +36 -2
  175. package/dist/store/reducers/fullscreen.ts +31 -0
  176. package/dist/store/reducers/header.ts +23 -0
  177. package/dist/store/reducers/hotKeys.js +1 -1
  178. package/dist/store/reducers/index.js +6 -0
  179. package/dist/store/reducers/saveQuery.ts +33 -0
  180. package/dist/store/reducers/schema.js +14 -0
  181. package/dist/store/reducers/shardsWorkload.js +1 -1
  182. package/dist/store/state-url-mapping.js +1 -1
  183. package/dist/store/utils.js +2 -6
  184. package/dist/styles/mixins.scss +49 -34
  185. package/dist/utils/autofetcher.ts +51 -0
  186. package/dist/utils/constants.js +26 -7
  187. package/dist/utils/createToast.tsx +23 -0
  188. package/dist/utils/getNodesColumns.js +25 -28
  189. package/dist/utils/index.js +6 -2
  190. package/package.json +8 -4
  191. package/dist/components/SplitPane/SplitPane.js +0 -368
  192. package/dist/components/TenantOverview/TenantOverview.js +0 -148
  193. package/dist/containers/Cluster/Cluster.js +0 -168
  194. package/dist/containers/Header/Header.js +0 -88
  195. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +0 -81
  196. package/dist/containers/Tenant/Compute/Compute.scss +0 -6
  197. package/dist/containers/Tenant/Healthcheck/Healthcheck.js +0 -116
  198. package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +0 -64
  199. package/dist/containers/Tenant/Schema/Info/Info.js +0 -84
  200. package/dist/containers/Tenant/Schema/Info/Info.scss +0 -3
  201. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +0 -439
  202. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +0 -90
  203. package/dist/containers/Tenant/Schema/SchemaPages.js +0 -56
  204. package/dist/containers/Tenant/Tenant.js +0 -199
  205. package/dist/containers/Tenant/TenantPages.js +0 -35
@@ -0,0 +1,104 @@
1
+ import {Link} from 'react-router-dom';
2
+ import cn from 'bem-cn-lite';
3
+ import {useLocation} from 'react-router';
4
+ import qs from 'qs';
5
+ import _ from 'lodash';
6
+
7
+ import {Tabs, useThemeValue} from '@yandex-cloud/uikit';
8
+ //@ts-ignore
9
+ import QueryEditor from '../QueryEditor/QueryEditor';
10
+ import Diagnostics from '../Diagnostics/Diagnostics';
11
+
12
+ import {TenantGeneralTabsIds, TenantTabsGroups, TENANT_GENERAL_TABS} from '../TenantPages';
13
+ import routes, {createHref} from '../../../routes';
14
+
15
+ import './ObjectGeneral.scss';
16
+
17
+ const b = cn('object-general');
18
+
19
+ interface ObjectGeneralProps {
20
+ type: string;
21
+ additionalTenantInfo?: any;
22
+ additionalNodesInfo?: any;
23
+ }
24
+
25
+ function ObjectGeneral(props: ObjectGeneralProps) {
26
+ const location = useLocation();
27
+
28
+ const theme = useThemeValue();
29
+
30
+ const queryParams = qs.parse(location.search, {
31
+ ignoreQueryPrefix: true,
32
+ });
33
+
34
+ const {name: tenantName, general: generalTab} = queryParams;
35
+
36
+ const renderTabs = () => {
37
+ const pages = TENANT_GENERAL_TABS.map((page) => {
38
+ return {
39
+ ...page,
40
+ title: (
41
+ <div className={b('tab-label')}>
42
+ {page.icon}
43
+ {page.title}
44
+ </div>
45
+ ),
46
+ };
47
+ });
48
+ return (
49
+ <div className={b('tabs')}>
50
+ <Tabs
51
+ items={pages}
52
+ activeTab={generalTab as string}
53
+ wrapTo={({id}, node) => {
54
+ const path = createHref(routes.tenant, undefined, {
55
+ ...queryParams,
56
+ name: tenantName as string,
57
+ [TenantTabsGroups.general]: id,
58
+ });
59
+ return (
60
+ <Link to={path} key={id} className={b('tab')}>
61
+ {node}
62
+ </Link>
63
+ );
64
+ }}
65
+ allowNotSelected
66
+ />
67
+ </div>
68
+ );
69
+ };
70
+
71
+ const renderTabContent = () => {
72
+ const {type, additionalTenantInfo, additionalNodesInfo} = props;
73
+ switch (generalTab) {
74
+ case TenantGeneralTabsIds.query: {
75
+ return <QueryEditor path={tenantName as string} theme={theme} type={type} />;
76
+ }
77
+ default: {
78
+ return (
79
+ <Diagnostics
80
+ type={type}
81
+ additionalTenantInfo={additionalTenantInfo}
82
+ additionalNodesInfo={additionalNodesInfo}
83
+ />
84
+ );
85
+ }
86
+ }
87
+ };
88
+
89
+ const renderContent = () => {
90
+ if (!tenantName) {
91
+ return null;
92
+ }
93
+ return (
94
+ <div className={b()}>
95
+ {renderTabs()}
96
+ {renderTabContent()}
97
+ </div>
98
+ );
99
+ };
100
+
101
+ return renderContent();
102
+ }
103
+
104
+ export default ObjectGeneral;
@@ -0,0 +1,175 @@
1
+ @import '../../../styles/mixins.scss';
2
+
3
+ .object-summary {
4
+ position: relative;
5
+
6
+ display: flex;
7
+ overflow: hidden;
8
+ flex-grow: 1;
9
+ flex-direction: column;
10
+
11
+ width: 100%;
12
+ height: 100%;
13
+ max-height: 100%;
14
+
15
+ &__overview-wrapper {
16
+ display: flex;
17
+ overflow: auto;
18
+ flex-grow: 1;
19
+
20
+ padding: 0 12px 16px;
21
+ }
22
+
23
+ &_hidden {
24
+ visibility: hidden;
25
+ }
26
+
27
+ &__action-button {
28
+ position: absolute;
29
+ top: 12px;
30
+ right: 4px;
31
+
32
+ background-color: var(--yc-color-base-background);
33
+ &_hidden {
34
+ visibility: hidden;
35
+ }
36
+ }
37
+
38
+ &__loader {
39
+ display: flex;
40
+ justify-content: center;
41
+ align-items: center;
42
+ }
43
+
44
+ &__tree {
45
+ display: flex;
46
+ overflow: scroll;
47
+ flex: 0 0 auto;
48
+ flex-direction: column;
49
+
50
+ height: 100%;
51
+ padding: 0 12px 12px;
52
+
53
+ .tree-view_item {
54
+ margin: 0;
55
+ padding: 2px 0;
56
+ }
57
+
58
+ & > div > .tree-view {
59
+ padding-bottom: 15px;
60
+ }
61
+ }
62
+
63
+ &__tree-header {
64
+ display: flex;
65
+ justify-content: space-between;
66
+ align-items: center;
67
+
68
+ padding: 12px 12px 8px;
69
+ @include sticky-top();
70
+ }
71
+
72
+ &__tree-title {
73
+ font-weight: 600;
74
+ }
75
+
76
+ &__sticky-top {
77
+ z-index: 5;
78
+ @include sticky-top();
79
+ }
80
+
81
+ &__tabs {
82
+ padding: 8px 12px 16px;
83
+ }
84
+
85
+ &__tab {
86
+ margin-right: 40px;
87
+
88
+ text-decoration: none;
89
+
90
+ &:first-letter {
91
+ text-transform: uppercase;
92
+ }
93
+ }
94
+
95
+ &__info {
96
+ display: flex;
97
+ overflow: hidden;
98
+ flex-direction: column;
99
+ }
100
+
101
+ &__schema {
102
+ display: flex;
103
+ overflow: auto;
104
+ flex-grow: 1;
105
+ }
106
+
107
+ &__info-controls {
108
+ display: flex;
109
+ gap: 4px;
110
+ }
111
+
112
+ &__info-action-button {
113
+ background-color: var(--yc-color-base-background);
114
+ &_hidden {
115
+ display: none;
116
+ }
117
+ }
118
+
119
+ &__rotated90 {
120
+ transform: rotate(-90deg);
121
+ }
122
+ &__rotated180 {
123
+ transform: rotate(180deg);
124
+ }
125
+ &__rotated270 {
126
+ transform: rotate(90deg);
127
+ }
128
+
129
+ &__info-header {
130
+ display: flex;
131
+ justify-content: space-between;
132
+ align-items: center;
133
+
134
+ padding: 12px 12px 10px;
135
+
136
+ border-bottom: 1px solid var(--yc-color-line-generic);
137
+ }
138
+
139
+ &__info-title {
140
+ display: flex;
141
+ overflow: hidden;
142
+ align-items: center;
143
+
144
+ font-weight: 600;
145
+ }
146
+
147
+ &__path-name {
148
+ overflow: hidden;
149
+
150
+ text-overflow: ellipsis;
151
+ }
152
+
153
+ &__entity-type {
154
+ display: inline-block;
155
+
156
+ margin-right: 5px;
157
+ padding: 3px 8px;
158
+
159
+ font-weight: 400;
160
+ text-transform: lowercase;
161
+
162
+ border-radius: 3px;
163
+ background-color: var(--yc-color-base-generic);
164
+
165
+ &_error {
166
+ padding: 3px 0;
167
+
168
+ background-color: transparent;
169
+ }
170
+ }
171
+
172
+ .yc-button__text {
173
+ margin: 0 6px;
174
+ }
175
+ }
@@ -0,0 +1,319 @@
1
+ import React, {useEffect, useReducer} from 'react';
2
+ import {useDispatch, useSelector} from 'react-redux';
3
+ import {Link} from 'react-router-dom';
4
+ import cn from 'bem-cn-lite';
5
+ import {useHistory, useLocation} from 'react-router';
6
+ import qs from 'qs';
7
+ import _ from 'lodash';
8
+
9
+ import {Button, HelpTooltip, Loader, Tabs} from '@yandex-cloud/uikit';
10
+ //@ts-ignore
11
+ import SplitPane from '../../../components/SplitPane';
12
+ //@ts-ignore
13
+ import SchemaNode from '../Schema/SchemaNode/SchemaNode';
14
+ //@ts-ignore
15
+ import Acl from '../Acl/Acl';
16
+ //@ts-ignore
17
+ import SchemaViewer from '../Schema/SchemaViewer/SchemaViewer';
18
+ import CopyToClipboard from '../../../components/CopyToClipboard/CopyToClipboard';
19
+ //@ts-ignore
20
+ import InfoViewer from '../../../components/InfoViewer/InfoViewer';
21
+ //@ts-ignore
22
+ import Icon from '../../../components/Icon/Icon';
23
+
24
+ import {OLAP_TABLE_TYPE, TABLE_TYPE} from '../Tenant';
25
+
26
+ import {
27
+ DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED,
28
+ DEFAULT_SIZE_TENANT_SUMMARY_KEY,
29
+ //@ts-ignore
30
+ } from '../../../utils/constants';
31
+ import {
32
+ TenantGeneralTabsIds,
33
+ TenantInfoTabsIds,
34
+ TenantTabsGroups,
35
+ TENANT_INFO_TABS,
36
+ TENANT_SCHEMA_TAB,
37
+ } from '../TenantPages';
38
+ import routes, {createHref} from '../../../routes';
39
+ import {
40
+ PaneVisibilityActionTypes,
41
+ paneVisibilityToggleReducerCreator,
42
+ PaneVisibilityToggleButtons,
43
+ } from '../utils/paneVisibilityToggleHelpers';
44
+ //@ts-ignore
45
+ import {setShowPreview} from '../../../store/reducers/schema';
46
+
47
+ import './ObjectSummary.scss';
48
+ const b = cn('object-summary');
49
+
50
+ const getInitialIsSummaryCollapsed = () => {
51
+ return Boolean(localStorage.getItem(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED));
52
+ };
53
+
54
+ const initialTenantCommonInfoState = {
55
+ triggerExpand: false,
56
+ triggerCollapse: false,
57
+ collapsed: getInitialIsSummaryCollapsed(),
58
+ };
59
+
60
+ function prepareOlapTableSchema(tableSchema: any) {
61
+ const {Name, Schema = {}} = tableSchema;
62
+ const {Columns, KeyColumnNames} = Schema;
63
+ const KeyColumnIds = KeyColumnNames?.map((name: string) => {
64
+ const column = Columns?.find((el: any) => el.Name === name);
65
+ return column.Id;
66
+ });
67
+
68
+ return {
69
+ Columns,
70
+ KeyColumnNames,
71
+ Name,
72
+ KeyColumnIds,
73
+ };
74
+ }
75
+
76
+ interface ObjectSummaryProps {
77
+ type: string;
78
+ onCollapseSummary: VoidFunction;
79
+ onExpandSummary: VoidFunction;
80
+ isCollapsed: boolean;
81
+ additionalTenantInfo?: any;
82
+ }
83
+
84
+ function ObjectSummary(props: ObjectSummaryProps) {
85
+ const dispatch = useDispatch();
86
+ const [commonInfoVisibilityState, dispatchCommonInfoVisibilityState] = useReducer(
87
+ paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED),
88
+ initialTenantCommonInfoState,
89
+ );
90
+ const {
91
+ data,
92
+ currentSchemaPath,
93
+ currentSchema: currentItem = {},
94
+ loading: loadingSchema,
95
+ } = useSelector((state: any) => state.schema);
96
+
97
+ const location = useLocation();
98
+
99
+ const history = useHistory();
100
+
101
+ const queryParams = qs.parse(location.search, {
102
+ ignoreQueryPrefix: true,
103
+ });
104
+
105
+ const {name: tenantName, info: infoTab} = queryParams;
106
+ const tenantData = _.get(data[tenantName as string], 'PathDescription.Self');
107
+ const currentSchemaData = _.get(data[currentSchemaPath], 'PathDescription.Self');
108
+
109
+ const tableSchema =
110
+ currentItem?.PathDescription?.Table || currentItem?.PathDescription?.OlapTableDescription;
111
+
112
+ const schema =
113
+ props.type === OLAP_TABLE_TYPE ? prepareOlapTableSchema(tableSchema) : tableSchema;
114
+
115
+ useEffect(() => {
116
+ const {type} = props;
117
+ const isTable = type === TABLE_TYPE || type === OLAP_TABLE_TYPE;
118
+
119
+ if (type && !isTable && !TENANT_INFO_TABS.find((el) => el.id === infoTab)) {
120
+ history.push({
121
+ pathname: location.pathname,
122
+ search: qs.stringify({...queryParams, info: TenantInfoTabsIds.overview}),
123
+ });
124
+ }
125
+ }, [props.type]);
126
+
127
+ const renderTabs = () => {
128
+ const {type} = props;
129
+ const isTable = type === TABLE_TYPE || type === OLAP_TABLE_TYPE;
130
+ const tabsItems = isTable ? [...TENANT_INFO_TABS, ...TENANT_SCHEMA_TAB] : TENANT_INFO_TABS;
131
+
132
+ return (
133
+ <div className={b('tabs')}>
134
+ <Tabs
135
+ items={tabsItems}
136
+ activeTab={infoTab as string}
137
+ wrapTo={({id}, node) => {
138
+ const path = createHref(routes.tenant, undefined, {
139
+ ...queryParams,
140
+ name: tenantName as string,
141
+ [TenantTabsGroups.info]: id,
142
+ });
143
+ return (
144
+ <Link to={path} key={id} className={b('tab')}>
145
+ {node}
146
+ </Link>
147
+ );
148
+ }}
149
+ allowNotSelected
150
+ />
151
+ </div>
152
+ );
153
+ };
154
+
155
+ const renderObjectOverview = () => {
156
+ const startTimeInMilliseconds = currentSchemaData?.CreateStep / 1000;
157
+ let createTime = 'Unknown';
158
+ if (startTimeInMilliseconds) {
159
+ createTime = new Date(startTimeInMilliseconds).toUTCString();
160
+ }
161
+ return (
162
+ <div className={b('overview-wrapper')}>
163
+ <InfoViewer info={[{label: 'Create time', value: createTime}]} />
164
+ </div>
165
+ );
166
+ };
167
+
168
+ const renderTabContent = () => {
169
+ switch (infoTab) {
170
+ case TenantInfoTabsIds.acl: {
171
+ return <Acl additionalTenantInfo={props.additionalTenantInfo} />;
172
+ }
173
+ case TenantInfoTabsIds.schema: {
174
+ return loadingSchema ? (
175
+ renderLoader()
176
+ ) : (
177
+ <div className={b('schema')}>
178
+ <SchemaViewer data={schema} />
179
+ </div>
180
+ );
181
+ }
182
+ default: {
183
+ return renderObjectOverview();
184
+ }
185
+ }
186
+ };
187
+
188
+ const renderLoader = () => {
189
+ return (
190
+ <div className={b('loader')}>
191
+ <Loader size="m" />
192
+ </div>
193
+ );
194
+ };
195
+
196
+ const renderTree = () => {
197
+ return (
198
+ <div>
199
+ <div className={b('tree-header')}>
200
+ <div className={b('tree-title')}>Navigation</div>
201
+ </div>
202
+ <div className={b('tree')}>
203
+ {tenantData && (
204
+ <SchemaNode fullPath={tenantName as string} data={tenantData} isRoot />
205
+ )}
206
+ </div>
207
+ </div>
208
+ );
209
+ };
210
+
211
+ const onCollapseInfoHandler = () => {
212
+ dispatchCommonInfoVisibilityState(PaneVisibilityActionTypes.triggerCollapse);
213
+ };
214
+ const onExpandInfoHandler = () => {
215
+ dispatchCommonInfoVisibilityState(PaneVisibilityActionTypes.triggerExpand);
216
+ };
217
+
218
+ const onSplitStartDrugAdditional = () => {
219
+ dispatchCommonInfoVisibilityState(PaneVisibilityActionTypes.clear);
220
+ };
221
+
222
+ const onOpenPreview = () => {
223
+ dispatch(setShowPreview(true));
224
+ history.push(
225
+ createHref(routes.tenant, undefined, {
226
+ ...queryParams,
227
+ [TenantTabsGroups.general]: TenantGeneralTabsIds.query,
228
+ }),
229
+ );
230
+ };
231
+
232
+ const renderCommonInfoControls = () => {
233
+ const {type} = props;
234
+ const isTable = type === TABLE_TYPE || type === OLAP_TABLE_TYPE;
235
+ return (
236
+ <React.Fragment>
237
+ {isTable && (
238
+ <Button view="flat-secondary" onClick={onOpenPreview} title="Show preview">
239
+ <Icon name="tablePreview" viewBox={'0 0 16 16'} height={16} width={16} />
240
+ </Button>
241
+ )}
242
+ <CopyToClipboard text={currentSchemaPath} title="Copy schema path" />
243
+ <PaneVisibilityToggleButtons
244
+ onCollapse={onCollapseInfoHandler}
245
+ onExpand={onExpandInfoHandler}
246
+ isCollapsed={commonInfoVisibilityState.collapsed}
247
+ initialDirection="bottom"
248
+ />
249
+ </React.Fragment>
250
+ );
251
+ };
252
+
253
+ const renderEntityTypeBadge = () => {
254
+ const {type} = props;
255
+ const {Status, Reason} = currentItem;
256
+
257
+ let message;
258
+ if (!type && Status && Reason) {
259
+ message = `${Status}: ${Reason}`;
260
+ }
261
+
262
+ return props.type ? (
263
+ <div className={b('entity-type')}>{type}</div>
264
+ ) : (
265
+ <div className={b('entity-type', {error: true})}>
266
+ <HelpTooltip content={message} offset={{left: 0}} />
267
+ </div>
268
+ );
269
+ };
270
+
271
+ const renderContent = () => {
272
+ if (!tenantName) {
273
+ return null;
274
+ }
275
+ return (
276
+ <div className={b()}>
277
+ <div className={b({hidden: props.isCollapsed})}>
278
+ <SplitPane
279
+ direction="vertical"
280
+ defaultSizePaneKey={DEFAULT_SIZE_TENANT_SUMMARY_KEY}
281
+ onSplitStartDrugAdditional={onSplitStartDrugAdditional}
282
+ triggerCollapse={commonInfoVisibilityState.triggerCollapse}
283
+ triggerExpand={commonInfoVisibilityState.triggerExpand}
284
+ minSize={[200, 52]}
285
+ collapsedSizes={[100, 0]}
286
+ >
287
+ {currentSchemaPath ? renderTree() : renderLoader()}
288
+ <div className={b('info')}>
289
+ <div className={b('sticky-top')}>
290
+ <div className={b('info-header')}>
291
+ <div className={b('info-title')}>
292
+ {renderEntityTypeBadge()}
293
+ <div className={b('path-name')}>{currentSchemaPath}</div>
294
+ </div>
295
+ <div className={b('info-controls')}>
296
+ {renderCommonInfoControls()}
297
+ </div>
298
+ </div>
299
+ {renderTabs()}
300
+ </div>
301
+ {renderTabContent()}
302
+ </div>
303
+ </SplitPane>
304
+ </div>
305
+ <PaneVisibilityToggleButtons
306
+ onCollapse={props.onCollapseSummary}
307
+ onExpand={props.onExpandSummary}
308
+ isCollapsed={props.isCollapsed}
309
+ initialDirection="left"
310
+ className={b('action-button')}
311
+ />
312
+ </div>
313
+ );
314
+ };
315
+
316
+ return renderContent();
317
+ }
318
+
319
+ export default ObjectSummary;