|
1 | 1 | import type {NavigationTreeNodeType} from 'ydb-ui-components'; |
| 2 | + |
2 | 3 | import {EPathSubType, EPathType} from '../../../types/api/schema'; |
| 4 | +import {ETenantType} from '../../../types/api/tenant'; |
3 | 5 |
|
4 | 6 | // this file contains verbose mappings that are typed in a way that ensures |
5 | 7 | // correctness when a new node type or a new path type is added |
@@ -41,6 +43,49 @@ export const mapPathTypeToNavigationTreeType = ( |
41 | 43 |
|
42 | 44 | // ==================== |
43 | 45 |
|
| 46 | +const pathSubTypeToEntityName: Record<EPathSubType, string | undefined> = { |
| 47 | + [EPathSubType.EPathSubTypeSyncIndexImplTable]: 'Secondary Index Table', |
| 48 | + [EPathSubType.EPathSubTypeAsyncIndexImplTable]: 'Secondary Index Table', |
| 49 | + |
| 50 | + [EPathSubType.EPathSubTypeStreamImpl]: undefined, |
| 51 | + [EPathSubType.EPathSubTypeEmpty]: undefined, |
| 52 | +}; |
| 53 | + |
| 54 | +const pathTypeToEntityName: Record<EPathType, string | undefined> = { |
| 55 | + [EPathType.EPathTypeInvalid]: undefined, |
| 56 | + |
| 57 | + [EPathType.EPathTypeSubDomain]: 'Database', |
| 58 | + [EPathType.EPathTypeExtSubDomain]: 'Database', |
| 59 | + |
| 60 | + [EPathType.EPathTypeDir]: 'Directory', |
| 61 | + [EPathType.EPathTypeTable]: 'Table', |
| 62 | + [EPathType.EPathTypeTableIndex]: 'Secondary Index', |
| 63 | + [EPathType.EPathTypeColumnStore]: 'Tablestore', |
| 64 | + [EPathType.EPathTypeColumnTable]: 'Columntable', |
| 65 | + [EPathType.EPathTypeCdcStream]: 'Changefeed', |
| 66 | + [EPathType.EPathTypePersQueueGroup]: 'Topic', |
| 67 | +}; |
| 68 | + |
| 69 | +export const mapPathTypeToEntityName = ( |
| 70 | + type?: EPathType, |
| 71 | + subType?: EPathSubType, |
| 72 | +): string | undefined => |
| 73 | + (subType && pathSubTypeToEntityName[subType]) || (type && pathTypeToEntityName[type]); |
| 74 | + |
| 75 | +// ==================== |
| 76 | + |
| 77 | +const databaseTypeToDBName: Record<ETenantType, string | undefined> = { |
| 78 | + [ETenantType.UnknownTenantType]: 'Database', |
| 79 | + [ETenantType.Domain]: 'Cluster Root', |
| 80 | + [ETenantType.Dedicated]: 'Dedicated Database', |
| 81 | + [ETenantType.Shared]: 'Shared Database', |
| 82 | + [ETenantType.Serverless]: 'Serverless Database', |
| 83 | +}; |
| 84 | + |
| 85 | +export const mapDatabaseTypeToDBName = (type?: ETenantType) => type && databaseTypeToDBName[type]; |
| 86 | + |
| 87 | +// ==================== |
| 88 | + |
44 | 89 | const pathTypeToIsTable: Record<EPathType, boolean> = { |
45 | 90 | [EPathType.EPathTypeTable]: true, |
46 | 91 | [EPathType.EPathTypeColumnTable]: true, |
|
0 commit comments