From c33351d75df97edebaa7f4ca64bfff778276a367 Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Wed, 30 Oct 2019 00:46:34 +0000 Subject: [PATCH] Add when param functionality to the config renderer --- web/init/package.json | 2 +- web/init/src/components/config_render/ConfigCheckbox.jsx | 4 +++- .../src/components/config_render/ConfigFileInput.jsx | 5 +++-- web/init/src/components/config_render/ConfigGroup.jsx | 9 ++++++++- web/init/src/components/config_render/ConfigInput.jsx | 4 +++- .../src/components/config_render/ConfigItemTitle.jsx | 8 ++++++-- .../src/components/config_render/ConfigSelectOne.jsx | 4 +++- web/init/src/components/config_render/ConfigTextarea.jsx | 4 +++- 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/web/init/package.json b/web/init/package.json index 6ba6de097..393476fda 100644 --- a/web/init/package.json +++ b/web/init/package.json @@ -1,6 +1,6 @@ { "name": "@replicatedhq/ship-init", - "version": "1.6.10", + "version": "1.6.11", "description": "Shared component that contains the Ship Init app", "author": "Replicated, Inc.", "license": "Apache-2.0", diff --git a/web/init/src/components/config_render/ConfigCheckbox.jsx b/web/init/src/components/config_render/ConfigCheckbox.jsx index 2a8e74968..75ccd8f45 100644 --- a/web/init/src/components/config_render/ConfigCheckbox.jsx +++ b/web/init/src/components/config_render/ConfigCheckbox.jsx @@ -18,8 +18,10 @@ export default class ConfigCheckbox extends React.Component { } var checked = val === "1"; + var hidden = this.props.hidden || this.props.when === "false"; + return ( -
+
+
{this.props.title !== "" ?
@@ -75,6 +79,7 @@ export default class ConfigGroup extends React.Component { required={item.required} handleChange={this.handleItemChange} hidden={item.hidden} + when={item.when} />
); @@ -84,12 +89,13 @@ export default class ConfigGroup extends React.Component { key={`${i}-${item.name}`} handleOnChange={this.handleItemChange} hidden={item.hidden} + when={item.when} {...item} /> ); case "heading": return ( -
+

{item.title}

); @@ -99,6 +105,7 @@ export default class ConfigGroup extends React.Component { key={`${i}-${item.name}`} handleOnChange={this.handleItemChange} hidden={item.hidden} + when={item.when} inputType="password" {...item} /> diff --git a/web/init/src/components/config_render/ConfigInput.jsx b/web/init/src/components/config_render/ConfigInput.jsx index 98478f65c..e96a5ae8e 100644 --- a/web/init/src/components/config_render/ConfigInput.jsx +++ b/web/init/src/components/config_render/ConfigInput.jsx @@ -36,8 +36,10 @@ export default class ConfigInput extends React.Component { // Use title -OR- required prop to render to make sure error // elements are rendered. render() { + var hidden = this.props.hidden || this.props.when === "false"; + return ( -
+
{this.props.title !== "" || this.props.required ? {title} { +

{title} { required ? Required : recommended ? diff --git a/web/init/src/components/config_render/ConfigSelectOne.jsx b/web/init/src/components/config_render/ConfigSelectOne.jsx index 6f5c4ae15..bd97dbec2 100644 --- a/web/init/src/components/config_render/ConfigSelectOne.jsx +++ b/web/init/src/components/config_render/ConfigSelectOne.jsx @@ -32,8 +32,10 @@ export default class ConfigSelectOne extends React.Component { ) }); + var hidden = this.props.hidden || this.props.when === "false"; + return ( -
+
{this.props.title !== "" ?