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

Samples table metadata fields toggle #348

Merged
merged 64 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e33ae16
chore: Setup fake metadata for samples
joshsadam Dec 22, 2023
3037c4b
chore: Working template selector
joshsadam Dec 22, 2023
f541c30
chore: persist template in search
joshsadam Dec 22, 2023
de62f9b
chore: Update dropdown label
joshsadam Dec 22, 2023
47611a2
chore: Renamed default to none
joshsadam Dec 22, 2023
70fc4b7
chore: Updated time_ago component to inherit parent component's text …
joshsadam Jan 2, 2024
2932a0a
chore: Updated missing module comment
joshsadam Jan 2, 2024
cebf3de
chore: Changed Faker to use en-CA
joshsadam Jan 2, 2024
be0bced
chore: Horizontal scrolling when metadata is displayed
joshsadam Jan 2, 2024
60b9c79
chore: Ignore rubocop metrics methodlength
joshsadam Jan 2, 2024
d1f3bf2
chore: Disable abcsize
joshsadam Jan 2, 2024
40514b3
chore: Fixed incorrect rubocop syntax
joshsadam Jan 2, 2024
babe8c4
chore: Moved rubocop message
joshsadam Jan 2, 2024
b8f6ac6
chore: Re-enable rubocop after method
joshsadam Jan 3, 2024
01e48a3
chore: Moved rubocop to inline with method declaration
joshsadam Jan 3, 2024
579f684
chore: Updated transfer to use templates
joshsadam Jan 3, 2024
3d9bf5c
chore: Fixed selector for timeago
joshsadam Jan 3, 2024
a8f58a2
revert: dom_id sample already set elsewhere
joshsadam Jan 3, 2024
f1be09b
chore: Matched table styling to existing tables
joshsadam Jan 9, 2024
d652a3a
chore: This should be lower case
joshsadam Jan 9, 2024
6071275
chore: Fix the sample name column when horizontal scrolling
joshsadam Jan 9, 2024
4245949
chore: Fixed bad merge
joshsadam Jan 12, 2024
805ff5d
chore: Fixed broken tests after moving checkbox
joshsadam Jan 12, 2024
d322861
chore: Work on updating seeds
joshsadam Jan 15, 2024
88414db
chore: Updated to use more accurate fake data
joshsadam Jan 16, 2024
538bf67
chore: Made first column darker since it is fixed when scrolling
joshsadam Jan 16, 2024
9b371b4
chore: Fixed line length of commmented out extra fields
joshsadam Jan 16, 2024
1072c4b
chore: Cleaned up dark mode first column colours
joshsadam Jan 16, 2024
f664e58
chore: Removed commented out lines of possible fields
joshsadam Jan 16, 2024
d77ed07
chore: Display only all or none for metadata field templates
joshsadam Jan 17, 2024
5d00731
chore: Fixed group samples table spacing issues
joshsadam Jan 19, 2024
e7db78b
chore: Fixed rebase errors
joshsadam Jan 22, 2024
a90e613
chore: Moved common methods to Projects::ApplicationController
joshsadam Jan 22, 2024
2e2d917
chore: Fixed table header when horizontally scrolling
joshsadam Jan 23, 2024
e0ea011
chore: Moved template logic into a concern
joshsadam Jan 23, 2024
d666b66
chore: Removed templates dropdown and added toggle for fields
joshsadam Jan 23, 2024
a4e22d1
chore: Created component for metadata fields toggle
joshsadam Jan 23, 2024
6479e85
chore: Removed from turbo response as does not need to be there
joshsadam Jan 23, 2024
2c01886
chore: Updating groups samples page to use metadata fields
joshsadam Jan 24, 2024
ec915ee
chore: Working on group samples
joshsadam Jan 24, 2024
3dc3d95
chore: Fixed mutliple request issue.
joshsadam Jan 24, 2024
3eef25f
chore: Fixed rubocop errors
joshsadam Jan 24, 2024
59eadb4
chore: Fixed linting issue
joshsadam Jan 24, 2024
8b08edf
chore: Fixed response when deleting sample
joshsadam Jan 24, 2024
20df0c7
chore: Fixed transfer table reload
joshsadam Jan 25, 2024
e4ade61
chore: Fixed project sample UI testing
joshsadam Jan 25, 2024
4301497
chore: Added testing for metadata fields on project samples
joshsadam Jan 25, 2024
f04bf0b
chore: Fixed layout for toggle on group samples
joshsadam Jan 25, 2024
aff596e
chore: Cleaned up layouts
joshsadam Jan 25, 2024
1b2f592
chore: Testing for group samples
joshsadam Jan 25, 2024
50aa4ee
chore: Fixed testing issue
joshsadam Jan 25, 2024
f5ad7a7
chore: Removed unused file
joshsadam Jan 25, 2024
d8e930d
chore: Removed unnecessarily include
joshsadam Jan 25, 2024
cafa8b4
chore: Renamed turbo frame tag
joshsadam Jan 25, 2024
569bddd
chore: Fixed z-index for table header not to interfere with popover
joshsadam Jan 26, 2024
2e86100
chore: Removed unnecessary metadata param from hidden fields
joshsadam Jan 26, 2024
2b505ec
chore: Removed redundant logic
joshsadam Jan 26, 2024
70e64dd
chore: Cleaned up variable names for Metadata
joshsadam Jan 26, 2024
68b4107
chore: Fixed lookbook preview for time_ago
joshsadam Jan 26, 2024
a420bdb
chore: Ignore class length warning
joshsadam Jan 26, 2024
b7d07e9
chore: Fixed broken test for time ago
joshsadam Jan 26, 2024
3414ef3
chore: Fixed z-index
joshsadam Jan 26, 2024
0937d9b
chore: Moved created and updated on groups table
joshsadam Jan 26, 2024
0b0986d
chore: Fixed text
joshsadam Jan 26, 2024
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
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem 'web-console'

