mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove usages of legacy global storageClassApi
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
ade0775061
commit
a9fa8fa0df
@ -15,7 +15,6 @@ import resourceQuotaApiInjectable from "./resource-quota.api.injectable";
|
||||
import roleApiInjectable from "./role.api.injectable";
|
||||
import secretApiInjectable from "./secret.api.injectable";
|
||||
import serviceApiInjectable from "./service.api.injectable";
|
||||
import storageClassApiInjectable from "./storage-class.api.injectable";
|
||||
|
||||
/**
|
||||
* @deprecated use `di.inject(roleApiInjectable)` instead
|
||||
@ -71,8 +70,3 @@ export const secretApi = asLegacyGlobalForExtensionApi(secretApiInjectable);
|
||||
* @deprecated use `di.inject(serviceApiInjectable)` instead
|
||||
*/
|
||||
export const serviceApi = asLegacyGlobalForExtensionApi(serviceApiInjectable);
|
||||
|
||||
/**
|
||||
* @deprecated use `di.inject(storageClassApiInjectable)` instead
|
||||
*/
|
||||
export const storageClassApi = asLegacyGlobalForExtensionApi(storageClassApiInjectable);
|
||||
|
||||
@ -11,39 +11,52 @@ import { Link } from "react-router-dom";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import { PersistentVolume, persistentVolumeClaimApi, storageClassApi } from "../../../common/k8s-api/endpoints";
|
||||
import type { PersistentVolumeClaimApi, StorageClassApi } from "../../../common/k8s-api/endpoints";
|
||||
import { PersistentVolume } from "../../../common/k8s-api/endpoints";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { getDetailsUrl } from "../kube-detail-params";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
import { stopPropagation } from "../../../renderer/utils";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import type { GetDetailsUrl } from "../kube-detail-params/get-details-url.injectable";
|
||||
import getDetailsUrlInjectable from "../kube-detail-params/get-details-url.injectable";
|
||||
import persistentVolumeClaimApiInjectable from "../../../common/k8s-api/endpoints/persistent-volume-claim.api.injectable";
|
||||
import storageClassApiInjectable from "../../../common/k8s-api/endpoints/storage-class.api.injectable";
|
||||
|
||||
export interface PersistentVolumeDetailsProps extends KubeObjectDetailsProps<PersistentVolume> {
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
logger: Logger;
|
||||
getDetailsUrl: GetDetailsUrl;
|
||||
storageClassApi: StorageClassApi;
|
||||
persistentVolumeClaimApi: PersistentVolumeClaimApi;
|
||||
}
|
||||
|
||||
@observer
|
||||
class NonInjectedPersistentVolumeDetails extends React.Component<PersistentVolumeDetailsProps & Dependencies> {
|
||||
render() {
|
||||
const { object: volume } = this.props;
|
||||
const {
|
||||
object: volume,
|
||||
storageClassApi,
|
||||
getDetailsUrl,
|
||||
logger,
|
||||
persistentVolumeClaimApi,
|
||||
} = this.props;
|
||||
|
||||
if (!volume) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(volume instanceof PersistentVolume)) {
|
||||
this.props.logger.error("[PersistentVolumeDetails]: passed object that is not an instanceof PersistentVolume", volume);
|
||||
logger.error("[PersistentVolumeDetails]: passed object that is not an instanceof PersistentVolume", volume);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const { accessModes, capacity, persistentVolumeReclaimPolicy, storageClassName, claimRef, flexVolume, mountOptions, nfs } = volume.spec;
|
||||
|
||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.getUrl({
|
||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.formatUrlForNotListing({
|
||||
name: storageClassName,
|
||||
}));
|
||||
|
||||
@ -114,7 +127,7 @@ class NonInjectedPersistentVolumeDetails extends React.Component<PersistentVolum
|
||||
{claimRef.kind}
|
||||
</DrawerItem>
|
||||
<DrawerItem name="Name">
|
||||
<Link to={getDetailsUrl(persistentVolumeClaimApi.getUrl(claimRef))}>
|
||||
<Link to={getDetailsUrl(persistentVolumeClaimApi.formatUrlForNotListing(claimRef))}>
|
||||
{claimRef.name}
|
||||
</Link>
|
||||
</DrawerItem>
|
||||
@ -132,5 +145,8 @@ export const PersistentVolumeDetails = withInjectables<Dependencies, PersistentV
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
logger: di.inject(loggerInjectable),
|
||||
getDetailsUrl: di.inject(getDetailsUrlInjectable),
|
||||
persistentVolumeClaimApi: di.inject(persistentVolumeClaimApiInjectable),
|
||||
storageClassApi: di.inject(storageClassApiInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
@ -9,13 +9,18 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
import { getDetailsUrl } from "../kube-detail-params";
|
||||
import { stopPropagation } from "../../utils";
|
||||
import { persistentVolumeStore } from "./legacy-store";
|
||||
import { persistentVolumeClaimApi, storageClassApi } from "../../../common/k8s-api/endpoints";
|
||||
import type { PersistentVolumeClaimApi, StorageClassApi } from "../../../common/k8s-api/endpoints";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||
import { KubeObjectAge } from "../kube-object/age";
|
||||
import type { PersistentVolumeStore } from "./store";
|
||||
import type { GetDetailsUrl } from "../kube-detail-params/get-details-url.injectable";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import getDetailsUrlInjectable from "../kube-detail-params/get-details-url.injectable";
|
||||
import persistentVolumeClaimApiInjectable from "../../../common/k8s-api/endpoints/persistent-volume-claim.api.injectable";
|
||||
import persistentVolumeStoreInjectable from "./store.injectable";
|
||||
import storageClassApiInjectable from "../../../common/k8s-api/endpoints/storage-class.api.injectable";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
@ -26,9 +31,23 @@ enum columnId {
|
||||
age = "age",
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
storageClassApi: StorageClassApi;
|
||||
persistentVolumeStore: PersistentVolumeStore;
|
||||
persistentVolumeClaimApi: PersistentVolumeClaimApi;
|
||||
getDetailsUrl: GetDetailsUrl;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PersistentVolumes extends React.Component {
|
||||
class NonInjectedPersistentVolumes extends React.Component<Dependencies> {
|
||||
render() {
|
||||
const {
|
||||
getDetailsUrl,
|
||||
persistentVolumeStore,
|
||||
storageClassApi,
|
||||
persistentVolumeClaimApi,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<SiblingsInTabLayout>
|
||||
<KubeObjectListLayout
|
||||
@ -59,7 +78,7 @@ export class PersistentVolumes extends React.Component {
|
||||
]}
|
||||
renderTableContents={volume => {
|
||||
const { claimRef, storageClassName } = volume.spec;
|
||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.getUrl({
|
||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.formatUrlForNotListing({
|
||||
name: storageClassName,
|
||||
}));
|
||||
|
||||
@ -75,7 +94,7 @@ export class PersistentVolumes extends React.Component {
|
||||
</Link>,
|
||||
volume.getCapacity(),
|
||||
claimRef && (
|
||||
<Link to={getDetailsUrl(persistentVolumeClaimApi.getUrl(claimRef))} onClick={stopPropagation}>
|
||||
<Link to={getDetailsUrl(persistentVolumeClaimApi.formatUrlForNotListing(claimRef))} onClick={stopPropagation}>
|
||||
{claimRef.name}
|
||||
</Link>
|
||||
),
|
||||
@ -88,3 +107,13 @@ export class PersistentVolumes extends React.Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const PersistentVolumes = withInjectables<Dependencies>(NonInjectedPersistentVolumes, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
getDetailsUrl: di.inject(getDetailsUrlInjectable),
|
||||
persistentVolumeClaimApi: di.inject(persistentVolumeClaimApiInjectable),
|
||||
persistentVolumeStore: di.inject(persistentVolumeStoreInjectable),
|
||||
storageClassApi: di.inject(storageClassApiInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user