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

Add 'No selection' option to GID selector #254

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

carma12
Copy link
Collaborator

@carma12 carma12 commented Jan 12, 2024

To replicate the same behavior as in the current WebUI, the 'GID' field located in the 'Add user' modal should have a 'No selection' option. Also, a new GID value can be added and associated to a newly-created user.

Fixes: #236

@carma12 carma12 force-pushed the issue236-no-selection-gid branch from a1a5dd6 to a53027b Compare January 12, 2024 09:11
@carma12 carma12 force-pushed the issue236-no-selection-gid branch from a53027b to af55785 Compare January 12, 2024 10:24
@pvoborni
Copy link
Member

Note: in the review which lead to #236 was mentioned: In user add dialog, I cannot unset GID when I selected some, also the GID field should allow to enter arbitrary integer.

This and #236 is about the first part. But it won't solve the other: "the GID field should allow to enter arbitrary integer" - see the old UI.

@carma12 carma12 force-pushed the issue236-no-selection-gid branch 2 times, most recently from 985b0c0 to 9604ac0 Compare January 18, 2024 08:12
@carma12
Copy link
Collaborator Author

carma12 commented Jan 18, 2024

Note: in the review which lead to #236 was mentioned: In user add dialog, I cannot unset GID when I selected some, also the GID field should allow to enter arbitrary integer.

This and #236 is about the first part. But it won't solve the other: "the GID field should allow to enter arbitrary integer" - see the old UI.

I think the PF Select component currently doesn't allow any writing functionality, but I can check with them in case there is some tweak/alternative component we can use for that.

If not, I can open a discussion with Brian to find out how to approach this design-wise. I will set the 'WIP' tag on this PR while discussing this topic.

@carma12 carma12 added the WIP Work in Progress (do not merge) label Jan 18, 2024
@carma12
Copy link
Collaborator Author

carma12 commented Jan 18, 2024

I checked with the PatternFly team and there is a type of Selector that allows type-ahead functionality. So I can replace the existing Select component with this one and modify the description of the PR.

@carma12
Copy link
Collaborator Author

carma12 commented Jan 18, 2024

@pvoborni - I have added a new commit to handle the type-ahead functionality in the GID field. Feel free to review it and share your thoughts on it. Thanks!

@carma12 carma12 force-pushed the issue236-no-selection-gid branch from 1aa3e0f to 2637312 Compare January 19, 2024 14:19
@carma12 carma12 removed the WIP Work in Progress (do not merge) label Jan 19, 2024
Copy link
Member

@pvoborni pvoborni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've provided some simplifying/readability suggestions.

But I'd do one more, I'd say more important. The AddUser modal is "polluted" with a "large" GID logic that makes the AddUser component hard to read. It would be more readable to move out the GID logic to a separate component e.g. called GidSelector which would wrap TypeAheadSelectWithCreate the same way as the dialog does. Thus the dialog could have only:

import GIdSelector from "../form/GIdSelector"

const [gid, setGid] = useState("");

<GidSelector selected={gid} onSelectedChange={setGid} />


interface PropsToTypeAheadSelectWithCreate {
initialSelectOptions: SelectOptionProps[];
onChangeSelectOptions: (selectOptions: SelectOptionProps[]) => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this useful? I see that it is used in AddUser but is there a reason for it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to update the selection list options that are retrieved from the AddUser, IIRC. As this bit was included in the Select with Type ahead original code, I decided to include it as well as part of the functionality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that it was in the example code is not a reason to have it here. But in this case it was not even in the example. The example implements a component SelectTypeaheadCreatable that has no externally definable props. I.e. these functions were internal to the component.

The only reason to expose them would be to allow the parent component to work with the new states. E.g. to use them in adding new users. But this imho not needed.

Also with

let gidOptions = getGidOptions(GIDs);

  const onChangeGidOptions = (newList: SelectOptionProps[]) => {
    gidOptions = newList;
  };

it has no effect now.

@carma12 carma12 force-pushed the issue236-no-selection-gid branch from 2637312 to 903be38 Compare January 31, 2024 12:58
@carma12
Copy link
Collaborator Author

carma12 commented Jan 31, 2024

@pvoborni - The code has been updated based on your feedback. Feel free to keep reviewing.

@pvoborni
Copy link
Member

pvoborni commented Feb 8, 2024

Provided another round of comments.

To replicate the same behavior as in
the current WebUI, the 'GID' field
located in the 'Add user' modal should
have a 'No selection' option.

Fixes: freeipa#236
Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12 carma12 force-pushed the issue236-no-selection-gid branch from 903be38 to 97af0c3 Compare February 22, 2024 08:14
To replicate the same behavior as in the
current WebUI, the Select component should
also have the option to add a new GID value.

Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12 carma12 force-pushed the issue236-no-selection-gid branch from 97af0c3 to 6c2785e Compare February 22, 2024 08:42
@carma12
Copy link
Collaborator Author

carma12 commented Feb 22, 2024

@pvoborni - As suggested, I removed the onOptionsChange prop from the TypeAheadSelectWithCreate component and adjusted the AddUser one. You were right, it is not needed and works fine this way. Feel free to review it.

Copy link
Member

@pvoborni pvoborni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@carma12 carma12 merged commit b509da9 into freeipa:main Feb 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow no selection in the 'Add user' > 'GID' field
2 participants