From aaeee5152c5c03b1f17647ce6c92767411318cef Mon Sep 17 00:00:00 2001 From: Gianni Guida Date: Mon, 19 Feb 2024 00:43:41 +0100 Subject: [PATCH] feat: add link to polls page in session dropdown --- js/src/forum/addRouteToSessionDropdown.js | 22 ++++++++++++++++++++++ js/src/forum/index.ts | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 js/src/forum/addRouteToSessionDropdown.js diff --git a/js/src/forum/addRouteToSessionDropdown.js b/js/src/forum/addRouteToSessionDropdown.js new file mode 100644 index 00000000..08b91861 --- /dev/null +++ b/js/src/forum/addRouteToSessionDropdown.js @@ -0,0 +1,22 @@ +import app from 'flarum/forum/app'; +import { extend } from 'flarum/common/extend'; +import Acl from '../common/Acl'; +import SessionDropdown from 'flarum/forum/components/SessionDropdown'; +import LinkButton from 'flarum/common/components/LinkButton'; + +export default () => { + extend(SessionDropdown.prototype, 'items', (items) => { + if (Acl.canStartPoll() && m.route.get()) { + items.add( + 'fof-polls-directory', + + {app.translator.trans('fof-polls.forum.page.nav')} + , + 10, + ); + } + }); +}; \ No newline at end of file diff --git a/js/src/forum/index.ts b/js/src/forum/index.ts index 2c746bbc..2ab74687 100755 --- a/js/src/forum/index.ts +++ b/js/src/forum/index.ts @@ -5,6 +5,7 @@ import addComposerItems from './addComposerItems'; import addPollsToPost from './addPollsToPost'; import addPostControls from './addPostControls'; import addNavItem from './addNavItem'; +import addRouteToSessionDropdown from './addRouteToSessionDropdown'; export * from './components'; export * from './models'; @@ -17,6 +18,7 @@ app.initializers.add('fof/polls', () => { addPollsToPost(); addPostControls(); addNavItem(); + addRouteToSessionDropdown(); }); export { default as extend } from './extend';