2017-05-24 00:50:20 -05:00
|
|
|
import { withPluginApi } from 'discourse/lib/plugin-api';
|
|
|
|
|
|
|
|
function initialize(api) {
|
|
|
|
const messageBus = api.container.lookup('message-bus:main');
|
|
|
|
const currentUser = api.getCurrentUser();
|
|
|
|
const appEvents = api.container.lookup('app-events:main');
|
|
|
|
|
2017-06-13 14:52:08 -05:00
|
|
|
api.modifyClass('component:site-header', {
|
2017-05-24 00:50:20 -05:00
|
|
|
didInsertElement() {
|
|
|
|
this._super();
|
|
|
|
this.dispatch('header:search-context-trigger', 'header');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
api.attachWidgetAction('header', 'headerSearchContextTrigger', function() {
|
|
|
|
if (this.site.mobileView) {
|
|
|
|
this.state.skipSearchContext = false;
|
|
|
|
} else {
|
|
|
|
this.state.contextEnabled = true;
|
|
|
|
this.state.searchContextType = 'topic';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (messageBus && currentUser) {
|
|
|
|
messageBus.subscribe(`/new_user_narrative/tutorial_search`, () => {
|
|
|
|
appEvents.trigger('header:search-context-trigger');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "new-user-narratve",
|
|
|
|
|
|
|
|
initialize(container) {
|
|
|
|
const siteSettings = container.lookup('site-settings:main');
|
2017-06-13 14:52:08 -05:00
|
|
|
if (siteSettings.discourse_narrative_bot_enabled) withPluginApi('0.8.7', initialize);
|
2017-05-24 00:50:20 -05:00
|
|
|
}
|
|
|
|
};
|