mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove last usage of legacy global endpointsStore
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
665e3a5443
commit
fabde6acc4
@ -1,12 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
|
||||||
import endpointsStoreInjectable from "./store.injectable";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use `di.inject(endpointsStoreInjectable)`
|
|
||||||
*/
|
|
||||||
export const endpointsStore = asLegacyGlobalForExtensionApi(endpointsStoreInjectable);
|
|
||||||
@ -7,31 +7,33 @@ import { observer } from "mobx-react";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Table, TableHead, TableCell, TableRow } from "../table";
|
import { Table, TableHead, TableCell, TableRow } from "../table";
|
||||||
import { prevDefault } from "../../utils";
|
import { prevDefault } from "../../utils";
|
||||||
import { endpointsStore } from "../+network-endpoints/legacy-store";
|
import type { Logger } from "../../../common/logger";
|
||||||
import { Spinner } from "../spinner";
|
|
||||||
import { showDetails } from "../kube-detail-params";
|
|
||||||
import logger from "../../../common/logger";
|
|
||||||
import { Endpoints } from "../../../common/k8s-api/endpoints";
|
import { Endpoints } from "../../../common/k8s-api/endpoints";
|
||||||
|
import type { ShowDetails } from "../kube-detail-params/show-details.injectable";
|
||||||
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
|
import showDetailsInjectable from "../kube-detail-params/show-details.injectable";
|
||||||
|
|
||||||
export interface ServiceDetailsEndpointProps {
|
export interface ServiceDetailsEndpointProps {
|
||||||
endpoints: Endpoints;
|
endpoints: Endpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Dependencies {
|
||||||
|
logger: Logger;
|
||||||
|
showDetails: ShowDetails;
|
||||||
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ServiceDetailsEndpoint extends React.Component<ServiceDetailsEndpointProps> {
|
class NonInjectedServiceDetailsEndpoint extends React.Component<ServiceDetailsEndpointProps & Dependencies> {
|
||||||
render() {
|
render() {
|
||||||
const { endpoints } = this.props;
|
const { endpoints } = this.props;
|
||||||
|
|
||||||
if (!endpoints && !endpointsStore.isLoaded) return (
|
|
||||||
<div className="PodDetailsList flex justify-center"><Spinner/></div>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!endpoints) {
|
if (!endpoints) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(endpoints instanceof Endpoints)) {
|
if (!(endpoints instanceof Endpoints)) {
|
||||||
logger.error("[ServiceDetailsEndpoint]: passed object that is not an instanceof Endpoints", endpoints);
|
this.props.logger.error("[ServiceDetailsEndpoint]: passed object that is not an instanceof Endpoints", endpoints);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -51,7 +53,7 @@ export class ServiceDetailsEndpoint extends React.Component<ServiceDetailsEndpoi
|
|||||||
<TableRow
|
<TableRow
|
||||||
key={endpoints.getId()}
|
key={endpoints.getId()}
|
||||||
nowrap
|
nowrap
|
||||||
onClick={prevDefault(() => showDetails(endpoints.selfLink, false))}
|
onClick={prevDefault(() => this.props.showDetails(endpoints.selfLink, false))}
|
||||||
>
|
>
|
||||||
<TableCell className="name">{endpoints.getName()}</TableCell>
|
<TableCell className="name">{endpoints.getName()}</TableCell>
|
||||||
<TableCell className="endpoints">{ endpoints.toString()}</TableCell>
|
<TableCell className="endpoints">{ endpoints.toString()}</TableCell>
|
||||||
@ -61,3 +63,11 @@ export class ServiceDetailsEndpoint extends React.Component<ServiceDetailsEndpoi
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ServiceDetailsEndpoint = withInjectables<Dependencies, ServiceDetailsEndpointProps>(NonInjectedServiceDetailsEndpoint, {
|
||||||
|
getProps: (di, props) => ({
|
||||||
|
...props,
|
||||||
|
logger: di.inject(loggerInjectable),
|
||||||
|
showDetails: di.inject(showDetailsInjectable),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user