From d8d54232c31609fb0fc14e1caf051d173f467a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Fri, 2 Jun 2017 19:08:51 +0200 Subject: [PATCH] After repository renaming user is redirected to the same repository. Removed the unimplemented repository copy dropdown option. [SCI-1269] --- app/assets/javascripts/repositories/index.js | 4 ++-- app/controllers/repositories_controller.rb | 4 +++- app/views/repositories/index.html.erb | 17 +++++++---------- config/locales/en.yml | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/repositories/index.js b/app/assets/javascripts/repositories/index.js index 19eb54b94..e9f3e0084 100644 --- a/app/assets/javascripts/repositories/index.js +++ b/app/assets/javascripts/repositories/index.js @@ -42,9 +42,9 @@ if ($modal) { var form = $modal.find('form'); form - .on('ajax:success', function() { + .on('ajax:success', function(ev, data) { animateSpinner(form, true); - location.reload(); + $(location).attr('href', data.url); }) .on('ajax:error', function(e, error) { var msg = JSON.parse(error.responseText); diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8cf47b7d1..365656061 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -52,7 +52,9 @@ class RepositoriesController < ApplicationController if @repository.save flash[:success] = t('repositories.index.rename_flash', old_name: old_name, new_name: @repository.name) - render json: {}, status: :ok + render json: { + url: team_repositories_path(@team, repository: @repository) + }, status: :ok else render json: @repository.errors, status: :unprocessable_entity end diff --git a/app/views/repositories/index.html.erb b/app/views/repositories/index.html.erb index e82b3f870..b1ea121f2 100644 --- a/app/views/repositories/index.html.erb +++ b/app/views/repositories/index.html.erb @@ -6,9 +6,12 @@ <% if @repositories.present? %> + <% active_repo = @repositories.find_by_id(params[:repository]) %> + <% active_repo = @repositories.first if !active_repo %> +