Skip to content

Commit 8103bb6

Browse files
committed
fix(Tenant): support name param
1 parent 25b7bf9 commit 8103bb6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/containers/Tenant/Tenant.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,24 @@ interface TenantProps {
4343
additionalNodesProps?: AdditionalNodesProps;
4444
}
4545

46+
// eslint-disable-next-line complexity
4647
export function Tenant(props: TenantProps) {
4748
const [summaryVisibilityState, dispatchSummaryVisibilityAction] = React.useReducer(
4849
paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED),
4950
undefined,
5051
getTenantSummaryState,
5152
);
5253

53-
const {database, schema} = useTenantQueryParams();
54+
// TODO: name is used together with database to keep old links valid, do not remove
55+
const {database: queryDatabase, schema, name, handleDatabaseChange} = useTenantQueryParams();
56+
57+
React.useEffect(() => {
58+
if (name && !queryDatabase) {
59+
handleDatabaseChange(name);
60+
}
61+
}, [queryDatabase, name, handleDatabaseChange]);
62+
63+
const database = queryDatabase ?? name;
5464

5565
if (!database) {
5666
throw new Error('Tenant name is not defined');

src/containers/Tenant/useTenantQueryParams.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import React from 'react';
33
import {BooleanParam, StringParam, useQueryParams} from 'use-query-params';
44

55
export function useTenantQueryParams() {
6-
const [{showHealthcheck, database, schema, view, issuesFilter}, setQueryParams] =
6+
const [{showHealthcheck, database, schema, view, issuesFilter, name}, setQueryParams] =
77
useQueryParams({
88
showHealthcheck: BooleanParam,
99
database: StringParam,
1010
schema: StringParam,
1111
view: StringParam,
1212
issuesFilter: StringParam,
13+
name: StringParam,
1314
});
1415
const handleShowHealthcheckChange = React.useCallback(
1516
(value?: boolean) => {
@@ -55,5 +56,6 @@ export function useTenantQueryParams() {
5556
handleHealthcheckViewChange,
5657
issuesFilter,
5758
handleIssuesFilterChange,
59+
name,
5860
};
5961
}

0 commit comments

Comments
 (0)