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.
- package/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +3 -3
- package/dist/assets/icons/cluster.svg +1 -0
- package/dist/assets/icons/hide.svg +1 -0
- package/dist/assets/icons/show.svg +1 -0
- package/dist/assets/icons/user-check.svg +1 -1
- package/dist/assets/icons/user-secret.svg +1 -1
- package/dist/components/AsideNavigation/AsideHeader.scss +1 -2
- package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.scss +7 -7
- package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.scss +2 -2
- package/dist/components/AsideNavigation/CompositeBar/CompositeBar.scss +6 -6
- package/dist/components/AsideNavigation/Drawer/Drawer.scss +5 -5
- package/dist/components/AsideNavigation/Logo/Logo.scss +3 -4
- package/dist/components/AsideNavigation/Settings/Settings.scss +27 -12
- package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.scss +14 -6
- package/dist/components/Breadcrumbs/Breadcrumbs.scss +2 -1
- package/dist/components/ClusterInfo/ClusterInfo.scss +19 -12
- package/dist/components/ClusterInfo/ClusterInfo.tsx +110 -10
- package/dist/components/CopyToClipboard/CopyToClipboard.tsx +39 -0
- package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +5 -4
- package/dist/components/Divider/Divider.scss +7 -0
- package/dist/components/Divider/Divider.tsx +11 -0
- package/dist/components/EmptyState/EmptyState.scss +14 -10
- package/dist/components/EnableFullscreenButton/EnableFullscreenButton.tsx +22 -0
- package/dist/components/EntityStatus/EntityStatus.js +5 -3
- package/dist/components/EntityStatus/EntityStatus.scss +35 -13
- package/dist/components/FullGroupViewer/FullGroupViewer.js +2 -4
- package/dist/components/FullGroupViewer/FullGroupViewer.scss +6 -3
- package/dist/components/FullNodeViewer/FullNodeViewer.scss +19 -11
- package/dist/components/Fullscreen/Fullscreen.scss +28 -0
- package/dist/components/Fullscreen/Fullscreen.tsx +81 -0
- package/dist/components/GroupTreeViewer/GroupTreeViewer.scss +1 -0
- package/dist/components/GroupViewer/GroupViewer.scss +8 -4
- package/dist/components/Icon/Icon.js +2 -0
- package/dist/components/InfoViewer/InfoViewer.scss +22 -16
- package/dist/components/NodesViewer/NodesViewer.js +25 -35
- package/dist/components/NodesViewer/NodesViewer.scss +15 -11
- package/dist/components/PDiskViewer/PDiskViewer.scss +10 -4
- package/dist/components/Pagination/Pagination.scss +6 -3
- package/dist/components/PoolBar/PoolBar.scss +14 -10
- package/dist/components/PoolUsage/PoolUsage.scss +17 -9
- package/dist/components/ProgressViewer/ProgressViewer.js +1 -1
- package/dist/components/ProgressViewer/ProgressViewer.scss +28 -18
- package/dist/components/QueryExecutionStatus/QueryExecutionStatus.scss +14 -0
- package/dist/components/QueryExecutionStatus/QueryExecutionStatus.tsx +29 -0
- package/dist/components/SplitPane/SplitPane.scss +33 -40
- package/dist/components/SplitPane/SplitPane.tsx +94 -0
- package/dist/components/Tablet/Tablet.scss +9 -6
- package/dist/components/TabletsOverall/TabletsOverall.scss +19 -0
- package/dist/components/TabletsOverall/TabletsOverall.tsx +105 -0
- package/dist/components/TabletsStatistic/TabletsStatistic.scss +24 -18
- package/dist/components/TabletsViewer/TabletsViewer.scss +12 -9
- package/dist/components/Tag/Tag.scss +6 -4
- package/dist/components/Tags/Tags.scss +1 -1
- package/dist/components/TreeView/TreeView.js +1 -1
- package/dist/components/TreeView/TreeView.scss +9 -0
- package/dist/components/TruncatedQuery/TruncatedQuery.scss +4 -3
- package/dist/containers/App/App.js +1 -0
- package/dist/containers/App/App.scss +50 -31
- package/dist/containers/App/Content.js +2 -2
- package/dist/containers/App/NodesTable.scss +25 -0
- package/dist/containers/App/TipPopup/TipPopup.scss +10 -6
- package/dist/containers/AppIcons/AppIcons.js +46 -22
- package/dist/containers/AsideNavigation/AsideNavigation.scss +1 -1
- package/dist/containers/AsideNavigation/AsideNavigation.tsx +12 -5
- package/dist/containers/Authentication/Authentication.scss +63 -14
- package/dist/containers/Authentication/Authentication.tsx +42 -9
- package/dist/containers/Cluster/Cluster.scss +5 -3
- package/dist/containers/Cluster/Cluster.tsx +49 -0
- package/dist/containers/Group/Group.scss +1 -1
- package/dist/containers/Header/Header.scss +15 -59
- package/dist/containers/Header/Header.tsx +75 -0
- package/dist/containers/Header/Host/Host.scss +10 -3
- package/dist/containers/Heatmap/Heatmap.js +1 -1
- package/dist/containers/Heatmap/Heatmap.scss +16 -7
- package/dist/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js +3 -3
- package/dist/containers/Heatmap/Histogram/Histogram.scss +21 -9
- package/dist/containers/Node/Node.js +1 -1
- package/dist/containers/Node/Node.scss +6 -4
- package/dist/containers/Nodes/Nodes.js +28 -27
- package/dist/containers/Nodes/Nodes.scss +5 -17
- package/dist/containers/Pdisk/Pdisk.scss +6 -4
- package/dist/containers/Pool/Pool.scss +7 -4
- package/dist/containers/ReduxTooltip/ReduxTooltip.scss +5 -1
- package/dist/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.scss +77 -0
- package/dist/containers/{StorageV2 → Storage}/DiskStateProgressBar/DiskStateProgressBar.tsx +1 -1
- package/dist/containers/{StorageV2 → Storage}/Pdisk/Pdisk.scss +6 -4
- package/dist/containers/{StorageV2 → Storage}/Pdisk/Pdisk.tsx +1 -2
- package/dist/containers/{StorageV2 → Storage}/Storage.js +72 -34
- package/dist/containers/{StorageV2 → Storage}/Storage.scss +12 -14
- package/dist/containers/{StorageV2 → Storage}/StorageFilter/StorageFilter.js +1 -9
- package/dist/containers/{StorageV2 → Storage}/StorageGroups/StorageGroups.scss +2 -0
- package/dist/containers/{StorageV2 → Storage}/StorageGroups/StorageGroups.tsx +1 -1
- package/dist/containers/{StorageV2 → Storage}/StorageNodes/StorageNodes.scss +2 -0
- package/dist/containers/{StorageV2 → Storage}/StorageNodes/StorageNodes.tsx +1 -1
- package/dist/containers/{StorageV2 → Storage}/Vdisk/Vdisk.js +0 -0
- package/dist/containers/{StorageV2 → Storage}/Vdisk/Vdisk.scss +6 -4
- package/dist/containers/Tablet/Tablet.scss +13 -9
- package/dist/containers/Tablets/Tablets.js +21 -90
- package/dist/containers/Tablets/Tablets.scss +9 -35
- package/dist/containers/TabletsFilters/TabletsFilters.js +2 -75
- package/dist/containers/TabletsFilters/TabletsFilters.scss +15 -35
- package/dist/containers/Tenant/Acl/Acl.js +54 -47
- package/dist/containers/Tenant/Acl/Acl.scss +15 -4
- package/dist/containers/Tenant/{Compute → Diagnostics/Compute}/Compute.js +35 -12
- package/dist/containers/Tenant/Diagnostics/Compute/Compute.scss +14 -0
- package/dist/containers/Tenant/{Describe → Diagnostics/Describe}/Describe.js +50 -1
- package/dist/containers/Tenant/{Describe → Diagnostics/Describe}/Describe.scss +5 -3
- package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.scss +27 -0
- package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.tsx +88 -0
- package/dist/containers/Tenant/Diagnostics/Diagnostics.scss +50 -0
- package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +208 -0
- package/dist/containers/Tenant/Diagnostics/DiagnosticsPages.ts +75 -0
- package/dist/containers/Tenant/Diagnostics/Healthcheck/Healthcheck.js +191 -0
- package/dist/containers/Tenant/Diagnostics/Healthcheck/Healthcheck.scss +79 -0
- package/dist/containers/Tenant/{Healthcheck → Diagnostics/Healthcheck}/IssuesViewer/IssueViewer.scss +25 -13
- package/dist/containers/Tenant/{Healthcheck → Diagnostics/Healthcheck}/IssuesViewer/IssuesViewer.js +2 -2
- package/dist/containers/Tenant/{Schema → Diagnostics}/HotKeys/HotKeys.js +14 -8
- package/dist/containers/Tenant/{Schema → Diagnostics}/HotKeys/HotKeys.scss +7 -5
- package/dist/containers/Tenant/{Network → Diagnostics/Network}/Network.js +39 -9
- package/dist/containers/Tenant/{Network → Diagnostics/Network}/Network.scss +35 -36
- package/dist/containers/Tenant/{Network → Diagnostics/Network}/NodeNetwork/NodeNetwork.js +0 -0
- package/dist/containers/Tenant/{Network → Diagnostics/Network}/NodeNetwork/NodeNetwork.scss +11 -9
- package/dist/containers/Tenant/Diagnostics/Overview/Overview.scss +13 -0
- package/dist/containers/Tenant/Diagnostics/Overview/Overview.tsx +123 -0
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +200 -0
- package/dist/{components → containers/Tenant/Diagnostics}/TenantOverview/TenantOverview.scss +24 -17
- package/dist/containers/Tenant/{TopQueries → Diagnostics/TopQueries}/TopQueries.js +32 -30
- package/dist/containers/Tenant/{TopQueries → Diagnostics/TopQueries}/TopQueries.scss +10 -9
- package/dist/containers/Tenant/{TopShards → Diagnostics/TopShards}/TopShards.js +25 -29
- package/dist/containers/Tenant/{TopShards → Diagnostics/TopShards}/TopShards.scss +1 -13
- package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.scss +38 -0
- package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.tsx +104 -0
- package/dist/containers/Tenant/ObjectSummary/ObjectSummary.scss +175 -0
- package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +319 -0
- package/dist/containers/Tenant/Preview/Preview.js +50 -12
- package/dist/containers/Tenant/Preview/Preview.scss +45 -3
- package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.scss +85 -0
- package/dist/containers/Tenant/QueryEditor/QueriesHistory/QueriesHistory.tsx +95 -0
- package/dist/containers/Tenant/QueryEditor/QueryEditor.js +319 -268
- package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +47 -18
- package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +190 -75
- package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.scss +47 -11
- package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +89 -20
- package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.scss +60 -6
- package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +10 -23
- package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss +15 -7
- package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.js +7 -3
- package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.scss +28 -17
- package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +7 -7
- package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss +1 -11
- package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.js +37 -17
- package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.scss +33 -12
- package/dist/containers/Tenant/Schema/SchemaNodeActions/SchemaNodeActions.scss +17 -0
- package/dist/containers/Tenant/Schema/SchemaNodeActions/SchemaNodeActions.tsx +125 -0
- package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.js +5 -4
- package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.scss +6 -2
- package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +53 -34
- package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.scss +1 -22
- package/dist/containers/Tenant/Tenant.scss +3 -32
- package/dist/containers/Tenant/Tenant.tsx +161 -0
- package/dist/containers/Tenant/TenantPages.tsx +48 -0
- package/dist/containers/Tenant/utils/ToggleButton.scss +26 -0
- package/dist/containers/Tenant/utils/paneVisibilityToggleHelpers.tsx +126 -0
- package/dist/containers/Tenants/Tenants.js +41 -55
- package/dist/containers/Tenants/Tenants.scss +4 -17
- package/dist/containers/UserSettings/UserSettings.tsx +0 -2
- package/dist/containers/Vdisk/Vdisk.scss +6 -4
- package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.js +1 -1
- package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.scss +5 -5
- package/dist/{routes.js → routes.ts} +14 -4
- package/dist/store/reducers/clusterNodes.js +1 -1
- package/dist/store/reducers/executeQuery.js +36 -2
- package/dist/store/reducers/fullscreen.ts +31 -0
- package/dist/store/reducers/header.ts +23 -0
- package/dist/store/reducers/hotKeys.js +1 -1
- package/dist/store/reducers/index.js +6 -0
- package/dist/store/reducers/saveQuery.ts +33 -0
- package/dist/store/reducers/schema.js +14 -0
- package/dist/store/reducers/shardsWorkload.js +1 -1
- package/dist/store/state-url-mapping.js +1 -1
- package/dist/store/utils.js +2 -6
- package/dist/styles/mixins.scss +49 -34
- package/dist/utils/autofetcher.ts +51 -0
- package/dist/utils/constants.js +26 -7
- package/dist/utils/createToast.tsx +23 -0
- package/dist/utils/getNodesColumns.js +25 -28
- package/dist/utils/index.js +6 -2
- package/package.json +8 -4
- package/dist/components/SplitPane/SplitPane.js +0 -368
- package/dist/components/TenantOverview/TenantOverview.js +0 -148
- package/dist/containers/Cluster/Cluster.js +0 -168
- package/dist/containers/Header/Header.js +0 -88
- package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +0 -81
- package/dist/containers/Tenant/Compute/Compute.scss +0 -6
- package/dist/containers/Tenant/Healthcheck/Healthcheck.js +0 -116
- package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +0 -64
- package/dist/containers/Tenant/Schema/Info/Info.js +0 -84
- package/dist/containers/Tenant/Schema/Info/Info.scss +0 -3
- package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +0 -439
- package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +0 -90
- package/dist/containers/Tenant/Schema/SchemaPages.js +0 -56
- package/dist/containers/Tenant/Tenant.js +0 -199
- package/dist/containers/Tenant/TenantPages.js +0 -35
@@ -4,21 +4,26 @@ import {connect} from 'react-redux';
|
|
4
4
|
import cn from 'bem-cn-lite';
|
5
5
|
|
6
6
|
import DataTable from '@yandex-cloud/react-data-table';
|
7
|
-
import {Loader} from '@yandex-cloud/uikit';
|
7
|
+
import {Loader, Button} from '@yandex-cloud/uikit';
|
8
|
+
|
9
|
+
import Icon from '../../../components/Icon/Icon';
|
10
|
+
import Fullscreen from '../../../components/Fullscreen/Fullscreen';
|
8
11
|
|
9
12
|
import {sendQuery, setQueryOptions} from '../../../store/reducers/preview';
|
10
13
|
import {showTooltip, hideTooltip} from '../../../store/reducers/tooltip';
|
11
14
|
import {prepareQueryResponse} from '../../../utils/index';
|
12
15
|
|
13
|
-
import {OLAP_TABLE_TYPE, TABLE_TYPE} from '../
|
14
|
-
import {AutoFetcher} from '
|
16
|
+
import {OLAP_TABLE_TYPE, TABLE_TYPE} from '../Tenant';
|
17
|
+
import {AutoFetcher} from '../../../utils/autofetcher';
|
18
|
+
import EnableFullscreenButton from '../../../components/EnableFullscreenButton/EnableFullscreenButton';
|
19
|
+
import {DEFAULT_TABLE_SETTINGS} from '../../../utils/constants';
|
20
|
+
import {setShowPreview} from '../../../store/reducers/schema';
|
15
21
|
|
16
22
|
import './Preview.scss';
|
17
23
|
|
18
24
|
const TABLE_SETTINGS = {
|
19
|
-
|
20
|
-
|
21
|
-
stickyHead: DataTable.MOVING,
|
25
|
+
...DEFAULT_TABLE_SETTINGS,
|
26
|
+
stripedRows: true,
|
22
27
|
};
|
23
28
|
|
24
29
|
const b = cn('kv-preview');
|
@@ -90,6 +95,31 @@ class Preview extends React.Component {
|
|
90
95
|
});
|
91
96
|
};
|
92
97
|
|
98
|
+
onClosePreview = () => {
|
99
|
+
this.props.setShowPreview(false);
|
100
|
+
};
|
101
|
+
|
102
|
+
renderHeader = () => {
|
103
|
+
const {currentSchemaPath, error} = this.props;
|
104
|
+
return (
|
105
|
+
<div className={b('header')}>
|
106
|
+
<div className={b('title')}>
|
107
|
+
Preview <div className={b('table-name')}>{currentSchemaPath}</div>
|
108
|
+
</div>
|
109
|
+
<div className={b('controls-left')}>
|
110
|
+
<EnableFullscreenButton disabled={Boolean(error)} />
|
111
|
+
<Button
|
112
|
+
view="flat-secondary"
|
113
|
+
onClick={this.onClosePreview}
|
114
|
+
title="Close preview"
|
115
|
+
>
|
116
|
+
<Icon name="close" viewBox={'0 0 16 16'} width={16} height={16} />
|
117
|
+
</Button>
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
);
|
121
|
+
};
|
122
|
+
|
93
123
|
renderTable = () => {
|
94
124
|
const {data, showTooltip} = this.props;
|
95
125
|
|
@@ -116,10 +146,12 @@ class Preview extends React.Component {
|
|
116
146
|
};
|
117
147
|
|
118
148
|
render() {
|
119
|
-
const {error, loading, data = [], type, wasLoaded} = this.props;
|
149
|
+
const {error, loading, data = [], type, wasLoaded, isFullscreen} = this.props;
|
150
|
+
|
151
|
+
let message;
|
120
152
|
|
121
153
|
if (type !== TABLE_TYPE && type !== OLAP_TABLE_TYPE) {
|
122
|
-
|
154
|
+
message = <div className={b('message-container')}>Not available</div>;
|
123
155
|
}
|
124
156
|
|
125
157
|
if (loading && !wasLoaded) {
|
@@ -131,16 +163,19 @@ class Preview extends React.Component {
|
|
131
163
|
}
|
132
164
|
|
133
165
|
if (error) {
|
134
|
-
|
166
|
+
message = <div className={b('message-container')}>{error.data || error}</div>;
|
135
167
|
}
|
136
168
|
|
137
169
|
if (!loading && data.length === 0) {
|
138
|
-
|
170
|
+
message = <div className={b('message-container')}>Table is empty</div>;
|
139
171
|
}
|
140
172
|
|
173
|
+
const content = message ?? <div className={b('result')}>{this.renderTable()}</div>;
|
174
|
+
|
141
175
|
return (
|
142
176
|
<div className={b()}>
|
143
|
-
|
177
|
+
{this.renderHeader()}
|
178
|
+
{isFullscreen ? <Fullscreen>{content}</Fullscreen> : content}
|
144
179
|
</div>
|
145
180
|
);
|
146
181
|
}
|
@@ -148,7 +183,7 @@ class Preview extends React.Component {
|
|
148
183
|
|
149
184
|
const mapStateToProps = (state) => {
|
150
185
|
const {data = [], loading, error, wasLoaded} = state.preview;
|
151
|
-
const {autorefresh} = state.schema;
|
186
|
+
const {autorefresh, currentSchemaPath} = state.schema;
|
152
187
|
|
153
188
|
return {
|
154
189
|
data,
|
@@ -156,6 +191,8 @@ const mapStateToProps = (state) => {
|
|
156
191
|
error,
|
157
192
|
autorefresh,
|
158
193
|
wasLoaded,
|
194
|
+
currentSchemaPath,
|
195
|
+
isFullscreen: state.fullscreen,
|
159
196
|
};
|
160
197
|
};
|
161
198
|
|
@@ -164,6 +201,7 @@ const mapDispatchToProps = {
|
|
164
201
|
showTooltip,
|
165
202
|
hideTooltip,
|
166
203
|
setQueryOptions,
|
204
|
+
setShowPreview,
|
167
205
|
};
|
168
206
|
|
169
207
|
export default connect(mapStateToProps, mapDispatchToProps)(Preview);
|
@@ -1,20 +1,62 @@
|
|
1
1
|
@import '../../../styles/mixins.scss';
|
2
2
|
|
3
3
|
.kv-preview {
|
4
|
+
height: 100%;
|
5
|
+
@include query-data-table;
|
6
|
+
|
7
|
+
.yc-button__text {
|
8
|
+
margin: 0 6px;
|
9
|
+
}
|
10
|
+
|
11
|
+
&__header {
|
12
|
+
position: sticky;
|
13
|
+
top: 0;
|
14
|
+
|
15
|
+
display: flex;
|
16
|
+
justify-content: space-between;
|
17
|
+
align-items: center;
|
18
|
+
|
19
|
+
height: 40px;
|
20
|
+
padding: 0 19px;
|
21
|
+
|
22
|
+
border-bottom: 1px solid var(--yc-color-line-generic);
|
23
|
+
background-color: var(--yc-color-base-background);
|
24
|
+
}
|
25
|
+
|
26
|
+
&__title {
|
27
|
+
display: flex;
|
28
|
+
}
|
29
|
+
|
30
|
+
&__table-name {
|
31
|
+
margin-left: 4px;
|
32
|
+
|
33
|
+
color: var(--yc-color-text-complementary);
|
34
|
+
}
|
35
|
+
|
36
|
+
&__controls-left {
|
37
|
+
display: flex;
|
38
|
+
gap: 5px;
|
39
|
+
}
|
4
40
|
&__message-container {
|
5
|
-
padding: 15px
|
41
|
+
padding: 15px 19px;
|
6
42
|
}
|
7
43
|
|
8
44
|
&__loader-container {
|
9
45
|
display: flex;
|
10
46
|
justify-content: center;
|
11
47
|
align-items: center;
|
48
|
+
|
12
49
|
height: 100%;
|
13
50
|
}
|
14
51
|
|
15
|
-
@include query-data-table;
|
16
|
-
|
17
52
|
&__cell {
|
18
53
|
@include cell-container;
|
19
54
|
}
|
55
|
+
|
56
|
+
&__result {
|
57
|
+
overflow: auto;
|
58
|
+
|
59
|
+
height: calc(100% - 40px);
|
60
|
+
padding: 0 19px;
|
61
|
+
}
|
20
62
|
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
$popup-width: 700px;
|
2
|
+
|
3
|
+
.kv-queries-history {
|
4
|
+
$block: &;
|
5
|
+
padding: 12px 16px;
|
6
|
+
|
7
|
+
&__empty {
|
8
|
+
font-weight: 600;
|
9
|
+
text-align: center;
|
10
|
+
}
|
11
|
+
&__popup-wrapper {
|
12
|
+
overflow: hidden;
|
13
|
+
|
14
|
+
width: $popup-width;
|
15
|
+
max-width: $popup-width !important;
|
16
|
+
|
17
|
+
border-radius: 4px;
|
18
|
+
:nth-child(2) {
|
19
|
+
overflow-y: auto;
|
20
|
+
|
21
|
+
max-height: 50vh;
|
22
|
+
}
|
23
|
+
|
24
|
+
&::before {
|
25
|
+
width: $popup-width;
|
26
|
+
|
27
|
+
border-radius: 4px;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
&__saved-queries-row {
|
31
|
+
display: flex;
|
32
|
+
align-items: center;
|
33
|
+
|
34
|
+
padding: 8px 5px;
|
35
|
+
|
36
|
+
border-bottom: 1px solid var(--yc-color-line-generic);
|
37
|
+
&:hover {
|
38
|
+
cursor: pointer;
|
39
|
+
|
40
|
+
color: var(--yc-color-text-link-hover);
|
41
|
+
background: var(--yc-color-base-simple-hover);
|
42
|
+
#{$block}__query-controls {
|
43
|
+
display: flex;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
&_header {
|
47
|
+
font-weight: 600;
|
48
|
+
&:hover {
|
49
|
+
cursor: auto;
|
50
|
+
|
51
|
+
color: var(--yc-color-text-primary);
|
52
|
+
background: var(--yc-color-base-background);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
&__query-body {
|
57
|
+
overflow: hidden;
|
58
|
+
flex-grow: 1;
|
59
|
+
|
60
|
+
white-space: pre;
|
61
|
+
text-overflow: ellipsis;
|
62
|
+
&_header {
|
63
|
+
display: flex;
|
64
|
+
justify-content: center;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
&__query-controls {
|
68
|
+
display: none;
|
69
|
+
}
|
70
|
+
&__control-button {
|
71
|
+
display: flex;
|
72
|
+
justify-content: center;
|
73
|
+
align-items: center;
|
74
|
+
|
75
|
+
width: 24px;
|
76
|
+
|
77
|
+
color: var(--yc-color-text-hint);
|
78
|
+
&:hover {
|
79
|
+
color: var(--yc-color-text-secondary);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
&__dialog-query-name {
|
83
|
+
font-weight: 500;
|
84
|
+
}
|
85
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import React, {useRef, useState} from 'react';
|
2
|
+
import cn from 'bem-cn-lite';
|
3
|
+
import _ from 'lodash';
|
4
|
+
import {Button, Popup} from '@yandex-cloud/uikit';
|
5
|
+
import TruncatedQuery from '../../../../components/TruncatedQuery/TruncatedQuery';
|
6
|
+
import {useSelector} from 'react-redux';
|
7
|
+
|
8
|
+
import './QueriesHistory.scss';
|
9
|
+
|
10
|
+
const b = cn('kv-queries-history');
|
11
|
+
|
12
|
+
const MAX_QUERY_HEIGHT = 3;
|
13
|
+
|
14
|
+
interface QueriesHistoryProps {
|
15
|
+
changeUserInput: (value: {input: string}) => void;
|
16
|
+
}
|
17
|
+
|
18
|
+
function QueriesHistory(props: QueriesHistoryProps) {
|
19
|
+
const [isHistoryVisible, setIsHistoryVisible] = useState(false);
|
20
|
+
const history: string[] =
|
21
|
+
useSelector((state: any) => state.executeQuery.history?.queries) ?? [];
|
22
|
+
const anchor = useRef(null);
|
23
|
+
|
24
|
+
const onShowHistoryClick = () => {
|
25
|
+
setIsHistoryVisible(true);
|
26
|
+
};
|
27
|
+
|
28
|
+
const onCloseHistory = () => {
|
29
|
+
setIsHistoryVisible(false);
|
30
|
+
};
|
31
|
+
|
32
|
+
const onQueryClick = (queryText: string) => {
|
33
|
+
const {changeUserInput} = props;
|
34
|
+
return () => {
|
35
|
+
changeUserInput({input: queryText});
|
36
|
+
onCloseHistory();
|
37
|
+
};
|
38
|
+
};
|
39
|
+
|
40
|
+
const renderSavedQueries = () => {
|
41
|
+
const reversedHistory = ([] as string[]).concat(history).reverse();
|
42
|
+
return (
|
43
|
+
<Popup
|
44
|
+
className={b('popup-wrapper')}
|
45
|
+
anchorRef={anchor}
|
46
|
+
open={isHistoryVisible}
|
47
|
+
placement={['bottom-end']}
|
48
|
+
onClose={onCloseHistory}
|
49
|
+
>
|
50
|
+
<div className={b()}>
|
51
|
+
{reversedHistory.length === 0 ? (
|
52
|
+
<div className={b('empty')}>History is empty</div>
|
53
|
+
) : (
|
54
|
+
<React.Fragment>
|
55
|
+
<div className={b('saved-queries-row', {header: true})}>
|
56
|
+
<div className={b('query-body', {header: true})}>
|
57
|
+
<span>QueryText</span>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
<div>
|
61
|
+
{reversedHistory.map((query, index) => {
|
62
|
+
return (
|
63
|
+
<div
|
64
|
+
className={b('saved-queries-row')}
|
65
|
+
onClick={onQueryClick(query)}
|
66
|
+
key={index}
|
67
|
+
>
|
68
|
+
<div className={b('query-body')}>
|
69
|
+
<TruncatedQuery
|
70
|
+
value={query}
|
71
|
+
maxQueryHeight={MAX_QUERY_HEIGHT}
|
72
|
+
/>
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
);
|
76
|
+
})}
|
77
|
+
</div>
|
78
|
+
</React.Fragment>
|
79
|
+
)}
|
80
|
+
</div>
|
81
|
+
</Popup>
|
82
|
+
);
|
83
|
+
};
|
84
|
+
|
85
|
+
return (
|
86
|
+
<React.Fragment>
|
87
|
+
<Button ref={anchor} onClick={onShowHistoryClick}>
|
88
|
+
Query history
|
89
|
+
</Button>
|
90
|
+
{isHistoryVisible && renderSavedQueries()}
|
91
|
+
</React.Fragment>
|
92
|
+
);
|
93
|
+
}
|
94
|
+
|
95
|
+
export default QueriesHistory;
|