mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-08 23:32:45 +00:00
**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
35 lines
1.2 KiB
JavaScript
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"];
|
|
}
|
|
);
|
|
});
|
|
},
|
|
};
|