Skip to content

Commit 974775f

Browse files
fix!: use uiFactory for logs and monitoring links (#2274)
1 parent 82f32d9 commit 974775f

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/containers/AppWithClusters/AppWithClusters.tsx

+7-23
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import React from 'react';
33
import type {Store} from '@reduxjs/toolkit';
44
import type {History} from 'history';
55

6-
import type {GetLogsLink} from '../../utils/logs';
7-
import type {GetMonitoringClusterLink, GetMonitoringLink} from '../../utils/monitoring';
8-
import {
9-
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
10-
getMonitoringLink as getMonitoringLinkDefault,
11-
} from '../../utils/monitoring';
6+
import {uiFactory} from '../../uiFactory/uiFactory';
127
import {App, AppSlots} from '../App';
138
import type {YDBEmbeddedUISettings} from '../UserSettings/settings';
149

@@ -18,32 +13,21 @@ import {ExtendedTenant} from './ExtendedTenant/ExtendedTenant';
1813
export interface AppWithClustersProps {
1914
store: Store;
2015
history: History;
21-
getLogsLink?: GetLogsLink;
22-
getMonitoringLink?: GetMonitoringLink;
23-
getMonitoringClusterLink?: GetMonitoringClusterLink;
2416
userSettings?: YDBEmbeddedUISettings;
2517
children?: React.ReactNode;
2618
}
2719

28-
export function AppWithClusters({
29-
store,
30-
history,
31-
getLogsLink,
32-
getMonitoringLink = getMonitoringLinkDefault,
33-
getMonitoringClusterLink = getMonitoringClusterLinkDefault,
34-
userSettings,
35-
children,
36-
}: AppWithClustersProps) {
20+
export function AppWithClusters({store, history, userSettings, children}: AppWithClustersProps) {
3721
return (
3822
<App store={store} history={history} userSettings={userSettings}>
3923
<AppSlots.ClusterSlot>
4024
{({component}) => {
4125
return (
4226
<ExtendedCluster
4327
component={component}
44-
getLogsLink={getLogsLink}
45-
getMonitoringLink={getMonitoringLink}
46-
getMonitoringClusterLink={getMonitoringClusterLink}
28+
getLogsLink={uiFactory.getLogsLink}
29+
getMonitoringLink={uiFactory.getMonitoringLink}
30+
getMonitoringClusterLink={uiFactory.getMonitoringClusterLink}
4731
/>
4832
);
4933
}}
@@ -53,8 +37,8 @@ export function AppWithClusters({
5337
return (
5438
<ExtendedTenant
5539
component={component}
56-
getLogsLink={getLogsLink}
57-
getMonitoringLink={getMonitoringLink}
40+
getLogsLink={uiFactory.getLogsLink}
41+
getMonitoringLink={uiFactory.getMonitoringLink}
5842
/>
5943
);
6044
}}

src/uiFactory/types.ts

+7
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

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
import {
2+
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
3+
getMonitoringLink as getMonitoringLinkDefault,
4+
} from '../utils/monitoring';
5+
16
import type {UIFactory} from './types';
27

3-
const uiFactoryBase: UIFactory = {};
8+
const uiFactoryBase: UIFactory = {
9+
getMonitoringLink: getMonitoringLinkDefault,
10+
getMonitoringClusterLink: getMonitoringClusterLinkDefault,
11+
};
412

513
export function configureUIFactory(overrides: UIFactory) {
614
Object.assign(uiFactoryBase, overrides);

0 commit comments

Comments
 (0)