Skip to content

Commit 3cd946a

Browse files
committed
fix(Tenant): own context actions for table indexes
1 parent 23e70a1 commit 3cd946a

File tree

4 files changed

+48
-25
lines changed

4 files changed

+48
-25
lines changed

src/containers/Tenant/Schema/SchemaTree/SchemaTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function SchemaTree(props: SchemaTreeProps) {
3232
{concurrentId: `NavigationTree.getSchema|${path}`},
3333
)
3434
.then(({PathDescription: {Children = []} = {}}) => {
35-
return Children.map(({Name = '', PathType}) => ({
35+
return Children.map(({Name = '', PathType, PathSubType}) => ({
3636
name: Name,
37-
type: mapPathTypeToNavigationTreeType(PathType),
37+
type: mapPathTypeToNavigationTreeType(PathType, PathSubType),
3838
// FIXME: should only be explicitly set to true for tables with indexes
3939
// at the moment of writing there is no property to determine this, fix later
4040
expandable: true,

src/containers/Tenant/utils/schema.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
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+
};
313

414
export const mapPathTypeToNavigationTreeType = (
515
type: EPathType = EPathType.EPathTypeDir,
16+
subType?: EPathSubType,
617
defaultType: NavigationTreeNodeType = 'directory'
718
): NavigationTreeNodeType => {
819
switch (type) {
920
case EPathType.EPathTypeSubDomain:
1021
return 'database';
1122
case EPathType.EPathTypeTable:
1223
case EPathType.EPathTypeColumnTable:
13-
return 'table';
24+
return mapTablePathSubTypeToNavigationTreeType(subType);
1425
case EPathType.EPathTypeDir:
1526
case EPathType.EPathTypeColumnStore:
16-
case EPathType.EPathTypeTableIndex:
1727
return 'directory';
28+
case EPathType.EPathTypeTableIndex:
29+
return 'index';
1830
default:
1931
return defaultType;
2032
}

src/containers/Tenant/utils/schemaActions.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,35 @@ export const getActions = (
8181
const actions = bindActions(path, dispatch, setActivePath);
8282
const copyItem = {text: 'Copy path', action: actions.copyPath};
8383

84-
return type === 'table'
85-
? [
86-
[
87-
{text: 'Open preview', action: actions.openPreview},
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 [
88109
copyItem,
89-
],
90-
[
91-
{text: 'Alter table...', action: actions.alterTable},
92-
{text: 'Select query...', action: actions.selectQuery},
93-
{text: 'Upsert query...', action: actions.upsertQuery},
94-
],
95-
]
96-
: [
97-
[
98-
copyItem,
99-
],
100-
[
101-
{text: 'Create table...', action: actions.createTable},
102-
],
103-
];
110+
];
111+
case 'index':
112+
default:
113+
return [];
114+
}
104115
};

src/types/api/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export enum EPathType {
9191
EPathTypeTableIndex = 'EPathTypeTableIndex',
9292
}
9393

94-
enum EPathSubType {
94+
export enum EPathSubType {
9595
EPathSubTypeEmpty = 'EPathSubTypeEmpty',
9696
EPathSubTypeSyncIndexImplTable = 'EPathSubTypeSyncIndexImplTable',
9797
EPathSubTypeAsyncIndexImplTable = 'EPathSubTypeAsyncIndexImplTable',

0 commit comments

Comments
 (0)