Tim님, 안녕하세요.
대안안을 첨부합니다. 여기 포함된 내용은 컴포넌트의 초기화(initializer) JS 파일에 들어가야 한다는 점에 유의해 주세요. 전체 컴포넌트 구조의 간단한 예시는 여기에서 확인하실 수 있습니다.
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 =
'Your account is currently restricted and you no longer have access to valuable resources. <a href="https://meta.discourse.org">Click here</a> for more information.';
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,
});
});
}
});
},
};
도움이 되셨으면 좋겠습니다.