Skip to content

Commit

Permalink
add nav item
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Jan 29, 2024
1 parent d4032dc commit adf5393
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/src/forum/addNavItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import IndexPage from 'flarum/forum/components/IndexPage';
import LinkButton from 'flarum/common/components/LinkButton';

export default function addNavItem() {
extend(IndexPage.prototype, 'navItems', (items) => {
items.add(
'fof-polls-directory',
LinkButton.component(
{
href: app.route('fof_polls_directory'),
icon: 'fas fa-poll',
},
app.translator.trans('fof-polls.forum.page.nav')
),
35
);
});
}
2 changes: 2 additions & 0 deletions js/src/forum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import addDiscussionBadge from './addDiscussionBadge';
import addComposerItems from './addComposerItems';
import addPollsToPost from './addPollsToPost';
import addPostControls from './addPostControls';
import addNavItem from './addNavItem';

export * from './components';
export * from './models';
Expand All @@ -13,6 +14,7 @@ app.initializers.add('fof/polls', () => {
addComposerItems();
addPollsToPost();
addPostControls();
addNavItem();
});

export { default as extend } from './extend';
3 changes: 3 additions & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ fof-polls:
delete_confirm: Are you sure you want to delete this poll?
edit: Edit Poll

page:
nav: Polls

tooltip:
badge: Poll
votes: "{count, plural, one {# vote} other {# votes}}"
Expand Down

0 comments on commit adf5393

Please sign in to comment.