I have developed a theme component specifically for our moderators. This component adds a modal that reminds moderators to consider suspending a user after handling a flag. I placed this component at javascripts/discourse/admin/components/modal/remove-post.gjs
, and at the top, it imports AdminUser with import AdminUser from "admin/models/admin-user";
.
For moderators, everything works perfectly. However, regular users are experiencing issues. Discourse still tries to load this component for all users, and since regular users don’t load any admin/**
modules, it results in the following error:
Error: Could not find module `admin/models/admin-user`
Ideally, I would like this subcomponent (or even just this import) to only load for moderators and admins. Is there an officially supported way to ensure a Glimmer component within a theme component is loaded only for staff (moderators/admins) in Discourse, so that regular users never encounter missing module errors for admin-specific imports?