Support adding items to the site map via plugin outlet.

This commit is contained in:
Robin Ward 2015-01-09 15:40:25 -05:00
parent bce12d17c7
commit 38e4defaee
4 changed files with 14 additions and 7 deletions

View File

@ -1,4 +1,6 @@
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, { export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
needs: ['application'],
showBadgesLink: function(){return Discourse.SiteSettings.enable_badges;}.property(), showBadgesLink: function(){return Discourse.SiteSettings.enable_badges;}.property(),
showAdminLinks: Em.computed.alias('currentUser.staff'), showAdminLinks: Em.computed.alias('currentUser.staff'),
flaggedPostsCount: Em.computed.alias("currentUser.site_flagged_posts_count"), flaggedPostsCount: Em.computed.alias("currentUser.site_flagged_posts_count"),
@ -22,8 +24,8 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
}.property(), }.property(),
categories: function() { categories: function() {
var hideUncategorized = !Discourse.SiteSettings.allow_uncategorized_topics, var hideUncategorized = !this.siteSettings.allow_uncategorized_topics,
showSubcatList = Discourse.SiteSettings.show_subcategory_list, showSubcatList = this.siteSettings.show_subcategory_list,
isStaff = Discourse.User.currentProp('staff'); isStaff = Discourse.User.currentProp('staff');
return Discourse.Category.list().reject(function(c) { return Discourse.Category.list().reject(function(c) {
if (showSubcatList && c.get('parent_category_id')) { return true; } if (showSubcatList && c.get('parent_category_id')) { return true; }
@ -34,7 +36,7 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
actions: { actions: {
keyboardShortcuts: function(){ keyboardShortcuts: function(){
Discourse.__container__.lookup('controller:application').send('showKeyboardShortcutsHelp'); this.get('controllers.application').send('showKeyboardShortcutsHelp');
}, },
toggleMobileView: function() { toggleMobileView: function() {
Discourse.Mobile.toggleMobileView(); Discourse.Mobile.toggleMobileView();

View File

@ -87,7 +87,7 @@
{{render "notifications" notifications}} {{render "notifications" notifications}}
{{#if view.renderSiteMap}} {{#if view.renderSiteMap}}
{{render "siteMap"}} {{render "site-map"}}
{{/if}} {{/if}}
{{render "user-dropdown"}} {{render "user-dropdown"}}

View File

@ -21,8 +21,11 @@
<a href="{{unbound badgesUrl}}" class="badge-link">{{i18n 'badges.title'}}</a> <a href="{{unbound badgesUrl}}" class="badge-link">{{i18n 'badges.title'}}</a>
</li> </li>
{{/if}} {{/if}}
{{plugin-outlet "site-map-links"}}
{{#if showKeyboardShortcuts}} {{#if showKeyboardShortcuts}}
<li><a href="#" {{action "keyboardShortcuts"}} class="keyboard-shortcuts-link">{{i18n 'keyboard_shortcuts_help.title'}}</a></li> <li><a href {{action "keyboardShortcuts"}} class="keyboard-shortcuts-link">{{i18n 'keyboard_shortcuts_help.title'}}</a></li>
{{/if}} {{/if}}
<li> <li>
<a href="{{unbound faqUrl}}" class="faq-link">{{i18n 'faq'}}</a> <a href="{{unbound faqUrl}}" class="faq-link">{{i18n 'faq'}}</a>
@ -31,7 +34,7 @@
{{#link-to 'about'}}{{i18n 'about.simple_title'}}{{/link-to}} {{#link-to 'about'}}{{i18n 'about.simple_title'}}{{/link-to}}
</li> </li>
{{#if showMobileToggle}} {{#if showMobileToggle}}
<li><a href="#" class="mobile-toggle-link" {{action "toggleMobileView"}}>{{boundI18n mobileViewLinkTextKey}}</a></li> <li><a href class="mobile-toggle-link" {{action "toggleMobileView"}}>{{boundI18n mobileViewLinkTextKey}}</a></li>
{{/if}} {{/if}}
</ul> </ul>

View File

@ -1,6 +1,8 @@
var oldMobileView; var oldMobileView;
moduleFor("controller:site-map", "controller:site-map", { moduleFor("controller:site-map", "controller:site-map", {
needs: ['controller:application'],
setup: function() { setup: function() {
oldMobileView = Discourse.Mobile.mobileView; oldMobileView = Discourse.Mobile.mobileView;
}, },
@ -77,7 +79,7 @@ test("categories", function() {
var categoryListStub = ["category1", "category2"]; var categoryListStub = ["category1", "category2"];
sandbox.stub(Discourse.Category, "list").returns(categoryListStub); sandbox.stub(Discourse.Category, "list").returns(categoryListStub);
var controller = this.subject(); var controller = this.subject({ siteSettings: Discourse.SiteSettings });
deepEqual(controller.get("categories"), categoryListStub, "returns the list of categories"); deepEqual(controller.get("categories"), categoryListStub, "returns the list of categories");
}); });