gem 'faker'

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ GEM
erubi (1.12.0)
et-orbi (1.2.7)
tzinfo
faker (3.2.2)
i18n (>= 1.8.11, < 2)
faraday (2.0.0)
ruby2_keywords (>= 0.0.4)
faraday-follow_redirects (0.3.0)
Expand Down Expand Up @@ -557,6 +559,7 @@ DEPENDENCIES
debug
devise (~> 4.9.2)
erb-formatter (~> 0.4.3)
faker
faraday
faraday-net_http_persistent (~> 2.0)
fx
Expand Down
2 changes: 1 addition & 1 deletion app/components/viral/time_ago_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%= viral_tooltip(title: l(original_time, format: :long)) do %>
<span class='text-sm text-gray-900 dark:text-white'><%= time_ago %></span>
<%= time_ago %>
ericenns marked this conversation as resolved.
Show resolved Hide resolved
<% end %>
14 changes: 14 additions & 0 deletions app/controllers/concerns/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# Executes basic metadata logic for controllers
module Metadata
extend ActiveSupport::Concern

included do
helper_method :fields_for_namespace
end

def fields_for_namespace(namespace: nil, show_fields: false)
@fields = !show_fields || namespace.nil? ? [] : namespace.metadata_summary.keys
end
end
6 changes: 3 additions & 3 deletions app/controllers/groups/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ module Groups
# Controller actions for Samples within a Group
class SamplesController < ApplicationController
layout 'groups'
include Metadata
before_action :group, :current_page, only: %i[index]

def index
def index # rubocop:disable Metrics/AbcSize
authorize! @group, to: :sample_listing?

@q = authorized_samples.ransack(params[:q])

set_default_sort

respond_to do |format|
format.html do
@has_samples = @q.result.count.positive?
end
format.turbo_stream do
@pagy, @samples = pagy(@q.result)
fields_for_namespace(namespace: @group, show_fields: params[:q] && params[:q][:metadata].to_i == 1)
end
end
end
Expand Down
14 changes: 12 additions & 2 deletions app/controllers/projects/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

module Projects
# Controller actions for Samples
class SamplesController < Projects::ApplicationController
class SamplesController < Projects::ApplicationController # rubocop:disable Metrics/ClassLength
include Metadata

before_action :sample, only: %i[show edit update destroy]
before_action :current_page

def index
def index # rubocop:disable Metrics/AbcSize
authorize! @project, to: :sample_listing?

@q = load_samples.ransack(params[:q])
Expand All @@ -17,6 +19,10 @@ def index
end
format.turbo_stream do
@pagy, @samples = pagy(@q.result)
fields_for_namespace(
namespace: @project.namespace,
show_fields: params[:q] && params[:q][:metadata].to_i == 1
)
end
end
end
Expand Down Expand Up @@ -75,6 +81,10 @@ def destroy # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
redirect_to namespace_project_samples_path(format: :html)
end
format.turbo_stream do
fields_for_namespace(
namespace: @project.namespace,
show_fields: params[:q] && params[:q][:metadata].to_i == 1
)
render status: :ok, locals: { type: 'success',
message: t('.success', sample_name: @sample.name,
project_name: @project.namespace.human_name) }
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
<%= viral_icon(name: "magnifying_glass", classes: "h-5 w-5") %>
</div>
<%= turbo_frame_tag "project_hidden_search_value" %>
<%= turbo_frame_tag "project_hidden_values" %>
<%= f.search_field :namespace_name_cont,
"data-action": "filters#submit",
class:
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/projects/index.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
) %>
<% end %>

