diff --git a/package-lock.json b/package-lock.json index 2c9b715576..0fb294953e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,7 @@ "use-query-params": "^2.2.1", "uuid": "^10.0.0", "web-vitals": "^1.1.2", - "ydb-ui-components": "^5.1.0", + "ydb-ui-components": "^5.1.1", "zod": "^3.24.1" }, "devDependencies": { @@ -29853,9 +29853,10 @@ } }, "node_modules/ydb-ui-components": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ydb-ui-components/-/ydb-ui-components-5.1.0.tgz", - "integrity": "sha512-bjn4cqBvc7RJ9/B4gdvb/+RYSOkYy0twhRtpnNXq88Yzz5dUAWxMZQBo6wFAEDMgmxXbEnVM0iPh8cG/paRbSQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/ydb-ui-components/-/ydb-ui-components-5.1.1.tgz", + "integrity": "sha512-4AsYjFHIcI/swCGrhFFdUCmka6fR6TyD2zeDI1It7CoKc59Br2jmsRVZWm0ksSveRq6GRhkxrzBah6MI3g/5Og==", + "license": "MIT", "dependencies": { "@bem-react/classname": "^1.6.0", "react-list": "^0.8.17", diff --git a/package.json b/package.json index 0fa1c98f88..c7fc78088e 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "use-query-params": "^2.2.1", "uuid": "^10.0.0", "web-vitals": "^1.1.2", - "ydb-ui-components": "^5.1.0", + "ydb-ui-components": "^5.1.1", "zod": "^3.24.1" }, "scripts": { diff --git a/src/containers/Tenant/ObjectSummary/SchemaTree/SchemaTree.tsx b/src/containers/Tenant/ObjectSummary/SchemaTree/SchemaTree.tsx index dd4f86b7dd..c481f81516 100644 --- a/src/containers/Tenant/ObjectSummary/SchemaTree/SchemaTree.tsx +++ b/src/containers/Tenant/ObjectSummary/SchemaTree/SchemaTree.tsx @@ -60,50 +60,56 @@ export function SchemaTree(props: SchemaTreeProps) { ? 'database' : mapPathTypeToNavigationTreeType(rootType); - const fetchPath = async (path: string) => { - let schemaData: TEvDescribeSchemeResult | undefined; - do { - const promise = dispatch( - schemaApi.endpoints.getSchema.initiate( - {path, database, databaseFullPath}, - {forceRefetch: true}, - ), - ); - const {data, originalArgs} = await promise; - promise.unsubscribe(); - // Check if the result from the current request is received. rtk-query may skip the current request and - // return data from a parallel request, due to the same cache key. - if (originalArgs?.path === path) { - schemaData = data?.[path]; - break; + const fetchPath = React.useCallback( + async (path: string) => { + let schemaData: TEvDescribeSchemeResult | undefined; + + do { + const promise = dispatch( + schemaApi.endpoints.getSchema.initiate( + {path, database, databaseFullPath}, + {forceRefetch: true}, + ), + ); + + const {data, originalArgs} = await promise; + promise.unsubscribe(); + // Check if the result from the current request is reonceived. rtk-query may skip the current request and + // return data from a parallel request, due to the same cache key. + if (originalArgs?.path === path) { + schemaData = data?.[path]; + break; + } + // eslint-disable-next-line no-constant-condition + } while (true); + + if (!schemaData) { + throw new Error(`No describe data about path ${path}`); } - // eslint-disable-next-line no-constant-condition - } while (true); - if (!schemaData) { - throw new Error(`no describe data about path ${path}`); - } - const {PathDescription: {Children = []} = {}} = schemaData; - - const childItems = Children.map((childData) => { - const {Name = '', PathType, PathSubType, ChildrenExist} = childData; - - const isChildless = - isChildlessPathType(PathType, PathSubType) || - (valueIsDefined(ChildrenExist) && !ChildrenExist); - - return { - name: Name, - type: mapPathTypeToNavigationTreeType(PathType, PathSubType), - // FIXME: should only be explicitly set to true for tables with indexes - // at the moment of writing there is no property to determine this, fix later - expandable: !isChildless, - meta: {subType: PathSubType}, - }; - }); - - return childItems; - }; + const {PathDescription: {Children = []} = {}} = schemaData; + + const childItems = Children.map((childData) => { + const {Name = '', PathType, PathSubType, ChildrenExist} = childData; + + const isChildless = + isChildlessPathType(PathType, PathSubType) || + (valueIsDefined(ChildrenExist) && !ChildrenExist); + + return { + name: Name, + type: mapPathTypeToNavigationTreeType(PathType, PathSubType), + // FIXME: should only be explicitly set to true for tables with indexes + // at the moment of writing there is no property to determine this, fix later + expandable: !isChildless, + meta: {subType: PathSubType}, + }; + }); + + return childItems; + }, + [dispatch, database, databaseFullPath], + ); React.useEffect(() => { // if the cached path is not in the current tree, show root if (!currentPath?.startsWith(databaseFullPath)) {