From dcebd31df97548527b7ba829995e65884de4b79e Mon Sep 17 00:00:00 2001 From: mufazalov Date: Thu, 13 Jun 2024 10:39:28 +0300 Subject: [PATCH] feat(Overview): add view info --- package-lock.json | 10 ++-- package.json | 2 +- .../Tenant/Diagnostics/Overview/Overview.tsx | 5 +- src/containers/Tenant/Info/View/View.scss | 13 ++++ src/containers/Tenant/Info/View/View.tsx | 60 +++++++++++++++++++ src/containers/Tenant/Info/i18n/en.json | 4 +- src/containers/Tenant/Info/i18n/index.ts | 3 +- src/containers/Tenant/Info/i18n/ru.json | 8 --- 8 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 src/containers/Tenant/Info/View/View.scss create mode 100644 src/containers/Tenant/Info/View/View.tsx delete mode 100644 src/containers/Tenant/Info/i18n/ru.json diff --git a/package-lock.json b/package-lock.json index 441d9e6e1..9b4d30453 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@bem-react/classname": "^1.6.0", "@gravity-ui/axios-wrapper": "^1.4.1", "@gravity-ui/chartkit": "^5.5.0", - "@gravity-ui/components": "^3.4.1", + "@gravity-ui/components": "^3.6.2", "@gravity-ui/date-utils": "^2.4.0", "@gravity-ui/i18n": "^1.5.0", "@gravity-ui/icons": "^2.9.1", @@ -3560,9 +3560,9 @@ } }, "node_modules/@gravity-ui/components": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@gravity-ui/components/-/components-3.4.1.tgz", - "integrity": "sha512-fH/N8IIi6LaSvl2rSpO+Q2X+EKJi8FbP7jFrUA8dmGJqryx1ddJszYFAik5TxFnxhOU9j9fYvwVe8ulLfd4lfQ==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/@gravity-ui/components/-/components-3.6.2.tgz", + "integrity": "sha512-b9Pcw23g2vb9CMc7xMs/FwWpK4tWkhA7VUwgBw6izE24gMFbz6TcsQHwmPrKe1HgoyX4QYd5gpv8hh1yGLsfYA==", "dependencies": { "@bem-react/classname": "^1.6.0", "@gravity-ui/date-utils": "^2.1.0", @@ -3573,7 +3573,7 @@ "universal-cookie": "^6.1.3" }, "peerDependencies": { - "@gravity-ui/uikit": "^6.0.0", + "@gravity-ui/uikit": "^6.13.0", "react": "^16.0.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0" } diff --git a/package.json b/package.json index d78dcebd3..cc441368a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@bem-react/classname": "^1.6.0", "@gravity-ui/axios-wrapper": "^1.4.1", "@gravity-ui/chartkit": "^5.5.0", - "@gravity-ui/components": "^3.4.1", + "@gravity-ui/components": "^3.6.2", "@gravity-ui/date-utils": "^2.4.0", "@gravity-ui/i18n": "^1.5.0", "@gravity-ui/icons": "^2.9.1", diff --git a/src/containers/Tenant/Diagnostics/Overview/Overview.tsx b/src/containers/Tenant/Diagnostics/Overview/Overview.tsx index 9037fca05..32f272084 100644 --- a/src/containers/Tenant/Diagnostics/Overview/Overview.tsx +++ b/src/containers/Tenant/Diagnostics/Overview/Overview.tsx @@ -13,6 +13,7 @@ import {EPathType} from '../../../../types/api/schema'; import {useTypedSelector} from '../../../../utils/hooks'; import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource'; import {ExternalTableInfo} from '../../Info/ExternalTable/ExternalTable'; +import {ViewInfo} from '../../Info/View/View'; import { isColumnEntityType, isEntityWithMergedImplementation, @@ -91,7 +92,7 @@ function Overview({type, tenantName}: OverviewProps) { [EPathType.EPathTypePersQueueGroup]: () => , [EPathType.EPathTypeExternalTable]: () => , [EPathType.EPathTypeExternalDataSource]: () => , - [EPathType.EPathTypeView]: undefined, + [EPathType.EPathTypeView]: () => , [EPathType.EPathTypeReplication]: () => , }; @@ -110,7 +111,7 @@ function Overview({type, tenantName}: OverviewProps) { return ; } - return
{renderContent()}
; + return renderContent(); } export default Overview; diff --git a/src/containers/Tenant/Info/View/View.scss b/src/containers/Tenant/Info/View/View.scss new file mode 100644 index 000000000..df0a43606 --- /dev/null +++ b/src/containers/Tenant/Info/View/View.scss @@ -0,0 +1,13 @@ +@import '../../../../styles/mixins.scss'; + +.ydb-view-info { + @include flex-container(); + + &__properties-list { + max-width: calc(100% - 40px); + } + + &__title { + @include info-viewer-title(); + } +} diff --git a/src/containers/Tenant/Info/View/View.tsx b/src/containers/Tenant/Info/View/View.tsx new file mode 100644 index 000000000..5667da0be --- /dev/null +++ b/src/containers/Tenant/Info/View/View.tsx @@ -0,0 +1,60 @@ +import type {DefinitionListItem} from '@gravity-ui/components'; +import {DefinitionList} from '@gravity-ui/components'; +import {Text} from '@gravity-ui/uikit'; + +import {ResponseError} from '../../../../components/Errors/ResponseError'; +import type {TEvDescribeSchemeResult} from '../../../../types/api/schema'; +import {cn} from '../../../../utils/cn'; +import {useTypedSelector} from '../../../../utils/hooks'; +import {getEntityName} from '../../utils'; +import i18n from '../i18n'; + +const b = cn('ydb-view-info'); + +import './View.scss'; + +const prepareViewItems = (data: TEvDescribeSchemeResult): DefinitionListItem[] => { + const queryText = data.PathDescription?.ViewDescription?.QueryText; + + return [ + { + name: i18n('view.query-text'), + copyText: queryText, + content: ( + + {queryText} + + ), + }, + ]; +}; + +interface ViewInfoProps { + data?: TEvDescribeSchemeResult; +} + +export function ViewInfo({data}: ViewInfoProps) { + const entityName = getEntityName(data?.PathDescription); + + const {error: schemaError} = useTypedSelector((state) => state.schema); + + if (schemaError) { + return ; + } + + if (!data) { + return
No {entityName} data
; + } + + return ( +
+
{entityName}
+ +
+ ); +} diff --git a/src/containers/Tenant/Info/i18n/en.json b/src/containers/Tenant/Info/i18n/en.json index f58df7231..f25d7a013 100644 --- a/src/containers/Tenant/Info/i18n/en.json +++ b/src/containers/Tenant/Info/i18n/en.json @@ -4,5 +4,7 @@ "external-objects.location": "Location", "external-objects.auth-method": "Auth Method", "external-objects.auth-method.none": "None", - "external-objects.auth-method.service-account": "Service Account" + "external-objects.auth-method.service-account": "Service Account", + + "view.query-text": "Query Text" } diff --git a/src/containers/Tenant/Info/i18n/index.ts b/src/containers/Tenant/Info/i18n/index.ts index eedac2f26..7f9d3e3e5 100644 --- a/src/containers/Tenant/Info/i18n/index.ts +++ b/src/containers/Tenant/Info/i18n/index.ts @@ -1,8 +1,7 @@ import {registerKeysets} from '../../../../utils/i18n'; import en from './en.json'; -import ru from './ru.json'; const COMPONENT = 'ydb-tenant-objects-info'; -export default registerKeysets(COMPONENT, {ru, en}); +export default registerKeysets(COMPONENT, {en}); diff --git a/src/containers/Tenant/Info/i18n/ru.json b/src/containers/Tenant/Info/i18n/ru.json deleted file mode 100644 index e16a208f5..000000000 --- a/src/containers/Tenant/Info/i18n/ru.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "external-objects.source-type": "Тип источника", - "external-objects.data-source": "Источник", - "external-objects.location": "Расположение", - "external-objects.auth-method": "Авторизация", - "external-objects.auth-method.none": "Нет", - "external-objects.auth-method.service-account": "Сервисный аккаунт" -}