-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
WIP: chore: Migrate AdminIndexComponent to use ViewComponent #2666
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class AdminIndexComponent < ViewComponent::Base | ||
def initialize(additional_links:, default: []) | ||
super | ||
@additional_links = additional_links | ||
@default = default | ||
end | ||
|
||
def model_name | ||
properties[:model].to_s.chop.humanize | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ugh also surely theres a way to do this referring directly to the type itself and not with this method chain 😓 embarrased for old me lol |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<%# TODO: Only show Edit link for root users %> | ||
|
||
<%= render_component "admin_index", | ||
<%= render_component AdminIndexComponent.new( | ||
title: "Collections", | ||
model: :collections, | ||
column_titles: ['ID', 'Name', 'Description'], | ||
columns: %i[id name description], | ||
data: @collections, | ||
new_link: new_admin_collection_path | ||
) | ||
%> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<%= render_component "admin_index", | ||
<%= render_component AdminIndexComponent.new( | ||
title: "Supporters", | ||
model: :supporters, | ||
column_titles: ['ID', 'Name', 'Logo', 'Global?'], | ||
columns: %i[id name logo is_global], | ||
data: @supporters, | ||
new_link: new_admin_supporter_path | ||
) | ||
%> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class AdminIndexComponentTest < ViewComponent::TestCase | ||
def test_component_renders_something_useful | ||
# assert_equal( | ||
# %(<span>Hello, components!</span>), | ||
# render_inline(AdminIndexComponent.new(message: "Hello, components!")).css("span").to_html | ||
# ) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in answer to your q i think all you need to do is pass in all the params here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OH sorry i read your comment again
this is making additional_links mandatory i think? i am a bit rusty but i think
additional_links: [], default: []
should fix it? think you jsut need a default value. from a search it doesn't look like this is actually in use anywhere so it might be cuttable along with the comments referring to it? i think we can purge it!