Skip to content

Commit b23fc79

Browse files
authored
fix: pass database to topic api handlers (#1128)
1 parent a30258f commit b23fc79

File tree

10 files changed

+47
-30
lines changed

10 files changed

+47
-30
lines changed

src/containers/Tenant/Diagnostics/Consumers/Consumers.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,25 @@ const b = cn('ydb-diagnostics-consumers');
2727

2828
interface ConsumersProps {
2929
path: string;
30+
database: string;
3031
type?: EPathType;
3132
}
3233

33-
export const Consumers = ({path, type}: ConsumersProps) => {
34+
export const Consumers = ({path, database, type}: ConsumersProps) => {
3435
const isCdcStream = isCdcStreamEntityType(type);
3536

3637
const [searchValue, setSearchValue] = React.useState('');
3738

3839
const [autoRefreshInterval] = useAutoRefreshInterval();
3940
const {currentData, isFetching, error} = topicApi.useGetTopicQuery(
40-
{path},
41+
{path, database},
4142
{pollingInterval: autoRefreshInterval},
4243
);
4344
const loading = isFetching && currentData === undefined;
44-
const consumers = useTypedSelector((state) => selectPreparedConsumersData(state, path));
45-
const topic = useTypedSelector((state) => selectPreparedTopicStats(state, path));
45+
const consumers = useTypedSelector((state) =>
46+
selectPreparedConsumersData(state, path, database),
47+
);
48+
const topic = useTypedSelector((state) => selectPreparedTopicStats(state, path, database));
4649

4750
const dataToRender = React.useMemo(() => {
4851
if (!consumers) {

src/containers/Tenant/Diagnostics/Diagnostics.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ function Diagnostics(props: DiagnosticsProps) {
125125
return <Heatmap path={path} database={tenantName} />;
126126
}
127127
case TENANT_DIAGNOSTICS_TABS_IDS.consumers: {
128-
return <Consumers path={path} type={type} />;
128+
return <Consumers path={path} database={tenantName} type={type} />;
129129
}
130130
case TENANT_DIAGNOSTICS_TABS_IDS.partitions: {
131-
return <Partitions path={path} />;
131+
return <Partitions path={path} database={tenantName} />;
132132
}
133133
default: {
134134
return <div>No data...</div>;

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ const prepareChangefeedInfo = (
3636

3737
interface ChangefeedProps {
3838
path: string;
39+
database: string;
3940
data?: TEvDescribeSchemeResult;
4041
topic?: TEvDescribeSchemeResult;
4142
}
4243

4344
/** Displays overview for CDCStream EPathType */
44-
export const ChangefeedInfo = ({path, data, topic}: ChangefeedProps) => {
45+
export const ChangefeedInfo = ({path, database, data, topic}: ChangefeedProps) => {
4546
const entityName = getEntityName(data?.PathDescription);
4647

4748
if (!data || !topic) {
@@ -51,7 +52,7 @@ export const ChangefeedInfo = ({path, data, topic}: ChangefeedProps) => {
5152
return (
5253
<div>
5354
<InfoViewer title={entityName} info={prepareChangefeedInfo(data, topic)} />
54-
<TopicStats path={path} />
55+
<TopicStats path={path} database={database} />
5556
</div>
5657
);
5758
};

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@ function Overview({type, path, database}: OverviewProps) {
7676
[EPathType.EPathTypeColumnStore]: undefined,
7777
[EPathType.EPathTypeColumnTable]: undefined,
7878
[EPathType.EPathTypeCdcStream]: () => (
79-
<ChangefeedInfo path={path} data={data} topic={additionalData?.[0] ?? undefined} />
79+
<ChangefeedInfo
80+
path={path}
81+
database={database}
82+
data={data}
83+
topic={additionalData?.[0] ?? undefined}
84+
/>
85+
),
86+
[EPathType.EPathTypePersQueueGroup]: () => (
87+
<TopicInfo data={data} path={path} database={database} />
8088
),
81-
[EPathType.EPathTypePersQueueGroup]: () => <TopicInfo data={data} path={path} />,
8289
[EPathType.EPathTypeExternalTable]: () => <ExternalTableInfo data={data} />,
8390
[EPathType.EPathTypeExternalDataSource]: () => <ExternalDataSourceInfo data={data} />,
8491
[EPathType.EPathTypeView]: () => <ViewInfo data={data} />,

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import {prepareTopicSchemaInfo} from '../utils';
66

77
interface TopicInfoProps {
88
path: string;
9+
database: string;
910
data?: TEvDescribeSchemeResult;
1011
}
1112

1213
/** Displays overview for PersQueueGroup EPathType */
13-
export const TopicInfo = ({data, path}: TopicInfoProps) => {
14+
export const TopicInfo = ({data, path, database}: TopicInfoProps) => {
1415
const entityName = getEntityName(data?.PathDescription);
1516

1617
if (!data) {
@@ -20,7 +21,7 @@ export const TopicInfo = ({data, path}: TopicInfoProps) => {
2021
return (
2122
<div>
2223
<InfoViewer title={entityName} info={prepareTopicSchemaInfo(data)} />
23-
<TopicStats path={path} />
24+
<TopicStats path={path} database={database} />
2425
</div>
2526
);
2627
};

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ const prepareBytesWrittenInfo = (data: IPreparedTopicStats): Array<InfoViewerIte
7171
];
7272
};
7373

74-
export const TopicStats = ({path}: {path: string}) => {
74+
export const TopicStats = ({path, database}: {path: string; database: string}) => {
7575
const [autoRefreshInterval] = useAutoRefreshInterval();
7676
const {currentData, isFetching, error} = topicApi.useGetTopicQuery(
77-
{path},
77+
{path, database},
7878
{pollingInterval: autoRefreshInterval},
7979
);
8080
const loading = isFetching && currentData === undefined;
81-
const data = useTypedSelector((state) => selectPreparedTopicStats(state, path));
81+
const data = useTypedSelector((state) => selectPreparedTopicStats(state, path, database));
8282

8383
if (loading) {
8484
return (

src/containers/Tenant/Diagnostics/Partitions/Partitions.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,25 @@ import './Partitions.scss';
2929
export const b = cn('ydb-diagnostics-partitions');
3030

3131
interface PartitionsProps {
32-
path?: string;
32+
path: string;
33+
database: string;
3334
}
3435

35-
export const Partitions = ({path}: PartitionsProps) => {
36+
export const Partitions = ({path, database}: PartitionsProps) => {
3637
const dispatch = useTypedDispatch();
3738

3839
const [partitionsToRender, setPartitionsToRender] = React.useState<
3940
PreparedPartitionDataWithHosts[]
4041
>([]);
4142

42-
const consumers = useTypedSelector((state) => selectConsumersNames(state, path));
43+
const consumers = useTypedSelector((state) => selectConsumersNames(state, path, database));
4344
const [autoRefreshInterval] = useAutoRefreshInterval();
4445
const {selectedConsumer} = useTypedSelector((state) => state.partitions);
4546
const {
4647
currentData: topicData,
4748
isFetching: topicIsFetching,
4849
error: topicError,
49-
} = topicApi.useGetTopicQuery({path});
50+
} = topicApi.useGetTopicQuery({path, database});
5051
const topicLoading = topicIsFetching && topicData === undefined;
5152
const {
5253
currentData: nodesData,
@@ -60,7 +61,7 @@ export const Partitions = ({path}: PartitionsProps) => {
6061

6162
const [columns, columnsIdsForSelector] = useGetPartitionsColumns(selectedConsumer);
6263

63-
const params = !topicLoading && path ? {path, consumerName: selectedConsumer} : skipToken;
64+
const params = topicLoading ? skipToken : {path, database, consumerName: selectedConsumer};
6465
const {
6566
currentData: partitionsData,
6667
isFetching: partitionsIsFetching,

src/services/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
359359
);
360360
}
361361
getTopic(
362-
{path, database}: {path?: string; database?: string},
362+
{path, database}: {path: string; database: string},
363363
{concurrentId, signal}: AxiosOptions = {},
364364
) {
365365
return this.get<DescribeTopicResult>(
@@ -374,7 +374,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
374374
);
375375
}
376376
getConsumer(
377-
{path, consumer, database}: {path: string; consumer: string; database?: string},
377+
{path, consumer, database}: {path: string; consumer: string; database: string},
378378
{concurrentId, signal}: AxiosOptions = {},
379379
) {
380380
return this.get<DescribeConsumerResult>(

src/store/reducers/partitions/partitions.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,24 @@ export const partitionsApi = api.injectEndpoints({
2727
endpoints: (build) => ({
2828
getPartitions: build.query({
2929
queryFn: async (
30-
{path, consumerName}: {path: string; consumerName?: string},
30+
{
31+
path,
32+
database,
33+
consumerName,
34+
}: {path: string; database: string; consumerName?: string},
3135
{signal},
3236
) => {
3337
try {
3438
if (consumerName) {
3539
const response = await window.api.getConsumer(
36-
{path, consumer: consumerName},
40+
{path, database, consumer: consumerName},
3741
{signal},
3842
);
3943
const rawPartitions = response.partitions;
4044
const data = prepareConsumerPartitions(rawPartitions);
4145
return {data};
4246
} else {
43-
const response = await window.api.getTopic({path}, {signal});
47+
const response = await window.api.getTopic({path, database}, {signal});
4448
const rawPartitions = response.partitions;
4549
const data = prepareTopicPartitions(rawPartitions);
4650
return {data};

src/store/reducers/topic.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {api} from './api';
1010
export const topicApi = api.injectEndpoints({
1111
endpoints: (build) => ({
1212
getTopic: build.query({
13-
queryFn: async (params: {path?: string}) => {
13+
queryFn: async (params: {path: string; database: string}) => {
1414
try {
1515
const data = await window.api.getTopic(params);
1616
// On older version it can return HTML page of Developer UI with an error
@@ -29,18 +29,18 @@ export const topicApi = api.injectEndpoints({
2929
});
3030

3131
const createGetTopicSelector = createSelector(
32-
(path?: string) => path,
33-
(path) => topicApi.endpoints.getTopic.select({path}),
32+
(path: string, database: string) => ({path, database}),
33+
(params) => topicApi.endpoints.getTopic.select(params),
3434
);
3535

3636
const selectTopicStats = createSelector(
3737
(state: RootState) => state,
38-
(_state: RootState, path?: string) => createGetTopicSelector(path),
38+
(_state: RootState, path: string, database: string) => createGetTopicSelector(path, database),
3939
(state, selectGetTopic) => selectGetTopic(state).data?.topic_stats,
4040
);
4141
const selectConsumers = createSelector(
4242
(state: RootState) => state,
43-
(_state: RootState, path?: string) => createGetTopicSelector(path),
43+
(_state: RootState, path: string, database: string) => createGetTopicSelector(path, database),
4444
(state, selectGetTopic) => selectGetTopic(state).data?.consumers,
4545
);
4646

0 commit comments

Comments
 (0)