Skip to content

Commit ce1fb66

Browse files
authored
fix: support name param for database (#2426)
1 parent 5dcaaa9 commit ce1fb66

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
@@ -44,14 +44,24 @@ interface TenantProps {
4444
additionalNodesProps?: AdditionalNodesProps;
4545
}
4646

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

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

5666
if (!database) {
5767
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
@@ -4,9 +4,10 @@ import {BooleanParam, StringParam, useQueryParams} from 'use-query-params';
44

55
export function useTenantQueryParams() {
66
const [
7-
{showHealthcheck, database, schema, view, issuesFilter, showGrantAccess, aclSubject},
7+
{showHealthcheck, database, schema, view, issuesFilter, showGrantAccess, aclSubject, name},
88
setQueryParams,
99
] = useQueryParams({
10+
name: StringParam,
1011
showHealthcheck: BooleanParam,
1112
database: StringParam,
1213
schema: StringParam,
@@ -75,5 +76,6 @@ export function useTenantQueryParams() {
7576
handleIssuesFilterChange,
7677
aclSubject,
7778
handleAclSubjectChange,
79+
name,
7880
};
7981
}

0 commit comments

Comments
 (0)