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:
Penar Musaraj 2020-11-02 09:36:27 -05:00 committed by GitHub
parent 7fa6aca9db
commit f5a726e52b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -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() {

View File

@ -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"
); );
}); });
}); });