Ciao Tim,
Ecco l’alternativa, nota che i contenuti qui devono andare in un file JS inizializzatore in un componente. Puoi vedere un semplice esempio di una struttura di componente completa qui.
import { withPluginApi } from "discourse/lib/plugin-api";
import { getOwner } from "discourse-common/lib/get-owner";
import { schedule } from "@ember/runloop";
import { htmlSafe } from "@ember/template";
export default {
name: "tester-initializer",
initialize() {
withPluginApi("0.8", (api) => {
const currentUser = api.getCurrentUser();
if (currentUser) {
const userGroups = currentUser.groups.map((group) => group.name);
let showPopup = false;
switch (true) {
case userGroups.includes("admins"):
showPopup = true;
break;
}
if (!showPopup) {
return;
}
const alertHeading = "Oh no!";
const alertBody =
'Il tuo account è attualmente limitato e non hai più accesso a risorse preziose. \u003ca href="https://meta.discourse.org"\u003eClicca qui\u003c/a\u003e per maggiori informazioni.';
schedule("afterRender", () => {
// delay needed so that the dialog service is loaded
const dialog = getOwner(this).lookup("service:dialog");
dialog.alert({
message: htmlSafe(alertBody),
title: alertHeading,
});
});
}
});
},
};
Spero che questo aiuti.