ydb-embedded-ui 1.8.0 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.8.3](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.8.2...v1.8.3) (2022-07-08)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * timeout 600 sec for requests /viewer/json/query ([cf65122](https://github.com/ydb-platform/ydb-embedded-ui/commit/cf651221f866e5f56ecf6c900b3778dedc31eb95))
9
+
10
+ ## [1.8.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.8.1...v1.8.2) (2022-07-07)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **Tenant:** 3 tabs for indexes ([9280384](https://github.com/ydb-platform/ydb-embedded-ui/commit/9280384733938c4bd269bf6f9adf23efb552c6e8))
16
+ * **Tenant:** hide preview button for index tables ([a25e0ea](https://github.com/ydb-platform/ydb-embedded-ui/commit/a25e0ea0413277e27c54d123e2be7a15b8a2aaa4))
17
+
18
+ ## [1.8.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.8.0...v1.8.1) (2022-07-06)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **Tenant:** diagnostics view for table indexes ([63d3133](https://github.com/ydb-platform/ydb-embedded-ui/commit/63d3133c0d61f6d39186f0c5df2eb6983a9c8bf7))
24
+ * **Tenant:** own context actions for table indexes ([3cd946a](https://github.com/ydb-platform/ydb-embedded-ui/commit/3cd946a333be402cec70569affef5865b0dd8934))
25
+
3
26
  ## [1.8.0](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.7.1...v1.8.0) (2022-07-05)
4
27
 
5
28
 
@@ -30,9 +30,8 @@ import Tablets from '../../Tablets/Tablets';
30
30
 
31
31
  import routes, {createHref} from '../../../routes';
32
32
  import type {EPathType} from '../../../types/api/schema';
33
- import {isTableType} from '../utils/schema';
34
33
  import {TenantGeneralTabsIds, TenantTabsGroups} from '../TenantPages';
35
- import {GeneralPagesIds, DATABASE_PAGES, TABLE_PAGES, DIR_PAGES} from './DiagnosticsPages';
34
+ import {GeneralPagesIds, DATABASE_PAGES, getPagesByType} from './DiagnosticsPages';
36
35
  //@ts-ignore
37
36
  import {enableAutorefresh, disableAutorefresh} from '../../../store/reducers/schema';
38
37
  import {setTopLevelTab, setDiagnosticsTab} from '../../../store/reducers/tenant';
@@ -66,20 +65,15 @@ function Diagnostics(props: DiagnosticsProps) {
66
65
 
67
66
  const {name: tenantName} = queryParams;
68
67
 
69
- const isDatabase = currentSchemaPath === tenantName;
68
+ const isRoot = currentSchemaPath === tenantName;
70
69
 
71
70
  const pages = useMemo(() => {
72
- const isTable = isTableType(props.type);
73
-
74
- let pages = DIR_PAGES;
75
-
76
- if (isDatabase) {
77
- pages = DATABASE_PAGES;
78
- } else if (isTable) {
79
- pages = TABLE_PAGES;
71
+ if (isRoot) {
72
+ return DATABASE_PAGES;
80
73
  }
81
- return pages;
82
- }, [props.type, isDatabase]);
74
+
75
+ return getPagesByType(props.type);
76
+ }, [props.type, isRoot]);
83
77
 
84
78
  const forwardToDiagnosticTab = (tab: GeneralPagesIds) => {
85
79
  dispatch(setDiagnosticsTab(tab));
@@ -1,3 +1,5 @@
1
+ import {EPathType} from "../../../types/api/schema";
2
+
1
3
  export enum GeneralPagesIds {
2
4
  'overview' = 'Overview',
3
5
  'topQueries' = 'topQueries',
@@ -73,3 +75,18 @@ export const DATABASE_PAGES = [
73
75
  export const TABLE_PAGES = [overview, topShards, graph, tablets, hotKeys, describe];
74
76
 
75
77
  export const DIR_PAGES = [overview, topShards, describe];
78
+
79
+ export const getPagesByType = (type?: EPathType) => {
80
+ switch (type) {
81
+ case EPathType.EPathTypeColumnStore:
82
+ case EPathType.EPathTypeSubDomain:
83
+ return DATABASE_PAGES;
84
+ case EPathType.EPathTypeColumnTable:
85
+ case EPathType.EPathTypeTable:
86
+ return TABLE_PAGES;
87
+ case EPathType.EPathTypeDir:
88
+ case EPathType.EPathTypeTableIndex:
89
+ default:
90
+ return DIR_PAGES;
91
+ }
92
+ }
@@ -16,8 +16,8 @@ import CopyToClipboard from '../../../components/CopyToClipboard/CopyToClipboard
16
16
  import InfoViewer from '../../../components/InfoViewer/InfoViewer';
17
17
  import Icon from '../../../components/Icon/Icon';
18
18
 
19
- import type {EPathType} from '../../../types/api/schema';
20
- import {isColumnEntityType, isTableType} from '../utils/schema';
19
+ import type {EPathSubType, EPathType} from '../../../types/api/schema';
20
+ import {isColumnEntityType, isIndexTable, isTableType} from '../utils/schema';
21
21
 
22
22
  import {
23
23
  DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED,
@@ -71,6 +71,7 @@ function prepareOlapTableSchema(tableSchema: any) {
71
71
 
72
72
  interface ObjectSummaryProps {
73
73
  type?: EPathType;
74
+ subType?: EPathSubType;
74
75
  onCollapseSummary: VoidFunction;
75
76
  onExpandSummary: VoidFunction;
76
77
  isCollapsed: boolean;
@@ -229,10 +230,10 @@ function ObjectSummary(props: ObjectSummaryProps) {
229
230
  };
230
231
 
231
232
  const renderCommonInfoControls = () => {
232
- const isTable = isTableType(props.type);
233
+ const showPreview = isTableType(props.type) && !isIndexTable(props.subType);
233
234
  return (
234
235
  <React.Fragment>
235
- {isTable && (
236
+ {showPreview && (
236
237
  <Button view="flat-secondary" onClick={onOpenPreview} title="Show preview">
237
238
  <Icon name="tablePreview" viewBox={'0 0 16 16'} height={16} width={16} />
238
239
  </Button>
@@ -32,9 +32,9 @@ export function SchemaTree(props: SchemaTreeProps) {
32
32
  {concurrentId: `NavigationTree.getSchema|${path}`},
33
33
  )
34
34
  .then(({PathDescription: {Children = []} = {}}) => {
35
- return Children.map(({Name = '', PathType}) => ({
35
+ return Children.map(({Name = '', PathType, PathSubType}) => ({
36
36
  name: Name,
37
- type: mapPathTypeToNavigationTreeType(PathType),
37
+ type: mapPathTypeToNavigationTreeType(PathType, PathSubType),
38
38
  // FIXME: should only be explicitly set to true for tables with indexes
39
39
  // at the moment of writing there is no property to determine this, fix later
40
40
  expandable: true,
@@ -104,7 +104,10 @@ function Tenant(props: TenantProps) {
104
104
  };
105
105
  }, [tenantName, dispatch]);
106
106
 
107
- const currentPathType = (currentItem as TEvDescribeSchemeResult).PathDescription?.Self?.PathType;
107
+ const {
108
+ PathType: currentPathType,
109
+ PathSubType: currentPathSubType,
110
+ } = (currentItem as TEvDescribeSchemeResult).PathDescription?.Self || {};
108
111
 
109
112
  const onCollapseSummaryHandler = () => {
110
113
  dispatchSummaryVisibilityAction(PaneVisibilityActionTypes.triggerCollapse);
@@ -138,6 +141,7 @@ function Tenant(props: TenantProps) {
138
141
  >
139
142
  <ObjectSummary
140
143
  type={currentPathType}
144
+ subType={currentPathSubType}
141
145
  onCollapseSummary={onCollapseSummaryHandler}
142
146
  onExpandSummary={onExpandSummaryHandler}
143
147
  isCollapsed={summaryVisibilityState.collapsed}
@@ -1,8 +1,19 @@
1
1
  import type {NavigationTreeNodeType} from 'ydb-ui-components';
2
- import {EPathType} from '../../../types/api/schema';
2
+ import {EPathSubType, EPathType} from '../../../types/api/schema';
3
+
4
+ const mapTablePathSubTypeToNavigationTreeType = (subType?: EPathSubType) => {
5
+ switch (subType) {
6
+ case EPathSubType.EPathSubTypeSyncIndexImplTable:
7
+ case EPathSubType.EPathSubTypeAsyncIndexImplTable:
8
+ return 'index_table';
9
+ default:
10
+ return 'table';
11
+ }
12
+ };
3
13
 
4
14
  export const mapPathTypeToNavigationTreeType = (
5
15
  type: EPathType = EPathType.EPathTypeDir,
16
+ subType?: EPathSubType,
6
17
  defaultType: NavigationTreeNodeType = 'directory'
7
18
  ): NavigationTreeNodeType => {
8
19
  switch (type) {
@@ -10,11 +21,12 @@ export const mapPathTypeToNavigationTreeType = (
10
21
  return 'database';
11
22
  case EPathType.EPathTypeTable:
12
23
  case EPathType.EPathTypeColumnTable:
13
- return 'table';
24
+ return mapTablePathSubTypeToNavigationTreeType(subType);
14
25
  case EPathType.EPathTypeDir:
15
26
  case EPathType.EPathTypeColumnStore:
16
- case EPathType.EPathTypeTableIndex:
17
27
  return 'directory';
28
+ case EPathType.EPathTypeTableIndex:
29
+ return 'index';
18
30
  default:
19
31
  return defaultType;
20
32
  }
@@ -23,6 +35,9 @@ export const mapPathTypeToNavigationTreeType = (
23
35
  export const isTableType = (type?: EPathType) =>
24
36
  mapPathTypeToNavigationTreeType(type) === 'table';
25
37
 
38
+ export const isIndexTable = (subType?: EPathSubType) =>
39
+ mapTablePathSubTypeToNavigationTreeType(subType) === 'index_table';
40
+
26
41
  export const isColumnEntityType = (type?: EPathType) =>
27
42
  type === EPathType.EPathTypeColumnStore ||
28
43
  type === EPathType.EPathTypeColumnTable;
@@ -15,7 +15,6 @@ const createTableTemplate = (path: string) => {
15
15
  PRIMARY KEY (\`id\`)
16
16
  );`;
17
17
  };
18
-
19
18
  const alterTableTemplate = (path: string) => {
20
19
  return `ALTER TABLE \`${path}\`
21
20
  ADD COLUMN is_deleted Bool;`;
@@ -32,40 +31,23 @@ const upsertQueryTemplate = (path: string) => {
32
31
  VALUES ( );`;
33
32
  };
34
33
 
35
- export const getActions = (
34
+ const bindActions = (
35
+ path: string,
36
36
  dispatch: Dispatch<any>,
37
37
  setActivePath: (path: string) => void,
38
- ) =>
39
- (path: string, type: NavigationTreeNodeType) => {
40
- const switchTabToQuery = () => {
41
- dispatch(setTopLevelTab(TenantGeneralTabsIds.query));
42
- };
43
-
44
- const onCreateTableClick = () => {
45
- dispatch(changeUserInput({input: createTableTemplate(path)}));
46
- switchTabToQuery();
47
- setActivePath(path);
48
- };
38
+ ) => {
39
+ const inputQuery = (tmpl: (path: string) => string) => () => {
40
+ dispatch(changeUserInput({input: tmpl(path)}));
41
+ dispatch(setTopLevelTab(TenantGeneralTabsIds.query))
42
+ setActivePath(path);
43
+ }
49
44
 
50
- const onAlterTableClick = () => {
51
- dispatch(changeUserInput({input: alterTableTemplate(path)}));
52
- switchTabToQuery();
53
- setActivePath(path);
54
- };
55
-
56
- const onSelectQueryClick = () => {
57
- dispatch(changeUserInput({input: selectQueryTemplate(path)}));
58
- switchTabToQuery();
59
- setActivePath(path);
60
- };
61
-
62
- const onUpsertQueryClick = () => {
63
- dispatch(changeUserInput({input: upsertQueryTemplate(path)}));
64
- switchTabToQuery();
65
- setActivePath(path);
66
- };
67
-
68
- const onCopyPathClick = () => {
45
+ return {
46
+ createTable: inputQuery(createTableTemplate),
47
+ alterTable: inputQuery(alterTableTemplate),
48
+ selectQuery: inputQuery(selectQueryTemplate),
49
+ upsertQuery: inputQuery(upsertQueryTemplate),
50
+ copyPath: () => {
69
51
  navigator.clipboard
70
52
  .writeText(path)
71
53
  .then(() => {
@@ -82,34 +64,52 @@ export const getActions = (
82
64
  type: 'error',
83
65
  });
84
66
  });
85
- };
86
-
87
- const onOpenPreviewClick = () => {
67
+ },
68
+ openPreview: () => {
88
69
  dispatch(setShowPreview(true));
89
- switchTabToQuery();
70
+ dispatch(setTopLevelTab(TenantGeneralTabsIds.query))
90
71
  setActivePath(path);
91
- };
72
+ },
73
+ };
74
+ };
92
75
 
93
- const copyItem = {text: 'Copy path', action: onCopyPathClick};
76
+ export const getActions = (
77
+ dispatch: Dispatch<any>,
78
+ setActivePath: (path: string) => void,
79
+ ) =>
80
+ (path: string, type: NavigationTreeNodeType) => {
81
+ const actions = bindActions(path, dispatch, setActivePath);
82
+ const copyItem = {text: 'Copy path', action: actions.copyPath};
94
83
 
95
- return type === 'table'
96
- ? [
97
- [
98
- {text: 'Open preview', action: onOpenPreviewClick},
99
- copyItem,
100
- ],
101
- [
102
- {text: 'Alter table...', action: onAlterTableClick},
103
- {text: 'Select query...', action: onSelectQueryClick},
104
- {text: 'Upsert query...', action: onUpsertQueryClick},
105
- ],
106
- ]
107
- : [
108
- [
84
+ switch (type) {
85
+ case 'database':
86
+ case 'directory':
87
+ return [
88
+ [
89
+ copyItem,
90
+ ],
91
+ [
92
+ {text: 'Create table...', action: actions.createTable},
93
+ ],
94
+ ];
95
+ case 'table':
96
+ return [
97
+ [
98
+ {text: 'Open preview', action: actions.openPreview},
99
+ copyItem,
100
+ ],
101
+ [
102
+ {text: 'Alter table...', action: actions.alterTable},
103
+ {text: 'Select query...', action: actions.selectQuery},
104
+ {text: 'Upsert query...', action: actions.upsertQuery},
105
+ ],
106
+ ];
107
+ case 'index_table':
108
+ return [
109
109
  copyItem,
110
- ],
111
- [
112
- {text: 'Create table...', action: onCreateTableClick},
113
- ],
114
- ];
110
+ ];
111
+ case 'index':
112
+ default:
113
+ return [];
114
+ }
115
115
  };
@@ -153,6 +153,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
153
153
  database,
154
154
  action,
155
155
  stats,
156
+ timeout: 600000,
156
157
  });
157
158
  }
158
159
  getExplainQuery(query, database) {
@@ -160,6 +161,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
160
161
  query,
161
162
  database,
162
163
  action: 'explain',
164
+ timeout: 600000,
163
165
  });
164
166
  }
165
167
  getExplainQueryAst(query, database) {
@@ -167,6 +169,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
167
169
  query,
168
170
  database,
169
171
  action: 'explain-ast',
172
+ timeout: 600000,
170
173
  });
171
174
  }
172
175
  getHotKeys(path, enableSampling) {
@@ -91,7 +91,7 @@ export enum EPathType {
91
91
  EPathTypeTableIndex = 'EPathTypeTableIndex',
92
92
  }
93
93
 
94
- enum EPathSubType {
94
+ export enum EPathSubType {
95
95
  EPathSubTypeEmpty = 'EPathSubTypeEmpty',
96
96
  EPathSubTypeSyncIndexImplTable = 'EPathSubTypeSyncIndexImplTable',
97
97
  EPathSubTypeAsyncIndexImplTable = 'EPathSubTypeAsyncIndexImplTable',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "1.8.0",
3
+ "version": "1.8.3",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -40,7 +40,7 @@
40
40
  "reselect": "4.0.0",
41
41
  "sass": "1.32.8",
42
42
  "web-vitals": "1.1.2",
43
- "ydb-ui-components": "2.1.0"
43
+ "ydb-ui-components": "2.2.0"
44
44
  },
45
45
  "scripts": {
46
46
  "start": "react-app-rewired start",