Commit 098d41be authored by Mike Greiling's avatar Mike Greiling

keep protected environments section expanded after form submission

parent 09f9e1a2
......@@ -48,10 +48,7 @@ export default class ProtectedEnvironmentCreate {
// Enable submit button after selecting an option
onSelect() {
const $allowedToDeploy = this[`${ACCESS_LEVELS.DEPLOY}_dropdown`].getSelectedItems();
const toggle = !(
this.$form.find(PROTECTED_ENVIRONMENT_INPUT).val() &&
$allowedToDeploy.length
);
const toggle = !(this.$form.find(PROTECTED_ENVIRONMENT_INPUT).val() && $allowedToDeploy.length);
this.$form.find('input[type="submit"]').attr('disabled', toggle);
}
......@@ -114,6 +111,7 @@ export default class ProtectedEnvironmentCreate {
axios[this.$form.attr('method')](this.$form.attr('action'), this.getFormData())
.then(() => {
window.location.hash = 'js-protected-environments-settings';
window.location.reload();
})
.catch(() => Flash('Failed to protect the environment'));
......
......@@ -12,7 +12,7 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle
flash[:alert] = protected_environment.errors.full_messages.join(', ')
end
redirect_to project_settings_ci_cd_path(@project)
redirect_to project_settings_ci_cd_path(@project, anchor: 'js-protected-environments-settings')
end
def update
......@@ -34,7 +34,7 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle
flash[:alert] = s_("ProtectedEnvironment|Your environment can't be unprotected")
end
redirect_to project_settings_ci_cd_path(@project), status: :found
redirect_to project_settings_ci_cd_path(@project, anchor: 'js-protected-environments-settings'), status: :found
end
def search
......
......@@ -2,7 +2,7 @@
- can_admin_project = can?(current_user, :admin_project, @project)
- if protected_environments_enabled?
%section.protected-environments-settings.settings.no-animate{ class: ('expanded' if expanded) }
%section.protected-environments-settings.settings.no-animate#js-protected-environments-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
= _('Protected Environments')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment