Fixes #39505 - Update OrderableSelect to PF5#11018
Conversation
Lukshio
left a comment
There was a problem hiding this comment.
Hi, I went thru the PR and have some notes. Also we have something similar in our plugin, that leads me to the idea of creating reusable component. So could you please create new component from this PR?
Check also this PR so you can better design the new component. theforeman/foreman_ansible#796
Please also take a look at our PF guide.
There was a problem hiding this comment.
Do not include locale changes, they are updated in a bulk in a separate PR
Move Draggable inside DualListOptionItem so PF5 receives a single list item element, and guard option normalization for form field usage. Co-authored-by: Cursor <cursoragent@cursor.com>
foreman_ansible and katello still import the orderable HOC from foremanReact; keep helpers exported while the form input uses PF5. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Please add test for reordering and onDrop handling
| deprecate( | ||
| 'forms/OrderableSelect/helpers', | ||
| 'OrderableDualListSelector from foremanReact/components/common/OrderableDualListSelector/OrderableDualListSelector', | ||
| '3.21' |
There was a problem hiding this comment.
| '3.21' | |
| '5.1' |
| const newRemoveFrom = removeFrom.filter( | ||
| option => !selectedValues.includes(String(option.value)) | ||
| ); | ||
| const moved = selectedValues | ||
| .map(value => | ||
| removeFrom.find(option => String(option.value) === String(value)) | ||
| ) | ||
| .filter(Boolean); | ||
|
|
||
| return [newRemoveFrom, appendUniqueOptions(addTo, moved)]; |
There was a problem hiding this comment.
Converting array to set and then using .has instead of .includes will reduce time complexity
| }; | ||
|
|
||
| const isItemSelected = stateName => value => | ||
| selectState[stateName].includes(String(value)); |
There was a problem hiding this comment.
Creating helper Set for available and selected and then use .has instead of .include will also reduce time complexity.
| const listOptionType = PropTypes.oneOfType([ | ||
| PropTypes.string, | ||
| PropTypes.shape({ | ||
| label: PropTypes.string.isRequired, | ||
| value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, | ||
| }), | ||
| ]); |
Fixes #39505 - Update OrderableSelect to PF5
Summary
Replaces the legacy PF3
OrderableSelect(typeahead + react-dnd tokens) with a PF5 composable dual list for ordered multi-value form fields.The only current consumer is VMware VM Boot order (
orderable_select_fon the new VM form). The form contract is unchanged: multiple hidden inputs with the samename, values submitted in boot order.Intentional UX change (PF3 → PF5)
DragDropThis is an intentional structural change, not a 1:1 PF component swap. A dual list matches existing Foreman/Satellite patterns and was preferred over keeping the typeahead token UI. User-visible outcome is the same: users can select boot devices and control their order.
Implementation
OrderableDualListSelector— reusable PF5 dual list incommon/(controlled API, drag-and-drop on chosen pane, tooltips, dedup on move). Intended for reuse by plugins (e.g. foreman_ansible).OrderableDualList— thin form wrapper (initial state, hidden inputs,onChange).orderable_select_fcontinues to registerorderableSelectinInputFactory; no parallel helper added.OrderableSelect/helpers.jskept and deprecated for plugin compatibility (orderableHOC still used by foreman_ansible/katello until they migrate).