<%= turbo_stream.update "project_hidden_search_value" do %>
<%= turbo_stream.update "project_hidden_values" do %>
<%= render Ransack::HiddenSortFieldComponent.new(@q) %>
<% end %>
124 changes: 86 additions & 38 deletions app/views/groups/samples/_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,78 +1,126 @@
<table class="min-w-full table-fixed dark:divide-slate-600">
<thead class="text-slate-700 bg-slate-50 dark:bg-slate-700 dark:text-slate-400">
<div class="relative overflow-x-auto" data-turbo-temporary>
<table
class="
w-full
text-sm
text-left
rtl:text-right
text-slate-500
dark:text-slate-400
"
>
<thead
class="
text-xs
text-slate-700
uppercase
bg-slate-50
dark:bg-slate-700
dark:text-slate-400
"
>
<tr>
<th scope="col" class="px-4 py-3 text-left">
<th
scope="col"
class="
px-6
py-3
whitespace-nowrap
text-left
bg-slate-50
dark:bg-slate-700
sticky
left-0
z-10
"
>
<%= render Ransack::SortComponent.new(
ransack_obj: @q,
label: t(".sample"),
url: sorting_url(@q, :name),
field: :name
) %>
</th>
<th scope="col" class="px-4 py-3 text-left cursor-not-allowed">
<th
scope="col"
class="px-6 py-3 whitespace-nowrap text-left cursor-not-allowed"
>
<%= t(".project") %>
</th>
<th scope="col" class="px-4 py-3 text-left">
<th scope="col" class="px-6 py-3 whitespace-nowrap text-left">
<%= render Ransack::SortComponent.new(
ransack_obj: @q,
label: t(".created_at"),
url: sorting_url(@q, :created_at),
field: :created_at
) %>
</th>
<th scope="col" class="px-4 py-3 text-left">
<th scope="col" class="px-6 py-3 whitespace-nowrap text-left">
<%= render Ransack::SortComponent.new(
ransack_obj: @q,
label: t(".updated_at"),
url: sorting_url(@q, :updated_at),
field: :updated_at
) %>
</th>
<% @fields.each do |column| %>
<th
scope="col"
class="px-6 py-3 text-left whitespace-nowrap cursor-not-allowed"
><%= column %></th>
<% end %>
</tr>
</thead>
<tbody
id="group-samples-table-body"
class="
bg-white
divide-y
divide-slate-200
dark:bg-slate-800
dark:divide-slate-700
"
>
</thead>
<tbody
id="group-samples-table-body"
class="
bg-white
divide-y
divide-slate-200
dark:bg-slate-800
dark:divide-slate-700
"
>
<% samples.each do |sample| %>
<tr
id="<%= dom_id(sample) %>"
class="text-sm font-normal text-slate-500 dark:text-slate-400"
class="bg-white border-b dark:bg-slate-800 dark:border-slate-700"
>
<td class="px-4 py-3 whitespace-nowrap"><%= link_to sample.name,
namespace_project_sample_path(
id: sample.id,
namespace_id: sample.project.namespace.parent.full_path,
project_id: sample.project.path
),
data: {
turbo: false
},
class: "text-grey-900 dark:text-grey-100 font-semibold hover:underline" %>
<td class="px-6 py-3 whitespace-nowrap left-0 sticky bg-white dark:bg-slate-800">
<%= link_to sample.name,
namespace_project_sample_path(
id: sample.id,
namespace_id: sample.project.namespace.parent.full_path,
project_id: sample.project.path
),
data: {
turbo: false
},
class: "text-slate-900 dark:text-slate-100 font-semibold hover:underline" %>
</td>
<td class="px-4 py-3 whitespace-nowrap">
<td class="px-6 py-3 whitespace-nowrap">
<%= viral_tooltip(title: project_path(sample.project)) do %>
<%= link_to sample.project.abbreviated_path,
project_path(sample.project),
data: {
turbo: false
},
class: "text-grey-900 dark:text-grey-100 font-semibold hover:underline" %>
project_path(sample.project),
data: {
turbo: false
},
class: "text-slate-900 dark:text-slate-100 font-semibold hover:underline" %>
<% end %>
</td>
<td class="px-4 py-3 whitespace-nowrap">
<td class="px-6 py-3 whitespace-nowrap">
<%= l(sample.created_at.localtime, format: :full_date) %>
</td>
<td class="px-4 py-3 whitespace-nowrap">
<td class="px-6 py-3 whitespace-nowrap">
<%= viral_time_ago(original_time: sample.updated_at) %>
</td>
<% @fields.each do |column| %>
<td class="px-6 py-3 whitespace-nowrap">
<%= sample.metadata[column] %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</tbody>
</table>
</div>
Loading
Loading