mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
1 parent
e810eab39f
commit
b7974827d2
786 files changed
+14567
-24066
No files matched your search
@@ -0,0 +1,3 @@
|
||||
export * from "./volumes.route"
|
||||
export * from "./volumes"
|
||||
export * from "./volume-details"
|
||||
@@ -0,0 +1,3 @@
|
||||
.PersistentVolumeDetails {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import startCase from "lodash/startCase"
|
||||
import "./volume-details.scss"
|
||||
|
||||
import React from "react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { Link } from "react-router-dom";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import { KubeEventDetails } from "../+events/kube-event-details";
|
||||
import { getDetailsUrl } from "../../navigation";
|
||||
import { PersistentVolume, persistentVolumeApi, pvcApi } from "../../api/endpoints";
|
||||
import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<PersistentVolume> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PersistentVolumeDetails extends React.Component<Props> {
|
||||
render() {
|
||||
const { object: volume } = this.props;
|
||||
if (!volume) {
|
||||
return null;
|
||||
}
|
||||
const { accessModes, capacity, persistentVolumeReclaimPolicy, storageClassName, claimRef, flexVolume, mountOptions, nfs } = volume.spec;
|
||||
return (
|
||||
<div className="PersistentVolumeDetails">
|
||||
<KubeObjectMeta object={volume}/>
|
||||
<DrawerItem name={<Trans>Capacity</Trans>}>
|
||||
{capacity.storage}
|
||||
</DrawerItem>
|
||||
|
||||
{mountOptions && (
|
||||
<DrawerItem name={<Trans>Mount Options</Trans>}>
|
||||
{mountOptions.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
<DrawerItem name={<Trans>Access Modes</Trans>}>
|
||||
{accessModes.join(", ")}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Reclaim Policy</Trans>}>
|
||||
{persistentVolumeReclaimPolicy}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Storage Class Name</Trans>}>
|
||||
{storageClassName}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Status</Trans>} labelsOnly>
|
||||
<Badge label={volume.getStatus()}/>
|
||||
</DrawerItem>
|
||||
|
||||
{nfs && (
|
||||
<>
|
||||
<DrawerTitle title={<Trans>Network File System</Trans>}/>
|
||||
{
|
||||
Object.entries(nfs).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))
|
||||
}
|
||||
</>
|
||||
)}
|
||||
|
||||
{flexVolume && (
|
||||
<>
|
||||
<DrawerTitle title={<Trans>FlexVolume</Trans>}/>
|
||||
<DrawerItem name={<Trans>Driver</Trans>}>
|
||||
{flexVolume.driver}
|
||||
</DrawerItem>
|
||||
{
|
||||
Object.entries(flexVolume.options).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))
|
||||
}
|
||||
</>
|
||||
)}
|
||||
|
||||
{claimRef && (
|
||||
<>
|
||||
<DrawerTitle title={<Trans>Claim</Trans>}/>
|
||||
<DrawerItem name={<Trans>Type</Trans>}>
|
||||
{claimRef.kind}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Name</Trans>}>
|
||||
<Link to={getDetailsUrl(pvcApi.getUrl(claimRef))}>
|
||||
{claimRef.name}
|
||||
</Link>
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Namespace</Trans>}>
|
||||
{claimRef.namespace}
|
||||
</DrawerItem>
|
||||
</>
|
||||
)}
|
||||
|
||||
<KubeEventDetails object={volume}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
apiManager.registerViews(persistentVolumeApi, {
|
||||
Details: PersistentVolumeDetails
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
import { RouteProps } from "react-router"
|
||||
import { buildURL } from "../../navigation";
|
||||
|
||||
export const volumesRoute: RouteProps = {
|
||||
path: "/persistent-volumes"
|
||||
}
|
||||
|
||||
export interface IVolumesRouteParams {
|
||||
}
|
||||
|
||||
export const volumesURL = buildURL<IVolumesRouteParams>(volumesRoute.path);
|
||||
@@ -0,0 +1,33 @@
|
||||
@import "../+storage/storage-mixins";
|
||||
|
||||
.PersistentVolumes {
|
||||
.TableCell {
|
||||
&.name {
|
||||
flex-grow: 3;
|
||||
}
|
||||
|
||||
&.storage {
|
||||
flex: 0.6;
|
||||
}
|
||||
|
||||
&.storageClass {
|
||||
flex-grow: 1.5;
|
||||
}
|
||||
|
||||
&.capacity {
|
||||
flex: 0.6;
|
||||
}
|
||||
|
||||
&.claim {
|
||||
flex-grow: 3;
|
||||
}
|
||||
|
||||
.status {
|
||||
@include pv-status-colors;
|
||||
}
|
||||
|
||||
&.age {
|
||||
flex: 0.4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { PersistentVolume, persistentVolumeApi } from "../../api/endpoints/persistent-volume.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@autobind()
|
||||
export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> {
|
||||
api = persistentVolumeApi
|
||||
}
|
||||
|
||||
export const volumesStore = new PersistentVolumesStore();
|
||||
apiManager.registerStore(persistentVolumeApi, volumesStore);
|
||||
@@ -0,0 +1,91 @@
|
||||
import "./volumes.scss"
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { Link, RouteComponentProps } from "react-router-dom";
|
||||
import { PersistentVolume, persistentVolumeApi } from "../../api/endpoints/persistent-volume.api";
|
||||
import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IVolumesRouteParams } from "./volumes.route";
|
||||
import { stopPropagation } from "../../utils";
|
||||
import { getDetailsUrl } from "../../navigation";
|
||||
import { volumesStore } from "./volumes.store";
|
||||
import { pvcApi, storageClassApi } from "../../api/endpoints";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
storageClass = "storage-class",
|
||||
capacity = "capacity",
|
||||
status = "status",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
interface Props extends RouteComponentProps<IVolumesRouteParams> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PersistentVolumes extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
className="PersistentVolumes"
|
||||
store={volumesStore} isClusterScoped
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: PersistentVolume) => item.getName(),
|
||||
[sortBy.storageClass]: (item: PersistentVolume) => item.spec.storageClassName,
|
||||
[sortBy.capacity]: (item: PersistentVolume) => item.getCapacity(true),
|
||||
[sortBy.status]: (item: PersistentVolume) => item.getStatus(),
|
||||
[sortBy.age]: (item: PersistentVolume) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: PersistentVolume) => item.getSearchFields(),
|
||||
(item: PersistentVolume) => item.getClaimRefName(),
|
||||
]}
|
||||
renderHeaderTitle={<Trans>Persistent Volumes</Trans>}
|
||||
renderTableHeader={[
|
||||
{ title: <Trans>Name</Trans>, className: "name", sortBy: sortBy.name },
|
||||
{ title: <Trans>Storage Class</Trans>, className: "storageClass", sortBy: sortBy.storageClass },
|
||||
{ title: <Trans>Capacity</Trans>, className: "capacity", sortBy: sortBy.capacity },
|
||||
{ title: <Trans>Claim</Trans>, className: "claim" },
|
||||
{ title: <Trans>Age</Trans>, className: "age", sortBy: sortBy.age },
|
||||
{ title: <Trans>Status</Trans>, className: "status", sortBy: sortBy.status },
|
||||
]}
|
||||
renderTableContents={(volume: PersistentVolume) => {
|
||||
const { claimRef, storageClassName } = volume.spec;
|
||||
const storageClassDetailsUrl = getDetailsUrl(storageClassApi.getUrl({
|
||||
name: storageClassName
|
||||
}));
|
||||
return [
|
||||
volume.getName(),
|
||||
<Link to={storageClassDetailsUrl} onClick={stopPropagation}>
|
||||
{storageClassName}
|
||||
</Link>,
|
||||
volume.getCapacity(),
|
||||
claimRef && (
|
||||
<Link to={getDetailsUrl(pvcApi.getUrl(claimRef))} onClick={stopPropagation}>
|
||||
{claimRef.name}
|
||||
</Link>
|
||||
),
|
||||
volume.getAge(),
|
||||
{ title: volume.getStatus(), className: volume.getStatus().toLowerCase() }
|
||||
]
|
||||
}}
|
||||
renderItemMenu={(item: PersistentVolume) => {
|
||||
return <PersistentVolumeMenu object={item}/>
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export function PersistentVolumeMenu(props: KubeObjectMenuProps<PersistentVolume>) {
|
||||
return (
|
||||
<KubeObjectMenu {...props}/>
|
||||
)
|
||||
}
|
||||
|
||||
apiManager.registerViews(persistentVolumeApi, {
|
||||
Menu: PersistentVolumeMenu,
|
||||
})
|
||||
Reference in new issue
Block a user