mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Rename ResourceStatus* -> KubeObjectStatus*
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
18b05568dd
commit
04610ec4c6
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "event-resource-status",
|
||||
"name": "kube-object-event-status",
|
||||
"version": "0.1.0",
|
||||
"description": "Adds resource status from events",
|
||||
"description": "Adds kube object status from events",
|
||||
"renderer": "dist/renderer.js",
|
||||
"lens": {
|
||||
"metadata": {},
|
||||
@ -2,7 +2,7 @@ import { LensRendererExtension, K8sApi } from "@k8slens/extensions";
|
||||
import { resolveStatus, resolveStatusForCronJobs, resolveStatusForPods } from "./src/resolver"
|
||||
|
||||
export default class EventResourceStatusRendererExtension extends LensRendererExtension {
|
||||
resourceStatusTexts = [
|
||||
kubeObjectStatusTexts = [
|
||||
{
|
||||
kind: "Pod",
|
||||
apiVersions: ["v1"],
|
||||
@ -1,6 +1,6 @@
|
||||
import { ResourceStatus, K8sApi } from "@k8slens/extensions";
|
||||
import { KubeObjectStatus, K8sApi } from "@k8slens/extensions";
|
||||
|
||||
export function resolveStatus(object: K8sApi.KubeObject): ResourceStatus.Status {
|
||||
export function resolveStatus(object: K8sApi.KubeObject): KubeObjectStatus.Status {
|
||||
const eventStore = K8sApi.apiManager.getStore(K8sApi.eventApi)
|
||||
const events = (eventStore as K8sApi.EventStore).getEventsByObject(object);
|
||||
let warnings = events.filter(evt => evt.isWarning());
|
||||
@ -9,13 +9,13 @@ export function resolveStatus(object: K8sApi.KubeObject): ResourceStatus.Status
|
||||
}
|
||||
const event = [...warnings, ...events][0]; // get latest event
|
||||
return {
|
||||
level: ResourceStatus.Level.WARNING,
|
||||
level: KubeObjectStatus.Level.WARNING,
|
||||
text: `${event.message}`,
|
||||
timestamp: event.metadata.creationTimestamp
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveStatusForPods(pod: K8sApi.Pod): ResourceStatus.Status {
|
||||
export function resolveStatusForPods(pod: K8sApi.Pod): KubeObjectStatus.Status {
|
||||
if (!pod.hasIssues()) {
|
||||
return null
|
||||
}
|
||||
@ -27,13 +27,13 @@ export function resolveStatusForPods(pod: K8sApi.Pod): ResourceStatus.Status {
|
||||
}
|
||||
const event = [...warnings, ...events][0]; // get latest event
|
||||
return {
|
||||
level: ResourceStatus.Level.WARNING,
|
||||
level: KubeObjectStatus.Level.WARNING,
|
||||
text: `${event.message}`,
|
||||
timestamp: event.metadata.creationTimestamp
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveStatusForCronJobs(cronJob: K8sApi.CronJob): ResourceStatus.Status {
|
||||
export function resolveStatusForCronJobs(cronJob: K8sApi.CronJob): KubeObjectStatus.Status {
|
||||
const eventStore = K8sApi.apiManager.getStore(K8sApi.eventApi)
|
||||
let events = (eventStore as K8sApi.EventStore).getEventsByObject(cronJob);
|
||||
let warnings = events.filter(evt => evt.isWarning());
|
||||
@ -45,7 +45,7 @@ export function resolveStatusForCronJobs(cronJob: K8sApi.CronJob): ResourceStatu
|
||||
}
|
||||
const event = [...warnings, ...events][0]; // get latest event
|
||||
return {
|
||||
level: ResourceStatus.Level.WARNING,
|
||||
level: KubeObjectStatus.Level.WARNING,
|
||||
text: `${event.message}`,
|
||||
timestamp: event.metadata.creationTimestamp
|
||||
}
|
||||
@ -191,7 +191,7 @@
|
||||
"metrics-cluster-feature",
|
||||
"license-menu-item",
|
||||
"support-page",
|
||||
"event-resource-status"
|
||||
"kube-object-event-status"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@ -8,7 +8,7 @@ import logger from "../main/logger"
|
||||
import { app, ipcRenderer, remote } from "electron"
|
||||
import {
|
||||
appPreferenceRegistry, clusterFeatureRegistry, clusterPageRegistry, globalPageRegistry,
|
||||
kubeObjectDetailRegistry, kubeObjectMenuRegistry, menuRegistry, statusBarRegistry, resourceStatusRegistry
|
||||
kubeObjectDetailRegistry, kubeObjectMenuRegistry, menuRegistry, statusBarRegistry, kubeObjectStatusRegistry
|
||||
} from "./registries";
|
||||
|
||||
export interface InstalledExtension extends ExtensionModel {
|
||||
@ -60,7 +60,7 @@ export class ExtensionLoader {
|
||||
extension.registerTo(clusterPageRegistry, extension.clusterPages)
|
||||
extension.registerTo(kubeObjectMenuRegistry, extension.kubeObjectMenuItems)
|
||||
extension.registerTo(kubeObjectDetailRegistry, extension.kubeObjectDetailItems)
|
||||
extension.registerTo(resourceStatusRegistry, extension.resourceStatusTexts)
|
||||
extension.registerTo(kubeObjectStatusRegistry, extension.kubeObjectStatusTexts)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type {
|
||||
AppPreferenceRegistration, ClusterFeatureRegistration,
|
||||
KubeObjectMenuRegistration, KubeObjectDetailRegistration,
|
||||
PageRegistration, StatusBarRegistration, ResourceStatusRegistration
|
||||
PageRegistration, StatusBarRegistration, KubeObjectStatusRegistration
|
||||
} from "./registries"
|
||||
import { observable } from "mobx";
|
||||
import { LensExtension } from "./lens-extension"
|
||||
@ -9,7 +9,7 @@ import { LensExtension } from "./lens-extension"
|
||||
export class LensRendererExtension extends LensExtension {
|
||||
@observable.shallow globalPages: PageRegistration[] = []
|
||||
@observable.shallow clusterPages: PageRegistration[] = []
|
||||
@observable.shallow resourceStatusTexts: ResourceStatusRegistration[] = []
|
||||
@observable.shallow kubeObjectStatusTexts: KubeObjectStatusRegistration[] = []
|
||||
@observable.shallow appPreferences: AppPreferenceRegistration[] = []
|
||||
@observable.shallow clusterFeatures: ClusterFeatureRegistration[] = []
|
||||
@observable.shallow statusBarItems: StatusBarRegistration[] = []
|
||||
|
||||
@ -7,4 +7,4 @@ export * from "./status-bar-registry"
|
||||
export * from "./kube-object-detail-registry";
|
||||
export * from "./kube-object-menu-registry";
|
||||
export * from "./cluster-feature-registry"
|
||||
export * from "./resource-status-registry"
|
||||
export * from "./kube-object-status-registry"
|
||||
|
||||
@ -2,25 +2,25 @@ import { KubeObject } from "../renderer-api/k8s-api";
|
||||
|
||||
import { BaseRegistry } from "./base-registry";
|
||||
|
||||
export enum ResourceStatusLevel {
|
||||
export enum KubeObjectStatusLevel {
|
||||
INFO = 1,
|
||||
WARNING = 2,
|
||||
CRITICAL = 3
|
||||
}
|
||||
|
||||
export type ResourceStatus = {
|
||||
export type KubeObjectStatus = {
|
||||
level: number;
|
||||
text: string;
|
||||
timestamp?: string;
|
||||
}
|
||||
|
||||
export interface ResourceStatusRegistration {
|
||||
export interface KubeObjectStatusRegistration {
|
||||
kind: string;
|
||||
apiVersions: string[];
|
||||
resolve: (object: KubeObject) => ResourceStatus;
|
||||
resolve: (object: KubeObject) => KubeObjectStatus;
|
||||
}
|
||||
|
||||
export class ResourceStatusRegistry extends BaseRegistry<ResourceStatusRegistration> {
|
||||
export class KubeObjectStatusRegistry extends BaseRegistry<KubeObjectStatusRegistration> {
|
||||
getItemsForKind(kind: string, apiVersion: string) {
|
||||
return this.items.filter((item) => {
|
||||
return item.kind === kind && item.apiVersions.includes(apiVersion)
|
||||
@ -28,4 +28,4 @@ export class ResourceStatusRegistry extends BaseRegistry<ResourceStatusRegistrat
|
||||
}
|
||||
}
|
||||
|
||||
export const resourceStatusRegistry = new ResourceStatusRegistry();
|
||||
export const kubeObjectStatusRegistry = new KubeObjectStatusRegistry();
|
||||
@ -4,11 +4,11 @@
|
||||
import * as Component from "./components"
|
||||
import * as K8sApi from "./k8s-api"
|
||||
import * as Navigation from "./navigation"
|
||||
import * as ResourceStatus from "./resource-status"
|
||||
import * as KubeObjectStatus from "./kube-object-status"
|
||||
|
||||
export {
|
||||
Component,
|
||||
K8sApi,
|
||||
Navigation,
|
||||
ResourceStatus
|
||||
KubeObjectStatus
|
||||
}
|
||||
|
||||
1
src/extensions/renderer-api/kube-object-status.ts
Normal file
1
src/extensions/renderer-api/kube-object-status.ts
Normal file
@ -0,0 +1 @@
|
||||
export { KubeObjectStatus as Status, KubeObjectStatusLevel as Level } from "../registries/kube-object-status-registry"
|
||||
@ -1 +0,0 @@
|
||||
export { ResourceStatus as Status, ResourceStatusLevel as Level } from "../registries/resource-status-registry"
|
||||
@ -10,7 +10,7 @@ import { HorizontalPodAutoscaler } from "../../api/endpoints/hpa.api";
|
||||
import { hpaStore } from "./hpa.store";
|
||||
import { Badge } from "../badge";
|
||||
import { cssNames } from "../../utils";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -62,7 +62,7 @@ export class HorizontalPodAutoscalers extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(hpa: HorizontalPodAutoscaler) => [
|
||||
hpa.getName(),
|
||||
<KubeResourceStatusIcon object={hpa} />,
|
||||
<KubeObjectStatusIcon object={hpa} />,
|
||||
hpa.getNs(),
|
||||
this.getTargets(hpa),
|
||||
hpa.getMinPods(),
|
||||
|
||||
@ -10,7 +10,7 @@ import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IConfigMapsRouteParams } from "./config-maps.route";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -48,7 +48,7 @@ export class ConfigMaps extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(configMap: ConfigMap) => [
|
||||
configMap.getName(),
|
||||
<KubeResourceStatusIcon object={configMap}/>,
|
||||
<KubeObjectStatusIcon object={configMap}/>,
|
||||
configMap.getNs(),
|
||||
configMap.getKeys().join(", "),
|
||||
configMap.getAge(),
|
||||
|
||||
@ -10,7 +10,7 @@ import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-
|
||||
import { KubeObjectDetailsProps, KubeObjectListLayout } from "../kube-object";
|
||||
import { IPodDisruptionBudgetsRouteParams } from "./pod-disruption-budgets.route";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -58,7 +58,7 @@ export class PodDisruptionBudgets extends React.Component<Props> {
|
||||
renderTableContents={(pdb: PodDisruptionBudget) => {
|
||||
return [
|
||||
pdb.getName(),
|
||||
<KubeResourceStatusIcon object={pdb} />,
|
||||
<KubeObjectStatusIcon object={pdb} />,
|
||||
pdb.getNs(),
|
||||
pdb.getMinAvailable(),
|
||||
pdb.getMaxUnavailable(),
|
||||
|
||||
@ -11,7 +11,7 @@ import { AddQuotaDialog } from "./add-quota-dialog";
|
||||
import { resourceQuotaStore } from "./resource-quotas.store";
|
||||
import { IResourceQuotaRouteParams } from "./resource-quotas.route";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -47,7 +47,7 @@ export class ResourceQuotas extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(resourceQuota: ResourceQuota) => [
|
||||
resourceQuota.getName(),
|
||||
<KubeResourceStatusIcon object={resourceQuota}/>,
|
||||
<KubeObjectStatusIcon object={resourceQuota}/>,
|
||||
resourceQuota.getNs(),
|
||||
resourceQuota.getAge(),
|
||||
]}
|
||||
|
||||
@ -12,7 +12,7 @@ import { KubeObjectListLayout } from "../kube-object";
|
||||
import { Badge } from "../badge";
|
||||
import { secretsStore } from "./secrets.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -57,7 +57,7 @@ export class Secrets extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(secret: Secret) => [
|
||||
secret.getName(),
|
||||
<KubeResourceStatusIcon object={secret} />,
|
||||
<KubeObjectStatusIcon object={secret} />,
|
||||
secret.getNs(),
|
||||
secret.getLabels().map(label => <Badge key={label} label={label}/>),
|
||||
secret.getKeys().join(", "),
|
||||
|
||||
@ -10,7 +10,7 @@ import { RouteComponentProps } from "react-router";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { INamespacesRouteParams } from "./namespaces.route";
|
||||
import { namespaceStore } from "./namespace.store";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -49,7 +49,7 @@ export class Namespaces extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(item: Namespace) => [
|
||||
item.getName(),
|
||||
<KubeResourceStatusIcon object={item} />,
|
||||
<KubeObjectStatusIcon object={item} />,
|
||||
item.getLabels().map(label => <Badge key={label} label={label}/>),
|
||||
item.getAge(),
|
||||
{ title: item.getStatus(), className: item.getStatus().toLowerCase() },
|
||||
|
||||
@ -8,7 +8,7 @@ import { Endpoint } from "../../api/endpoints/endpoint.api"
|
||||
import { endpointStore } from "./endpoints.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -43,7 +43,7 @@ export class Endpoints extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(endpoint: Endpoint) => [
|
||||
endpoint.getName(),
|
||||
<KubeResourceStatusIcon object={endpoint} />,
|
||||
<KubeObjectStatusIcon object={endpoint} />,
|
||||
endpoint.getNs(),
|
||||
endpoint.toString(),
|
||||
endpoint.getAge(),
|
||||
|
||||
@ -8,7 +8,7 @@ import { Ingress } from "../../api/endpoints/ingress.api"
|
||||
import { ingressStore } from "./ingress.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -45,7 +45,7 @@ export class Ingresses extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(ingress: Ingress) => [
|
||||
ingress.getName(),
|
||||
<KubeResourceStatusIcon object={ingress} />,
|
||||
<KubeObjectStatusIcon object={ingress} />,
|
||||
ingress.getNs(),
|
||||
ingress.getLoadBalancers().map(lb => <p key={lb}>{lb}</p>),
|
||||
ingress.getRoutes().map(route => <p key={route}>{route}</p>),
|
||||
|
||||
@ -8,7 +8,7 @@ import { NetworkPolicy } from "../../api/endpoints/network-policy.api";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { INetworkPoliciesRouteParams } from "./network-policies.route";
|
||||
import { networkPolicyStore } from "./network-policy.store";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -43,7 +43,7 @@ export class NetworkPolicies extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(item: NetworkPolicy) => [
|
||||
item.getName(),
|
||||
<KubeResourceStatusIcon object={item} />,
|
||||
<KubeObjectStatusIcon object={item} />,
|
||||
item.getNs(),
|
||||
item.getTypes().join(", "),
|
||||
item.getAge(),
|
||||
|
||||
@ -9,7 +9,7 @@ import { Service } from "../../api/endpoints/service.api";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { Badge } from "../badge";
|
||||
import { serviceStore } from "./services.store";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -61,7 +61,7 @@ export class Services extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(service: Service) => [
|
||||
service.getName(),
|
||||
<KubeResourceStatusIcon object={service} />,
|
||||
<KubeObjectStatusIcon object={service} />,
|
||||
service.getNs(),
|
||||
service.getType(),
|
||||
service.getClusterIp(),
|
||||
|
||||
@ -16,7 +16,7 @@ import { bytesToUnits } from "../../utils/convertMemory";
|
||||
import { Tooltip, TooltipPosition } from "../tooltip";
|
||||
import kebabCase from "lodash/kebabCase";
|
||||
import upperFirst from "lodash/upperFirst";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -163,7 +163,7 @@ export class Nodes extends React.Component<Props> {
|
||||
const tooltipId = `node-taints-${node.getId()}`;
|
||||
return [
|
||||
node.getName(),
|
||||
<KubeResourceStatusIcon object={node} />,
|
||||
<KubeObjectStatusIcon object={node} />,
|
||||
this.renderCpuUsage(node),
|
||||
this.renderMemoryUsage(node),
|
||||
this.renderDiskUsage(node),
|
||||
|
||||
@ -6,7 +6,7 @@ import { Trans } from "@lingui/macro";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { podSecurityPoliciesStore } from "./pod-security-policies.store";
|
||||
import { PodSecurityPolicy, pspApi } from "../../api/endpoints";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -45,7 +45,7 @@ export class PodSecurityPolicies extends React.Component {
|
||||
renderTableContents={(item: PodSecurityPolicy) => {
|
||||
return [
|
||||
item.getName(),
|
||||
<KubeResourceStatusIcon object={item} />,
|
||||
<KubeObjectStatusIcon object={item} />,
|
||||
item.isPrivileged() ? <Trans>Yes</Trans> : <Trans>No</Trans>,
|
||||
item.getVolumes().join(", "),
|
||||
item.getAge(),
|
||||
|
||||
@ -8,7 +8,7 @@ import { StorageClass, storageClassApi } from "../../api/endpoints/storage-class
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IStorageClassesRouteParams } from "./storage-classes.route";
|
||||
import { storageClassStore } from "./storage-class.store";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -48,7 +48,7 @@ export class StorageClasses extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(storageClass: StorageClass) => [
|
||||
storageClass.getName(),
|
||||
<KubeResourceStatusIcon object={storageClass} />,
|
||||
<KubeObjectStatusIcon object={storageClass} />,
|
||||
storageClass.provisioner,
|
||||
storageClass.getReclaimPolicy(),
|
||||
storageClass.isDefault() ? <Trans>Yes</Trans> : null,
|
||||
|
||||
@ -13,7 +13,7 @@ import { unitsToBytes } from "../../utils/convertMemory";
|
||||
import { stopPropagation } from "../../utils";
|
||||
import { getDetailsUrl } from "../../navigation";
|
||||
import { storageClassApi } from "../../api/endpoints";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -68,7 +68,7 @@ export class PersistentVolumeClaims extends React.Component<Props> {
|
||||
}));
|
||||
return [
|
||||
pvc.getName(),
|
||||
<KubeResourceStatusIcon object={pvc} />,
|
||||
<KubeObjectStatusIcon object={pvc} />,
|
||||
pvc.getNs(),
|
||||
<Link to={storageClassDetailsUrl} onClick={stopPropagation}>
|
||||
{storageClassName}
|
||||
|
||||
@ -11,7 +11,7 @@ import { stopPropagation } from "../../utils";
|
||||
import { getDetailsUrl } from "../../navigation";
|
||||
import { volumesStore } from "./volumes.store";
|
||||
import { pvcApi, storageClassApi } from "../../api/endpoints";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -59,7 +59,7 @@ export class PersistentVolumes extends React.Component<Props> {
|
||||
}));
|
||||
return [
|
||||
volume.getName(),
|
||||
<KubeResourceStatusIcon object={volume} />,
|
||||
<KubeObjectStatusIcon object={volume} />,
|
||||
<Link to={storageClassDetailsUrl} onClick={stopPropagation}>
|
||||
{storageClassName}
|
||||
</Link>,
|
||||
|
||||
@ -9,7 +9,7 @@ import { RoleBinding } from "../../api/endpoints";
|
||||
import { roleBindingsStore } from "./role-bindings.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { AddRoleBindingDialog } from "./add-role-binding-dialog";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -48,7 +48,7 @@ export class RoleBindings extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(binding: RoleBinding) => [
|
||||
binding.getName(),
|
||||
<KubeResourceStatusIcon object={binding} />,
|
||||
<KubeObjectStatusIcon object={binding} />,
|
||||
binding.getSubjectNames(),
|
||||
binding.getNs() || "-",
|
||||
binding.getAge(),
|
||||
|
||||
@ -9,7 +9,7 @@ import { rolesStore } from "./roles.store";
|
||||
import { Role } from "../../api/endpoints";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { AddRoleDialog } from "./add-role-dialog";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -45,7 +45,7 @@ export class Roles extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(role: Role) => [
|
||||
role.getName(),
|
||||
<KubeResourceStatusIcon object={role} />,
|
||||
<KubeObjectStatusIcon object={role} />,
|
||||
role.getNs() || "-",
|
||||
role.getAge(),
|
||||
]}
|
||||
|
||||
@ -14,7 +14,7 @@ import { IServiceAccountsRouteParams } from "../+user-management";
|
||||
import { serviceAccountsStore } from "./service-accounts.store";
|
||||
import { CreateServiceAccountDialog } from "./create-service-account-dialog";
|
||||
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -49,7 +49,7 @@ export class ServiceAccounts extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(account: ServiceAccount) => [
|
||||
account.getName(),
|
||||
<KubeResourceStatusIcon object={account} />,
|
||||
<KubeObjectStatusIcon object={account} />,
|
||||
account.getNs(),
|
||||
account.getAge(),
|
||||
]}
|
||||
|
||||
@ -16,7 +16,7 @@ import { KubeObjectListLayout } from "../kube-object";
|
||||
import { _i18n } from "../../i18n";
|
||||
import { CronJobTriggerDialog } from "./cronjob-trigger-dialog";
|
||||
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -62,7 +62,7 @@ export class CronJobs extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(cronJob: CronJob) => [
|
||||
cronJob.getName(),
|
||||
<KubeResourceStatusIcon object={cronJob} />,
|
||||
<KubeObjectStatusIcon object={cronJob} />,
|
||||
cronJob.getNs(),
|
||||
cronJob.isNeverRun() ? <Trans>never</Trans> : cronJob.getSchedule(),
|
||||
cronJob.getSuspendFlag(),
|
||||
|
||||
@ -12,7 +12,7 @@ import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IDaemonSetsRouteParams } from "../+workloads";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { Badge } from "../badge";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -64,7 +64,7 @@ export class DaemonSets extends React.Component<Props> {
|
||||
daemonSet.getName(),
|
||||
daemonSet.getNs(),
|
||||
this.getPodsLength(daemonSet),
|
||||
<KubeResourceStatusIcon object={daemonSet}/>,
|
||||
<KubeObjectStatusIcon object={daemonSet}/>,
|
||||
this.renderNodeSelector(daemonSet),
|
||||
daemonSet.getAge(),
|
||||
]}
|
||||
|
||||
@ -21,7 +21,7 @@ import { cssNames } from "../../utils";
|
||||
import kebabCase from "lodash/kebabCase";
|
||||
import orderBy from "lodash/orderBy";
|
||||
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -81,7 +81,7 @@ export class Deployments extends React.Component<Props> {
|
||||
deployment.getNs(),
|
||||
this.renderPods(deployment),
|
||||
deployment.getReplicas(),
|
||||
<KubeResourceStatusIcon object={deployment}/>,
|
||||
<KubeObjectStatusIcon object={deployment}/>,
|
||||
deployment.getAge(),
|
||||
this.renderConditions(deployment),
|
||||
]}
|
||||
|
||||
@ -11,7 +11,7 @@ import { Job } from "../../api/endpoints/job.api";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IJobsRouteParams } from "../+workloads";
|
||||
import kebabCase from "lodash/kebabCase";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -54,7 +54,7 @@ export class Jobs extends React.Component<Props> {
|
||||
job.getName(),
|
||||
job.getNs(),
|
||||
`${job.getCompletions()} / ${job.getDesiredCompletions()}`,
|
||||
<KubeResourceStatusIcon object={job}/>,
|
||||
<KubeObjectStatusIcon object={job}/>,
|
||||
job.getAge(),
|
||||
condition && {
|
||||
title: condition.type,
|
||||
|
||||
@ -14,7 +14,7 @@ import { showDetails } from "../../navigation";
|
||||
import { reaction } from "mobx";
|
||||
import { Spinner } from "../spinner";
|
||||
import { DrawerTitle } from "../drawer";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -107,7 +107,7 @@ export class PodDetailsList extends React.Component<Props> {
|
||||
onClick={prevDefault(() => showDetails(pod.selfLink, false))}
|
||||
>
|
||||
<TableCell className="name">{pod.getName()}</TableCell>
|
||||
<TableCell className="warning"><KubeResourceStatusIcon object={pod}/></TableCell>
|
||||
<TableCell className="warning"><KubeObjectStatusIcon object={pod}/></TableCell>
|
||||
<TableCell className="namespace">{pod.getNs()}</TableCell>
|
||||
<TableCell className="cpu">{this.renderCpuUsage(`cpu-${pod.getId()}`, metrics.cpu)}</TableCell>
|
||||
<TableCell className="memory">{this.renderMemoryUsage(`memory-${pod.getId()}`, metrics.memory)}</TableCell>
|
||||
|
||||
@ -18,7 +18,7 @@ import toPairs from "lodash/toPairs";
|
||||
import startCase from "lodash/startCase";
|
||||
import kebabCase from "lodash/kebabCase";
|
||||
import { lookupApiLink } from "../../api/kube-api";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
|
||||
enum sortBy {
|
||||
@ -81,7 +81,7 @@ export class Pods extends React.Component<Props> {
|
||||
|
||||
renderPodStatusIcons(pod: Pod) {
|
||||
return (
|
||||
<KubeResourceStatusIcon object={pod} />
|
||||
<KubeObjectStatusIcon object={pod} />
|
||||
)
|
||||
}
|
||||
render() {
|
||||
|
||||
@ -12,7 +12,7 @@ import { DrawerTitle } from "../drawer";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import { showDetails } from "../../navigation";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -73,7 +73,7 @@ export class ReplicaSets extends React.Component<Props> {
|
||||
onClick={prevDefault(() => showDetails(replica.selfLink, false))}
|
||||
>
|
||||
<TableCell className="name">{replica.getName()}</TableCell>
|
||||
<TableCell className="warning"><KubeResourceStatusIcon object={replica}/></TableCell>
|
||||
<TableCell className="warning"><KubeObjectStatusIcon object={replica}/></TableCell>
|
||||
<TableCell className="namespace">{replica.getNs()}</TableCell>
|
||||
<TableCell className="pods">{this.getPodsLength(replica)}</TableCell>
|
||||
<TableCell className="age">{replica.getAge()}</TableCell>
|
||||
|
||||
@ -11,7 +11,7 @@ import { nodesStore } from "../+nodes/nodes.store";
|
||||
import { eventStore } from "../+events/event.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IStatefulSetsRouteParams } from "../+workloads";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -55,7 +55,7 @@ export class StatefulSets extends React.Component<Props> {
|
||||
statefulSet.getName(),
|
||||
statefulSet.getNs(),
|
||||
this.getPodsLength(statefulSet),
|
||||
<KubeResourceStatusIcon object={statefulSet}/>,
|
||||
<KubeObjectStatusIcon object={statefulSet}/>,
|
||||
statefulSet.getAge(),
|
||||
]}
|
||||
/>
|
||||
|
||||
1
src/renderer/components/kube-object-status-icon/index.ts
Normal file
1
src/renderer/components/kube-object-status-icon/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./kube-object-status-icon"
|
||||
@ -1,32 +1,32 @@
|
||||
.ResourceStatusIcon {
|
||||
.KubeObjectStatusIcon {
|
||||
&.warning {
|
||||
color: $golden;
|
||||
}
|
||||
}
|
||||
|
||||
.ResourceStatusTooltip {
|
||||
.KubeObjectStatusTooltip {
|
||||
white-space: normal;
|
||||
|
||||
|
||||
.ResourceStatusLevel {
|
||||
.level {
|
||||
padding: 4px;
|
||||
|
||||
&:not(:only-child):not(:last-child) {
|
||||
border-bottom: 1px solid $borderFaintColor;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-weight: bold;
|
||||
.Icon {
|
||||
margin-right: $margin;
|
||||
}
|
||||
}
|
||||
|
||||
.msg {
|
||||
margin: $margin / 2
|
||||
}
|
||||
|
||||
.age {
|
||||
color: $halfGray;
|
||||
}
|
||||
}
|
||||
|
||||
.ResourceStatusTitle {
|
||||
font-weight: bold;
|
||||
.Icon {
|
||||
margin-right: $margin;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
import "./kube-object-status-icon.scss";
|
||||
|
||||
import React from "react";
|
||||
import { Icon } from "../icon";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import { cssNames, formatDuration } from "../../utils";
|
||||
import { KubeObjectStatusRegistration, KubeObjectStatus, KubeObjectStatusLevel, kubeObjectStatusRegistry } from "../../../extensions/registries/kube-object-status-registry"
|
||||
import { computed } from "mobx";
|
||||
|
||||
interface Props {
|
||||
object: KubeObject;
|
||||
}
|
||||
|
||||
export class KubeObjectStatusIcon extends React.Component<Props> {
|
||||
@computed get objectStatuses() {
|
||||
const { object } = this.props;
|
||||
const registrations = kubeObjectStatusRegistry.getItemsForKind(object.kind, object.apiVersion)
|
||||
return registrations.map((item: KubeObjectStatusRegistration) => { return item.resolve(object) }).filter((item: KubeObjectStatus) => !!item)
|
||||
}
|
||||
|
||||
statusClassName(level: number): string {
|
||||
switch (level) {
|
||||
case KubeObjectStatusLevel.INFO:
|
||||
return "info"
|
||||
case KubeObjectStatusLevel.WARNING:
|
||||
return "warning"
|
||||
case KubeObjectStatusLevel.CRITICAL:
|
||||
return "error"
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
statusTitle(level: number): string {
|
||||
switch (level) {
|
||||
case KubeObjectStatusLevel.INFO:
|
||||
return "Info"
|
||||
case KubeObjectStatusLevel.WARNING:
|
||||
return "Warning"
|
||||
case KubeObjectStatusLevel.CRITICAL:
|
||||
return "Critical"
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
getAge(timestamp: string) {
|
||||
if (!timestamp) return ""
|
||||
const diff = new Date().getTime() - new Date(timestamp).getTime();
|
||||
return formatDuration(diff, true);
|
||||
}
|
||||
|
||||
renderStatuses(statuses: KubeObjectStatus[], level: number) {
|
||||
const filteredStatuses = statuses.filter((item) => item.level == level)
|
||||
|
||||
return filteredStatuses.length > 0 && (
|
||||
<div className={cssNames("level", this.statusClassName(level))}>
|
||||
<span className="title">
|
||||
{this.statusTitle(level)}
|
||||
</span>
|
||||
{ filteredStatuses.map((status, index) =>{
|
||||
return (
|
||||
<div key={`kube-resource-status-${level}-${index}`} className={cssNames("status", "msg")}>
|
||||
- {status.text} <span className="age"> · { this.getAge(status.timestamp) }</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { objectStatuses} = this
|
||||
if (!objectStatuses.length) return null
|
||||
|
||||
const sortedStatuses = objectStatuses.sort((a: KubeObjectStatus, b: KubeObjectStatus) => {
|
||||
if (a.level < b.level ) {
|
||||
return 1
|
||||
}
|
||||
if (a.level > b.level ) {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
const level = this.statusClassName(sortedStatuses[0].level)
|
||||
return (
|
||||
<Icon
|
||||
material={level}
|
||||
className={cssNames("KubeObjectStatusIcon", level)}
|
||||
tooltip={{
|
||||
children: (
|
||||
<div className="KubeObjectStatusTooltip">
|
||||
{this.renderStatuses(sortedStatuses, KubeObjectStatusLevel.CRITICAL)}
|
||||
{this.renderStatuses(sortedStatuses, KubeObjectStatusLevel.WARNING)}
|
||||
{this.renderStatuses(sortedStatuses, KubeObjectStatusLevel.INFO)}
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ import { DrawerItem, DrawerItemLabels } from "../drawer";
|
||||
import { getDetailsUrl } from "../../navigation";
|
||||
import { lookupApiLink } from "../../api/kube-api";
|
||||
import { Link } from "react-router-dom";
|
||||
import { KubeResourceStatusIcon } from "../kube-resource-status-icon";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
export interface Props {
|
||||
object: KubeObject;
|
||||
@ -37,7 +37,7 @@ export class KubeObjectMeta extends React.Component<Props> {
|
||||
{getAge(true, false)} <Trans>ago</Trans> ({creationTimestamp})
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Name</Trans>} hidden={this.isHidden("name")}>
|
||||
{getName()} <KubeResourceStatusIcon object={object} />
|
||||
{getName()} <KubeObjectStatusIcon object={object} />
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Namespace</Trans>} hidden={this.isHidden("namespace") || !getNs()}>
|
||||
{getNs()}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
export * from "./kube-resource-status-icon"
|
||||
@ -1,103 +0,0 @@
|
||||
import "./kube-resource-status-icon.scss";
|
||||
|
||||
import React from "react";
|
||||
import { Icon } from "../icon";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import { cssNames, formatDuration } from "../../utils";
|
||||
import { ResourceStatusRegistration, ResourceStatus, ResourceStatusLevel, resourceStatusRegistry } from "../../../extensions/registries/resource-status-registry"
|
||||
import { computed } from "mobx";
|
||||
|
||||
interface Props {
|
||||
object: KubeObject;
|
||||
}
|
||||
|
||||
export class KubeResourceStatusIcon extends React.Component<Props> {
|
||||
@computed get resourceStatuses() {
|
||||
const { object } = this.props;
|
||||
const registrations = resourceStatusRegistry.getItemsForKind(object.kind, object.apiVersion)
|
||||
return registrations.map((item: ResourceStatusRegistration) => { return item.resolve(object) }).filter((item: ResourceStatus) => !!item)
|
||||
}
|
||||
|
||||
resourceStatusClassName(level: number): string {
|
||||
switch (level) {
|
||||
case ResourceStatusLevel.INFO:
|
||||
return "info"
|
||||
case ResourceStatusLevel.WARNING:
|
||||
return "warning"
|
||||
case ResourceStatusLevel.CRITICAL:
|
||||
return "error"
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
resourceStatusTitle(level: number): string {
|
||||
switch (level) {
|
||||
case ResourceStatusLevel.INFO:
|
||||
return "Info"
|
||||
case ResourceStatusLevel.WARNING:
|
||||
return "Warning"
|
||||
case ResourceStatusLevel.CRITICAL:
|
||||
return "Critical"
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
getAge(timestamp: string) {
|
||||
if (!timestamp) return ""
|
||||
const diff = new Date().getTime() - new Date(timestamp).getTime();
|
||||
return formatDuration(diff, true);
|
||||
}
|
||||
|
||||
renderStatuses(statuses: ResourceStatus[], level: number) {
|
||||
const filteredStatuses = statuses.filter((item) => item.level == level)
|
||||
|
||||
return filteredStatuses.length > 0 && (
|
||||
<div className={cssNames("ResourceStatusLevel", this.resourceStatusClassName(level))}>
|
||||
<span className="ResourceStatusTitle">
|
||||
{this.resourceStatusTitle(level)}
|
||||
</span>
|
||||
{ filteredStatuses.map((status, index) =>{
|
||||
return (
|
||||
<div key={`kube-resource-status-${level}-${index}`} className={cssNames("status", "msg")}>
|
||||
- {status.text} <span className="age"> · { this.getAge(status.timestamp) }</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { resourceStatuses} = this
|
||||
if (!resourceStatuses.length) return null
|
||||
|
||||
const sortedStatuses = resourceStatuses.sort((a: ResourceStatus, b: ResourceStatus) => {
|
||||
if (a.level < b.level ) {
|
||||
return 1
|
||||
}
|
||||
if (a.level > b.level ) {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
const level = this.resourceStatusClassName(sortedStatuses[0].level)
|
||||
return (
|
||||
<Icon
|
||||
material={level}
|
||||
className={cssNames("ResourceStatusIcon", level)}
|
||||
tooltip={{
|
||||
children: (
|
||||
<div className="ResourceStatusTooltip">
|
||||
{this.renderStatuses(sortedStatuses, ResourceStatusLevel.CRITICAL)}
|
||||
{this.renderStatuses(sortedStatuses, ResourceStatusLevel.WARNING)}
|
||||
{this.renderStatuses(sortedStatuses, ResourceStatusLevel.INFO)}
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user