mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
e468105143
commit
b1ff34879a
470 files changed
+8447
-7443
No files matched your search
@@ -1,2 +1,2 @@
|
||||
export * from "./replicasets"
|
||||
export * from "./replicaset-details"
|
||||
export * from "./replicasets";
|
||||
export * from "./replicaset-details";
|
||||
@@ -12,12 +12,13 @@ import { KubeEventDetails } from "../+events/kube-event-details";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { ReplicaSet, replicaSetApi } from "../../api/endpoints";
|
||||
import { ReplicaSet, replicaSetApi, PodMetricsData } from "../../api/endpoints";
|
||||
import { ResourceMetrics, ResourceMetricsText } from "../resource-metrics";
|
||||
import { PodCharts, podMetricTabs } from "../+workloads-pods/pod-charts";
|
||||
import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
import { Metrics } from "client/api/endpoints/metrics.api";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<ReplicaSet> {
|
||||
}
|
||||
@@ -29,31 +30,33 @@ export class ReplicaSetDetails extends React.Component<Props> {
|
||||
replicaSetStore.reset();
|
||||
});
|
||||
|
||||
async componentDidMount() {
|
||||
async componentDidMount(): Promise<void> {
|
||||
if (!podsStore.isLoaded) {
|
||||
podsStore.loadAll();
|
||||
return podsStore.loadAll();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
componentWillUnmount(): void {
|
||||
replicaSetStore.reset();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { object: replicaSet } = this.props
|
||||
if (!replicaSet) return null
|
||||
const { metrics } = replicaSetStore
|
||||
const { status } = replicaSet
|
||||
const { availableReplicas, replicas } = status
|
||||
const selectors = replicaSet.getSelectors()
|
||||
const nodeSelector = replicaSet.getNodeSelectors()
|
||||
const images = replicaSet.getImages()
|
||||
const childPods = replicaSetStore.getChildPods(replicaSet)
|
||||
render(): JSX.Element {
|
||||
const { object: replicaSet } = this.props;
|
||||
if (!replicaSet) {
|
||||
return null;
|
||||
}
|
||||
const { metrics } = replicaSetStore;
|
||||
const { status } = replicaSet;
|
||||
const { availableReplicas, replicas } = status;
|
||||
const selectors = replicaSet.getSelectors();
|
||||
const nodeSelector = replicaSet.getNodeSelectors();
|
||||
const images = replicaSet.getImages();
|
||||
const childPods = replicaSetStore.getChildPods(replicaSet);
|
||||
return (
|
||||
<div className="ReplicaSetDetails">
|
||||
{podsStore.isLoaded && (
|
||||
<ResourceMetrics
|
||||
loader={() => replicaSetStore.loadMetrics(replicaSet)}
|
||||
loader={(): Promise<PodMetricsData<Metrics>> => replicaSetStore.loadMetrics(replicaSet)}
|
||||
tabs={podMetricTabs} object={replicaSet} params={{ metrics }}
|
||||
>
|
||||
<PodCharts/>
|
||||
@@ -62,23 +65,17 @@ export class ReplicaSetDetails extends React.Component<Props> {
|
||||
<KubeObjectMeta object={replicaSet}/>
|
||||
{selectors.length > 0 &&
|
||||
<DrawerItem name={<Trans>Selector</Trans>} labelsOnly>
|
||||
{
|
||||
selectors.map(label => <Badge key={label} label={label}/>)
|
||||
}
|
||||
{ selectors.map(label => <Badge key={label} label={label}/>) }
|
||||
</DrawerItem>
|
||||
}
|
||||
{nodeSelector.length > 0 &&
|
||||
<DrawerItem name={<Trans>Node Selector</Trans>} labelsOnly>
|
||||
{
|
||||
nodeSelector.map(label => <Badge key={label} label={label}/>)
|
||||
}
|
||||
{ nodeSelector.map(label => <Badge key={label} label={label}/>) }
|
||||
</DrawerItem>
|
||||
}
|
||||
{images.length > 0 &&
|
||||
<DrawerItem name={<Trans>Images</Trans>}>
|
||||
{
|
||||
images.map(image => <p key={image}>{image}</p>)
|
||||
}
|
||||
{ images.map(image => <p key={image}>{image}</p>) }
|
||||
</DrawerItem>
|
||||
}
|
||||
<DrawerItem name={<Trans>Replicas</Trans>}>
|
||||
@@ -93,10 +90,10 @@ export class ReplicaSetDetails extends React.Component<Props> {
|
||||
<PodDetailsList pods={childPods} owner={replicaSet}/>
|
||||
<KubeEventDetails object={replicaSet}/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
apiManager.registerViews(replicaSetApi, {
|
||||
Details: ReplicaSetDetails,
|
||||
})
|
||||
});
|
||||
@@ -1,33 +1,34 @@
|
||||
import { observable } from "mobx";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { Deployment, IPodMetrics, podsApi, ReplicaSet, replicaSetApi } from "../../api/endpoints";
|
||||
import { Deployment, PodMetricsData, podsApi, ReplicaSet, replicaSetApi, Pod } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { Metrics } from "client/api/endpoints/metrics.api";
|
||||
|
||||
@autobind()
|
||||
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
|
||||
api = replicaSetApi
|
||||
@observable metrics: IPodMetrics = null;
|
||||
@observable metrics: PodMetricsData = null;
|
||||
|
||||
loadMetrics(replicaSet: ReplicaSet) {
|
||||
loadMetrics(replicaSet: ReplicaSet): Promise<PodMetricsData<Metrics>> {
|
||||
const pods = this.getChildPods(replicaSet);
|
||||
return podsApi.getMetrics(pods, replicaSet.getNs(), "").then(metrics =>
|
||||
this.metrics = metrics
|
||||
);
|
||||
}
|
||||
|
||||
getChildPods(replicaSet: ReplicaSet) {
|
||||
getChildPods(replicaSet: ReplicaSet): Pod[] {
|
||||
return podsStore.getPodsByOwner(replicaSet);
|
||||
}
|
||||
|
||||
getReplicaSetsByOwner(deployment: Deployment) {
|
||||
getReplicaSetsByOwner(deployment: Deployment): ReplicaSet[] {
|
||||
return this.items.filter(replicaSet =>
|
||||
!!replicaSet.getOwnerRefs().find(owner => owner.uid === deployment.getId())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
reset() {
|
||||
reset(): void {
|
||||
this.metrics = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,22 +27,22 @@ interface Props {
|
||||
@observer
|
||||
export class ReplicaSets extends React.Component<Props> {
|
||||
private sortingCallbacks = {
|
||||
[sortBy.name]: (replicaSet: ReplicaSet) => replicaSet.getName(),
|
||||
[sortBy.namespace]: (replicaSet: ReplicaSet) => replicaSet.getNs(),
|
||||
[sortBy.age]: (replicaSet: ReplicaSet) => replicaSet.metadata.creationTimestamp,
|
||||
[sortBy.pods]: (replicaSet: ReplicaSet) => this.getPodsLength(replicaSet),
|
||||
[sortBy.name]: (replicaSet: ReplicaSet): string => replicaSet.getName(),
|
||||
[sortBy.namespace]: (replicaSet: ReplicaSet): string => replicaSet.getNs(),
|
||||
[sortBy.age]: (replicaSet: ReplicaSet): string => replicaSet.metadata.creationTimestamp,
|
||||
[sortBy.pods]: (replicaSet: ReplicaSet): number => replicaSetStore.getChildPods(replicaSet).length,
|
||||
}
|
||||
|
||||
getPodsLength(replicaSet: ReplicaSet) {
|
||||
return replicaSetStore.getChildPods(replicaSet).length;
|
||||
}
|
||||
|
||||
render() {
|
||||
render(): JSX.Element {
|
||||
const { replicaSets } = this.props;
|
||||
if (!replicaSets.length && !replicaSetStore.isLoaded) return (
|
||||
<div className="ReplicaSets"><Spinner center/></div>
|
||||
);
|
||||
if (!replicaSets.length) return null;
|
||||
if (!replicaSets.length && !replicaSetStore.isLoaded) {
|
||||
return (
|
||||
<div className="ReplicaSets"><Spinner center/></div>
|
||||
);
|
||||
}
|
||||
if (!replicaSets.length) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="ReplicaSets flex column">
|
||||
<DrawerTitle title={<Trans>Deploy Revisions</Trans>}/>
|
||||
@@ -72,13 +72,13 @@ export class ReplicaSets extends React.Component<Props> {
|
||||
>
|
||||
<TableCell className="name">{replica.getName()}</TableCell>
|
||||
<TableCell className="namespace">{replica.getNs()}</TableCell>
|
||||
<TableCell className="pods">{this.getPodsLength(replica)}</TableCell>
|
||||
<TableCell className="pods">{replicaSetStore.getChildPods(replica).length}</TableCell>
|
||||
<TableCell className="age">{replica.getAge()}</TableCell>
|
||||
<TableCell className="actions" onClick={stopPropagation}>
|
||||
<ReplicaSetMenu object={replica}/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</Table>
|
||||
@@ -87,10 +87,10 @@ export class ReplicaSets extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export function ReplicaSetMenu(props: KubeObjectMenuProps<ReplicaSet>) {
|
||||
export function ReplicaSetMenu(props: KubeObjectMenuProps<ReplicaSet>): JSX.Element {
|
||||
return (
|
||||
<KubeObjectMenu {...props}/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
apiManager.registerViews(replicaSetApi, {
|
||||
|
||||
Reference in new issue
Block a user