Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppNew: allow users to select a version in the appNew component #185

Merged
merged 11 commits into from
Mar 22, 2018

Conversation

sameersbn
Copy link
Contributor

@sameersbn sameersbn commented Mar 20, 2018

@sameersbn please, add a description here that explains a bit how you have implemented this

Copy link
Contributor

@prydonius prydonius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rather than having an internal state of what chart version will be deployed, we should just reuse the chartVersion from the props. Selecting a chartVersion in this form should update the URL with the selected version and componentWillReceiveProps can be used to call getChartVersion and getChartValues. This is similar to how the ChartView works when selecting a version.

@sameersbn
Copy link
Contributor Author

we should just reuse the chartVersion from the props

I was of the view the version field in the component should be reflected in the component state.
I will make the changes such that it's similar to how chartview works.

@prydonius
Copy link
Contributor

I was of the view the version field in the component should be reflected in the component state.

IMO it's weird that the props may have a different chartVersion than the state. Also, it means the URL will not always be correct. The nice thing about using the URL to determine the selected chart version is that you can share the link with someone else to install the same chart and version.

@sameersbn sameersbn force-pushed the appnew-select-version branch from 7ef691a to 94834e2 Compare March 21, 2018 09:15
Copy link
Contributor

@prydonius prydonius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm mostly, just some things we should address before merging in

}
} else {
const { version, values } = nextProps.selected;
if (version && values && !this.state.valuesModified) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make this else an else if and move this condition up, we can destructure version and values after line 69. That might be easier to read/follow.

@@ -200,6 +243,18 @@ class AppNew extends React.Component<IAppNewProps, IAppNewState> {
public handleReleaseNameChange = (e: React.FormEvent<HTMLInputElement>) => {
this.setState({ releaseName: e.currentTarget.value });
};
public handleChartVersionChange = (e: React.FormEvent<HTMLSelectElement>) => {
const { versions } = this.props.selected;
const cv = versions.find(v => v.attributes.version === e.currentTarget.value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be made simpler, looks like a lot of work to just get the repoName and chartName. We should be able to from the URL from this.props.chartID and e.currentTarget.value alone.

<option
key={v.id}
value={v.attributes.version}
selected={v.attributes.version === this.props.chartVersion}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning from js console: Warning: Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.

So we need to change line 154 to add <select value={this.props.chartVersion}>.

@@ -111,6 +135,11 @@ class AppNew extends React.Component<IAppNewProps, IAppNewState> {
<form className="container" onSubmit={this.handleDeploy}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really related to this PR, but while your on this view can we add the margin-b-bigger class to the form, right now there is no spacing underneath the form.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed! i assumed this was specific to firefox 😂

@sameersbn
Copy link
Contributor Author

thanks for the review @prydonius.
I've applied the suggested changes. Time to smash the approve button 😆

@sameersbn sameersbn force-pushed the appnew-select-version branch from a757482 to d75c889 Compare March 22, 2018 06:45
@sameersbn
Copy link
Contributor Author

Before we commit this change, there is one other thing i want to check with you.
If the user modifies the values and then goes and changes the version from the drop down; we persist the old values.yaml with the users modifications. IMO we should discard the users changes and load the default values.yaml associated with the chart version. WDYT?

@prydonius
Copy link
Contributor

@sameersbn I noticed it, and actually checked to see what would happen specifically in that case. IMO it makes sense to persist the user's values, but we could maybe add a reset button in the future if people want to use the chart's values.

@sameersbn sameersbn merged commit 9ff9621 into vmware-tanzu:master Mar 22, 2018
@sameersbn sameersbn deleted the appnew-select-version branch March 22, 2018 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants