Skip to content

Commit

Permalink
feat: add link to polls page in session dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
gianniguida committed Feb 18, 2024
1 parent c4c9705 commit aaeee51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions js/src/forum/addRouteToSessionDropdown.js
Original file line number Diff line number Diff line change
@@ -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',
<LinkButton
href={app.route('fof_polls_list')}
icon='fas fa-poll'
active={m.route.get().indexOf('/polls') === 0}>
{app.translator.trans('fof-polls.forum.page.nav')}
</LinkButton>,
10,
);
}
});
};
2 changes: 2 additions & 0 deletions js/src/forum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -17,6 +18,7 @@ app.initializers.add('fof/polls', () => {
addPollsToPost();
addPostControls();
addNavItem();
addRouteToSessionDropdown();
});

export { default as extend } from './extend';

0 comments on commit aaeee51

Please sign in to comment.