FIX: Disabled action buttons on newly-created category (#11080)
Ensures the newly created category record gives the current user permission to create a new topic and sets her notification level to the default (regular).
This commit is contained in:
parent
7fa6aca9db
commit
f5a726e52b
|
@ -5,6 +5,8 @@ import bootbox from "bootbox";
|
|||
import { extractError } from "discourse/lib/ajax-error";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import { readOnly } from "@ember/object/computed";
|
||||
import PermissionType from "discourse/models/permission-type";
|
||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||
|
||||
export default Controller.extend({
|
||||
selectedTab: "general",
|
||||
|
@ -93,8 +95,10 @@ export default Controller.extend({
|
|||
model.setProperties({
|
||||
slug: result.category.slug,
|
||||
id: result.category.id,
|
||||
createdCategory: true,
|
||||
permission: PermissionType.FULL,
|
||||
notification_level: NotificationLevels.REGULAR,
|
||||
});
|
||||
this.site.updateCategory(model);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -132,11 +136,7 @@ export default Controller.extend({
|
|||
},
|
||||
|
||||
goBack() {
|
||||
if (this.model.createdCategory) {
|
||||
DiscourseURL.redirectTo(this.model.url);
|
||||
} else {
|
||||
DiscourseURL.routeTo(this.model.url);
|
||||
}
|
||||
DiscourseURL.routeTo(this.model.url);
|
||||
},
|
||||
|
||||
toggleMenu() {
|
||||
|
|
|
@ -37,12 +37,12 @@ acceptance("Category New", function (needs) {
|
|||
"it can switch to the settings tab"
|
||||
);
|
||||
|
||||
sinon.stub(DiscourseURL, "redirectTo");
|
||||
sinon.stub(DiscourseURL, "routeTo");
|
||||
|
||||
await click(".category-back");
|
||||
assert.ok(
|
||||
DiscourseURL.redirectTo.calledWith("/c/testing/11"),
|
||||
"it full page redirects after a newly created category"
|
||||
DiscourseURL.routeTo.calledWith("/c/testing/11"),
|
||||
"back routing works"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue