Additional template partials and helpers extraction#8205
Merged
Conversation
These are common enough for helper methods. We'll also be adding some to a new partial so this will clean things up a bit. Although these are public methods that users can use as documented so its not really hiding anything, more for convenience.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8205 +/- ##
==========================================
- Coverage 99.12% 99.10% -0.02%
==========================================
Files 144 140 -4
Lines 4104 4013 -91
==========================================
- Hits 4068 3977 -91
Misses 36 36 ☔ View full report in Codecov by Sentry. |
This way users can customize this e.g. icons instead of text. These now use new helper methods to keep this clean. This also removes the title attribute since its advised not to include it if its the same text as the link label since its verbose/redundant (screen readers). Insert TableActions without builder_method since builder_method is just a shorthand around insert_tag, we can use that instead which is best otherwise we expose `table_actions` globally meaning any user can call it in their code but shouldn't be able too. It also takes up a name in Arbre. We noticed this with the original header/footer components for the site, where it would clash when trying to use header/footer HTML elements through Arbre.
By scanning the plugin.js file, we won't need to scan the `/lib/active_admin/*` path since our component classes are already listed in the plugin as Tailwind finds each correctly and adds to CSS. If it becomes an issue, we can add the original path back. For the host app, add specific paths for active_admin and admin (default namespace) rather than scan entire app/views directory. Remove scanning CSS files as Tailwind content configuration docs state to never do this. > It’s also important that you don’t scan any CSS files — configure Tailwind to scan your templates where your class names are being used, never the CSS file that Tailwind is generating. https://tailwindcss.com/docs/content-configuration#pattern-recommendations
Should help on the app host side since "activeAdmin" in the name to indicate that its scanning the files in the gem. Since there are complimentary ActiveAdmin gems, for sure those will update and need to be included in this file in the host app so they can follow a convention/pattern.
We'll update the docs separately from this changeset.
We'll be adding new helper methods that are used on the index view like scope_name is (scopes and active filters components).
With this, we remove the only use of the private DropdownMenu component which can now be removed.
With dropdown_menu removed, rename this class so its specific to batch actions.
This shows some of that bad DSLs we have since we only tested this using link_to but it doesn't work with multiple links here, you have to use the item method the actions method (table_actions component) provides.
840716e to
4a664ef
Compare
Some uses already rely on the `collection` helper method (InheritedResources::Base) as a default argument but others through a provided argument which happens to be the same name (!). We only use these 2 methods in views so we can define as a plain Rails helper. Since we have a feature spec using the paginated_collection in a page, we have to include the helper in our base controller so it's available to both resources and pages.
This will allow us to update this further with autoloading. This also moves the scopes to the model class to keep together. No need for accessors so changed to attribute readers.
These components are not meant to be used by users directly, only internally but by declaring a builder_method we take up that name in a global space that would compete with what users want to create. We had that originally with columns/column and header/footer components #8135 we will create these internal only components using insert_tag and provide the class leaving builder methods open to users and third party libraries.
4f38355 to
831a3f9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds helper methods for common actions, e.g. is a given action authorized for a resource and extracts collection helpers as well. The index_helper is now included in the base controller so its available to pages and resources.
This extracts the index table default actions to a partial so they can be customized. Also extracts the batch actions dropdown to a partial so with that the dropdown menu component can be removed which was only used internally. The objective is to simplify with partials, regardless if they will be public for customization or not, as it makes it easier on the library side to maintain and update in development. Any components that users interact with via a builder method (DSL) will remain as components.
This also reduces the builder methods to the bare minimum so users can declare their own components and use their preferred builder method without worrying about clashes. The same goes for potential third party component libraries.
This also does some final CSS changes before release, renaming any classes to use dashes.