Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Commit 38bafa7

Browse files
committed
Update value of PresetSelection from props
1 parent bf0afc9 commit 38bafa7

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/components/Configuration.jsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ export default class Configuration extends React.Component {
104104
<PresetSelection id="settings.preset" isCompact
105105
className="preset"
106106
inputName="preset"
107-
podmanDescription="This option will allow you to use podman to run containers inside a VM environment."
108-
openshiftDescription="This option will run a full cluster environment as a single node, providing a registry, monitoring and access to Operator Hub"
109-
value={this.state.preset}
107+
value={this.state["preset"]}
110108
onChange={value => this.updateValue('preset', value)} />
111109
</FormGroup>
112110
<FormGroup fieldId='config-telemetry' label="Telemetry">

src/components/PresetSelection.jsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export default class PresetSelection extends React.Component {
88
constructor(props) {
99
super(props);
1010
this.state = {
11-
presetSelected: this.props.value // from config
12-
};
11+
presetSelected: this.props.value
12+
}
1313
this.description = "";
1414

1515
this.handlePresetSelectClick = this.handlePresetSelectClick.bind(this);
@@ -30,21 +30,19 @@ export default class PresetSelection extends React.Component {
3030
}
3131
};
3232

33-
render() {
34-
var descriptionStyle= {
35-
fontSize: "var(--pf-global--FontSize--sm)",
36-
color: "var(--pf-global--Color--200)",
37-
display: "block",
38-
paddingTop: "5px"
39-
}
33+
componentWillReceiveProps(nextProps) {
34+
this.setState({
35+
presetSelected: nextProps.value
36+
})
37+
}
4038

39+
render() {
4140
var compactTemplate = (
4241
<>
4342
<div role="group">
4443
<Button className="preset-selection-button-compact"
4544
variant={ (this.state.presetSelected === "openshift") ? "primary" : "secondary" }
4645
onClick={ event => this.handlePresetSelectClick(event, 'openshift') }>OpenShift</Button>
47-
4846
<Button className="preset-selection-button-compact"
4947
variant={ (this.state.presetSelected === "podman") ? "primary" : "secondary" }
5048
onClick={ event => this.handlePresetSelectClick(event, 'podman') }>Podman</Button>
@@ -68,7 +66,9 @@ export default class PresetSelection extends React.Component {
6866
</>
6967
)
7068

71-
return (this.props.isCompact ? compactTemplate : regularTemplate);
69+
return (
70+
this.props.isCompact ? compactTemplate : regularTemplate
71+
);
7272
}
7373
}
7474

@@ -82,6 +82,6 @@ PresetSelection.propTypes = {
8282

8383
PresetSelection.defaultProps = {
8484
value: "unknown",
85-
podmanDescription: "",
86-
openshiftDescription: ""
85+
podmanDescription: "This option will allow you to use podman to run containers inside a VM environment.",
86+
openshiftDescription: "This option will run a full cluster environment as a single node, providing a registry, monitoring and access to Operator Hub"
8787
};

0 commit comments

Comments
 (0)