Skip to content

Commit 089f159

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

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/containers/Tenant/Diagnostics/Diagnostics.tsx

Lines changed: 6 additions & 0 deletions
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';
@@ -65,6 +66,7 @@ function Diagnostics(props: DiagnosticsProps) {
6566
hasFeatureFlags,
6667
hasTopicData,
6768
isTopLevel: path === database,
69+
hasBackups: typeof uiFactory.renderBackups === 'function',
6870
});
6971
let activeTab = pages.find((el) => el.id === diagnosticsTab);
7072
if (!activeTab) {
@@ -77,6 +79,7 @@ function Diagnostics(props: DiagnosticsProps) {
7779
}
7880
}, [activeTab, diagnosticsTab, dispatch]);
7981

82+
// eslint-disable-next-line complexity
8083
const renderTabContent = () => {
8184
switch (activeTab?.id) {
8285
case TENANT_DIAGNOSTICS_TABS_IDS.overview: {
@@ -161,6 +164,9 @@ function Diagnostics(props: DiagnosticsProps) {
161164
case TENANT_DIAGNOSTICS_TABS_IDS.operations: {
162165
return <Operations database={tenantName} />;
163166
}
167+
case TENANT_DIAGNOSTICS_TABS_IDS.backups: {
168+
return uiFactory.renderBackups?.();
169+
}
164170
default: {
165171
return <div>No data...</div>;
166172
}

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: 4 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,8 @@ export interface UIFactory<H extends string = CommonIssueType> {
2830
getDatabaseLinks?: GetDatabaseLinks;
2931
getClusterLinks?: GetClusterLinks;
3032

33+
renderBackups?: () => React.ReactNode;
34+
3135
healthcheck: {
3236
getHealthckechViewTitles: GetHealthcheckViewTitles<H>;
3337
getHealthcheckViewsOrder: GetHealthcheckViewsOrder<H>;

0 commit comments

Comments
 (0)