Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for setting enabled correctly for group settings #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions frontend/src/components/MultiSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
[inputValue, value],
);

console.log(`Value: `, value);

Check failure on line 44 in frontend/src/components/MultiSelection.tsx

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Unexpected console statement
React.useEffect(() => {
if (inputValue) {
setIsOpen(true);
Expand Down Expand Up @@ -112,10 +113,11 @@
};
const onSelect = (menuItem?: SelectionOptions) => {
if (menuItem) {
console.log(`Selected: `, menuItem.name);

Check failure on line 116 in frontend/src/components/MultiSelection.tsx

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Unexpected console statement
setValue(
selected.includes(menuItem)
? value.map((option) => (option === menuItem ? { ...option, enabled: false } : option))
: value.map((option) => (option === menuItem ? { ...option, enabled: true } : option)),
? value.map((option) => (option === menuItem ? { ...option, selected: false } : option))
: value.map((option) => (option === menuItem ? { ...option, selected: true } : option)),
);
}
textInputRef.current?.focus();
Expand Down Expand Up @@ -165,7 +167,7 @@
variant="plain"
onClick={() => {
setInputValue('');
setValue(value.map((option) => ({ ...option, enabled: false })));
setValue(value.map((option) => ({ ...option, selected: false })));
textInputRef.current?.focus();
}}
aria-label="Clear input value"
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/pages/groupSettings/GroupSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const GroupSettings: React.FC = () => {
>
<MultiSelection
ariaLabel={adminDesc}
value={groupSettings.adminGroups}
value={groupSettings.adminGroups.map((g) => ({
id: g.id,
name: g.name,
selected: g.enabled,
}))}
setValue={(newState) => handleMenuItemSelection(newState, GroupsConfigField.ADMIN)}
/>
{groupSettings.errorAdmin ? (
Expand Down Expand Up @@ -125,7 +129,11 @@ const GroupSettings: React.FC = () => {
>
<MultiSelection
ariaLabel={userDesc}
value={groupSettings.allowedGroups}
value={groupSettings.allowedGroups.map((g) => ({
id: g.id,
name: g.name,
selected: g.enabled,
}))}
setValue={(newState) => handleMenuItemSelection(newState, GroupsConfigField.USER)}
/>
{groupSettings.errorUser ? (
Expand Down
Loading