Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions src/containers/AppWithClusters/AppWithClusters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import React from 'react';
import type {Store} from '@reduxjs/toolkit';
import type {History} from 'history';

import type {GetLogsLink} from '../../utils/logs';
import type {GetMonitoringClusterLink, GetMonitoringLink} from '../../utils/monitoring';
import {
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
getMonitoringLink as getMonitoringLinkDefault,
} from '../../utils/monitoring';
import {uiFactory} from '../../uiFactory/uiFactory';
import {App, AppSlots} from '../App';
import type {YDBEmbeddedUISettings} from '../UserSettings/settings';

Expand All @@ -18,32 +13,21 @@ import {ExtendedTenant} from './ExtendedTenant/ExtendedTenant';
export interface AppWithClustersProps {
store: Store;
history: History;
getLogsLink?: GetLogsLink;
getMonitoringLink?: GetMonitoringLink;
getMonitoringClusterLink?: GetMonitoringClusterLink;
userSettings?: YDBEmbeddedUISettings;
children?: React.ReactNode;
}

export function AppWithClusters({
store,
history,
getLogsLink,
getMonitoringLink = getMonitoringLinkDefault,
getMonitoringClusterLink = getMonitoringClusterLinkDefault,
userSettings,
children,
}: AppWithClustersProps) {
export function AppWithClusters({store, history, userSettings, children}: AppWithClustersProps) {
return (
<App store={store} history={history} userSettings={userSettings}>
<AppSlots.ClusterSlot>
{({component}) => {
return (
<ExtendedCluster
component={component}
getLogsLink={getLogsLink}
getMonitoringLink={getMonitoringLink}
getMonitoringClusterLink={getMonitoringClusterLink}
getLogsLink={uiFactory.getLogsLink}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't refactored additional props themselves, it's could be done further, these changes are to merge with current major and to not do another

getMonitoringLink={uiFactory.getMonitoringLink}
getMonitoringClusterLink={uiFactory.getMonitoringClusterLink}
/>
);
}}
Expand All @@ -53,8 +37,8 @@ export function AppWithClusters({
return (
<ExtendedTenant
component={component}
getLogsLink={getLogsLink}
getMonitoringLink={getMonitoringLink}
getLogsLink={uiFactory.getLogsLink}
getMonitoringLink={uiFactory.getMonitoringLink}
/>
);
}}
Expand Down
7 changes: 7 additions & 0 deletions src/uiFactory/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import type {GetLogsLink} from '../utils/logs';
import type {GetMonitoringClusterLink, GetMonitoringLink} from '../utils/monitoring';

export interface UIFactory {
onCreateDB?: HandleCreateDB;
onDeleteDB?: HandleDeleteDB;

getLogsLink?: GetLogsLink;
getMonitoringLink?: GetMonitoringLink;
getMonitoringClusterLink?: GetMonitoringClusterLink;
}

export type HandleCreateDB = (params: {clusterName: string}) => Promise<boolean>;
Expand Down
10 changes: 9 additions & 1 deletion src/uiFactory/uiFactory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import {
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
getMonitoringLink as getMonitoringLinkDefault,
} from '../utils/monitoring';

import type {UIFactory} from './types';

const uiFactoryBase: UIFactory = {};
const uiFactoryBase: UIFactory = {
getMonitoringLink: getMonitoringLinkDefault,
getMonitoringClusterLink: getMonitoringClusterLinkDefault,
};

export function configureUIFactory(overrides: UIFactory) {
Object.assign(uiFactoryBase, overrides);
Expand Down
Loading