Commit 7ffeaf7f authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'mg-keep-project-settings-expanded' into 'master'

Keep project settings sections expanded after submitting form

See merge request gitlab-org/gitlab-ee!6832
parents 9615f7cb b9c474ef
- expanded = Rails.env.test?
- protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|')
%section.settings.project-mirror-settings.js-mirror-settings.no-animate{ class: ('expanded' if expanded) }
%section.settings.project-mirror-settings.js-mirror-settings.no-animate#js-push-remote-settings{ class: ('expanded' if expanded) }
.settings-header
%h4= _('Mirroring repositories')
%button.btn.js-settings-toggle
......
......@@ -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'));
......
......@@ -59,7 +59,7 @@ module EE
flash[:notice] = "The repository is being updated..."
end
redirect_to_repository_settings(project)
redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
end
def mirror_params_attributes
......
......@@ -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
......
......@@ -19,7 +19,7 @@ class Projects::PushRulesController < Projects::ApplicationController
flash[:alert] = @push_rule.errors.full_messages.join(', ').html_safe
end
redirect_to_repository_settings(@project)
redirect_to_repository_settings(@project, anchor: 'js-push-rules')
end
private
......
......@@ -10,6 +10,7 @@
Customize your issue restrictions.
.settings-content
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "issue-settings-form" }, authenticity_token: true do |f|
%input{ type: 'hidden', name: 'update_section', value: 'js-issue-settings' }
.form-group
= f.label :issues_template, class: 'label-bold' do
Default description template for issues
......
......@@ -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')
......
......@@ -44,7 +44,7 @@ describe Projects::ProtectedEnvironmentsController do
it 'should redirect to CI/CD settings' do
subject
expect(response).to redirect_to project_settings_ci_cd_path(project)
expect(response).to redirect_to project_settings_ci_cd_path(project, anchor: 'js-protected-environments-settings')
end
end
......@@ -64,7 +64,7 @@ describe Projects::ProtectedEnvironmentsController do
it 'should redirect to CI/CD settings' do
subject
expect(response).to redirect_to project_settings_ci_cd_path(project)
expect(response).to redirect_to project_settings_ci_cd_path(project, anchor: 'js-protected-environments-settings')
end
end
end
......@@ -166,7 +166,7 @@ describe Projects::ProtectedEnvironmentsController do
it 'should redirect to CI/CD settings' do
subject
expect(response).to redirect_to project_settings_ci_cd_path(project)
expect(response).to redirect_to project_settings_ci_cd_path(project, anchor: 'js-protected-environments-settings')
end
end
......
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