|
@@ -18,12 +18,10 @@ import KeyValueArray from "./KeyValueArray";
|
|
|
type PropsType = {
|
|
type PropsType = {
|
|
|
sections?: Section[];
|
|
sections?: Section[];
|
|
|
metaState?: any;
|
|
metaState?: any;
|
|
|
- setMetaState?: any;
|
|
|
|
|
|
|
+ setMetaState?: (key: string, value: any) => void;
|
|
|
handleEnvChange?: (x: any) => void;
|
|
handleEnvChange?: (x: any) => void;
|
|
|
disabled?: boolean;
|
|
disabled?: boolean;
|
|
|
- namespace?: string;
|
|
|
|
|
- clusterId?: number;
|
|
|
|
|
- procfileProcess?: string;
|
|
|
|
|
|
|
+ externalValues?: any;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
type StateType = any;
|
|
type StateType = any;
|
|
@@ -31,29 +29,26 @@ type StateType = any;
|
|
|
// Requires an internal representation unlike other values components because metaState value underdetermines input order
|
|
// Requires an internal representation unlike other values components because metaState value underdetermines input order
|
|
|
export default class ValuesForm extends Component<PropsType, StateType> {
|
|
export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
getInputValue = (item: FormElement) => {
|
|
getInputValue = (item: FormElement) => {
|
|
|
- let key = item.name || item.variable;
|
|
|
|
|
- let value = this.props.metaState[key];
|
|
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ let key = item.name || item.variable;
|
|
|
|
|
+ let value = this.props.metaState[key]?.value;
|
|
|
|
|
|
|
|
- if (item.settings && item.settings.unit && value && value.includes) {
|
|
|
|
|
- value = value.split(item.settings.unit)[0];
|
|
|
|
|
|
|
+ if (item.settings && item.settings.unit && value && value.includes) {
|
|
|
|
|
+ value = value.split(item.settings.unit)[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
}
|
|
}
|
|
|
- return value;
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
renderSection = (section: Section) => {
|
|
renderSection = (section: Section) => {
|
|
|
return section.contents.map((item: FormElement, i: number) => {
|
|
return section.contents.map((item: FormElement, i: number) => {
|
|
|
- // If no name is assigned use values.yaml variable as identifier
|
|
|
|
|
- let key = item.name || item.variable;
|
|
|
|
|
-
|
|
|
|
|
- // ugly exception to hide start command option when procfile process is set.
|
|
|
|
|
- if (
|
|
|
|
|
- (item.variable === "container.command" ||
|
|
|
|
|
- (item.type == "subtitle" && item.name == "command_description")) &&
|
|
|
|
|
- this.props.procfileProcess
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (!item) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // If no name is assigned use values.yaml variable as identifier
|
|
|
|
|
+ let key = item.name || item.variable;
|
|
|
|
|
+
|
|
|
switch (item.type) {
|
|
switch (item.type) {
|
|
|
case "heading":
|
|
case "heading":
|
|
|
return <Heading key={i}>{item.label}</Heading>;
|
|
return <Heading key={i}>{item.label}</Heading>;
|
|
@@ -62,7 +57,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "resource-list":
|
|
case "resource-list":
|
|
|
if (Array.isArray(item.value)) {
|
|
if (Array.isArray(item.value)) {
|
|
|
return (
|
|
return (
|
|
|
- <ResourceList key={i}>
|
|
|
|
|
|
|
+ <ResourceList key={key}>
|
|
|
{item.value.map((resource: any, i: number) => {
|
|
{item.value.map((resource: any, i: number) => {
|
|
|
return (
|
|
return (
|
|
|
<ExpandableResource
|
|
<ExpandableResource
|
|
@@ -79,10 +74,11 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "checkbox":
|
|
case "checkbox":
|
|
|
return (
|
|
return (
|
|
|
<CheckboxRow
|
|
<CheckboxRow
|
|
|
- key={i}
|
|
|
|
|
- checked={this.props.metaState[key]}
|
|
|
|
|
|
|
+ key={key}
|
|
|
|
|
+ isRequired={item.required}
|
|
|
|
|
+ checked={this.props.metaState[key]?.value}
|
|
|
toggle={() =>
|
|
toggle={() =>
|
|
|
- this.props.setMetaState({ [key]: !this.props.metaState[key] })
|
|
|
|
|
|
|
+ this.props.setMetaState(key, !this.props.metaState[key]?.value)
|
|
|
}
|
|
}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
/>
|
|
/>
|
|
@@ -90,20 +86,19 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "env-key-value-array":
|
|
case "env-key-value-array":
|
|
|
return (
|
|
return (
|
|
|
<KeyValueArray
|
|
<KeyValueArray
|
|
|
- key={i}
|
|
|
|
|
|
|
+ key={key}
|
|
|
envLoader={true}
|
|
envLoader={true}
|
|
|
- namespace={this.props.namespace}
|
|
|
|
|
- clusterId={this.props.clusterId}
|
|
|
|
|
- values={this.props.metaState[key]}
|
|
|
|
|
|
|
+ externalValues={this.props.externalValues}
|
|
|
|
|
+ values={this.props.metaState[key]?.value}
|
|
|
setValues={(x: any) => {
|
|
setValues={(x: any) => {
|
|
|
- this.props.setMetaState({ [key]: x });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, x);
|
|
|
|
|
|
|
|
// Need to pull env vars out of form.yaml for createGHA build env vars
|
|
// Need to pull env vars out of form.yaml for createGHA build env vars
|
|
|
if (
|
|
if (
|
|
|
this.props.handleEnvChange &&
|
|
this.props.handleEnvChange &&
|
|
|
key === "container.env.normal"
|
|
key === "container.env.normal"
|
|
|
) {
|
|
) {
|
|
|
- this.props.handleEnvChange(x);
|
|
|
|
|
|
|
+ // this.props.handleEnvChange(x);
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
@@ -114,21 +109,10 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "key-value-array":
|
|
case "key-value-array":
|
|
|
return (
|
|
return (
|
|
|
<KeyValueArray
|
|
<KeyValueArray
|
|
|
- key={i}
|
|
|
|
|
- namespace={this.props.namespace}
|
|
|
|
|
- clusterId={this.props.clusterId}
|
|
|
|
|
- values={this.props.metaState[key]}
|
|
|
|
|
- setValues={(x: any) => {
|
|
|
|
|
- this.props.setMetaState({ [key]: x });
|
|
|
|
|
-
|
|
|
|
|
- // Need to pull env vars out of form.yaml for createGHA build env vars
|
|
|
|
|
- if (
|
|
|
|
|
- this.props.handleEnvChange &&
|
|
|
|
|
- key === "container.env.normal"
|
|
|
|
|
- ) {
|
|
|
|
|
- this.props.handleEnvChange(x);
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
|
|
+ key={key}
|
|
|
|
|
+ externalValues={this.props.externalValues}
|
|
|
|
|
+ values={this.props.metaState[key]?.value}
|
|
|
|
|
+ setValues={(x: any) => this.props.setMetaState(key, x)}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
disabled={this.props.disabled}
|
|
disabled={this.props.disabled}
|
|
|
/>
|
|
/>
|
|
@@ -136,10 +120,10 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "array-input":
|
|
case "array-input":
|
|
|
return (
|
|
return (
|
|
|
<InputArray
|
|
<InputArray
|
|
|
- key={i}
|
|
|
|
|
- values={this.props.metaState[key]}
|
|
|
|
|
|
|
+ key={key}
|
|
|
|
|
+ values={this.props.metaState[key]?.value}
|
|
|
setValues={(x: string[]) => {
|
|
setValues={(x: string[]) => {
|
|
|
- this.props.setMetaState({ [key]: x });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, x);
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
disabled={this.props.disabled}
|
|
disabled={this.props.disabled}
|
|
@@ -148,7 +132,8 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "string-input":
|
|
case "string-input":
|
|
|
return (
|
|
return (
|
|
|
<InputRow
|
|
<InputRow
|
|
|
- key={i}
|
|
|
|
|
|
|
+ key={key}
|
|
|
|
|
+ placeholder={item.placeholder}
|
|
|
isRequired={item.required}
|
|
isRequired={item.required}
|
|
|
type="text"
|
|
type="text"
|
|
|
value={this.getInputValue(item)}
|
|
value={this.getInputValue(item)}
|
|
@@ -156,7 +141,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
|
x = x + item.settings.unit;
|
|
x = x + item.settings.unit;
|
|
|
}
|
|
}
|
|
|
- this.props.setMetaState({ [key]: x });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, x);
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
unit={item.settings ? item.settings.unit : null}
|
|
unit={item.settings ? item.settings.unit : null}
|
|
@@ -166,7 +151,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "string-input-password":
|
|
case "string-input-password":
|
|
|
return (
|
|
return (
|
|
|
<InputRow
|
|
<InputRow
|
|
|
- key={i}
|
|
|
|
|
|
|
+ key={key}
|
|
|
isRequired={item.required}
|
|
isRequired={item.required}
|
|
|
type="password"
|
|
type="password"
|
|
|
value={this.getInputValue(item)}
|
|
value={this.getInputValue(item)}
|
|
@@ -174,7 +159,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
|
x = x + item.settings.unit;
|
|
x = x + item.settings.unit;
|
|
|
}
|
|
}
|
|
|
- this.props.setMetaState({ [key]: x });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, x);
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
unit={item.settings ? item.settings.unit : null}
|
|
unit={item.settings ? item.settings.unit : null}
|
|
@@ -184,8 +169,9 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "number-input":
|
|
case "number-input":
|
|
|
return (
|
|
return (
|
|
|
<InputRow
|
|
<InputRow
|
|
|
- key={i}
|
|
|
|
|
|
|
+ key={key}
|
|
|
isRequired={item.required}
|
|
isRequired={item.required}
|
|
|
|
|
+ placeholder={item.placeholder}
|
|
|
type="number"
|
|
type="number"
|
|
|
value={this.getInputValue(item)}
|
|
value={this.getInputValue(item)}
|
|
|
setValue={(x: number) => {
|
|
setValue={(x: number) => {
|
|
@@ -200,7 +186,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
val = val + item.settings.unit;
|
|
val = val + item.settings.unit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.props.setMetaState({ [key]: val });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, val);
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
unit={item.settings ? item.settings.unit : null}
|
|
unit={item.settings ? item.settings.unit : null}
|
|
@@ -210,9 +196,9 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "select":
|
|
case "select":
|
|
|
return (
|
|
return (
|
|
|
<SelectRow
|
|
<SelectRow
|
|
|
- key={i}
|
|
|
|
|
- value={this.props.metaState[key]}
|
|
|
|
|
- setActiveValue={(val) => this.props.setMetaState({ [key]: val })}
|
|
|
|
|
|
|
+ key={key}
|
|
|
|
|
+ value={this.props.metaState[key]?.value}
|
|
|
|
|
+ setActiveValue={(val) => this.props.setMetaState(key, val)}
|
|
|
options={item.settings.options}
|
|
options={item.settings.options}
|
|
|
dropdownLabel=""
|
|
dropdownLabel=""
|
|
|
label={item.label}
|
|
label={item.label}
|
|
@@ -221,9 +207,9 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "provider-select":
|
|
case "provider-select":
|
|
|
return (
|
|
return (
|
|
|
<SelectRow
|
|
<SelectRow
|
|
|
- key={i}
|
|
|
|
|
- value={this.props.metaState[key]}
|
|
|
|
|
- setActiveValue={(val) => this.props.setMetaState({ [key]: val })}
|
|
|
|
|
|
|
+ key={key}
|
|
|
|
|
+ value={this.props.metaState[key]?.value}
|
|
|
|
|
+ setActiveValue={(val) => this.props.setMetaState(key, val)}
|
|
|
options={[
|
|
options={[
|
|
|
{ value: "aws", label: "Amazon Web Services (AWS)" },
|
|
{ value: "aws", label: "Amazon Web Services (AWS)" },
|
|
|
{ value: "gcp", label: "Google Cloud Platform (GCP)" },
|
|
{ value: "gcp", label: "Google Cloud Platform (GCP)" },
|
|
@@ -238,7 +224,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "base-64":
|
|
case "base-64":
|
|
|
return (
|
|
return (
|
|
|
<Base64InputRow
|
|
<Base64InputRow
|
|
|
- key={i}
|
|
|
|
|
|
|
+ key={key}
|
|
|
isRequired={item.required}
|
|
isRequired={item.required}
|
|
|
type="text"
|
|
type="text"
|
|
|
value={this.getInputValue(item)}
|
|
value={this.getInputValue(item)}
|
|
@@ -246,7 +232,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
|
x = x + item.settings.unit;
|
|
x = x + item.settings.unit;
|
|
|
}
|
|
}
|
|
|
- this.props.setMetaState({ [key]: btoa(x) });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, btoa(x));
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
unit={item.settings ? item.settings.unit : null}
|
|
unit={item.settings ? item.settings.unit : null}
|
|
@@ -256,7 +242,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
case "base-64-password":
|
|
case "base-64-password":
|
|
|
return (
|
|
return (
|
|
|
<Base64InputRow
|
|
<Base64InputRow
|
|
|
- key={i}
|
|
|
|
|
|
|
+ key={key}
|
|
|
isRequired={item.required}
|
|
isRequired={item.required}
|
|
|
type="password"
|
|
type="password"
|
|
|
value={this.getInputValue(item)}
|
|
value={this.getInputValue(item)}
|
|
@@ -264,7 +250,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
if (item.settings && item.settings.unit && x !== "") {
|
|
|
x = x + item.settings.unit;
|
|
x = x + item.settings.unit;
|
|
|
}
|
|
}
|
|
|
- this.props.setMetaState({ [key]: btoa(x) });
|
|
|
|
|
|
|
+ this.props.setMetaState(key, btoa(x));
|
|
|
}}
|
|
}}
|
|
|
label={item.label}
|
|
label={item.label}
|
|
|
unit={item.settings ? item.settings.unit : null}
|
|
unit={item.settings ? item.settings.unit : null}
|
|
@@ -281,7 +267,10 @@ export default class ValuesForm extends Component<PropsType, StateType> {
|
|
|
return this.props.sections.map((section: Section, i: number) => {
|
|
return this.props.sections.map((section: Section, i: number) => {
|
|
|
// Hide collapsible section if deciding field is false
|
|
// Hide collapsible section if deciding field is false
|
|
|
if (section.show_if) {
|
|
if (section.show_if) {
|
|
|
- if (!this.props.metaState[section.show_if]) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ !this.props.metaState[section.show_if] ||
|
|
|
|
|
+ this.props.metaState[section.show_if].value === false
|
|
|
|
|
+ ) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|