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 { ...@@ -48,10 +48,7 @@ export default class ProtectedEnvironmentCreate {
// Enable submit button after selecting an option // Enable submit button after selecting an option
onSelect() { onSelect() {
const $allowedToDeploy = this[`${ACCESS_LEVELS.DEPLOY}_dropdown`].getSelectedItems(); const $allowedToDeploy = this[`${ACCESS_LEVELS.DEPLOY}_dropdown`].getSelectedItems();
const toggle = !( const toggle = !(this.$form.find(PROTECTED_ENVIRONMENT_INPUT).val() && $allowedToDeploy.length);
this.$form.find(PROTECTED_ENVIRONMENT_INPUT).val() &&
$allowedToDeploy.length
);
this.$form.find('input[type="submit"]').attr('disabled', toggle); this.$form.find('input[type="submit"]').attr('disabled', toggle);
} }
...@@ -114,6 +111,7 @@ export default class ProtectedEnvironmentCreate { ...@@ -114,6 +111,7 @@ export default class ProtectedEnvironmentCreate {
axios[this.$form.attr('method')](this.$form.attr('action'), this.getFormData()) axios[this.$form.attr('method')](this.$form.attr('action'), this.getFormData())
.then(() => { .then(() => {
window.location.hash = 'js-protected-environments-settings';
window.location.reload(); window.location.reload();
}) })
.catch(() => Flash('Failed to protect the environment')); .catch(() => Flash('Failed to protect the environment'));
......
...@@ -12,7 +12,7 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle ...@@ -12,7 +12,7 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle
flash[:alert] = protected_environment.errors.full_messages.join(', ') flash[:alert] = protected_environment.errors.full_messages.join(', ')
end end
redirect_to project_settings_ci_cd_path(@project) redirect_to project_settings_ci_cd_path(@project, anchor: 'js-protected-environments-settings')
end end
def update def update
...@@ -34,7 +34,7 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle ...@@ -34,7 +34,7 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle
flash[:alert] = s_("ProtectedEnvironment|Your environment can't be unprotected") flash[:alert] = s_("ProtectedEnvironment|Your environment can't be unprotected")
end 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 end
def search def search
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- can_admin_project = can?(current_user, :admin_project, @project) - can_admin_project = can?(current_user, :admin_project, @project)
- if protected_environments_enabled? - 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 .settings-header
%h4 %h4
= _('Protected Environments') = _('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