From 83ac50c57d3d18dd73be6904e415151c70305918 Mon Sep 17 00:00:00 2001 From: artoscinote <85488244+artoscinote@users.noreply.github.com> Date: Tue, 12 Apr 2022 13:29:11 +0200 Subject: [PATCH] Add repository snapshot error modal [SCI-6613] (#3993) --- app/assets/javascripts/my_modules/repositories.js | 3 ++- .../my_module_repository_snapshots_controller.rb | 1 + app/views/my_modules/protocols.html.erb | 6 +++--- .../repositories/_repositories_list.html.erb | 11 +++++++++++ config/locales/en.yml | 5 ++++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/my_modules/repositories.js b/app/assets/javascripts/my_modules/repositories.js index a83edb644..436719405 100644 --- a/app/assets/javascripts/my_modules/repositories.js +++ b/app/assets/javascripts/my_modules/repositories.js @@ -399,9 +399,10 @@ var MyModuleRepositories = (function() { function checkSnapshotStatus(snapshotItem) { $.getJSON(snapshotItem.data('status-url'), (statusData) => { - if (statusData.status === 'ready') { + if (statusData.status !== 'provisioning') { $.getJSON(snapshotItem.data('version-item-url'), (itemData) => { snapshotItem.replaceWith(itemData.html); + $('#snapshot-error-' + itemData.repository_id).modal('show'); }); } else { setTimeout(function() { diff --git a/app/controllers/my_module_repository_snapshots_controller.rb b/app/controllers/my_module_repository_snapshots_controller.rb index 825d11381..1159fc48a 100644 --- a/app/controllers/my_module_repository_snapshots_controller.rb +++ b/app/controllers/my_module_repository_snapshots_controller.rb @@ -52,6 +52,7 @@ class MyModuleRepositorySnapshotsController < ApplicationController def show render json: { + repository_id: @repository_snapshot.parent_id, html: render_to_string(partial: 'my_modules/repositories/full_view_version', locals: { repository_snapshot: @repository_snapshot, can_delete_snapshot: can_manage_my_module_repository_snapshots?(@my_module) }) diff --git a/app/views/my_modules/protocols.html.erb b/app/views/my_modules/protocols.html.erb index 1fc9acee1..a3426afdc 100644 --- a/app/views/my_modules/protocols.html.erb +++ b/app/views/my_modules/protocols.html.erb @@ -3,10 +3,10 @@ id: "snapshot-error", type: "error", shown: true, - title: t("my_modules.modals.snapshot_error.title"), - body: + title: t("my_modules.modals.transition_snapshot_error.title"), + body: t( - "my_modules.modals.snapshot_error.body_html", + "my_modules.modals.transition_snapshot_error.body_html", repository: Repository.find(flash["repository_snapshot_error"]["repository_id"]).name ) %> diff --git a/app/views/my_modules/repositories/_repositories_list.html.erb b/app/views/my_modules/repositories/_repositories_list.html.erb index d758ec4aa..621677a87 100644 --- a/app/views/my_modules/repositories/_repositories_list.html.erb +++ b/app/views/my_modules/repositories/_repositories_list.html.erb @@ -42,5 +42,16 @@ + <%= render 'shared/dialog', + id: "snapshot-error-#{repository.id}", + type: "error", + shown: false, + title: t("my_modules.modals.snapshot_error.title"), + body: + t( + "my_modules.modals.snapshot_error.body_html", + repository: repository.name + ) + %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 424cb6300..efc5fed5c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1046,9 +1046,12 @@ en: hidden_tasks: "No permission: There are %{size} tasks you can’t assign to." task: 'Assign to task' task_and_downstream: 'Assign to task & downstream' - snapshot_error: + transition_snapshot_error: title: "Cannot change status" body_html: "The task cannot be moved to the next status because the %{repository} inventory snapshot failed to generate. Please contact support if this problem persists." + snapshot_error: + title: "Snapshot error" + body_html: "%{repository} inventory snapshot failed to generate. Please contact support if this problem persists." modules_list_partial: private_tasks_html: 'Assigned to %{nr} private task(s)' no_results: