Commit c90cfbd4 authored by Mike Greiling's avatar Mike Greiling

ensure all project repository settings panels remain open after form submission

parent 9c0f5271
module RepositorySettingsRedirect module RepositorySettingsRedirect
extend ActiveSupport::Concern extend ActiveSupport::Concern
def redirect_to_repository_settings(project) def redirect_to_repository_settings(project, anchor: nil)
redirect_to project_settings_repository_path(project) redirect_to project_settings_repository_path(project, anchor: anchor)
end end
end end
...@@ -10,7 +10,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -10,7 +10,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
def index def index
respond_to do |format| 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 format.json do
render json: Projects::Settings::DeployKeysPresenter.new(@project, current_user: current_user).as_json render json: Projects::Settings::DeployKeysPresenter.new(@project, current_user: current_user).as_json
end end
...@@ -18,7 +18,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -18,7 +18,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end end
def new def new
redirect_to_repository_settings(@project) redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
end end
def create def create
...@@ -28,7 +28,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -28,7 +28,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
flash[:alert] = @key.errors.full_messages.join(', ').html_safe flash[:alert] = @key.errors.full_messages.join(', ').html_safe
end end
redirect_to_repository_settings(@project) redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
end end
def edit def edit
...@@ -37,7 +37,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -37,7 +37,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
def update def update
if deploy_key.update(update_params) if deploy_key.update(update_params)
flash[:notice] = 'Deploy key was successfully updated.' flash[:notice] = 'Deploy key was successfully updated.'
redirect_to_repository_settings(@project) redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
else else
render 'edit' render 'edit'
end end
...@@ -47,7 +47,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -47,7 +47,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
Projects::EnableDeployKeyService.new(@project, current_user, params).execute Projects::EnableDeployKeyService.new(@project, current_user, params).execute
respond_to do |format| 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 } format.json { head :ok }
end end
end end
...@@ -59,7 +59,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -59,7 +59,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
deploy_key_project.destroy! deploy_key_project.destroy!
respond_to do |format| 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 } format.json { head :ok }
end end
end end
......
...@@ -5,6 +5,6 @@ class Projects::DeployTokensController < Projects::ApplicationController ...@@ -5,6 +5,6 @@ class Projects::DeployTokensController < Projects::ApplicationController
@token = @project.deploy_tokens.find(params[:id]) @token = @project.deploy_tokens.find(params[:id])
@token.revoke! @token.revoke!
redirect_to project_settings_repository_path(project) redirect_to project_settings_repository_path(project, anchor: 'js-deploy-tokens')
end end
end end
...@@ -9,7 +9,7 @@ class Projects::MirrorsController < Projects::ApplicationController ...@@ -9,7 +9,7 @@ class Projects::MirrorsController < Projects::ApplicationController
layout "project_settings" layout "project_settings"
def show def show
redirect_to_repository_settings(project) redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
end end
def update def update
...@@ -22,7 +22,7 @@ class Projects::MirrorsController < Projects::ApplicationController ...@@ -22,7 +22,7 @@ class Projects::MirrorsController < Projects::ApplicationController
end end
respond_to do |format| 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 format.json do
if project.errors.present? if project.errors.present?
render json: project.errors, status: :unprocessable_entity render json: project.errors, status: :unprocessable_entity
...@@ -39,7 +39,7 @@ class Projects::MirrorsController < Projects::ApplicationController ...@@ -39,7 +39,7 @@ class Projects::MirrorsController < Projects::ApplicationController
flash[:notice] = "The remote repository is being updated..." flash[:notice] = "The remote repository is being updated..."
end end
redirect_to_repository_settings(project) redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
end end
private private
......
...@@ -19,7 +19,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController ...@@ -19,7 +19,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
flash[:alert] = protected_ref.errors.full_messages.join(', ').html_safe flash[:alert] = protected_ref.errors.full_messages.join(', ').html_safe
end end
redirect_to_repository_settings(@project) redirect_to_repository_settings(@project, anchor: params[:update_section])
end end
def show def show
...@@ -40,7 +40,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController ...@@ -40,7 +40,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
destroy_service_class.new(@project, current_user).execute(@protected_ref) destroy_service_class.new(@project, current_user).execute(@protected_ref)
respond_to do |format| 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 } format.js { head :ok }
end end
end end
......
- expanded = Rails.env.test? - 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 .settings-header
%h4 %h4
Deploy Keys Deploy Keys
......
%p.profile-settings-content %p.profile-settings-content
= s_("DeployTokens|Pick a name for the application, and we'll give you a unique deploy token.") = 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_errors(token)
.form-group .form-group
......
= form_for [@project.namespace.becomes(Namespace), @project, @protected_branch], html: { class: 'new-protected-branch js-new-protected-branch' } do |f| = 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
.card-header .card-header
%h3.card-title %h3.card-title
......
- expanded = Rails.env.test? - 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 .settings-header
%h4 %h4
Protected Branches Protected Branches
......
...@@ -21,4 +21,4 @@ ...@@ -21,4 +21,4 @@
- if can_admin_project - if can_admin_project
%td %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| = 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
.card-header .card-header
%h3.card-title %h3.card-title
......
...@@ -19,4 +19,4 @@ ...@@ -19,4 +19,4 @@
- if can? current_user, :admin_project, @project - if can? current_user, :admin_project, @project
%td %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'
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