Skip to content

Commit

Permalink
fix remove mb class, add highlighting on search
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHuynh333 committed Oct 31, 2024
1 parent 5e9bec3 commit b01a2cb
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
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
3 changes: 2 additions & 1 deletion app/controllers/projects/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def process_samples

def search_params

Check warning on line 152 in app/controllers/projects/samples_controller.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Assignment Branch Condition size for search_params is too high. [<2, 21, 4> 21.47/20] Raw Output: app/controllers/projects/samples_controller.rb:152:5: C: Metrics/AbcSize: Assignment Branch Condition size for search_params is too high. [<2, 21, 4> 21.47/20]
updated_params = update_store(search_key, params[:q].present? ? params[:q].to_unsafe_h : {})

puts 'hihihihi'

Check warning on line 154 in app/controllers/projects/samples_controller.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Do not write to stdout. Use Rails's logger if you want to log. Raw Output: app/controllers/projects/samples_controller.rb:154:7: C: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
puts updated_params

Check warning on line 155 in app/controllers/projects/samples_controller.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Do not write to stdout. Use Rails's logger if you want to log. Raw Output: app/controllers/projects/samples_controller.rb:155:7: C: Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
if updated_params[:metadata].to_i.zero? && updated_params[:s].present? && updated_params[:s].match?(/metadata_/)
updated_params[:s] = default_sort
update_store(search_key, updated_params)
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
5 changes: 2 additions & 3 deletions app/views/projects/workflow_executions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="flow-root">
<div class="flex mb-2">
<% if allowed_to?(:export_data?, @project.namespace) %>
<div class="inline-flex grow 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 Down Expand Up @@ -62,11 +62,10 @@
</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
2 changes: 1 addition & 1 deletion app/views/workflow_executions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@
locals: {
workflow_executions: @workflow_executions,
pagy: @pagy,
q: @q,
q: @q
} %>

0 comments on commit b01a2cb

Please sign in to comment.