Skip to content

Commit b66e8d5

Browse files
authored
feat: add backups page with custom render (#2442)
1 parent 6001e22 commit b66e8d5

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/containers/Tenant/Diagnostics/Diagnostics.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../store/reducers/tenant/constants';
1414
import {setDiagnosticsTab} from '../../../store/reducers/tenant/tenant';
1515
import type {AdditionalNodesProps, AdditionalTenantsProps} from '../../../types/additionalProps';
16+
import {uiFactory} from '../../../uiFactory/uiFactory';
1617
import {cn} from '../../../utils/cn';
1718
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
1819
import {Heatmap} from '../../Heatmap';
@@ -49,7 +50,6 @@ const b = cn('kv-tenant-diagnostics');
4950
function Diagnostics(props: DiagnosticsProps) {
5051
const {path, database, type, subType} = useCurrentSchema();
5152
const containerRef = React.useRef<HTMLDivElement>(null);
52-
5353
const dispatch = useTypedDispatch();
5454
const {diagnosticsTab = TENANT_DIAGNOSTICS_TABS_IDS.overview} = useTypedSelector(
5555
(state) => state.tenant,
@@ -65,6 +65,7 @@ function Diagnostics(props: DiagnosticsProps) {
6565
hasFeatureFlags,
6666
hasTopicData,
6767
isTopLevel: path === database,
68+
hasBackups: typeof uiFactory.renderBackups === 'function',
6869
});
6970
let activeTab = pages.find((el) => el.id === diagnosticsTab);
7071
if (!activeTab) {
@@ -77,6 +78,7 @@ function Diagnostics(props: DiagnosticsProps) {
7778
}
7879
}, [activeTab, diagnosticsTab, dispatch]);
7980

81+
// eslint-disable-next-line complexity
8082
const renderTabContent = () => {
8183
switch (activeTab?.id) {
8284
case TENANT_DIAGNOSTICS_TABS_IDS.overview: {
@@ -161,6 +163,12 @@ function Diagnostics(props: DiagnosticsProps) {
161163
case TENANT_DIAGNOSTICS_TABS_IDS.operations: {
162164
return <Operations database={tenantName} />;
163165
}
166+
case TENANT_DIAGNOSTICS_TABS_IDS.backups: {
167+
return uiFactory.renderBackups?.({
168+
database: tenantName,
169+
scrollContainerRef: containerRef,
170+
});
171+
}
164172
default: {
165173
return <div>No data...</div>;
166174
}

src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const access = {
3737
id: TENANT_DIAGNOSTICS_TABS_IDS.access,
3838
title: 'Access',
3939
};
40+
const backups = {
41+
id: TENANT_DIAGNOSTICS_TABS_IDS.backups,
42+
title: 'Backups',
43+
};
4044

4145
const nodes = {
4246
id: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
@@ -111,6 +115,7 @@ const DATABASE_PAGES = [
111115
configs,
112116
access,
113117
operations,
118+
backups,
114119
];
115120

116121
const TABLE_PAGES = [overview, schema, topShards, nodes, graph, tablets, hotKeys, describe, access];
@@ -166,7 +171,12 @@ const pathSubTypeToPages: Record<EPathSubType, Page[] | undefined> = {
166171
export const getPagesByType = (
167172
type?: EPathType,
168173
subType?: EPathSubType,
169-
options?: {hasFeatureFlags?: boolean; hasTopicData?: boolean; isTopLevel?: boolean},
174+
options?: {
175+
hasFeatureFlags?: boolean;
176+
hasTopicData?: boolean;
177+
isTopLevel?: boolean;
178+
hasBackups?: boolean;
179+
},
170180
) => {
171181
const subTypePages = subType ? pathSubTypeToPages[subType] : undefined;
172182
const typePages = type ? pathTypeToPages[type] : undefined;
@@ -181,6 +191,9 @@ export const getPagesByType = (
181191
return pages.filter((item) => item.id !== TENANT_DIAGNOSTICS_TABS_IDS.configs);
182192
}
183193
}
194+
if (!options?.hasBackups) {
195+
return pages.filter((item) => item.id !== TENANT_DIAGNOSTICS_TABS_IDS.backups);
196+
}
184197
return pages;
185198
};
186199

src/store/reducers/tenant/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const TENANT_DIAGNOSTICS_TABS_IDS = {
2929
configs: 'configs',
3030
operations: 'operations',
3131
access: 'access',
32+
backups: 'backups',
3233
} as const;
3334

3435
export const TENANT_SUMMARY_TABS_IDS = {

src/uiFactory/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type React from 'react';
2+
13
import type {
24
CommonIssueType,
35
GetHealthcheckViewTitles,
@@ -28,6 +30,11 @@ export interface UIFactory<H extends string = CommonIssueType> {
2830
getDatabaseLinks?: GetDatabaseLinks;
2931
getClusterLinks?: GetClusterLinks;
3032

33+
renderBackups?: (props: {
34+
database: string;
35+
scrollContainerRef: React.RefObject<HTMLDivElement>;
36+
}) => React.ReactNode;
37+
3138
healthcheck: {
3239
getHealthckechViewTitles: GetHealthcheckViewTitles<H>;
3340
getHealthcheckViewsOrder: GetHealthcheckViewsOrder<H>;

0 commit comments

Comments
 (0)