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? - expanded = Rails.env.test?
- protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|') - 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 .settings-header
%h4= _('Mirroring repositories') %h4= _('Mirroring repositories')
%button.btn.js-settings-toggle %button.btn.js-settings-toggle
......
...@@ -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'));
......
...@@ -59,7 +59,7 @@ module EE ...@@ -59,7 +59,7 @@ module EE
flash[:notice] = "The repository is being updated..." flash[:notice] = "The repository is being updated..."
end end
redirect_to_repository_settings(project) redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
end end
def mirror_params_attributes def mirror_params_attributes
......
...@@ -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
......
...@@ -19,7 +19,7 @@ class Projects::PushRulesController < Projects::ApplicationController ...@@ -19,7 +19,7 @@ class Projects::PushRulesController < Projects::ApplicationController
flash[:alert] = @push_rule.errors.full_messages.join(', ').html_safe flash[:alert] = @push_rule.errors.full_messages.join(', ').html_safe
end end
redirect_to_repository_settings(@project) redirect_to_repository_settings(@project, anchor: 'js-push-rules')
end end
private private
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
Customize your issue restrictions. Customize your issue restrictions.
.settings-content .settings-content
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "issue-settings-form" }, authenticity_token: true do |f| = 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 .form-group
= f.label :issues_template, class: 'label-bold' do = f.label :issues_template, class: 'label-bold' do
Default description template for issues Default description template for issues
......
...@@ -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')
......
...@@ -44,7 +44,7 @@ describe Projects::ProtectedEnvironmentsController do ...@@ -44,7 +44,7 @@ describe Projects::ProtectedEnvironmentsController do
it 'should redirect to CI/CD settings' do it 'should redirect to CI/CD settings' do
subject 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 end
...@@ -64,7 +64,7 @@ describe Projects::ProtectedEnvironmentsController do ...@@ -64,7 +64,7 @@ describe Projects::ProtectedEnvironmentsController do
it 'should redirect to CI/CD settings' do it 'should redirect to CI/CD settings' do
subject 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 end
end end
...@@ -166,7 +166,7 @@ describe Projects::ProtectedEnvironmentsController do ...@@ -166,7 +166,7 @@ describe Projects::ProtectedEnvironmentsController do
it 'should redirect to CI/CD settings' do it 'should redirect to CI/CD settings' do
subject 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 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