Skip to content

Commit

Permalink
DEV: Switch to new addComposerToolbarPopupMenuOption plugin API (#59)
Browse files Browse the repository at this point in the history
Why this change?

`api.addToolbarPopupMenuOptionsCallback` has been deprecated in discourse/discourse@913fd3a
  • Loading branch information
tgxworld authored Oct 22, 2023
1 parent 6f5f00f commit f3f0ccd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
< 3.2.0.beta2: 6f5f00f7ee610da254b356ad11e9f3665235dcd6
3.1.999: d5ff8a7832ace8355e60a427e2269e81575a4707
2.7.0.beta3: 81120be3a7602834a18e93ddbd1a69bbf7ebb608
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,20 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import showModal from "discourse/lib/show-modal";

function initializeWebinarButton(api) {
api.modifyClass("controller:composer", {
pluginId: "discourse-zoom",
const composerService = api.container.lookup("service:composer");

actions: {
showWebinarModal() {
showModal("webinar-picker", {
model: this.model,
title: "zoom.webinar_picker.title",
});
},
api.addComposerToolbarPopupMenuOption({
condition: (composer) => {
return composer.model && composer.model.creatingTopic;
},
icon: "video",
label: "zoom.webinar_picker.button",
action: () => {
showModal("webinar-picker", {
model: composerService.model,
title: "zoom.webinar_picker.title",
});
},
});

api.addToolbarPopupMenuOptionsCallback((controller) => {
const composer = controller.model;
if (composer && composer.creatingTopic) {
return {
id: "associate_webinar_button",
icon: "video",
action: "showWebinarModal",
label: "zoom.webinar_picker.button",
};
}
});
}

Expand All @@ -35,7 +26,7 @@ export default {
const siteSettings = container.lookup("site-settings:main");
const currentUser = container.lookup("current-user:main");
if (siteSettings.zoom_enabled && currentUser) {
withPluginApi("0.5", initializeWebinarButton);
withPluginApi("1.15.0", initializeWebinarButton);
}
},
};

0 comments on commit f3f0ccd

Please sign in to comment.