diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a64ab363..498d1499 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -70,7 +70,7 @@ def create render :new end - def show + def details add_breadcrumb(project.title, project_path) add_breadcrumb("Details") project @@ -175,9 +175,9 @@ def index def confirmation; end def revision_confirmation; end - def contents + def show add_breadcrumb(project.title, project_path) - add_breadcrumb("Contents", project_contents_path) + add_breadcrumb("Contents") project @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last diff --git a/app/javascript/entrypoints/projectTabs.js b/app/javascript/entrypoints/projectTabs.js index 8b265736..8541d024 100644 --- a/app/javascript/entrypoints/projectTabs.js +++ b/app/javascript/entrypoints/projectTabs.js @@ -135,43 +135,26 @@ export function projectStyle(railsSession) { // }); } -export function projectTab() { - $('#project-content').on('click', (inv) => { - const element = inv; +export function projectTab(contentUrl, detailsUrl) { + $('#project-content').on('click', (element) => { element.preventDefault(); - const contentLocation = `${window.location}/contents`; - $.ajax({ type: 'GET', - url: contentLocation, - success() { // on success.. - window.location.href = contentLocation; // update the DIV + url: contentUrl, + success() { + window.location.href = contentUrl; // update the browser's URL }, }); }); - $('#project-details').on('click', (inv) => { - const element = inv; + $('#project-details').on('click', (element) => { element.preventDefault(); - const baseURL = window.location.href; - const content = '/contents'; - const detailLocation = baseURL.replace(content, ''); $.ajax({ type: 'GET', - url: detailLocation, - success() { // on success.. - window.location.href = detailLocation; // update the DIV + url: detailsUrl, + success() { + window.location.href = detailsUrl; // update the browser's URL }, }); }); - - // $('#project-script').on('click', (inv) => { - // const element = inv; - // element.preventDefault(); - // }); - - // $('#project-approval').on('click', (inv) => { - // const element = inv; - // element.preventDefault(); - // }); } diff --git a/app/views/projects/contents.html.erb b/app/views/projects/contents.html.erb deleted file mode 100644 index efe4014f..00000000 --- a/app/views/projects/contents.html.erb +++ /dev/null @@ -1,56 +0,0 @@ -<%= render partial: "project_details_heading" %> - - -
-
- - - - -
-
-
File Inventory:
-
Total Files: <%= @num_files %>
-
-
- -
-
-
- - <%= render partial: "contents", locals: { files: @files } %> -
-
-
- -
-
-
- - - - -
- \ No newline at end of file diff --git a/app/views/projects/details.html.erb b/app/views/projects/details.html.erb new file mode 100644 index 00000000..48dca3fc --- /dev/null +++ b/app/views/projects/details.html.erb @@ -0,0 +1,117 @@ +<%= render partial: "project_details_heading" %> + + +<% unless @project.in_mediaflux? %> +
+ Your new project request is in the queue. Please allow 5 business days for our team to review your needs and set everything up. For assistance, please contact tigerdata@princeton.edu. +
+<% end %> + +
+ + + + +
+ +
+

Roles + <%# Per ticket #1114 only superusers have edit access %> + <% if @project_eligible_to_edit && current_user.superuser || current_user.sysadmin %> + <%= link_to "Edit", edit_project_path(@project.id), id:"revisible-heading", class: "btn btn-primary btn-sm" %> + <% end %> +

+
+ <% if !@data_sponsor.nil? %> +
Data Sponsor
+
+ <%= @data_sponsor.display_name_safe %> +
+ <% end %> + <% if !@data_manager.nil? %> +
Data Manager
+
+ <%= @data_manager.display_name_safe %> +
+ <% end %> + +
Data Users
+ <% if @data_users.present? %> +
+ <%= @data_user_names %> +
+ <% else %> +
+

None

+
+ <% end %> +
+
+ +
+

Project Description + <%# Per ticket #1114 only superusers have edit access %> + <% if @project_eligible_to_edit && current_user.superuser %> + <%= link_to "Edit", edit_project_path(@project.id), id:"revisible-heading", class: "btn btn-primary btn-sm" %> + <% end %> +

+
+
Departments
+ <% if @departments.empty? %> +
None
+ <% else %> +
+ <% @project.project.metadata_json["departments"].each do |department_code| %> + <% Affiliation.all.each do |hash| %> + <% if hash[:code] == department_code %> + <%= hash[:name] %> + <% end %> + <% end %> + <% end %> +
+ <% end %> +
Project Directory
+
<%= @project.project_directory %>
+
Title
+
<%= @project.title %>
+
Description:
<%= @project.description %>
+
+
+ +
+ <%= if @project.pending? + render partial: "pending_details" + else + render partial: "approved_details" + end %> +
+ +
+

Provenance

+

Submission

+
    + <% @provenance_events.each do |event| %> +
  • <%= event.event_details %>, <%=event.created_at.to_time.in_time_zone("America/New_York").iso8601%>
  • + <% end %> +
+
+ +
+ <% if current_user.eligible_sysadmin? %> + <% if @project.pending? %> + <%= link_to "Approve Project", project_approve_path(@project.id), class: "btn btn-primary btn-sm" %> + <%= link_to " View Create Script", "#", class: "bi bi-code btn btn-secondary btn-sm", id: "create-script-btn" %> + <% end %> + <% end %> +
+ + +
+
+ + diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index b0a4c703..f111e133 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -1,117 +1,56 @@ <%= render partial: "project_details_heading" %> - -<% unless @project.in_mediaflux? %> -
- Your new project request is in the queue. Please allow 5 business days for our team to review your needs and set everything up. For assistance, please contact tigerdata@princeton.edu. + +
+
+ + + + +
+
+
File Inventory:
+
Total Files: <%= @num_files %>
+
+
+ +
+
+
+ + <%= render partial: "contents", locals: { files: @files } %> +
+
+
+ +
+
+
+ + + + -<% end %> - -
- - - - -
- -
-

Roles - <%# Per ticket #1114 only superusers have edit access %> - <% if @project_eligible_to_edit && current_user.superuser %> - <%= link_to "Edit", edit_project_path(@project.id), id:"revisible-heading", class: "btn btn-primary btn-sm" %> - <% end %> -

-
- <% if !@data_sponsor.nil? %> -
Data Sponsor
-
- <%= @data_sponsor.display_name_safe %> -
- <% end %> - <% if !@data_manager.nil? %> -
Data Manager
-
- <%= @data_manager.display_name_safe %> -
- <% end %> - -
Data Users
- <% if @data_users.present? %> -
- <%= @data_user_names %> -
- <% else %> -
-

None

-
- <% end %> -
-
- -
-

Project Description - <%# Per ticket #1114 only superusers have edit access %> - <% if @project_eligible_to_edit && current_user.superuser || current_user.sysadmin %> - <%= link_to "Edit", edit_project_path(@project.id), id:"revisible-heading", class: "btn btn-primary btn-sm" %> - <% end %> -

-
-
Departments
- <% if @departments.empty? %> -
None
- <% else %> -
- <% @project.project.metadata_json["departments"].each do |department_code| %> - <% Affiliation.all.each do |hash| %> - <% if hash[:code] == department_code %> - <%= hash[:name] %> - <% end %> - <% end %> - <% end %> -
- <% end %> -
Project Directory
-
<%= @project.project_directory %>
-
Title
-
<%= @project.title %>
-
Description:
<%= @project.description %>
-
-
- -
- <%= if @project.pending? - render partial: "pending_details" - else - render partial: "approved_details" - end %> -
- -
-

Provenance

-

Submission

-
    - <% @provenance_events.each do |event| %> -
  • <%= event.event_details %>, <%=event.created_at.to_time.in_time_zone("America/New_York").iso8601%>
  • - <% end %> -
- -
- <% if current_user.eligible_sysadmin? %> - <% if @project.pending? %> - <%= link_to "Approve Project", project_approve_path(@project.id), class: "btn btn-primary btn-sm" %> - <%= link_to " View Create Script", "#", class: "bi bi-code btn btn-secondary btn-sm", id: "create-script-btn" %> - <% end %> - <% end %> -
- - -
- - diff --git a/config/routes.rb b/config/routes.rb index f3befeeb..c2e3069b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,7 +29,7 @@ resources :projects get "projects/:id/approve", to: "projects#approve", as: :project_approve get "projects/:id/confirmation", to: "projects#confirmation", as: :project_confirmation - get "projects/:id/contents", to: "projects#contents", as: :project_contents + get "projects/:id/details", to: "projects#details", as: :project_details get "projects/:id/list-contents", to: "projects#list_contents", as: :project_list_contents get "projects/:id/revision_confirmation", to: "projects#revision_confirmation", as: :project_revision_confirmation get "projects/file_list_download/:job_id", to: "projects#file_list_download", as: :project_file_list_download diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index f2d21b6f..6f874631 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -3,9 +3,9 @@ RSpec.describe ProjectsController, type: ["controller", "feature"] do let(:project) { FactoryBot.create :project } - describe "#show" do + describe "#details" do it "renders an error when requesting json" do - get :show, params: { id: project.id, format: :json } + get :details, params: { id: project.id, format: :json } expect(response.content_type).to eq("application/json; charset=utf-8") expect(response.body).to eq("{\"error\":\"You need to sign in or sign up before continuing.\"}") end @@ -17,13 +17,13 @@ end it "renders the project metadata as json" do - get :show, params: { id: project.id, format: :json } + get :details, params: { id: project.id, format: :json } expect(response.content_type).to eq("application/json; charset=utf-8") expect(JSON.parse(response.body)).to eq(project.metadata) end it "shows affiliation code as being saved to the project" do - get :show, params: { id: project.id, format: :json } + get :details, params: { id: project.id, format: :json } expect(JSON.parse(response.body)["departments"]).to include("23100") .or(include("HPC")) .or(include("RDSS")) @@ -33,7 +33,7 @@ it "renders the project metadata as xml" do project = FactoryBot.create :project, project_id: "abc-123" - get :show, params: { id: project.id, format: :xml } + get :details, params: { id: project.id, format: :xml } expect(response.content_type).to eq("application/xml; charset=utf-8") expect(response.body).to eq( "\n" \ @@ -114,8 +114,8 @@ end it "shows the affiliation name (instead the internal code) on the project show views" do - get :show, params: { id: project.id } - expect(response).to render_template("show") + get :details, params: { id: project.id } + expect(response).to render_template("details") expect(response.body).to have_content("Astrophysical Sciences") .or(have_content("High Performance Computing")) .or(have_content("Research Data and Scholarship Services")) diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index 4d1d3b1c..d6672a58 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -117,7 +117,7 @@ expect(response).to be_redirect expect(Project.all).not_to be_empty new_project = Project.last - get(project_path(new_project)) + get(project_details_path(new_project)) expect(response.body).to include("Anonymous Foo (read only), Anonymous Qux (read only), Anonymous Zed") end diff --git a/spec/system/mediaflux_session_spec.rb b/spec/system/mediaflux_session_spec.rb index 1bf23131..78c3daef 100644 --- a/spec/system/mediaflux_session_spec.rb +++ b/spec/system/mediaflux_session_spec.rb @@ -18,7 +18,7 @@ # logout the session so we get an error and need to reset the session Mediaflux::LogoutRequest.new(session_token: original_session).resolve - expect { visit project_contents_path(project) }.not_to raise_error + expect { visit project_path(project) }.not_to raise_error expect(page).to have_content("Total Files: 0") # a new session got automatically connected for the user in the application controller diff --git a/spec/system/project_show_spec.rb b/spec/system/project_details_spec.rb similarity index 92% rename from spec/system/project_show_spec.rb rename to spec/system/project_details_spec.rb index 53b05532..d4b49d23 100644 --- a/spec/system/project_show_spec.rb +++ b/spec/system/project_details_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe "Project Page", type: :system, connect_to_mediaflux: true, js: true do +RSpec.describe "Project Details Page", type: :system, connect_to_mediaflux: true, js: true do let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123") } let(:sysadmin_user) { FactoryBot.create(:sysadmin, uid: "puladmin") } let(:data_manager) { FactoryBot.create(:user, uid: "pul987") } @@ -34,7 +34,7 @@ let(:project_in_mediaflux) { FactoryBot.create(:project, mediaflux_id: 8888, metadata_model: metadata_model) } let(:project_not_in_mediaflux) { FactoryBot.create(:project, metadata_model: metadata_model) } - context "Show page" do + context "Details page" do context "Navigation Buttons" do context "Approved projects" do context "Sponsor user" do @@ -42,7 +42,7 @@ sign_in sponsor_user project_in_mediaflux.metadata_model.status = Project::APPROVED_STATUS project_in_mediaflux.save! - visit "/projects/#{project_in_mediaflux.id}" + visit "/projects/#{project_in_mediaflux.id}/details" expect(page).to have_content(project_in_mediaflux.title) @@ -66,7 +66,7 @@ sign_in sysadmin_user project_in_mediaflux.metadata_model.status = Project::APPROVED_STATUS project_in_mediaflux.save! - visit "/projects/#{project_in_mediaflux.id}" + visit "/projects/#{project_in_mediaflux.id}/details" expect(page).to have_selector(:link_or_button, "Edit") # button next to project settings expect(page).not_to have_selector(:link_or_button, "Withdraw Project Request") @@ -80,7 +80,7 @@ context "Sponsor user" do it "Shows the correct nav buttons for a pending project" do sign_in sponsor_user - visit "/projects/#{project_not_in_mediaflux.id}" + visit "/projects/#{project_not_in_mediaflux.id}/details" expect(page).to have_content(project_not_in_mediaflux.title) expect(page).to have_content(pending_text) expect(page).to have_css ".pending" @@ -94,7 +94,7 @@ context "SysAdmin" do it "Shows the correct nav buttons for a pending project" do sign_in sysadmin_user - visit "/projects/#{project_not_in_mediaflux.id}" + visit "/projects/#{project_not_in_mediaflux.id}/details" expect(page).to have_content(project_not_in_mediaflux.title) expect(page).to have_content(pending_text) expect(page).to have_css ".pending" @@ -113,7 +113,7 @@ project_in_mediaflux.metadata_model.storage_capacity["unit"]["approved"] = "TB" project_in_mediaflux.metadata_model.storage_performance_expectations["approved"] = "slow" project_in_mediaflux.save! - visit "/projects/#{project_in_mediaflux.id}" + visit "/projects/#{project_in_mediaflux.id}/details" expect(page).to have_content(project_in_mediaflux.title) expect(page).to have_content("Storage Capacity\nRequested\n500 GB\nApproved\n1 TB") @@ -128,7 +128,7 @@ it "shows provenance events" do submission_event sign_in sponsor_user - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page).to have_content "#{submission_event.event_details}, #{submission_event.created_at.to_time.in_time_zone('America/New_York').iso8601}" end it "shows the project status under the provenance section" do @@ -159,7 +159,7 @@ it "Contents page has collection summary data" do # sign in and be able to view the file count for the collection sign_in sponsor_user - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page).to have_selector(:link_or_button, "Content Preview") click_on("Content Preview") expect(page).to have_content("8 out of 22 shown") @@ -176,7 +176,7 @@ it "displays the caveat message" do # sign in and be able to view the file count for the collection sign_in sponsor_user - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page).to have_selector(:link_or_button, "Content Preview") click_on("Content Preview") @@ -187,7 +187,7 @@ it "displays the file list" do # sign in and be able to view the file count for the collection sign_in sponsor_user - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page).to have_selector(:link_or_button, "Content Preview") click_on("Content Preview") @@ -204,7 +204,7 @@ context "when downloads do not exist" do it "does not include a link to the latest download in the download modal" do sign_in sponsor_user - visit "/projects/#{project.id}/contents" + visit "/projects/#{project.id}" click_on("Download Complete List") expect(page).not_to have_content("Download latest") end @@ -219,7 +219,7 @@ end it "includes a link to the latest download in the download modal" do sign_in sponsor_user - visit "/projects/#{project.id}/contents" + visit "/projects/#{project.id}" click_on("Download Complete List") expect(page).to have_content("Download latest report - generated 2 days ago") end @@ -231,7 +231,7 @@ let(:project_not_in_mediaflux) { FactoryBot.create(:project) } it "shows the sysadmin buttons for an approved project" do sign_in sysadmin_user - visit "/projects/#{project_in_mediaflux.id}" + visit "/projects/#{project_in_mediaflux.id}/details" # shows the project directory without the hidden root expect(page).to have_content(project_in_mediaflux.project_directory.gsub("/td-test-001", "")) @@ -246,7 +246,7 @@ it "does not show the mediaflux id to the sponsor" do sign_in sponsor_user - visit "/projects/#{project_in_mediaflux.id}" + visit "/projects/#{project_in_mediaflux.id}/details" expect(page).to have_content "project 123" expect(page).not_to have_content "1234" expect(page).not_to have_content "This project has not been saved to Mediaflux" @@ -257,7 +257,7 @@ it "shows the sysadmin buttons for a pending project" do sign_in sysadmin_user - visit "/projects/#{project_not_in_mediaflux.id}" + visit "/projects/#{project_not_in_mediaflux.id}/details" expect(page).to have_content "This project has not been saved to Mediaflux" expect(page).to have_content pending_text expect(page).to have_selector(:link_or_button, "Approve Project") diff --git a/spec/system/project_roles_spec.rb b/spec/system/project_roles_spec.rb index 4a5c09db..a748eda9 100644 --- a/spec/system/project_roles_spec.rb +++ b/spec/system/project_roles_spec.rb @@ -70,6 +70,7 @@ click_on "Return to Dashboard" expect(page).to have_content("Welcome") find(:xpath, "//h2[text()='My test project']").click + click_on "Details" expect(page).to have_content("This project has not been saved to Mediaflux") expect(page).to have_content(read_only.given_name) expect(page).to have_content(read_only.display_name) @@ -137,7 +138,7 @@ fill_in "project_id", with: "999-abc" page.find("body").click click_on "Submit" - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page.find(:css, "#data_sponsor").text).to eq sponsor_user.display_name expect(page.find(:css, "#project_id").text).to eq "999-abc" end @@ -158,7 +159,7 @@ fill_in "data_manager", with: new_data_manager.uid page.find("body").click click_on "Submit" - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page.find(:css, "#data_manager").text).to eq new_data_manager.display_name end it "does not allow anyone else to assign a Data Manager" do @@ -194,7 +195,7 @@ fill_in_and_out "ro-user-uid-to-add", with: ro_data_user.uid fill_in_and_out "rw-user-uid-to-add", with: rw_data_user.uid click_on "Submit" - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page).to have_content "#{ro_data_user.display_name} (read only)" expect(page).to have_content rw_data_user.display_name end @@ -204,7 +205,7 @@ fill_in_and_out "ro-user-uid-to-add", with: ro_data_user.uid fill_in_and_out "rw-user-uid-to-add", with: rw_data_user.uid click_on "Submit" - visit "/projects/#{project.id}" + visit "/projects/#{project.id}/details" expect(page).to have_content "#{ro_data_user.display_name} (read only)" expect(page).to have_content rw_data_user.display_name end diff --git a/spec/system/project_spec.rb b/spec/system/project_spec.rb index 9a598d8e..b8e9fa6c 100644 --- a/spec/system/project_spec.rb +++ b/spec/system/project_spec.rb @@ -46,7 +46,7 @@ context "Before it is in MediaFlux" do it "Shows the not yet approved (pending) project" do sign_in sponsor_user - visit "/projects/#{project_not_in_mediaflux.id}" + visit "/projects/#{project_not_in_mediaflux.id}/details" expect(page).to have_content pending_text end end @@ -75,7 +75,7 @@ it "shows none when the data user is empty" do sign_in data_manager - visit "/projects/#{project_not_in_mediaflux.id}" + visit "/projects/#{project_not_in_mediaflux.id}/details" expect(page).to have_content "This project has not been saved to Mediaflux" expect(page).to have_content pending_text expect(page).not_to have_button "Approve Project" @@ -205,6 +205,7 @@ click_on "Return to Dashboard" expect(page).to have_content "Sponsor" find(:xpath, "//h2[text()='My test project']").click + click_on "Details" # defaults have been applied expect(page).to have_content "Storage Capacity (Requested)\n500 GB" expect(page).to have_content "Storage Performance Expectations (Requested)\nStandard" @@ -468,7 +469,7 @@ end end - context "GET /projects/:id/content" do + context "GET /projects/:id" do context "when authenticated" do let(:completion_time) { Time.current.in_time_zone("America/New_York").iso8601 } let(:approved_project) do @@ -488,7 +489,7 @@ context "when the Mediaflux assets have one or multiple files" do it "enqueues a Sidekiq job for asynchronously requesting project files" do - visit project_contents_path(approved_project) + visit project_path(approved_project) expect(page).to have_content("Download Complete List") click_on "Download Complete List"