mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: When faq_url
is custom, track the FAQ clicks
This commit is contained in:
parent
35922bf692
commit
cd371fa20e
2 changed files with 27 additions and 10 deletions
|
@ -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"),
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue