Procházet zdrojové kódy

should fix some bugs

Feroze Mohideen před 3 roky
rodič
revize
80a670303c

+ 12 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/RevisionSection.tsx

@@ -191,7 +191,18 @@ class RevisionSection extends Component<PropsType, StateType> {
 
   handleClickRevision = (revision: ChartType) => {
     if (this.props.comparisonMode) {
-      this.props.setCompareChart(revision);
+      if (this.props.compareChart) {
+        if (revision.version === this.props.chart.version) {
+          this.props.setRevision(this.props.compareChart, this.props.compareChart.version === this.state.maxVersion)
+          this.props.toggleComparisonMode();
+          this.props.setCompareChart(null);
+        } else if (revision.version === this.props.compareChart.version) {
+          this.props.toggleComparisonMode();
+          this.props.setCompareChart(null);
+        } else {
+          this.props.setCompareChart(revision);
+        }
+      }
     } else {
       this.props.setRevision(
         revision,

+ 7 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/ValuesYaml.tsx

@@ -10,6 +10,7 @@ import { Context } from "shared/Context";
 import YamlEditor from "components/YamlEditor";
 import SaveButton from "components/SaveButton";
 import ReactDiffViewer from "react-diff-viewer";
+import { readableDate } from "shared/string_utils";
 
 type PropsType = {
   currentChart: ChartType;
@@ -101,16 +102,18 @@ export default class ValuesYaml extends Component<PropsType, StateType> {
   };
 
   render() {
+    const compareVersionPrecedesCurrentVersion = this.props.compareChart && this.props.compareChart.version < this.props.currentChart.version;
+
     return (
       <>
         {this.props.compareChart ?
           <ReactDiffViewer
-            oldValue={this.state.values}
-            newValue={this.state.compareValues}
+            oldValue={compareVersionPrecedesCurrentVersion ? this.state.compareValues : this.state.values}
+            newValue={compareVersionPrecedesCurrentVersion ? this.state.values : this.state.compareValues}
             splitView
             useDarkTheme
-            leftTitle={`Version ${this.props.currentChart.version.toString()}`}
-            rightTitle={`Version ${this.props.compareChart.version.toString()}`}
+            leftTitle={compareVersionPrecedesCurrentVersion ? `Version ${this.props.compareChart.version.toString()} (Deployed ${readableDate(this.props.compareChart.info.last_deployed)})` : `Version ${this.props.currentChart.version.toString()} (Deployed ${readableDate(this.props.currentChart.info.last_deployed)})`}
+            rightTitle={compareVersionPrecedesCurrentVersion ? `Version ${this.props.currentChart.version.toString()} (Deployed ${readableDate(this.props.currentChart.info.last_deployed)})` : `Version ${this.props.compareChart.version.toString()} (Deployed ${readableDate(this.props.compareChart.info.last_deployed)})`}
           />
           :
           <StyledValuesYaml>