ydb-embedded-ui 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ### [1.0.1](https://www.github.com/ydb-platform/ydb-embedded-ui/compare/v1.0.0...v1.0.1) (2022-03-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **QueriesHistory:** should save history to local storage ([#8](https://www.github.com/ydb-platform/ydb-embedded-ui/issues/8)) ([57031ab](https://www.github.com/ydb-platform/ydb-embedded-ui/commit/57031ab16900e9d1112bbf506d5c777f94f883bb))
9
+
3
10
  ## [1.0.0](https://www.github.com/ydb-platform/ydb-embedded-ui/compare/v0.2.0...v1.0.0) (2022-03-01)
4
11
 
5
12
 
@@ -1,6 +1,10 @@
1
1
  @import '../../../styles/mixins.scss';
2
2
 
3
3
  .kv-acl {
4
+ display: flex;
5
+ overflow: auto;
6
+ flex-grow: 1;
7
+
4
8
  padding: 0 12px 16px;
5
9
  @include query-data-table;
6
10
  &__message-container {
@@ -38,8 +42,4 @@
38
42
  color: var(--yc-color-text-danger);
39
43
  }
40
44
  }
41
-
42
- &__result {
43
- overflow: auto;
44
- }
45
45
  }
@@ -13,7 +13,9 @@
13
13
  max-height: 100%;
14
14
 
15
15
  &__overview-wrapper {
16
+ display: flex;
16
17
  overflow: auto;
18
+ flex-grow: 1;
17
19
 
18
20
  padding: 0 12px 16px;
19
21
  }
@@ -91,7 +93,15 @@
91
93
  }
92
94
 
93
95
  &__info {
96
+ display: flex;
94
97
  overflow: hidden;
98
+ flex-direction: column;
99
+ }
100
+
101
+ &__schema {
102
+ display: flex;
103
+ overflow: auto;
104
+ flex-grow: 1;
95
105
  }
96
106
 
