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

Hook semver auto deploy dropdown to api #2306

Merged
merged 3 commits into from Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions web/src/components/apps/AppVersionHistoryClassic.jsx
Expand Up @@ -1093,6 +1093,7 @@ class AppVersionHistory extends Component {
isOpen={showUpdateCheckerModal}
onRequestClose={this.hideUpdateCheckerModal}
updateCheckerSpec={app.updateCheckerSpec}
semverAutoDeploy={app.semverAutoDeploy}
appSlug={app.slug}
gitopsEnabled={gitopsEnabled}
onUpdateCheckerSpecSubmitted={() => {
Expand Down
1 change: 1 addition & 0 deletions web/src/components/apps/Dashboard.jsx
Expand Up @@ -663,6 +663,7 @@ class Dashboard extends Component {
isOpen={this.state.showUpdateCheckerModal}
onRequestClose={this.hideUpdateCheckerModal}
updateCheckerSpec={app.updateCheckerSpec}
semverAutoDeploy={app.semverAutoDeploy}
appSlug={app.slug}
gitopsEnabled={downstream?.gitops?.enabled}
onUpdateCheckerSpecSubmitted={() => {
Expand Down
1 change: 1 addition & 0 deletions web/src/components/apps/DashboardClassic.jsx
Expand Up @@ -883,6 +883,7 @@ class Dashboard extends Component {
isOpen={this.state.showUpdateCheckerModal}
onRequestClose={this.hideUpdateCheckerModal}
updateCheckerSpec={app.updateCheckerSpec}
semverAutoDeploy={app.semverAutoDeploy}
appSlug={app.slug}
gitopsEnabled={downstream?.gitops?.enabled}
onUpdateCheckerSpecSubmitted={() => {
Expand Down
44 changes: 23 additions & 21 deletions web/src/components/modals/UpdateCheckerModal.jsx
Expand Up @@ -26,22 +26,23 @@ const SCHEDULES = [
label: "Custom",
},
];
const AUTO_INSTALL_OPTIONS = [

const SEMVER_AUTO_DEPLOY_OPTIONS = [
{
value: "none",
label: "Do not automatically install new versions",
value: "disabled",
label: "Do not automatically deploy new versions",
},
{
value: "patch",
label: "Automatically install new patch versions",
label: "Automatically deploy new patch versions",
},
{
value: "minor-patch",
label: "Automatically install new patch and minor versions",
label: "Automatically deploy new patch and minor versions",
},
{
value: "minor-patch-major",
label: "Automatically install new path, minor, and major versions",
value: "major-minor-patch",
label: "Automatically deploy new patch, minor, and major versions",
}
];

Expand All @@ -54,20 +55,21 @@ export default class UpdateCheckerModal extends React.Component {
selectedSchedule = find(SCHEDULES, { value: "custom" });
}

let selectedInstallOption = find(AUTO_INSTALL_OPTIONS, ["value", props.autoInstallOption]);
if (!selectedInstallOption) {
selectedInstallOption = find(AUTO_INSTALL_OPTIONS, ["value", "none"])
let selectedSemverAutoDeploy = find(SEMVER_AUTO_DEPLOY_OPTIONS, ["value", props.semverAutoDeploy]);
if (!selectedSemverAutoDeploy) {
selectedSemverAutoDeploy = find(SEMVER_AUTO_DEPLOY_OPTIONS, ["value", "disabled"])
}

this.state = {
updateCheckerSpec: props.updateCheckerSpec,
submitUpdateCheckerSpecErr: "",
selectedSchedule,
selectedSemverAutoDeploy,
};
}

onSubmitUpdateCheckerSpec = () => {
const { updateCheckerSpec } = this.state;
const { updateCheckerSpec, selectedSemverAutoDeploy } = this.state;
const { appSlug } = this.props;

this.setState({
Expand All @@ -82,6 +84,7 @@ export default class UpdateCheckerModal extends React.Component {
method: "PUT",
body: JSON.stringify({
updateCheckerSpec: updateCheckerSpec,
semverAutoDeploy: selectedSemverAutoDeploy.value,
})
})
.then(async (res) => {
Expand Down Expand Up @@ -135,16 +138,15 @@ export default class UpdateCheckerModal extends React.Component {
});
}

handleInstallOptionChange = selectedInstallOption => {
handleSemverAutoDeployOptionChange = selectedSemverAutoDeploy => {
this.setState({
selectedInstallOption,
selectedInstallOptionValue: selectedInstallOption.value,
selectedSemverAutoDeploy: { ...selectedSemverAutoDeploy },
});
}

render() {
const { isOpen, onRequestClose, gitopsEnabled } = this.props;
const { updateCheckerSpec, selectedSchedule, selectedInstallOption, submitUpdateCheckerSpecErr } = this.state;
const { updateCheckerSpec, selectedSchedule, selectedSemverAutoDeploy, submitUpdateCheckerSpecErr } = this.state;

const humanReadableCron = this.getReadableCronExpression(updateCheckerSpec);

Expand Down Expand Up @@ -212,17 +214,17 @@ export default class UpdateCheckerModal extends React.Component {
</div>
</div>
<div className="flex-column flex1 u-marginTop--15">
<p className="u-fontSize--normal u-textColor--primary u-fontWeight--bold u-lineHeight--normal u-marginBottom--10">Automatically install new versions</p>
<p className="u-fontSize--normal u-textColor--primary u-fontWeight--bold u-lineHeight--normal u-marginBottom--10">Automatically deploy new versions</p>
<Select
className="replicated-select-container flex1"
classNamePrefix="replicated-select"
placeholder="Automatically install new versions"
options={AUTO_INSTALL_OPTIONS}
placeholder="Automatically deploy new versions"
options={SEMVER_AUTO_DEPLOY_OPTIONS}
isSearchable={false}
getOptionValue={(option) => option.label}
value={selectedInstallOption}
onChange={this.handleInstallOptionChange}
isOptionSelected={(option) => { option.value === selectedInstallOption }}
value={selectedSemverAutoDeploy}
onChange={this.handleSemverAutoDeployOptionChange}
isOptionSelected={(option) => { option.value === selectedSemverAutoDeploy }}
/>
</div>
<div className="flex u-marginTop--20">
Expand Down