Skip to content

Commit

Permalink
Fix for setting enabled correctly for group settings (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 authored Jul 15, 2024
1 parent 3d1d41a commit ba55a53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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 @@ export const MultiSelection: React.FC<MultiSelectionProps> = ({ value, setValue
[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 @@ export const MultiSelection: React.FC<MultiSelectionProps> = ({ value, setValue
};
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 @@ export const MultiSelection: React.FC<MultiSelectionProps> = ({ value, setValue
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

0 comments on commit ba55a53

Please sign in to comment.