97
107
  &__info-controls {
@@ -78,7 +78,7 @@ interface ObjectSummaryProps {
78
78
  onCollapseSummary: VoidFunction;
79
79
  onExpandSummary: VoidFunction;
80
80
  isCollapsed: boolean;
81
- additionalTenantInfo?: any
81
+ additionalTenantInfo?: any;
82
82
  }
83
83
 
84
84
  function ObjectSummary(props: ObjectSummaryProps) {
@@ -168,10 +168,16 @@ function ObjectSummary(props: ObjectSummaryProps) {
168
168
  const renderTabContent = () => {
169
169
  switch (infoTab) {
170
170
  case TenantInfoTabsIds.acl: {
171
- return <Acl additionalTenantInfo={props.additionalTenantInfo}/>;
171
+ return <Acl additionalTenantInfo={props.additionalTenantInfo} />;
172
172
  }
173
173
  case TenantInfoTabsIds.schema: {
174
- return loadingSchema ? renderLoader() : <SchemaViewer data={schema} />;
174
+ return loadingSchema ? (
175
+ renderLoader()
176
+ ) : (
177
+ <div className={b('schema')}>
178
+ <SchemaViewer data={schema} />
179
+ </div>
180
+ );
175
181
  }
176
182
  default: {
177
183
  return renderObjectOverview();
@@ -194,7 +200,9 @@ function ObjectSummary(props: ObjectSummaryProps) {
194
200
  <div className={b('tree-title')}>Navigation</div>
195
201
  </div>
196
202
  <div className={b('tree')}>
197
- {tenantData && <SchemaNode fullPath={tenantName as string} data={tenantData} isRoot />}
203
+ {tenantData && (
204
+ <SchemaNode fullPath={tenantName as string} data={tenantData} isRoot />
205
+ )}
198
206
  </div>
199
207
  </div>
200
208
  );
@@ -38,6 +38,7 @@ function QueriesHistory(props: QueriesHistoryProps) {
38
38
  };
39
39
 
40
40
  const renderSavedQueries = () => {
41
+ const reversedHistory = ([] as string[]).concat(history).reverse();
41
42
  return (
42
43
  <Popup
43
44
  className={b('popup-wrapper')}
@@ -47,7 +48,7 @@ function QueriesHistory(props: QueriesHistoryProps) {
47
48
  onClose={onCloseHistory}
48
49
  >
49
50
  <div className={b()}>
50
- {history.length === 0 ? (
51
+ {reversedHistory.length === 0 ? (
51
52
  <div className={b('empty')}>History is empty</div>
52
53
  ) : (
53
54
  <React.Fragment>
@@ -57,7 +58,7 @@ function QueriesHistory(props: QueriesHistoryProps) {
57
58
  </div>
58
59
  </div>
59
60
  <div>
60
- {history?.reverse().map((query, index) => {
61
+ {reversedHistory.map((query, index) => {
61
62
  return (
62
63
  <div
63
64
  className={b('saved-queries-row')}
@@ -67,7 +67,7 @@ class SchemaViewer extends React.Component {
67
67
  theme="yandex-cloud"
68
68
  data={tableData}
69
69
  columns={columns}
70
- settings={{...DEFAULT_TABLE_SETTINGS, stickyTop: 107}}
70
+ settings={DEFAULT_TABLE_SETTINGS}
71
71
  dynamicRender={true}
72
72
  initialSortOrder={{columnId: SchemaViewerColumns.key, order: DataTable.DESCENDING}}
73
73
  />
@@ -1,5 +1,9 @@
1
1
  import {createRequestActionTypes, createApiRequest} from '../utils';
2
2
  import '../../services/api';
3
+ import {getValueFromLS, parseJson} from '../../utils/utils';
4
+ import {QUERIES_HISTORY_KEY} from '../../utils/constants';
5
+
6
+ const MAXIMUM_QUERIES_IN_HISTORY = 20;
3
7
 
4
8
  const SEND_QUERY = createRequestActionTypes('query', 'SEND_QUERY');
5
9
  const CHANGE_USER_INPUT = 'query/CHANGE_USER_INPUT';
@@ -9,6 +13,10 @@ const GO_TO_NEXT_QUERY = 'query/GO_TO_NEXT_QUERY';
9
13
  const SELECT_RUN_ACTION = 'query/SELECT_RUN_ACTION';
10
14
  const MONACO_HOT_KEY = 'query/MONACO_HOT_KEY';
11
15
 
16
+ const queriesHistoryInitial = parseJson(getValueFromLS(QUERIES_HISTORY_KEY, []));
17
+
18
+ const sliceLimit = queriesHistoryInitial.length - MAXIMUM_QUERIES_IN_HISTORY;
19
+
12
20
  export const RUN_ACTIONS_VALUES = {
13
21
  script: 'execute-script',
14
22
  scan: 'execute-scan',
@@ -25,7 +33,7 @@ const initialState = {
25
33
  loading: false,
26
34
  input: '',
27
35
  history: {
28
- queries: [],
36
+ queries: queriesHistoryInitial.slice(sliceLimit < 0 ? 0 : sliceLimit),
29
37
  currentIndex: -1,
30
38
  },
31
39
  runAction: RUN_ACTIONS_VALUES.script,
@@ -76,7 +84,10 @@ const executeQuery = (state = initialState, action) => {
76
84
 
77
85
  case SAVE_QUERY_TO_HISTORY: {
78
86
  const query = action.data;
79
- const newQueries = [...state.history.queries, query];
87
+ const newQueries = [...state.history.queries, query].slice(
88
+ state.history.queries.length >= MAXIMUM_QUERIES_IN_HISTORY ? 1 : 0,
89
+ );
90
+ window.localStorage.setItem(QUERIES_HISTORY_KEY, JSON.stringify(newQueries));
80
91
  const currentIndex = newQueries.length - 1;
81
92
 
82
93
  return {
@@ -120,6 +120,7 @@ export const PROBLEMS = 'With problems';
120
120
 
121
121
  export const THEME_KEY = 'theme';
122
122
  export const SAVED_QUERIES_KEY = 'saved_queries';
123
+ export const QUERIES_HISTORY_KEY = 'queries_history';
123
124
  export const DATA_QA_TUNE_COLUMNS_POPUP = 'tune-columns-popup';
124
125
 
125
126
  export const defaultUserSettings = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],