Keegan George 8863cf0c86
DEV: Updates to sentiment analysis reports (#1161)
**This PR includes a variety of updates to the Sentiment Analysis report:**
- [X] Conditionally showing sentiment reports based on `sentiment_enabled` setting
- [X] Sentiment reports should only be visible in sidebar if data is in the reports
- [X] Fix infinite loading of posts in drill down
- [x] Fix markdown emojis showing not showing as emoji representation
- [x] Drill down of posts should have URL
- [x] ~~Different doughnut sizing based on post count~~ [reverting and will address in follow-up (see: `/t/146786/47`)]
- [X] Hide non-functional export button 
- [X] Sticky drill down filter nav
2025-03-05 13:53:56 -08:00

35 lines
1.2 KiB
JavaScript

import { withPluginApi } from "discourse/lib/plugin-api";
import AdminReportEmotion from "discourse/plugins/discourse-ai/discourse/components/admin-report-emotion";
export default {
name: "discourse-ai-admin-reports",
initialize(container) {
const currentUser = container.lookup("service:current-user");
if (!currentUser || !currentUser.admin) {
return;
}
// We need to import dynamically with CommonJS require because
// using ESM import in an initializer would cause the component to be imported globally
// and cause errors for non-admin users since the component is only available to admins
const AdminReportSentimentAnalysis =
require("discourse/plugins/discourse-ai/discourse/components/admin-report-sentiment-analysis").default;
withPluginApi((api) => {
api.registerReportModeComponent("emotion", AdminReportEmotion);
api.registerReportModeComponent(
"sentiment_analysis",
AdminReportSentimentAnalysis
);
api.registerValueTransformer(
"admin-reports-show-query-params",
({ value }) => {
return [...value, "selectedChart"];
}
);
});
},
};