mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
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 { extractError } from "discourse/lib/ajax-error";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import { readOnly } from "@ember/object/computed";
|
import { readOnly } from "@ember/object/computed";
|
||||||
|
import PermissionType from "discourse/models/permission-type";
|
||||||
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
selectedTab: "general",
|
selectedTab: "general",
|
||||||
@ -93,8 +95,10 @@ export default Controller.extend({
|
|||||||
model.setProperties({
|
model.setProperties({
|
||||||
slug: result.category.slug,
|
slug: result.category.slug,
|
||||||
id: result.category.id,
|
id: result.category.id,
|
||||||
createdCategory: true,
|
permission: PermissionType.FULL,
|
||||||
|
notification_level: NotificationLevels.REGULAR,
|
||||||
});
|
});
|
||||||
|
this.site.updateCategory(model);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -132,11 +136,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
goBack() {
|
goBack() {
|
||||||
if (this.model.createdCategory) {
|
DiscourseURL.routeTo(this.model.url);
|
||||||
DiscourseURL.redirectTo(this.model.url);
|
|
||||||
} else {
|
|
||||||
DiscourseURL.routeTo(this.model.url);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMenu() {
|
toggleMenu() {
|
||||||
|
@ -37,12 +37,12 @@ acceptance("Category New", function (needs) {
|
|||||||
"it can switch to the settings tab"
|
"it can switch to the settings tab"
|
||||||
);
|
);
|
||||||
|
|
||||||
sinon.stub(DiscourseURL, "redirectTo");
|
sinon.stub(DiscourseURL, "routeTo");
|
||||||
|
|
||||||
await click(".category-back");
|
await click(".category-back");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
DiscourseURL.redirectTo.calledWith("/c/testing/11"),
|
DiscourseURL.routeTo.calledWith("/c/testing/11"),
|
||||||
"it full page redirects after a newly created category"
|
"back routing works"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user