Skip to content

Commit

Permalink
Merge pull request #945 from hmrc/BDOG-3248
Browse files Browse the repository at this point in the history
BDOG-3248: Add checkbox confirmation on first time production deployment
  • Loading branch information
BriWak committed Sep 18, 2024
2 parents 855f0ab + c722651 commit d4d6e55
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,23 @@ <h1 class="page-heading mt-4">Deploy Service</h1>
@helper.form(
action = appRoutes.DeployServiceController.step3()
, Symbol("method") -> "POST"
, Symbol("id") -> "deployServiceForm"
) {
@csrfFormField
<hr/>
<input type="hidden" name="serviceName" value='@form("serviceName").value' />
<input type="hidden" name="version" value='@form("version").value' />
<input type="hidden" name="environment" value='@form("environment").value' />
<button id="deploy-btn" class="btn btn-success float-end" type="submit" @if(!hasPerm){disabled}>Deploy</button>
<br/><br/>
@if(form.get.environment == Environment.Production && !releases.exists(_.environment == Environment.Production)) {
<div class="form-check">
<input class="form-check-input" type="checkbox" id="firstDeploymentCheckbox">
<label class="form-check-label" for="firstDeploymentCheckbox">
I have <a href="https://docs.tax.service.gov.uk/mdtp-handbook/documentation/create-a-microservice/create-a-pra-page.html" target="_blank" rel="noreferrer noopener">Change Approval Board (CAB)</a> approval to release this service into production.
</label>
</div>
}
<button id="deploy-btn" class="btn btn-success float-end" type="submit" @if(!hasPerm){disabled}>Deploy</button>
<br/><br/>
}
}
</div>
Expand All @@ -171,6 +180,28 @@ <h1 class="page-heading mt-4">Deploy Service</h1>
minSearch : 1
});

document.addEventListener('DOMContentLoaded', function () {
const form = document.getElementById('deployServiceForm');
const deployButton = document.getElementById('deploy-btn');
const checkbox = document.getElementById('firstDeploymentCheckbox');

if (form && checkbox && deployButton) {
const initialButtonIsDisabled = deployButton.disabled;

deployButton.disabled = !!(!checkbox.checked || initialButtonIsDisabled);

checkbox.addEventListener('change', function () {
if (checkbox.checked) {
if (!initialButtonIsDisabled) {
deployButton.disabled = false;
}
} else {
deployButton.disabled = true;
}
});
}
});

@if(form("serviceName").value.isDefined) {
let form2 = document.forms['version-environment-form'];
let helpfulVersions = document.getElementById('helpful-versions')
Expand Down

0 comments on commit d4d6e55

Please sign in to comment.