Skip to content

DEV: Change admin site settings filter to be route based #33167

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 7 commits into from
Jun 16, 2025

Conversation

Drenmi
Copy link
Contributor

@Drenmi Drenmi commented Jun 12, 2025

What is this change?

The filtering is currently being done in the controller. This leads to weird things where the filter loop might already be initiated and we get double filtering, as well as the issue that we can't abort like we could with a route transition.

How does it work?

  • Cache the site settings fetched from the server in the route instance.
  • Hook up the controller to the query params.
  • Use the query params to filter the model in the route.

@Drenmi Drenmi force-pushed the dev/admin-site-settings-routing branch 3 times, most recently from 21b7efa to c1eb0dd Compare June 12, 2025 03:57
@Drenmi Drenmi force-pushed the dev/admin-site-settings-routing branch 7 times, most recently from f241e92 to 93cd89c Compare June 12, 2025 05:35
@Drenmi Drenmi force-pushed the dev/admin-site-settings-routing branch from 93cd89c to 193dd0e Compare June 12, 2025 05:36
siteSettings: categories[n],
};
});
static async findAll(params = {}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only change here is to add async/await. Unfortunately that touches all lines.

Comment on lines -12 to -16
this.router.replaceWith(
"adminSiteSettingsCategory",
this.controllerFor("adminSiteSettings").get("visibleSiteSettings")[0]
.nameKey
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to be so fancy here. This just evaluates to "required".

if (!controller.get("visibleSiteSettings")) {
controller.set("visibleSiteSettings", siteSettings);
async model(params) {
if (!this._siteSettings) {
Copy link
Contributor Author

@Drenmi Drenmi Jun 13, 2025

Choose a reason for hiding this comment

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

We could consider clearing this when exiting the site settings area so it has to be refetched, but I'm not sure if that'd serve any use TBH.

@Drenmi Drenmi requested a review from jjaffeux June 13, 2025 03:57
@Drenmi Drenmi marked this pull request as ready for review June 13, 2025 03:57
@lis2
Copy link
Contributor

lis2 commented Jun 13, 2025

Looks good to me. I also played with that on my local and didn't notice any regression 🎊

filteredContent(category) {
return category ? category.siteSettings : [];
}
@alias("model") filteredSiteSettings;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need alias each time? (this one and the ones in app/assets/javascripts/admin/addon/controllers/admin-site-settings.js). I don't like alias it makes things super hard to debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it the decorator that interferes with debugging? I.e. would manually defining a getter be okay?

Copy link
Contributor

@jjaffeux jjaffeux left a comment

Choose a reason for hiding this comment

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

Only few comments, which are not directly related to your change for most of them, would be nice to get to it, but I can already approve it. Thanks!

@Drenmi Drenmi merged commit b3894e8 into main Jun 16, 2025
16 checks passed
@Drenmi Drenmi deleted the dev/admin-site-settings-routing branch June 16, 2025 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants