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

add ability to filter plugin routes in routes tab #851

Merged
merged 11 commits into from
Dec 13, 2021

Conversation

LordSimal
Copy link
Contributor

2021-12-11_17-20-51 (1)

This PR refactors the routes tab in that sense that you are now able to filter routes per plugin.

Also you can see how many routes are loaded for that specific plugin next to the filter button.

Activating the button will hide the routes for that selected plugin.

The DebugKit routes are hidden by default as they have been before as well.

Fixes #850

@LordSimal
Copy link
Contributor Author

Stickler-CI doesn't like my way of adding styling to the is-active filter buttons 😠

LordSimal and others added 2 commits December 11, 2021 18:16
Co-authored-by: Edgaras Janušauskas <edgaras.janusauskas@gmail.com>
foreach (CorePlugin::loaded() as $pluginName) {
if (!empty($amountOfRoutesPerGroup[$pluginName])) {
$name = sprintf('%s (%s)', $pluginName, $amountOfRoutesPerGroup[$pluginName]);
$pluginNames[$name] = preg_replace('/\W+/', '', strtolower($pluginName));
Copy link
Member

Choose a reason for hiding this comment

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

This could be a call to Inflector I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not able to find a suitable function in the Inflector Utility Class to handle a plugin name like ADmad/Sequence

  • Inflector::variable('ADmad/Sequence'); results in aDmad/sequence which is not a valid CSS class
  • Inflector::dasherize('ADmad/Sequence'); results in a-dmad/sequence which is also not a valid CSS class

Thats why I used this rather simple regex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would love to have a static cakephp function to just put any string into it and it returns me a valid CSS class.
Currently I have used a custom Helper in my app for that since it is mainly used in the template.

Copy link
Member

Choose a reason for hiding this comment

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

Did you try Text::slug()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this looks good, will push that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be fair I would have never thought that a Text::slug() method could be used to convert a string to a valid CSS class.

$class = 'route-entry route-entry--app';
else :
$class = 'route-entry route-entry--plugin route-entry--plugin-' .
preg_replace('/\W+/', '', strtolower($route->defaults['plugin']));
Copy link
Member

Choose a reason for hiding this comment

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

This could be Inflector based as well.

.btn-primary:hover {
cursor:pointer;
}
.toggle-plugin-route-active {
background-color: #fff;
color: #2a6496;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I love these colours in this context but I can fiddle with it afterwards.

@markstory markstory merged commit 0676773 into cakephp:4.x Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Group plugin-routes into tab-sections in routes panel
6 participants