Ver código fonte

local storage chart ver

sunguroku 5 anos atrás
pai
commit
c25f943883

+ 2 - 0
dashboard/src/main/home/dashboard/expanded-chart/ExpandedChart.tsx

@@ -74,11 +74,13 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
 
   renderTabContents = () => {
     let { currentChart, refreshChart, setSidebar} = this.props;
+    
     if (this.state.currentTab === 'graph') {
       return (
         <GraphSection
           components={this.state.components}
           currentChartName={currentChart.name}
+          currentChartVersion={currentChart.version}
           setSidebar={setSidebar}
         />
       );

+ 2 - 0
dashboard/src/main/home/dashboard/expanded-chart/GraphSection.tsx

@@ -10,6 +10,7 @@ import Loading from '../../../../components/Loading';
 type PropsType = {
   components: ResourceType[],
   currentChartName: string,
+  currentChartVersion: number,
   setSidebar: (x: boolean) => void
 };
 
@@ -30,6 +31,7 @@ export default class GraphSection extends Component<PropsType, StateType> {
           components={this.props.components}
           isExpanded={this.state.isExpanded}
           currentChartName={this.props.currentChartName}
+          currentChartVersion={this.props.currentChartVersion}
         />
       );
     }

+ 12 - 5
dashboard/src/main/home/dashboard/expanded-chart/graph/GraphDisplay.tsx

@@ -15,7 +15,8 @@ type PropsType = {
   components: ResourceType[],
   isExpanded: boolean,
   setSidebar: (x: boolean) => void,
-  currentChartName: string
+  currentChartName: string,
+  currentChartVersion: number
 };
 
 type StateType = {
@@ -100,8 +101,7 @@ export default class GraphDisplay extends Component<PropsType, StateType> {
     // Suppress trackpad gestures
     this.spaceRef.addEventListener("touchmove", (e: any) => e.preventDefault());
     this.spaceRef.addEventListener("mousewheel", (e: any) => e.preventDefault());
-
-    let graph = localStorage.getItem(`charts.${this.props.currentChartName}`)
+    let graph = localStorage.getItem(`charts.${this.props.currentChartName}-${this.props.currentChartVersion}`)
     let nodes = [] as NodeType[]
     let edges = [] as EdgeType[]
 
@@ -110,7 +110,10 @@ export default class GraphDisplay extends Component<PropsType, StateType> {
       edges = this.createEdges(components)
       this.setState({ nodes, edges });
     } else {
-      let storedState = JSON.parse(localStorage.getItem(`charts.${this.props.currentChartName}`))
+      let storedState = JSON.parse(localStorage.getItem(
+        `charts.${this.props.currentChartName}-${this.props.currentChartVersion}`
+        )
+      )
       this.setState(storedState);
     }
 
@@ -175,7 +178,11 @@ export default class GraphDisplay extends Component<PropsType, StateType> {
     graph.suppressDisplay = false;
     graph.suppressCloseNode = false;
 
-    localStorage.setItem(`charts.${this.props.currentChartName}`, JSON.stringify(graph))
+    localStorage.setItem(
+      `charts.${this.props.currentChartName}-${this.props.currentChartVersion}`, 
+      JSON.stringify(graph)
+    )
+    
     this.spaceRef.removeEventListener("touchmove", (e: any) => e.preventDefault());
     this.spaceRef.removeEventListener("mousewheel", (e: any) => e.preventDefault());
     document.removeEventListener("keydown", this.handleKeyDown);

+ 6 - 4
internal/helm/grapher/object.go

@@ -17,6 +17,12 @@ func ParseObjs(objs []map[string]interface{}) []Object {
 
 	for i, obj := range objs {
 		kind := getField(obj, "kind")
+
+		// ignore block comments
+		if kind == nil {
+			continue
+		}
+
 		name := getField(obj, "metadata", "name")
 		namespace := getField(obj, "metadata", "namespace")
 
@@ -24,10 +30,6 @@ func ParseObjs(objs []map[string]interface{}) []Object {
 			namespace = "default"
 		}
 
-		if kind == nil {
-			kind = ""
-		}
-
 		if name == nil {
 			name = ""
 		}

+ 1 - 2
internal/helm/grapher/relation.go

@@ -1,7 +1,6 @@
 package grapher
 
 import (
-	"fmt"
 	"strconv"
 )
 
@@ -295,7 +294,7 @@ func (parsed *ParsedObjs) findRBACTargets(parentID int, yaml map[string]interfac
 					Target: o.ID,
 				},
 			}
-			fmt.Println(tr["namespace"], o.Kind, tr["kind"], o.Name, tr["name"])
+
 			// first consider case of targets added via subjects, which are namespace scoped.
 			if tr["namespace"] != nil && o.Kind == tr["kind"] && o.Name == tr["name"] &&
 				(o.Namespace == tr["namespace"] || o.Namespace == "default") {