import React from "react"; import { Renderer } from "@k8slens/extensions"; import { observable, computed, makeObservable, action } from "mobx"; import { observer } from "mobx-react" import { KubescapeControlTable, KubescapeIcon, controlTableColumn } from "."; import { KubescapePreferenceStore, KubescapeReportStore } from "../stores"; const { Component: { Button, Icon, TabLayout, SearchInput } } = Renderer; import "./ClusterPage.scss"; import { IpcRenderer } from "../ipc/renderer"; import { scanClusterTask } from "../kubescape/clusterScan"; export function ClusterPageIcon(props: Renderer.Component.IconProps) { return } @observer export class ClusterPage extends React.Component { constructor(props) { super(props); makeObservable(this); } @observable controlTableSearch = ""; @computed get preferenceStore() { return KubescapePreferenceStore.getInstance(); } @computed get reportStore() { return KubescapeReportStore.getInstance(); } @computed get ipc() { return IpcRenderer.getInstance(); } @computed get isInstalled() { return this.preferenceStore.isInstalled; } @computed get config() { return this.preferenceStore.kubescapeConfig; } @computed get scanTime() { const options = { year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric" } as const; return (new Date(this.reportStore.activeClusterReportResult.time)).toLocaleTimeString("en-US", options); } @action scanCluster = async () => { const filtered = this.reportStore.scanResults.filter(result => result.clusterId != this.reportStore.activeClusterId); this.reportStore.scanResults = filtered; await scanClusterTask(this.preferenceStore, this.reportStore, this.ipc); } configInfo = () => { if (!this.isInstalled) { return
Initializing
} return ( <>

Version: {this.config.version}

Base directory: {this.config.baseDirectory}

); } render() { const columns = [ controlTableColumn.status, controlTableColumn.severity, controlTableColumn.id, controlTableColumn.name, controlTableColumn.failedResources, controlTableColumn.allResources, controlTableColumn.riskScore ]; return (

Kubescape

{this.reportStore.isScanReady ? { this.controlTableSearch = value }}> : null }
); } }