From 9b49745194bbdbbc12ae1c3d5167c271b9df2a14 Mon Sep 17 00:00:00 2001 From: ajugo Date: Tue, 25 Apr 2023 15:18:12 +0200 Subject: [PATCH] Fix repository_row call when no repository row is selected [SCI-8281] (#5301) --- app/assets/javascripts/sitewide/repository_row_info_modal.js | 2 +- app/controllers/repository_rows_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/sitewide/repository_row_info_modal.js b/app/assets/javascripts/sitewide/repository_row_info_modal.js index 3f896c490..ba0b5afd7 100644 --- a/app/assets/javascripts/sitewide/repository_row_info_modal.js +++ b/app/assets/javascripts/sitewide/repository_row_info_modal.js @@ -65,7 +65,7 @@ $('#modal-info-repository-row').modal('hide'); PrintModalComponent.row_ids = selectedRows; } else { - PrintModalComponent.row_ids = RepositoryDatatable.selectedRows(); + PrintModalComponent.row_ids = [...RepositoryDatatable.selectedRows()]; } } }); diff --git a/app/controllers/repository_rows_controller.rb b/app/controllers/repository_rows_controller.rb index 9376ae2d3..946e2d7b0 100644 --- a/app/controllers/repository_rows_controller.rb +++ b/app/controllers/repository_rows_controller.rb @@ -307,8 +307,8 @@ class RepositoryRowsController < ApplicationController end def load_repository_or_snapshot - @repository = Repository.accessible_by_teams(current_team).find_by(id: @repository_row.first.repository_id) - @repository ||= RepositorySnapshot.find_by(id: @repository_row.first.repository_id) + @repository = Repository.accessible_by_teams(current_team).find_by(id: @repository_row&.first&.repository_id) + @repository ||= RepositorySnapshot.find_by(id: @repository_row&.first&.repository_id) render_404 unless @repository end