Commit cc9764ac authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '35952-keep-project-repository-settings-open-after-submit' into 'master'

Keep project repository settings sections expanded after submitting form

See merge request gitlab-org/gitlab-ce!21082
parents e7ff0dfd c3d0545a
module RepositorySettingsRedirect
extend ActiveSupport::Concern
def redirect_to_repository_settings(project)
redirect_to project_settings_repository_path(project)
def redirect_to_repository_settings(project, anchor: nil)
redirect_to project_settings_repository_path(project, anchor: anchor)
end
end
......@@ -10,7 +10,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
def index
respond_to do |format|
format.html { redirect_to_repository_settings(@project) }
format.html { redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings') }
format.json do
render json: Projects::Settings::DeployKeysPresenter.new(@project, current_user: current_user).as_json
end
......@@ -18,7 +18,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
def new
redirect_to_repository_settings(@project)
redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
end
def create
......@@ -28,7 +28,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
flash[:alert] = @key.errors.full_messages.join(', ').html_safe
end
redirect_to_repository_settings(@project)
redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
end
def edit
......@@ -37,7 +37,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
def update
if deploy_key.update(update_params)
flash[:notice] = 'Deploy key was successfully updated.'
redirect_to_repository_settings(@project)
redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
else
render 'edit'
end
......@@ -47,7 +47,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
Projects::EnableDeployKeyService.new(@project, current_user, params).execute
respond_to do |format|
format.html { redirect_to_repository_settings(@project) }
format.html { redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings') }
format.json { head :ok }
end
end
......@@ -59,7 +59,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
deploy_key_project.destroy!
respond_to do |format|
format.html { redirect_to_repository_settings(@project) }
format.html { redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings') }
format.json { head :ok }
end
end
......
......@@ -5,6 +5,6 @@ class Projects::DeployTokensController < Projects::ApplicationController
@token = @project.deploy_tokens.find(params[:id])
@token.revoke!
redirect_to project_settings_repository_path(project)
redirect_to project_settings_repository_path(project, anchor: 'js-deploy-tokens')
end
end
......@@ -9,7 +9,7 @@ class Projects::MirrorsController < Projects::ApplicationController
layout "project_settings"
def show
redirect_to_repository_settings(project)
redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
end
def update
......@@ -22,7 +22,7 @@ class Projects::MirrorsController < Projects::ApplicationController
end
respond_to do |format|
format.html { redirect_to_repository_settings(project) }
format.html { redirect_to_repository_settings(project, anchor: 'js-push-remote-settings') }
format.json do
if project.errors.present?
render json: project.errors, status: :unprocessable_entity
......@@ -39,7 +39,7 @@ class Projects::MirrorsController < Projects::ApplicationController
flash[:notice] = "The remote repository is being updated..."
end
redirect_to_repository_settings(project)
redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
end
private
......
......@@ -19,7 +19,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
flash[:alert] = protected_ref.errors.full_messages.join(', ').html_safe
end
redirect_to_repository_settings(@project)
redirect_to_repository_settings(@project, anchor: params[:update_section])
end
def show
......@@ -40,7 +40,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
destroy_service_class.new(@project, current_user).execute(@protected_ref)
respond_to do |format|
format.html { redirect_to_repository_settings(@project) }
format.html { redirect_to_repository_settings(@project, anchor: params[:update_section]) }
format.js { head :ok }
end
end
......
- expanded = Rails.env.test?
%section.qa-deploy-keys-settings.settings.no-animate{ class: ('expanded' if expanded) }
%section.qa-deploy-keys-settings.settings.no-animate#js-deploy-keys-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
Deploy Keys
......
%p.profile-settings-content
= s_("DeployTokens|Pick a name for the application, and we'll give you a unique deploy token.")
= form_for token, url: create_deploy_token_namespace_project_settings_repository_path(project.namespace, project), method: :post do |f|
= form_for token, url: create_deploy_token_namespace_project_settings_repository_path(project.namespace, project, anchor: 'js-deploy-tokens'), method: :post do |f|
= form_errors(token)
.form-group
......
= form_for [@project.namespace.becomes(Namespace), @project, @protected_branch], html: { class: 'new-protected-branch js-new-protected-branch' } do |f|
%input{ type: 'hidden', name: 'update_section', value: 'js-protected-branches-settings' }
.card
.card-header
%h3.card-title
......
- expanded = Rails.env.test?
%section.qa-protected-branches-settings.settings.no-animate{ class: ('expanded' if expanded) }
%section.qa-protected-branches-settings.settings.no-animate#js-protected-branches-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
Protected Branches
......
......@@ -21,4 +21,4 @@
- if can_admin_project
%td
= link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, protected_branch], disabled: local_assigns[:disabled], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-warning"
= link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, protected_branch, { update_section: 'js-protected-branches-settings' }], disabled: local_assigns[:disabled], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-warning"
= form_for [@project.namespace.becomes(Namespace), @project, @protected_tag], html: { class: 'new-protected-tag js-new-protected-tag' } do |f|
%input{ type: 'hidden', name: 'update_section', value: 'js-protected-tags-settings' }
.card
.card-header
%h3.card-title
......
......@@ -19,4 +19,4 @@
- if can? current_user, :admin_project, @project
%td
= link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, protected_tag], data: { confirm: 'Tag will be writable for developers. Are you sure?' }, method: :delete, class: 'btn btn-warning'
= link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, protected_tag, { update_section: 'js-protected-tags-settings' }], data: { confirm: 'Tag will be writable for developers. Are you sure?' }, method: :delete, class: 'btn btn-warning'
......@@ -19,7 +19,7 @@ describe Projects::DeployKeysController do
it 'redirects to blob' do
get :index, params
expect(response).to redirect_to(namespace_project_settings_repository_path(params))
expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings'))
end
end
......
......@@ -36,7 +36,7 @@ describe Projects::MirrorsController do
it 'processes a successful update' do
do_put(project, remote_mirrors_attributes: remote_mirror_attributes)
expect(response).to redirect_to(project_settings_repository_path(project))
expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-push-remote-settings'))
expect(flash[:notice]).to match(/successfully updated/)
end
......@@ -53,7 +53,7 @@ describe Projects::MirrorsController do
it 'processes an unsuccessful update' do
do_put(project, remote_mirrors_attributes: remote_mirror_attributes)
expect(response).to redirect_to(project_settings_repository_path(project))
expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-push-remote-settings'))
expect(flash[:alert]).to match(/Only allowed protocols are/)
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