diff --git a/app/assets/javascripts/discourse/controllers/static.js.es6 b/app/assets/javascripts/discourse/controllers/static.js.es6 index c656b99df..5b87c64c7 100644 --- a/app/assets/javascripts/discourse/controllers/static.js.es6 +++ b/app/assets/javascripts/discourse/controllers/static.js.es6 @@ -2,7 +2,6 @@ import { ajax } from 'discourse/lib/ajax'; import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ - needs: ['application'], showLoginButton: Em.computed.equal("model.path", "login"), diff --git a/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 b/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 index 9201b70bd..099e51d8e 100644 --- a/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6 @@ -1,17 +1,33 @@ import { createWidget, applyDecorators } from 'discourse/widgets/widget'; import { h } from 'virtual-dom'; +import DiscourseURL from 'discourse/lib/url'; +import { ajax } from 'discourse/lib/ajax'; + +createWidget('priority-faq-link', { + tagName: 'a.faq-priority', + + buildAttributes(attrs) { + return { href: attrs.href }; + }, + + html() { + return [ I18n.t('faq'), ' ', h('span.badge.badge-notification', I18n.t('new_item')) ]; + }, + + click(e) { + if (this.siteSettings.faq_url === this.attrs.href) { + e.preventDefault(); + ajax("/users/read-faq", { method: "POST" }).then(() => { + this.currentUser.set('read_faq', true); + return DiscourseURL.routeToTag($(e.target).closest('a')[0]); + }); + } + } +}); export default createWidget('hamburger-menu', { tagName: 'div.hamburger-panel', - faqLink(href) { - return h('a.faq-priority', { attributes: { href } }, [ - I18n.t('faq'), - ' ', - h('span.badge.badge-notification', I18n.t('new_item')) - ]); - }, - adminLinks() { const { currentUser } = this; @@ -139,7 +155,9 @@ export default createWidget('hamburger-menu', { const prioritizeFaq = this.currentUser && !this.currentUser.read_faq; if (prioritizeFaq) { - results.push(this.attach('menu-links', { heading: true, contents: () => this.faqLink(faqUrl) })); + results.push(this.attach('menu-links', { heading: true, contents: () => { + return this.attach('priority-faq-link', { href: faqUrl }); + }})); } if (currentUser && currentUser.staff) {