Ver Fonte

form read in preconfigured values

jusrhee há 5 anos atrás
pai
commit
b715c317b3

+ 6 - 0
dashboard/src/components/values-form/ValuesForm.tsx

@@ -33,6 +33,12 @@ export default class ValuesForm extends Component<PropsType, StateType> {
         let key = item.name || item.variable;
         
         let def = item.settings && item.settings.default;
+
+        // Set default value from chart config if available
+        if (this.props.config) {
+          this.props.config[key] ? def = this.props.config[key] : null;
+        }
+
         switch (item.type) {
           case 'checkbox':
             formState[key] = def ? def : false;

+ 4 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -35,7 +35,6 @@ type StateType = {
   tabContents: any,
   checkTabExists: boolean,
   saveValuesStatus: string | null,
-  config: any | null, // Chart config for form defaults
 };
 
 // Tabs not display when previewing an old revision
@@ -60,7 +59,6 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
     tabContents: [] as any,
     checkTabExists: false,
     saveValuesStatus: null as (string | null),
-    config: null as any | null,
   }
 
   updateResources = () => {
@@ -102,7 +100,10 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
 
   upgradeValues = (values: any) => {
     let { currentProject, currentCluster, setCurrentError } = this.context;
-    values = yaml.dump(values);
+
+    // Weave in pre-existing values and convert to yaml
+    values = yaml.dump({ ...(this.props.currentChart.config as Object), ...values });
+    
     this.setState({ saveValuesStatus: 'loading' });
     this.props.refreshChart();
     api.upgradeChartValues('<token>', {

+ 1 - 2
dashboard/src/main/home/sidebar/Sidebar.tsx

@@ -117,9 +117,8 @@ export default class Sidebar extends Component<PropsType, StateType> {
             Dashboard
           </NavButton>
           <NavButton
-            onClick={() => false ? this.props.setCurrentView('templates') : null}
+            onClick={() => this.props.setCurrentView('templates')}
             selected={this.props.currentView === 'templates'}
-            disabled={true}
           >
             <img src={filter} />
             Templates