diff --git a/src/components/LinkToSchemaObject/LinkToSchemaObject.tsx b/src/components/LinkToSchemaObject/LinkToSchemaObject.tsx index d8f2a7d07..92a44f8a8 100644 --- a/src/components/LinkToSchemaObject/LinkToSchemaObject.tsx +++ b/src/components/LinkToSchemaObject/LinkToSchemaObject.tsx @@ -2,7 +2,7 @@ import type {Location} from 'history'; import {Link, type LinkProps} from '@gravity-ui/uikit'; -import {getSchemaObjectPath, parseQuery} from '../../routes'; +import {createExternalUILink, parseQuery} from '../../routes'; interface LinkToSchemaObjectProps extends LinkProps { path: string; @@ -11,7 +11,7 @@ interface LinkToSchemaObjectProps extends LinkProps { export function LinkToSchemaObject({path, location, ...props}: LinkToSchemaObjectProps) { const queryParams = parseQuery(location); - const pathToSchemaObject = getSchemaObjectPath({ + const pathToSchemaObject = createExternalUILink({ ...queryParams, schema: path, }); diff --git a/src/containers/Tenant/Info/ExternalTable/ExternalTable.tsx b/src/containers/Tenant/Info/ExternalTable/ExternalTable.tsx index f3dafcc18..1544fd2d9 100644 --- a/src/containers/Tenant/Info/ExternalTable/ExternalTable.tsx +++ b/src/containers/Tenant/Info/ExternalTable/ExternalTable.tsx @@ -3,7 +3,7 @@ import block from 'bem-cn-lite'; import type {TEvDescribeSchemeResult} from '../../../../types/api/schema'; import {useTypedSelector} from '../../../../utils/hooks'; -import {getSchemaObjectPath, parseQuery} from '../../../../routes'; +import {createExternalUILink, parseQuery} from '../../../../routes'; import {formatCommonItem} from '../../../../components/InfoViewer/formatters'; import {InfoViewer, InfoViewerItem} from '../../../../components/InfoViewer'; import {ExternalLinkWithIcon} from '../../../../components/ExternalLinkWithIcon/ExternalLinkWithIcon'; @@ -72,7 +72,7 @@ const ExternalTable = ({data, prepareData}: ExternalTableProps) => { const location = useLocation(); const query = parseQuery(location); - const pathToDataSource = getSchemaObjectPath({ + const pathToDataSource = createExternalUILink({ ...query, schema: data?.PathDescription?.ExternalTableDescription?.DataSourcePath, }); diff --git a/src/routes.ts b/src/routes.ts index 0ed3ce352..98975bad1 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -51,7 +51,8 @@ export function createHref( // embedded version could be located in some folder (e.g. host/some_folder/app_router_path) // window.location has the full pathname, while location from router ignores path to project -export const getSchemaObjectPath = (query = {}) => +// this navigation assumes page reloading +export const createExternalUILink = (query = {}) => createHref(window.location.pathname, undefined, query); export default routes;