mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 12:03:45 +08:00
Merge pull request #3788 from getabetterpic/fix-create-topic-when-insufficient-category-permissions
Fix bug where create topic is suggested when insufficient permissions
This commit is contained in:
commit
64ef5f79bd
|
@ -63,9 +63,15 @@ export default (filter, params) => {
|
|||
|
||||
setupController(controller, model) {
|
||||
const topics = this.get('topics'),
|
||||
periodId = topics.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : '');
|
||||
periodId = topics.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : ''),
|
||||
canCreateTopic = topics.get('can_create_topic'),
|
||||
canCreateTopicOnCategory = model.get('permission') === Discourse.PermissionType.FULL;
|
||||
|
||||
this.controllerFor('navigation/category').set('canCreateTopic', topics.get('can_create_topic'));
|
||||
this.controllerFor('navigation/category').setProperties({
|
||||
canCreateTopicOnCategory: canCreateTopicOnCategory,
|
||||
cannotCreateTopicOnCategory: !canCreateTopicOnCategory,
|
||||
canCreateTopic: canCreateTopic
|
||||
});
|
||||
this.controllerFor('discovery/topics').setProperties({
|
||||
model: topics,
|
||||
category: model,
|
||||
|
@ -74,7 +80,9 @@ export default (filter, params) => {
|
|||
noSubcategories: params && !!params.no_subcategories,
|
||||
order: topics.get('params.order'),
|
||||
ascending: topics.get('params.ascending'),
|
||||
expandAllPinned: true
|
||||
expandAllPinned: true,
|
||||
canCreateTopic: canCreateTopic,
|
||||
canCreateTopicOnCategory: canCreateTopicOnCategory
|
||||
});
|
||||
|
||||
this.searchService.set('searchContext', model.get('searchContext'));
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
</div>
|
||||
<h3>
|
||||
{{footerMessage}}
|
||||
{{#if model.can_create_topic}}<a href {{action "createTopic"}}>{{i18n 'topic.suggest_create_topic'}}</a>{{/if}}
|
||||
{{#if canCreateTopicOnCategory}}<a href {{action "createTopic"}}>{{i18n 'topic.suggest_create_topic'}}</a>{{/if}}
|
||||
</h3>
|
||||
{{else}}
|
||||
{{#if top}}
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
{{/if}}
|
||||
|
||||
{{#if canCreateTopic}}
|
||||
{{d-button id="create-topic" class="btn-default" action="createTopic" icon="plus" label="topic.create"}}
|
||||
{{d-button id="create-topic"
|
||||
class="btn-default"
|
||||
action="createTopic"
|
||||
icon="plus"
|
||||
label="topic.create"
|
||||
disabled=cannotCreateTopicOnCategory}}
|
||||
{{/if}}
|
||||
|
||||
{{#if canEditCategory}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user