From b7b5b92c1270c252db5ab724e275597c188bca35 Mon Sep 17 00:00:00 2001 From: Kate Lynch Date: Thu, 12 Dec 2024 08:23:14 -0500 Subject: [PATCH] Added "Latest Download" link to inventory download modal (#1123) * Added latest download link to controller, added link to modal * Added a test to the modal --- app/assets/stylesheets/_projects.scss | 5 +++++ app/controllers/projects_controller.rb | 2 ++ .../projects/_latest_download_link.html.erb | 1 + app/views/projects/contents.html.erb | 2 ++ spec/system/project_show_spec.rb | 22 +++++++++++++++++++ 5 files changed, 32 insertions(+) create mode 100644 app/views/projects/_latest_download_link.html.erb diff --git a/app/assets/stylesheets/_projects.scss b/app/assets/stylesheets/_projects.scss index d394efec..cfca9070 100644 --- a/app/assets/stylesheets/_projects.scss +++ b/app/assets/stylesheets/_projects.scss @@ -92,3 +92,8 @@ } } + +.latest-download-link { + margin: 1em 0em 1em 0em; + display: block; +} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3b950081..51a3a47d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -114,6 +114,7 @@ def show @project_purpose = @project_metadata[:project_purpose] + respond_to do |format| format.html do @project = ProjectShowPresenter.new(project) @@ -176,6 +177,7 @@ def contents add_breadcrumb("Contents", project_contents_path) project + @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last @storage_usage = project.storage_usage(session_id: current_user.mediaflux_session) @storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session) diff --git a/app/views/projects/_latest_download_link.html.erb b/app/views/projects/_latest_download_link.html.erb new file mode 100644 index 00000000..47139016 --- /dev/null +++ b/app/views/projects/_latest_download_link.html.erb @@ -0,0 +1 @@ +<%= link_to("Download latest report - generated #{time_ago_in_words(@latest_completed_download.completion_time)} ago", project_file_list_download_path(@latest_completed_download.id, target: "_blank")) %> \ No newline at end of file diff --git a/app/views/projects/contents.html.erb b/app/views/projects/contents.html.erb index 764a677e..dc81b03a 100644 --- a/app/views/projects/contents.html.erb +++ b/app/views/projects/contents.html.erb @@ -38,6 +38,8 @@