import "./cluster-issues.scss" import * as React from "react"; import { observer } from "mobx-react"; import { computed } from "mobx"; import { Trans } from "@lingui/macro"; import { Icon } from "../icon"; import { SubHeader } from "../layout/sub-header"; import { Table, TableCell, TableHead, TableRow } from "../table"; import { nodesStore } from "../+nodes/nodes.store"; import { eventStore } from "../+events/event.store"; import { autobind, cssNames, prevDefault } from "../../utils"; import { getSelectedDetails, showDetails } from "../../navigation"; import { ItemObject } from "../../item.store"; import { Spinner } from "../spinner"; import { themeStore } from "../../theme.store"; import { lookupApiLink } from "../../api/kube-api"; interface Props { className?: string; } interface IWarning extends ItemObject { kind: string; message: string; selfLink: string; } enum sortBy { type = "type", object = "object" } @observer export class ClusterIssues extends React.Component { private sortCallbacks = { [sortBy.type]: (warning: IWarning) => warning.kind, [sortBy.object]: (warning: IWarning) => warning.getName(), }; @computed get warnings() { const warnings: IWarning[] = []; // Node bad conditions nodesStore.items.forEach(node => { const { kind, selfLink, getId, getName } = node node.getWarningConditions().forEach(({ message }) => { warnings.push({ kind, getId, getName, selfLink, message, }) }) }); // Warning events for Workloads const events = eventStore.getWarnings(); events.forEach(error => { const { message, involvedObject } = error; const { uid, name, kind } = involvedObject; warnings.push({ getId: () => uid, getName: () => name, message, kind, selfLink: lookupApiLink(involvedObject, error), }); }) return warnings; } @autobind() getTableRow(uid: string) { const { warnings } = this; const warning = warnings.find(warn => warn.getId() == uid); const { getId, getName, message, kind, selfLink } = warning; return ( showDetails(selfLink))} > {message} {getName()} {kind} ); } renderContent() { const { warnings } = this; if (!eventStore.isLoaded) { return ( ); } if (!warnings.length) { return (
No issues found
Everything is fine in the Cluster
); } return ( <> {" "} Warnings: {warnings.length} Message Object Type
); } render() { return (
{this.renderContent()}
); } }