RolePicker: Only select roles that is delegatable when selecting a group (#51246)

This commit is contained in:
Karl Persson 2022-06-22 15:49:32 +02:00 committed by GitHub
parent d2ab3556fa
commit 8b82bebdc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,14 +118,15 @@ export const RolePickerMenu = ({
const group = optionGroups.find((g) => {
return g.value === value;
});
if (groupSelected(value)) {
if (groupSelected(value) || groupPartiallySelected(value)) {
if (group) {
setSelectedOptions(selectedOptions.filter((role) => !group.options.find((option) => role.uid === option.uid)));
}
} else {
if (group) {
const groupOptions = group.options.filter((role) => role.delegatable);
const restOptions = selectedOptions.filter((role) => !group.options.find((option) => role.uid === option.uid));
setSelectedOptions([...restOptions, ...group.options]);
setSelectedOptions([...restOptions, ...groupOptions]);
}
}
};