Skip to content

Commit 4b34e05

Browse files
authored
fix: pass database param to all handlers inside DB (#1066)
1 parent 96976aa commit 4b34e05

File tree

22 files changed

+147
-104
lines changed

22 files changed

+147
-104
lines changed

src/containers/Heatmap/Heatmap.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ const b = cn('heatmap');
2121
const COLORS_RANGE = getColorRange(COLORS_RANGE_SIZE);
2222

2323
interface HeatmapProps {
24+
database: string;
2425
path: string;
2526
}
2627

27-
export const Heatmap = ({path}: HeatmapProps) => {
28+
export const Heatmap = ({path, database}: HeatmapProps) => {
2829
const dispatch = useTypedDispatch();
2930

3031
const itemsContainer = React.createRef<HTMLDivElement>();
3132

3233
const [autoRefreshInterval] = useAutoRefreshInterval();
3334

3435
const {currentData, isFetching, error} = heatmapApi.useGetHeatmapTabletsInfoQuery(
35-
{path},
36+
{path, database},
3637
{pollingInterval: autoRefreshInterval},
3738
);
3839

src/containers/Tenant/Acl/Acl.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ function getOwnerItem(owner?: string): DefinitionListItem[] {
127127
];
128128
}
129129

130-
export const Acl = ({path}: {path: string}) => {
131-
const {currentData, isFetching, error} = schemaAclApi.useGetSchemaAclQuery({path});
130+
export const Acl = ({path, database}: {path: string; database: string}) => {
131+
const {currentData, isFetching, error} = schemaAclApi.useGetSchemaAclQuery({path, database});
132132

133133
const loading = isFetching && !currentData;
134134

src/containers/Tenant/Diagnostics/Describe/Describe.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,32 @@ const expandMap = new Map();
2020

2121
interface IDescribeProps {
2222
path: string;
23+
database: string;
2324
type?: EPathType;
2425
}
2526

26-
const Describe = ({path, type}: IDescribeProps) => {
27+
const Describe = ({path, database, type}: IDescribeProps) => {
2728
const [autoRefreshInterval] = useAutoRefreshInterval();
2829

2930
const isEntityWithMergedImpl = isEntityWithMergedImplementation(type);
3031

3132
const mergedChildrenPaths = useTypedSelector(
32-
(state) => selectSchemaMergedChildrenPaths(state, path, type),
33+
(state) => selectSchemaMergedChildrenPaths(state, path, type, database),
3334
shallowEqual,
3435
);
3536

36-
let paths: string[] | typeof skipToken = skipToken;
37+
let paths: string[] = [];
3738
if (!isEntityWithMergedImpl) {
3839
paths = [path];
3940
} else if (mergedChildrenPaths) {
4041
paths = [path, ...mergedChildrenPaths];
4142
}
42-
const {currentData, isFetching, error} = describeApi.useGetDescribeQuery(paths, {
43-
pollingInterval: autoRefreshInterval,
44-
});
43+
const {currentData, isFetching, error} = describeApi.useGetDescribeQuery(
44+
paths.length ? {paths, database} : skipToken,
45+
{
46+
pollingInterval: autoRefreshInterval,
47+
},
48+
);
4549
const loading = isFetching && currentData === undefined;
4650
const currentDescribe = currentData;
4751

src/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ function DetailedOverview(props: DetailedOverviewProps) {
3636

3737
return (
3838
<div className={b()}>
39-
{isTenant ? renderTenantOverview() : <Overview type={type} path={path} />}
39+
{isTenant ? (
40+
renderTenantOverview()
41+
) : (
42+
<Overview type={type} path={path} database={tenantName} />
43+
)}
4044
</div>
4145
);
4246
}

src/containers/Tenant/Diagnostics/Diagnostics.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ function Diagnostics(props: DiagnosticsProps) {
116116
return <Network tenantName={tenantName} />;
117117
}
118118
case TENANT_DIAGNOSTICS_TABS_IDS.describe: {
119-
return <Describe path={path} type={type} />;
119+
return <Describe path={path} database={tenantName} type={type} />;
120120
}
121121
case TENANT_DIAGNOSTICS_TABS_IDS.hotKeys: {
122-
return <HotKeys path={path} />;
122+
return <HotKeys path={path} database={tenantName} />;
123123
}
124124
case TENANT_DIAGNOSTICS_TABS_IDS.graph: {
125-
return <Heatmap path={path} />;
125+
return <Heatmap path={path} database={tenantName} />;
126126
}
127127
case TENANT_DIAGNOSTICS_TABS_IDS.consumers: {
128128
return <Consumers path={path} type={type} />;

src/containers/Tenant/Diagnostics/HotKeys/HotKeys.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ const getHotKeysColumns = (keyColumnsIds: string[] = []): Column<HotKey>[] => {
5454
};
5555

5656
interface HotKeysProps {
57+
database: string;
5758
path: string;
5859
}
5960

60-
export function HotKeys({path}: HotKeysProps) {
61-
const {currentData: data, isFetching, error} = hotKeysApi.useGetHotKeysQuery({path});
61+
export function HotKeys({path, database}: HotKeysProps) {
62+
const {currentData: data, isFetching, error} = hotKeysApi.useGetHotKeysQuery({path, database});
6263
const loading = isFetching && data === undefined;
6364

64-
const {data: schemaData, isLoading: schemaLoading} = useGetSchemaQuery({path});
65+
const {data: schemaData, isLoading: schemaLoading} = useGetSchemaQuery({path, database});
6566

6667
const keyColumnsIds = schemaData?.PathDescription?.Table?.KeyColumnNames;
6768

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ import {TopicInfo} from './TopicInfo';
2626
interface OverviewProps {
2727
type?: EPathType;
2828
path: string;
29+
database: string;
2930
}
3031

31-
function Overview({type, path}: OverviewProps) {
32+
function Overview({type, path, database}: OverviewProps) {
3233
const [autoRefreshInterval] = useAutoRefreshInterval();
3334

3435
const isEntityWithMergedImpl = isEntityWithMergedImplementation(type);
3536

3637
// shallowEqual prevents rerenders when new schema data is loaded
3738
const mergedChildrenPaths = useTypedSelector(
38-
(state) => selectSchemaMergedChildrenPaths(state, path, type),
39+
(state) => selectSchemaMergedChildrenPaths(state, path, type, database),
3940
shallowEqual,
4041
);
4142

42-
let paths: string[] | typeof skipToken = skipToken;
43+
let paths: string[] = [];
4344
if (!isEntityWithMergedImpl) {
4445
paths = [path];
4546
} else if (mergedChildrenPaths) {
@@ -50,13 +51,13 @@ function Overview({type, path}: OverviewProps) {
5051
currentData,
5152
isFetching,
5253
error: overviewError,
53-
} = overviewApi.useGetOverviewQuery(paths, {
54+
} = overviewApi.useGetOverviewQuery(paths.length ? {paths, database} : skipToken, {
5455
pollingInterval: autoRefreshInterval,
5556
});
5657
const overviewLoading = isFetching && currentData === undefined;
5758
const {data: rawData, additionalData} = currentData || {};
5859

59-
const {error: schemaError} = useGetSchemaQuery({path});
60+
const {error: schemaError} = useGetSchemaQuery({path, database});
6061

6162
const entityLoading = overviewLoading;
6263
const entityNotReady = isEntityWithMergedImpl && !mergedChildrenPaths;

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function TenantOverview({
4646
const tenantType = mapDatabaseTypeToDBName(Type);
4747

4848
// FIXME: remove after correct data is added to tenantInfo
49-
const {data: tenantSchemaData} = useGetSchemaQuery({path: tenantName});
49+
const {data: tenantSchemaData} = useGetSchemaQuery({path: tenantName, database: tenantName});
5050
const {Tables, Topics} =
5151
tenantSchemaData?.PathDescription?.DomainDescription?.DiskSpaceUsage || {};
5252

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function ObjectSummary({
9292
ignoreQueryPrefix: true,
9393
});
9494

95-
const {data: currentObjectData} = useGetSchemaQuery({path});
95+
const {data: currentObjectData} = useGetSchemaQuery({path, database: tenantName});
9696
const currentSchemaData = currentObjectData?.PathDescription?.Self;
9797

9898
React.useEffect(() => {
@@ -282,7 +282,7 @@ export function ObjectSummary({
282282
const renderTabContent = () => {
283283
switch (summaryTab) {
284284
case TENANT_SUMMARY_TABS_IDS.acl: {
285-
return <Acl path={path} />;
285+
return <Acl path={path} database={tenantName} />;
286286
}
287287
case TENANT_SUMMARY_TABS_IDS.schema: {
288288
return <SchemaViewer type={type} path={path} tenantName={tenantName} />;
@@ -403,6 +403,7 @@ export function ObjectSummary({
403403
function ObjectTree({tenantName, path}: {tenantName: string; path?: string}) {
404404
const {data: tenantData = {}, isLoading} = useGetSchemaQuery({
405405
path: tenantName,
406+
database: tenantName,
406407
});
407408
const pathData = tenantData?.PathDescription?.Self;
408409

src/containers/Tenant/Schema/CreateDirectoryDialog/CreateDirectoryDialog.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ const b = cn('ydb-schema-create-directory-dialog');
1313

1414
const relativePathInputId = 'relativePath';
1515

16-
interface SchemaTreeProps {
16+
interface CreateDirectoryDialogProps {
1717
open: boolean;
1818
onClose: VoidFunction;
19+
database: string;
1920
parentPath: string;
2021
onSuccess: (value: string) => void;
2122
}
@@ -30,7 +31,13 @@ function validateRelativePath(value: string) {
3031
return '';
3132
}
3233

33-
export function CreateDirectoryDialog({open, onClose, parentPath, onSuccess}: SchemaTreeProps) {
34+
export function CreateDirectoryDialog({
35+
open,
36+
onClose,
37+
database,
38+
parentPath,
39+
onSuccess,
40+
}: CreateDirectoryDialogProps) {
3441
const [validationError, setValidationError] = React.useState('');
3542
const [relativePath, setRelativePath] = React.useState('');
3643
const [create, response] = schemaApi.useCreateDirectoryMutation();
@@ -54,7 +61,7 @@ export function CreateDirectoryDialog({open, onClose, parentPath, onSuccess}: Sc
5461
const handleSubmit = () => {
5562
const path = `${parentPath}/${relativePath}`;
5663
create({
57-
database: parentPath,
64+
database,
5865
path,
5966
})
6067
.unwrap()

src/containers/Tenant/Schema/SchemaTree/SchemaTree.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export function SchemaTree(props: SchemaTreeProps) {
3636
let schemaData: TEvDescribeSchemeResult | undefined;
3737
do {
3838
const promise = dispatch(
39-
schemaApi.endpoints.getSchema.initiate({path}, {forceRefetch: true}),
39+
schemaApi.endpoints.getSchema.initiate(
40+
{path, database: rootPath},
41+
{forceRefetch: true},
42+
),
4043
);
4144
const {data, originalArgs} = await promise;
4245
promise.unsubscribe();
@@ -94,6 +97,7 @@ export function SchemaTree(props: SchemaTreeProps) {
9497
<CreateDirectoryDialog
9598
onClose={handleCloseDialog}
9699
open={createDirectoryOpen}
100+
database={rootPath}
97101
parentPath={parentPath}
98102
onSuccess={handleSuccessSubmit}
99103
/>

src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface SchemaViewerProps {
3737
}
3838

3939
export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaViewerProps) => {
40-
const {data: schemaData, isLoading: loading} = useGetSchemaQuery({path});
40+
const {data: schemaData, isLoading: loading} = useGetSchemaQuery({path, database: tenantName});
4141

4242
const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;
4343

src/containers/Tenant/Tenant.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function Tenant(props: TenantProps) {
7474

7575
const path = schema ?? tenantName;
7676

77-
const {data: currentItem, error, isLoading} = useGetSchemaQuery({path});
77+
const {data: currentItem, error, isLoading} = useGetSchemaQuery({path, database: tenantName});
7878
const {PathType: currentPathType, PathSubType: currentPathSubType} =
7979
currentItem?.PathDescription?.Self || {};
8080

0 commit comments

Comments
 (0)