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 roleApiInjectable from "./role.api.injectable";
|
||||||
import secretApiInjectable from "./secret.api.injectable";
|
import secretApiInjectable from "./secret.api.injectable";
|
||||||
import serviceApiInjectable from "./service.api.injectable";
|
import serviceApiInjectable from "./service.api.injectable";
|
||||||
import storageClassApiInjectable from "./storage-class.api.injectable";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use `di.inject(roleApiInjectable)` instead
|
* @deprecated use `di.inject(roleApiInjectable)` instead
|
||||||
@ -71,8 +70,3 @@ export const secretApi = asLegacyGlobalForExtensionApi(secretApiInjectable);
|
|||||||
* @deprecated use `di.inject(serviceApiInjectable)` instead
|
* @deprecated use `di.inject(serviceApiInjectable)` instead
|
||||||
*/
|
*/
|
||||||
export const serviceApi = asLegacyGlobalForExtensionApi(serviceApiInjectable);
|
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 { observer } from "mobx-react";
|
||||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||||
import { Badge } from "../badge";
|
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 type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
import { getDetailsUrl } from "../kube-detail-params";
|
|
||||||
import type { Logger } from "../../../common/logger";
|
import type { Logger } from "../../../common/logger";
|
||||||
import { stopPropagation } from "../../../renderer/utils";
|
import { stopPropagation } from "../../../renderer/utils";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
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> {
|
export interface PersistentVolumeDetailsProps extends KubeObjectDetailsProps<PersistentVolume> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
|
getDetailsUrl: GetDetailsUrl;
|
||||||
|
storageClassApi: StorageClassApi;
|
||||||
|
persistentVolumeClaimApi: PersistentVolumeClaimApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
class NonInjectedPersistentVolumeDetails extends React.Component<PersistentVolumeDetailsProps & Dependencies> {
|
class NonInjectedPersistentVolumeDetails extends React.Component<PersistentVolumeDetailsProps & Dependencies> {
|
||||||
render() {
|
render() {
|
||||||
const { object: volume } = this.props;
|
const {
|
||||||
|
object: volume,
|
||||||
|
storageClassApi,
|
||||||
|
getDetailsUrl,
|
||||||
|
logger,
|
||||||
|
persistentVolumeClaimApi,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
if (!volume) {
|
if (!volume) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(volume instanceof PersistentVolume)) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { accessModes, capacity, persistentVolumeReclaimPolicy, storageClassName, claimRef, flexVolume, mountOptions, nfs } = volume.spec;
|
const { accessModes, capacity, persistentVolumeReclaimPolicy, storageClassName, claimRef, flexVolume, mountOptions, nfs } = volume.spec;
|
||||||
|
|
||||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.getUrl({
|
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.formatUrlForNotListing({
|
||||||
name: storageClassName,
|
name: storageClassName,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -114,7 +127,7 @@ class NonInjectedPersistentVolumeDetails extends React.Component<PersistentVolum
|
|||||||
{claimRef.kind}
|
{claimRef.kind}
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
<DrawerItem name="Name">
|
<DrawerItem name="Name">
|
||||||
<Link to={getDetailsUrl(persistentVolumeClaimApi.getUrl(claimRef))}>
|
<Link to={getDetailsUrl(persistentVolumeClaimApi.formatUrlForNotListing(claimRef))}>
|
||||||
{claimRef.name}
|
{claimRef.name}
|
||||||
</Link>
|
</Link>
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
@ -132,5 +145,8 @@ export const PersistentVolumeDetails = withInjectables<Dependencies, PersistentV
|
|||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
...props,
|
...props,
|
||||||
logger: di.inject(loggerInjectable),
|
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 { observer } from "mobx-react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { getDetailsUrl } from "../kube-detail-params";
|
|
||||||
import { stopPropagation } from "../../utils";
|
import { stopPropagation } from "../../utils";
|
||||||
import { persistentVolumeStore } from "./legacy-store";
|
import type { PersistentVolumeClaimApi, StorageClassApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { persistentVolumeClaimApi, storageClassApi } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
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 {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -26,9 +31,23 @@ enum columnId {
|
|||||||
age = "age",
|
age = "age",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Dependencies {
|
||||||
|
storageClassApi: StorageClassApi;
|
||||||
|
persistentVolumeStore: PersistentVolumeStore;
|
||||||
|
persistentVolumeClaimApi: PersistentVolumeClaimApi;
|
||||||
|
getDetailsUrl: GetDetailsUrl;
|
||||||
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class PersistentVolumes extends React.Component {
|
class NonInjectedPersistentVolumes extends React.Component<Dependencies> {
|
||||||
render() {
|
render() {
|
||||||
|
const {
|
||||||
|
getDetailsUrl,
|
||||||
|
persistentVolumeStore,
|
||||||
|
storageClassApi,
|
||||||
|
persistentVolumeClaimApi,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SiblingsInTabLayout>
|
<SiblingsInTabLayout>
|
||||||
<KubeObjectListLayout
|
<KubeObjectListLayout
|
||||||
@ -59,7 +78,7 @@ export class PersistentVolumes extends React.Component {
|
|||||||
]}
|
]}
|
||||||
renderTableContents={volume => {
|
renderTableContents={volume => {
|
||||||
const { claimRef, storageClassName } = volume.spec;
|
const { claimRef, storageClassName } = volume.spec;
|
||||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.getUrl({
|
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.formatUrlForNotListing({
|
||||||
name: storageClassName,
|
name: storageClassName,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -75,7 +94,7 @@ export class PersistentVolumes extends React.Component {
|
|||||||
</Link>,
|
</Link>,
|
||||||
volume.getCapacity(),
|
volume.getCapacity(),
|
||||||
claimRef && (
|
claimRef && (
|
||||||
<Link to={getDetailsUrl(persistentVolumeClaimApi.getUrl(claimRef))} onClick={stopPropagation}>
|
<Link to={getDetailsUrl(persistentVolumeClaimApi.formatUrlForNotListing(claimRef))} onClick={stopPropagation}>
|
||||||
{claimRef.name}
|
{claimRef.name}
|
||||||
</Link>
|
</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