mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FIX: Can't add categories when creating a new web hook.
This commit is contained in:
@ -65,10 +65,16 @@ export default Ember.Controller.extend({
|
|||||||
this.set('saved', false);
|
this.set('saved', false);
|
||||||
const url = extractDomainFromUrl(this.get('model.payload_url'));
|
const url = extractDomainFromUrl(this.get('model.payload_url'));
|
||||||
const model = this.get('model');
|
const model = this.get('model');
|
||||||
|
const isNew = model.get('isNew');
|
||||||
|
|
||||||
const saveWebHook = () => {
|
const saveWebHook = () => {
|
||||||
return model.save().then(() => {
|
return model.save().then(() => {
|
||||||
this.set('saved', true);
|
this.set('saved', true);
|
||||||
this.get('adminWebHooks').get('model').addObject(model);
|
this.get('adminWebHooks').get('model').addObject(model);
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
this.transitionToRoute('adminWebHooks.show', model.get('id'));
|
||||||
|
}
|
||||||
}).catch(popupAjaxError);
|
}).catch(popupAjaxError);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ export default RestModel.extend({
|
|||||||
verify_certificate: true,
|
verify_certificate: true,
|
||||||
active: false,
|
active: false,
|
||||||
web_hook_event_types: null,
|
web_hook_event_types: null,
|
||||||
categoriesFilter: null,
|
|
||||||
groupsFilterInName: null,
|
groupsFilterInName: null,
|
||||||
|
|
||||||
@computed('wildcard_web_hook')
|
@computed('wildcard_web_hook')
|
||||||
@ -23,9 +22,9 @@ export default RestModel.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('category_ids')
|
@computed('category_ids')
|
||||||
updateCategoriesFilter() {
|
categories(categoryIds) {
|
||||||
this.set('categoriesFilter', Category.findByIds(this.get('category_ids')));
|
return Category.findByIds(categoryIds);
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('group_ids')
|
@observes('group_ids')
|
||||||
@ -55,7 +54,9 @@ export default RestModel.extend({
|
|||||||
|
|
||||||
createProperties() {
|
createProperties() {
|
||||||
const types = this.get('web_hook_event_types');
|
const types = this.get('web_hook_event_types');
|
||||||
const categories = this.get('categoriesFilter');
|
const categories = this.get('categories');
|
||||||
|
const categoryIds = this.get('categories').map(c => c.id);
|
||||||
|
|
||||||
// Hack as {{group-selector}} accepts a comma-separated string as data source, but
|
// Hack as {{group-selector}} accepts a comma-separated string as data source, but
|
||||||
// we use an array to populate the datasource above.
|
// we use an array to populate the datasource above.
|
||||||
const groupsFilter = this.get('groupsFilterInName');
|
const groupsFilter = this.get('groupsFilterInName');
|
||||||
@ -69,7 +70,7 @@ export default RestModel.extend({
|
|||||||
verify_certificate: this.get('verify_certificate'),
|
verify_certificate: this.get('verify_certificate'),
|
||||||
active: this.get('active'),
|
active: this.get('active'),
|
||||||
web_hook_event_type_ids: Ember.isEmpty(types) ? [null] : types.map(type => type.id),
|
web_hook_event_type_ids: Ember.isEmpty(types) ? [null] : types.map(type => type.id),
|
||||||
category_ids: Ember.isEmpty(categories) ? [null] : categories.map(c => c.id),
|
category_ids: Ember.isEmpty(categoryIds) ? [null] : categoryIds,
|
||||||
group_ids: Ember.isEmpty(groupNames) || Ember.isEmpty(groupNames[0]) ? [null] : Discourse.Site.currentProp('groups')
|
group_ids: Ember.isEmpty(groupNames) || Ember.isEmpty(groupNames[0]) ? [null] : Discourse.Site.currentProp('groups')
|
||||||
.reduce((groupIds, g) => {
|
.reduce((groupIds, g) => {
|
||||||
if (groupNames.includes(g.name)) { groupIds.push(g.id); }
|
if (groupNames.includes(g.name)) { groupIds.push(g.id); }
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<div class='filters'>
|
<div class='filters'>
|
||||||
<div>
|
<div>
|
||||||
<label>{{fa-icon 'circle' class='tracking'}}{{i18n 'admin.web_hooks.categories_filter'}}</label>
|
<label>{{fa-icon 'circle' class='tracking'}}{{i18n 'admin.web_hooks.categories_filter'}}</label>
|
||||||
{{category-selector categories=model.categoriesFilter blacklist=model.categoriesFilter}}
|
{{category-selector categories=model.categories blacklist=model.categories}}
|
||||||
<div class="instructions">{{i18n 'admin.web_hooks.categories_filter_instructions'}}</div>
|
<div class="instructions">{{i18n 'admin.web_hooks.categories_filter_instructions'}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
Reference in New Issue
Block a user