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

[56339] Split content of Admin/Design page into separate tabs #16255

Merged

Conversation

bsatarnejad
Copy link
Contributor

@bsatarnejad bsatarnejad force-pushed the 56339-split-content-of-admin-design-page-into-separate-tabs branch from 20f492f to 57ba340 Compare August 6, 2024 13:11
@HDinger HDinger marked this pull request as draft August 7, 2024 06:36
@bsatarnejad bsatarnejad self-assigned this Sep 10, 2024
@bsatarnejad bsatarnejad marked this pull request as ready for review September 10, 2024 06:16
Copy link
Contributor

@HDinger HDinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works as expected. I have however some remark with regards to the code structure. You are currently mixing and repeating things a bit.
When you look at the code structure of other admin pages, we usually have one file per base route (show, new, index, etc). Addtional stuff is extracted in partials. That also requires separate controllers for each module.

You have a show page, and a branding and pdf_export_styles page while all three of them are routed with the same controller. The controller actions are however exact duplicates. So there is no really benefit of doing it like that. This approach also has another drawback: In each file, you have to repeat the call of the header with a magic number passed through:

<%=
  render(Admin::DesignHeaderComponent.new(
    title: t(:"admin.custom_styles.tab_branding"),
    selected: 2,
    ))
%>

As soon as we add another tab in between, the selection will not work any more and has to be changes not only in the view files but also in the header component as well.

I am aware that you basically copied that header approach from attachments, but I think it is a bad pattern. Further, attachements has extracted stuff in individual controllers since the logic is very different.

Tl;dr; Instead of extracting all in individual files and repeating stuff, please use partials. You then only have to call the header once in the show file and can probably even put the repeated theme selector in there. The partials would then only contain the actual differences.

spec/controllers/custom_styles_controller_spec.rb Outdated Show resolved Hide resolved
app/controllers/custom_styles_controller.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@EinLama EinLama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice and does what it should, nicely done! 👍🏻

I've found one issue with the localization. It uses British English in one spot where it should be US English. Another issue regards the naming of a spec and the redirect-verification within the specs.

The other comments and suggestions are mostly code style related nitpicks and nothing functional. Please consider them and add the ones that you agree with.

app/components/admin/design_header_component.html.erb Outdated Show resolved Hide resolved
app/components/admin/design_header_component.rb Outdated Show resolved Hide resolved
app/controllers/custom_styles_controller.rb Show resolved Hide resolved
app/controllers/custom_styles_controller.rb Show resolved Hide resolved
app/controllers/custom_styles_controller.rb Show resolved Hide resolved
app/views/custom_styles/show.html.erb Outdated Show resolved Hide resolved
config/locales/en.yml Outdated Show resolved Hide resolved
config/locales/en.yml Outdated Show resolved Hide resolved
spec/controllers/custom_styles_controller_spec.rb Outdated Show resolved Hide resolved
spec/features/custom_styles/tabs_spec.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@EinLama EinLama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉 great work!

@EinLama EinLama merged commit b1b10d6 into dev Sep 20, 2024
14 checks passed
@EinLama EinLama deleted the 56339-split-content-of-admin-design-page-into-separate-tabs branch September 20, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants