FIX: Selected Tag Group permission shouldn’t change during save (#11274)

`setPermissionsGroups` would initialize an empty permissions object whenever new groups were added to the Tag Group. This meant that if you selected the `visible` permission and then added groups to the Tag Group, the `visible` permission would be obliterated and the Tag Group would be treated as though it was `private`.
This commit is contained in:
jbrw 2020-11-18 11:22:19 -05:00 committed by GitHub
parent 69eef5e8b3
commit 8e8dca9246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -99,14 +99,18 @@ export default Component.extend(bufferedProperty("model"), {
},
setPermissionsGroups(groupIds) {
let permissions = {};
let updatedPermissions = Object.assign(
{},
this.buffered.get("permissions")
);
this.allGroups.forEach((group) => {
if (groupIds.includes(group.id)) {
permissions[group.name] = PermissionType.FULL;
updatedPermissions[group.name] = PermissionType.FULL;
}
});
this.buffered.set("permissions", permissions);
this.buffered.set("permissions", updatedPermissions);
},
save() {

View File

@ -62,12 +62,18 @@ acceptance("Tag Groups", function (needs) {
await tags.expand();
await tags.selectRowByValue("monkey");
await click("#private-permission");
await click("#visible-permission");
assert.ok(queryAll(".tag-group-content .btn.btn-default:disabled").length);
await groups.expand();
await groups.selectRowByIndex(1);
await groups.selectRowByIndex(0);
assert.ok(!queryAll(".tag-group-content .btn.btn-default")[0].disabled);
await click(".tag-group-content .btn.btn-default");
assert.ok(
exists("#visible-permission:checked"),
"selected permission does not change after saving"
);
});
});