Skip to content

Commit 80272f9

Browse files
fix: use uiFactory for logs and monitoring links
1 parent 5a9b4a0 commit 80272f9

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

src/containers/AppWithClusters/AppWithClusters.tsx

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@ import React from 'react';
33
import type {Store} from '@reduxjs/toolkit';
44
import type {History} from 'history';
55

6-
import {getLogsLink as getLogsLinkDefault} from '../../utils/logs';
7-
import type {
8-
GetLogsLink,
9-
GetMonitoringClusterLink,
10-
GetMonitoringLink,
11-
} from '../../utils/monitoring';
12-
import {
13-
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
14-
getMonitoringLink as getMonitoringLinkDefault,
15-
} from '../../utils/monitoring';
6+
import {uiFactory} from '../../uiFactory/uiFactory';
167
import {App, AppSlots} from '../App';
178
import type {YDBEmbeddedUISettings} from '../UserSettings/settings';
189

@@ -22,32 +13,21 @@ import {ExtendedTenant} from './ExtendedTenant/ExtendedTenant';
2213
export interface AppWithClustersProps {
2314
store: Store;
2415
history: History;
25-
getLogsLink?: GetLogsLink;
26-
getMonitoringLink?: GetMonitoringLink;
27-
getMonitoringClusterLink?: GetMonitoringClusterLink;
2816
userSettings?: YDBEmbeddedUISettings;
2917
children?: React.ReactNode;
3018
}
3119

32-
export function AppWithClusters({
33-
store,
34-
history,
35-
getLogsLink = getLogsLinkDefault,
36-
getMonitoringLink = getMonitoringLinkDefault,
37-
getMonitoringClusterLink = getMonitoringClusterLinkDefault,
38-
userSettings,
39-
children,
40-
}: AppWithClustersProps) {
20+
export function AppWithClusters({store, history, userSettings, children}: AppWithClustersProps) {
4121
return (
4222
<App store={store} history={history} userSettings={userSettings}>
4323
<AppSlots.ClusterSlot>
4424
{({component}) => {
4525
return (
4626
<ExtendedCluster
4727
component={component}
48-
getLogsLink={getLogsLink}
49-
getMonitoringLink={getMonitoringLink}
50-
getMonitoringClusterLink={getMonitoringClusterLink}
28+
getLogsLink={uiFactory.getLogsLink}
29+
getMonitoringLink={uiFactory.getMonitoringLink}
30+
getMonitoringClusterLink={uiFactory.getMonitoringClusterLink}
5131
/>
5232
);
5333
}}
@@ -57,8 +37,8 @@ export function AppWithClusters({
5737
return (
5838
<ExtendedTenant
5939
component={component}
60-
getLogsLink={getLogsLink}
61-
getMonitoringLink={getMonitoringLink}
40+
getLogsLink={uiFactory.getLogsLink}
41+
getMonitoringLink={uiFactory.getMonitoringLink}
6242
/>
6343
);
6444
}}

src/uiFactory/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import type {GetLogsLink} from '../utils/logs';
2+
import type {GetMonitoringClusterLink, GetMonitoringLink} from '../utils/monitoring';
3+
14
export interface UIFactory {
25
onCreateDB?: HandleCreateDB;
36
onDeleteDB?: HandleDeleteDB;
7+
8+
getLogsLink?: GetLogsLink;
9+
getMonitoringLink?: GetMonitoringLink;
10+
getMonitoringClusterLink?: GetMonitoringClusterLink;
411
}
512

613
export type HandleCreateDB = (params: {clusterName: string}) => Promise<boolean>;

src/uiFactory/uiFactory.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
import {getLogsLink as getLogsLinkDefault} from '../utils/logs';
2+
import {
3+
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
4+
getMonitoringLink as getMonitoringLinkDefault,
5+
} from '../utils/monitoring';
6+
17
import type {UIFactory} from './types';
28

3-
const uiFactoryBase: UIFactory = {};
9+
const uiFactoryBase: UIFactory = {
10+
getLogsLink: getLogsLinkDefault,
11+
getMonitoringLink: getMonitoringLinkDefault,
12+
getMonitoringClusterLink: getMonitoringClusterLinkDefault,
13+
};
414

515
export function configureUIFactory(overrides: UIFactory) {
616
Object.assign(uiFactoryBase, overrides);

0 commit comments

Comments
 (0)