Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow Executions: Filter #826

Merged
merged 8 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions app/components/workflow_executions/table_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,21 @@
<% end %>
<% if column == :id %>
<%= link_to(
workflow_execution.id,
individual_path(workflow_execution),
data: {
turbo: false,
},
class: "text-slate-900 dark:text-slate-100 font-semibold hover:underline",
) %>
) do %>
<span class="font-semibold">
<%= highlight(
workflow_execution.id,
defined?(@search_params[:name_or_id_cont]) &&
@search_params[:name_or_id_cont],
highlighter: '<mark class="bg-primary-300 dark:bg-primary-600">\1</mark>',
) %>
</span>
<% end %>
<% elsif column == :state %>
<%= viral_pill(
text: t(:"workflow_executions.state.#{workflow_execution[column]}"),
Expand All @@ -118,6 +126,15 @@
<% if workflow_execution[column].present? %>
<%= helpers.local_time_ago(workflow_execution[column]) %>
<% end %>
<% elsif column == :name %>
<span class="font-semibold">
<%= highlight(
workflow_execution.name,
defined?(@search_params[:name_or_id_cont]) &&
@search_params[:name_or_id_cont],
highlighter: '<mark class="bg-primary-300 dark:bg-primary-600">\1</mark>',
) %>
</span>
<% else %>
<%= workflow_execution[column.to_sym] %>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions app/components/workflow_executions/table_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def initialize(
q,
namespace: nil,
row_actions: false,
search_params: nil,
abilities: {},
empty: {},
**system_arguments
Expand All @@ -23,6 +24,7 @@ def initialize(
@q = q
@namespace = namespace
@abilities = abilities
@search_params = search_params
@row_actions = row_actions
@empty = empty
@renders_row_actions = @row_actions.select { |_key, value| value }.count.positive?
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/concerns/workflow_execution_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def index
authorize! @namespace, to: :view_workflow_executions? unless @namespace.nil?

@q = load_workflows.ransack(params[:q])
@search_params = search_params

set_default_sort
@pagy, @workflow_executions = pagy_with_metadata_sort(@q.result)
end
Expand Down Expand Up @@ -153,4 +155,10 @@ def format_attachment(samplesheet)
end
attachments
end

def search_params
search_params = {}
search_params[:name_or_id_cont] = params.dig(:q, :name_or_id_cont)
search_params
end
end
4 changes: 4 additions & 0 deletions app/models/workflow_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def as_wes_params
}.compact
end

ransacker :id do
Arel.sql('id::varchar')
end

def self.ransackable_attributes(_auth_object = nil)
%w[id name run_id state created_at updated_at]
end
Expand Down
1 change: 1 addition & 0 deletions app/views/projects/workflow_executions/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
pagy,
q,
namespace: namespace,
search_params: @search_params,
abilities: {
select_workflow_executions: allowed_to?(:export_data?, namespace)
},
Expand Down
14 changes: 12 additions & 2 deletions app/views/projects/workflow_executions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<% end %>
<% end %>
<div class="flow-root">
<div class="flex mb-2">
<% if allowed_to?(:export_data?, @project.namespace) %>
<div class="float-left inline-flex space-x-2 mb-4">
<div class="inline-flex grow space-x-2">
<%= search_form_for(
@q,
url: select_namespace_project_workflow_executions_url(**request.query_parameters),
Expand All @@ -51,11 +52,20 @@
<% end %>
</div>
<% end %>
<div class="grow-0">
<%= render SearchComponent.new(
query: @q,
url: namespace_project_workflow_executions_path(**request.query_parameters),
search_attribute: :name_or_id_cont,
placeholder: t('.search.placeholder')
) %>
</div>
</div>
</div>
<%= render partial: "table",
locals: {
workflow_executions: @workflow_executions,
pagy: @pagy,
q: @q,
namespace: @namespace,
namespace: @namespace
} %>
1 change: 1 addition & 0 deletions app/views/workflow_executions/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
workflow_executions,
pagy,
q,
search_params: @search_params,
abilities: {
select_workflow_executions: true
},
Expand Down
56 changes: 33 additions & 23 deletions app/views/workflow_executions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,43 @@
<% end %>
<% end %>
<div class="flow-root">
<div class="float-left inline-flex space-x-2 mb-4">
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "select-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<input type="hidden" name="select" value="on"/>
<%= f.submit t(".select_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "deselect-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<%= f.submit t(".deselect_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
<div class="flex mb-2">
<div class="inline-flex grow space-x-2">
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "select-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<input type="hidden" name="select" value="on"/>
<%= f.submit t(".select_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "deselect-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<%= f.submit t(".deselect_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
</div>
<div class="grow-0">
<%= render SearchComponent.new(
query: @q,
url: workflow_executions_path,
search_attribute: :name_or_id_cont,
placeholder: t('.search.placeholder')
) %>
</div>
</div>
</div>
<%= render partial: "table",
locals: {
workflow_executions: @workflow_executions,
pagy: @pagy,
q: @q,
q: @q
} %>
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,8 @@ en:
index:
create_export_button: Create Export
deselect_all_button: Deselect All
search:
placeholder: Filter by ID or name
select_all_button: Select All
subtitle: These are the workflow executions that have been automatically launched for this project
title: Workflow Executions
Expand Down Expand Up @@ -1686,6 +1688,8 @@ en:
delete_confirm: Are you sure you want to delete this workflow execution?
create_export_button: Create Export
deselect_all_button: Deselect All
search:
placeholder: Filter by ID or name
select_all_button: Select All
title: Workflow Executions
samples:
Expand Down
4 changes: 4 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,8 @@ fr:
index:
create_export_button: Create Export
deselect_all_button: Deselect All
search:
placeholder: Filter by ID or name
select_all_button: Select All
subtitle: These are the workflow executions that have been automatically launched for this project
title: Workflow Executions
Expand Down Expand Up @@ -1686,6 +1688,8 @@ fr:
delete_confirm: Are you sure you want to delete this workflow execution?
create_export_button: Create Export
deselect_all_button: Deselect All
search:
placeholder: Filter by ID or name
select_all_button: Select All
title: Workflow Executions
samples:
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/workflow_executions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ irida_next_example_completed_2_files:
run_id: "my_run_id_6"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:john_doe, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project1_namespace, :uuid) %>
name: 'irida_next_example_completed_2_files'
state: "completed"
blob_run_directory: "not a run dir"
cleaned: true
Expand Down Expand Up @@ -479,6 +480,7 @@ irida_next_example_completed_with_output:
run_id: "my_run_id_13"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:john_doe, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:projectA_namespace, :uuid) %>
name: "irida_next_example_completed_with_output"
state: "completed"
blob_run_directory: "not a run dir"
cleaned: false
Expand Down Expand Up @@ -602,6 +604,7 @@ automated_example_completed:
run_id: "my_run_id_6"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:project1_automation_bot, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project1_namespace, :uuid) %>
name: "autmoated_example_completed"
joshsadam marked this conversation as resolved.
Show resolved Hide resolved
state: "completed"
blob_run_directory: "not a run dir"
cleaned: true
Expand Down Expand Up @@ -663,6 +666,7 @@ automated_example_canceled:
run_id: "my_run_id_9"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:project1_automation_bot, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project1_namespace, :uuid) %>
name: "automated_example_canceled"
state: "canceled"
cleaned: true

Expand Down
6 changes: 3 additions & 3 deletions test/jobs/data_exports/create_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def setup
{ 'name' => workflow_execution.id,
'type' => 'folder',
'irida-next-type' => 'workflow_execution',
'irida-next-name' => workflow_execution.id,
'irida-next-name' => workflow_execution.name,
'children' => [
{
'name' => workflow_execution.outputs[0].filename.to_s,
Expand Down Expand Up @@ -383,7 +383,7 @@ def setup
{ 'name' => workflow_execution.id,
'type' => 'folder',
'irida-next-type' => 'workflow_execution',
'irida-next-name' => workflow_execution.id,
'irida-next-name' => workflow_execution.name,
'children' => [
{
'name' => workflow_execution.outputs[0].filename.to_s,
Expand Down Expand Up @@ -414,7 +414,7 @@ def setup
'',
'contents:',
"#{@data_export6.id}/",
"└─ #{workflow_execution.id}/ (#{workflow_execution.id})",
"└─ #{workflow_execution.id}/ (#{workflow_execution.name})",
" ├─ #{workflow_execution.outputs[0].filename}",
" └─ #{samples_workflow_execution.samplesheet_params['sample']}/ (Deleted Sample)",
" └─ #{samples_workflow_execution.outputs[0].filename}",
Expand Down
Loading
Loading