From 815fbb954edb86993c0e25d9ef038b6ff4372cba Mon Sep 17 00:00:00 2001 From: Ashton South Date: Mon, 28 Oct 2024 15:31:42 -0400 Subject: [PATCH] pass project instead of using safe navigation --- apps/dashboard/app/controllers/projects_controller.rb | 4 ++-- apps/dashboard/app/helpers/projects_helper.rb | 4 ++-- .../app/views/projects/_job_details.turbo_stream.erb | 2 +- .../app/views/projects/_job_details_content.html.erb | 2 +- apps/dashboard/app/views/projects/show.html.erb | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/dashboard/app/controllers/projects_controller.rb b/apps/dashboard/app/controllers/projects_controller.rb index 2ac74a36c9..4693471461 100644 --- a/apps/dashboard/app/controllers/projects_controller.rb +++ b/apps/dashboard/app/controllers/projects_controller.rb @@ -111,8 +111,8 @@ def job_details hpc_job = project.job(job_details_params[:jobid].to_s, cluster_str) @project = project - - render(partial: 'job_details', locals: { job: hpc_job }) + + render(partial: 'job_details', locals: { job: hpc_job, project: @project }) end # DELETE /projects/:project_id/jobs/:cluster/:jobid diff --git a/apps/dashboard/app/helpers/projects_helper.rb b/apps/dashboard/app/helpers/projects_helper.rb index 56a464f89e..87df4858d4 100644 --- a/apps/dashboard/app/helpers/projects_helper.rb +++ b/apps/dashboard/app/helpers/projects_helper.rb @@ -15,8 +15,8 @@ def render_readme(readme_location) end end - def job_details_buttons(status, job) - locals = { project_id: @project&.id, id: job&.id, cluster: job&.cluster } + def job_details_buttons(status, job, project) + locals = { project_id: project.id, id: job.id, cluster: job.cluster } button_partial = button_category(status) render(partial: "projects/buttons/#{button_category(status)}_buttons", locals: locals) unless button_partial.nil? end diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index b85c80f7b8..838f73339e 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -5,6 +5,6 @@ diff --git a/apps/dashboard/app/views/projects/_job_details_content.html.erb b/apps/dashboard/app/views/projects/_job_details_content.html.erb index 2917618a4a..ac39ff326c 100644 --- a/apps/dashboard/app/views/projects/_job_details_content.html.erb +++ b/apps/dashboard/app/views/projects/_job_details_content.html.erb @@ -20,7 +20,7 @@ <% end %>
- <%= job_details_buttons(job.status.to_s, job) %> + <%= job_details_buttons(job.status.to_s, job, project) %>
diff --git a/apps/dashboard/app/views/projects/show.html.erb b/apps/dashboard/app/views/projects/show.html.erb index 2d3db7aff5..6d4e82b56b 100644 --- a/apps/dashboard/app/views/projects/show.html.erb +++ b/apps/dashboard/app/views/projects/show.html.erb @@ -59,7 +59,7 @@

Active Jobs

- <%= render(partial: 'job_details', collection: @project.active_jobs, as: :job ) %> + <%= render(partial: 'job_details', collection: @project.active_jobs, as: :job, locals: { project: @project }) %>
@@ -67,7 +67,7 @@
<%- @project.completed_jobs.each do |job| -%>
"> - <%= render(partial: 'job_details_content', locals: { job: job }) %> + <%= render(partial: 'job_details_content', locals: { job: job, project: @project }) %>
<%- end -%>