Skip to content

Commit 6ca8a70

Browse files
authored
fix(LinkToSchemaObject): fix schema link (#566)
1 parent e9b918f commit 6ca8a70

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/components/LinkToSchemaObject/LinkToSchemaObject.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type {Location} from 'history';
22

33
import {Link, type LinkProps} from '@gravity-ui/uikit';
44

5-
import {parseQuery} from '../../routes';
6-
import {getTenantPath} from '../../containers/Tenant/TenantPages';
5+
import {createExternalUILink, parseQuery} from '../../routes';
76

87
interface LinkToSchemaObjectProps extends LinkProps {
98
path: string;
@@ -12,6 +11,10 @@ interface LinkToSchemaObjectProps extends LinkProps {
1211

1312
export function LinkToSchemaObject({path, location, ...props}: LinkToSchemaObjectProps) {
1413
const queryParams = parseQuery(location);
14+
const pathToSchemaObject = createExternalUILink({
15+
...queryParams,
16+
schema: path,
17+
});
1518

16-
return <Link view="normal" href={getTenantPath({...queryParams, schema: path})} {...props} />;
19+
return <Link view="normal" href={pathToSchemaObject} {...props} />;
1720
}

src/containers/Tenant/Info/ExternalTable/ExternalTable.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import block from 'bem-cn-lite';
33

44
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
55
import {useTypedSelector} from '../../../../utils/hooks';
6-
import {createHref, parseQuery} from '../../../../routes';
6+
import {createExternalUILink, parseQuery} from '../../../../routes';
77
import {formatCommonItem} from '../../../../components/InfoViewer/formatters';
88
import {InfoViewer, InfoViewerItem} from '../../../../components/InfoViewer';
99
import {ExternalLinkWithIcon} from '../../../../components/ExternalLinkWithIcon/ExternalLinkWithIcon';
@@ -72,9 +72,7 @@ const ExternalTable = ({data, prepareData}: ExternalTableProps) => {
7272
const location = useLocation();
7373
const query = parseQuery(location);
7474

75-
// embedded version could be located in some folder (e.g. host/some_folder/app_router_path)
76-
// window.location has the full pathname, while location from router ignores path to project
77-
const pathToDataSource = createHref(window.location.pathname, undefined, {
75+
const pathToDataSource = createExternalUILink({
7876
...query,
7977
schema: data?.PathDescription?.ExternalTableDescription?.DataSourcePath,
8078
});

src/routes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ export function createHref(
4949
return `${compile(route)(params)}${search}`;
5050
}
5151

52+
// embedded version could be located in some folder (e.g. host/some_folder/app_router_path)
53+
// window.location has the full pathname, while location from router ignores path to project
54+
// this navigation assumes page reloading
55+
export const createExternalUILink = (query = {}) =>
56+
createHref(window.location.pathname, undefined, query);
57+
5258
export default routes;

0 commit comments

Comments
 (0)