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 %> +