Skip to content

FEATURE: Add reusable AdminFilterControls component, apply to plugins and reports #33706

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

Merged
merged 2 commits into from
Jul 24, 2025

Conversation

awesomerobot
Copy link
Member

This creates a reusable filter component for admin areas that includes a text filter and dropdown.

The component accepts an array to filter, an array of searchable property names, and optional dropdown values. An additional option is available if you'd like the default dropdown value to be something other than "all."

It looks like this:

image

The dropdown is optional, without it:

image

When there are no matching filters, it provides a reset button:

image

I'll use this to replace occurrences of similar filters, we've added a couple to the AI plugin.

@github-actions github-actions bot added the i18n PRs which update English locale files or i18n related code label Jul 18, 2025
Copy link
Contributor

@pmusaraj pmusaraj left a comment

Choose a reason for hiding this comment

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

Looks very nice and the code is very easy to read!

File.join(Rails.root, "plugins", "spoiler-alert", "plugin.rb"),
)

Discourse.stubs(:plugins_sorted_by_name).returns([poll_plugin, spoiler_alert_plugin])
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, interesting. Without stubbing, the system spec would have zero plugins?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, that's the problem I was running into... so I did something similar to what I saw elsewhere:

Discourse.stubs(:plugins_by_name).returns({ "discourse-ai" => true })

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, yeah, I see. I guess we run system specs with essentially LOAD_PLUGINS=0 in core. I understand why we initially did that, but it's an environment that doesn't match production, we never run prod without plugins, especially now that plenty of plugins moved to core.

Anyway, worth a separate discussion.

@awesomerobot awesomerobot merged commit c544d7a into main Jul 24, 2025
16 checks passed
@awesomerobot awesomerobot deleted the feature-admin-filter-controls branch July 24, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n PRs which update English locale files or i18n related code
Development

Successfully merging this pull request may close these issues.

2 participants