jnfrati пре 4 година
родитељ
комит
5f5056f413

+ 2 - 130
dashboard/src/main/home/cluster-dashboard/expanded-chart/status/StatusSection.tsx

@@ -9,140 +9,12 @@ import Loading from "components/Loading";
 import Logs from "./Logs";
 import ControllerTab from "./ControllerTab";
 
-type PropsType = {
+type Props = {
   selectors?: string[];
   currentChart: ChartType;
 };
 
-type StateType = {
-  logs: string[];
-  pods: any[];
-  selectedPod: any;
-  controllers: any[];
-  loading: boolean;
-  podError: string;
-};
-
-class StatusSection extends Component<PropsType, StateType> {
-  state = {
-    logs: [] as string[],
-    pods: [] as any[],
-    selectedPod: {} as any,
-    controllers: [] as any[],
-    loading: true,
-    podError: "",
-  };
-
-  renderLogs = () => {
-    return (
-      <Logs
-        podError={this.state.podError}
-        key={this.state.selectedPod?.metadata?.name}
-        selectedPod={this.state.selectedPod}
-      />
-    );
-  };
-
-  selectPod = (pod: any) => {
-    this.setState({
-      selectedPod: pod,
-    });
-  };
-
-  renderTabs = () => {
-    return this.state.controllers.map((c, i) => {
-      return (
-        <ControllerTab
-          // handle CronJob case
-          key={c.metadata?.uid || c.uid}
-          selectedPod={this.state.selectedPod}
-          selectPod={this.selectPod.bind(this)}
-          selectors={this.props.selectors ? [this.props.selectors[i]] : null}
-          controller={c}
-          isLast={i === this.state.controllers?.length - 1}
-          isFirst={i === 0}
-          setPodError={(x: string) => this.setState({ podError: x })}
-        />
-      );
-    });
-  };
-
-  renderStatusSection = () => {
-    if (this.state.loading) {
-      return (
-        <NoControllers>
-          <Loading />
-        </NoControllers>
-      );
-    }
-    if (this.state.controllers?.length > 0) {
-      return (
-        <Wrapper>
-          <TabWrapper>{this.renderTabs()}</TabWrapper>
-          {this.renderLogs()}
-        </Wrapper>
-      );
-    }
-
-    if (this.props.currentChart.chart.metadata.name === "job") {
-      return (
-        <NoControllers>
-          <i className="material-icons">category</i>
-          There are no jobs currently running.
-        </NoControllers>
-      );
-    }
-
-    return (
-      <NoControllers>
-        <i className="material-icons">category</i>
-        No objects to display. This might happen while your app is still
-        deploying.
-      </NoControllers>
-    );
-  };
-
-  componentDidMount() {
-    const { currentChart } = this.props;
-    let { currentCluster, currentProject, setCurrentError } = this.context;
-
-    api
-      .getChartControllers(
-        "<token>",
-        {
-          namespace: currentChart.namespace,
-          cluster_id: currentCluster.id,
-          storage: StorageType.Secret,
-        },
-        {
-          id: currentProject.id,
-          name: currentChart.name,
-          revision: currentChart.version,
-        }
-      )
-      .then((res: any) => {
-        let controllers =
-          currentChart.chart.metadata.name == "job"
-            ? res.data[0]?.status.active
-            : res.data;
-        this.setState({ controllers, loading: false });
-      })
-      .catch((err) => {
-        setCurrentError(JSON.stringify(err));
-        this.setState({ controllers: [], loading: false });
-      });
-  }
-
-  render() {
-    return (
-      <StyledStatusSection>{this.renderStatusSection()}</StyledStatusSection>
-    );
-  }
-}
-
-StatusSection.contextType = Context;
-
-const StatusSectionFC: React.FunctionComponent<PropsType> = ({
+const StatusSectionFC: React.FunctionComponent<Props> = ({
   currentChart,
   selectors,
 }) => {