mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use navigateToEntitySettings instead of broadcastMessage
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
995d4e8418
commit
61bfb9cffe
@ -8,28 +8,48 @@ import styles from "./cluster-no-metrics.module.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { broadcastMessage } from "../../../common/ipc";
|
import type { NavigateToEntitySettings } from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||||
import { IpcRendererNavigationEvents } from "../../navigation/events";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import navigateToEntitySettingsInjectable from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||||
|
import hostedClusterInjectable from "../../../common/cluster-store/hosted-cluster.injectable";
|
||||||
|
|
||||||
export interface ClusterNoMetricsProps {
|
export interface ClusterNoMetricsProps {
|
||||||
className: string;
|
className: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ClusterNoMetrics({ className }: ClusterNoMetricsProps) {
|
interface Dependencies {
|
||||||
function getClusterId() {
|
navigateToEntitySettings: NavigateToEntitySettings;
|
||||||
return catalogEntityRegistry.activeEntity;
|
clusterId: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openSettingsPage() {
|
export function NonInjectedClusterNoMetrics({ className, navigateToEntitySettings, clusterId }: Dependencies & ClusterNoMetricsProps) {
|
||||||
broadcastMessage(IpcRendererNavigationEvents.NAVIGATE_IN_APP, `/entity/${getClusterId()?.getId()}/settings`);
|
function openMetricSettingsPage() {
|
||||||
|
if (clusterId) {
|
||||||
|
navigateToEntitySettings(clusterId, "metrics");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cssNames(styles.ClusterNoMetrics, className)} data-testid="no-metrics-message">
|
<div className={cssNames(styles.ClusterNoMetrics, className)} data-testid="no-metrics-message">
|
||||||
<Icon material="info"/>
|
<Icon material="info"/>
|
||||||
<p>Metrics are not available due to missing or invalid Prometheus configuration.</p>
|
<p>Metrics are not available due to missing or invalid Prometheus configuration.</p>
|
||||||
<p><span className={styles.link} onClick={openSettingsPage}>Open cluster settings</span></p>
|
<p><span className={styles.link} onClick={openMetricSettingsPage}>Open cluster settings</span></p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ClusterNoMetrics = withInjectables<Dependencies, ClusterNoMetricsProps>(
|
||||||
|
NonInjectedClusterNoMetrics,
|
||||||
|
|
||||||
|
{
|
||||||
|
getProps: (di, props) => {
|
||||||
|
const cluster = di.inject(hostedClusterInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
navigateToEntitySettings: di.inject(navigateToEntitySettingsInjectable),
|
||||||
|
clusterId: cluster?.id,
|
||||||
|
...props,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user