|
1 | 1 | import React, { ReactElement, useState } from 'react';
|
2 | 2 |
|
3 |
| -import { FormGroup } from '@patternfly/react-core'; |
4 | 3 | import {
|
| 4 | + FormGroup, |
| 5 | + MenuToggle, |
| 6 | + MenuToggleElement, |
5 | 7 | Select,
|
| 8 | + SelectList, |
6 | 9 | SelectOption,
|
7 |
| - SelectVariant, |
8 |
| -} from '@patternfly/react-core/deprecated'; |
| 10 | +} from '@patternfly/react-core'; |
9 | 11 |
|
10 | 12 | import {
|
11 | 13 | RELEASES,
|
@@ -45,13 +47,15 @@ const ReleaseSelect = () => {
|
45 | 47 | const releases = process.env.IS_ON_PREMISE ? ON_PREM_RELEASES : RELEASES;
|
46 | 48 |
|
47 | 49 | const handleSelect = (_event: React.MouseEvent, selection: Distributions) => {
|
48 |
| - if (!isRhel(selection)) { |
49 |
| - dispatch(changeRegistrationType('register-later')); |
50 |
| - } else { |
51 |
| - dispatch(changeRegistrationType('register-now-rhc')); |
| 50 | + if (selection !== ('loader' as Distributions)) { |
| 51 | + if (!isRhel(selection)) { |
| 52 | + dispatch(changeRegistrationType('register-later')); |
| 53 | + } else { |
| 54 | + dispatch(changeRegistrationType('register-now-rhc')); |
| 55 | + } |
| 56 | + dispatch(changeDistribution(selection)); |
| 57 | + setIsOpen(false); |
52 | 58 | }
|
53 |
| - dispatch(changeDistribution(selection)); |
54 |
| - setIsOpen(false); |
55 | 59 | };
|
56 | 60 |
|
57 | 61 | const handleExpand = () => {
|
@@ -124,26 +128,43 @@ const ReleaseSelect = () => {
|
124 | 128 | return options;
|
125 | 129 | };
|
126 | 130 |
|
| 131 | + const onToggleClick = () => { |
| 132 | + setIsOpen(!isOpen); |
| 133 | + }; |
| 134 | + |
| 135 | + const toggle = (toggleRef: React.Ref<MenuToggleElement>) => ( |
| 136 | + <MenuToggle |
| 137 | + ref={toggleRef} |
| 138 | + onClick={onToggleClick} |
| 139 | + isExpanded={isOpen} |
| 140 | + isFullWidth |
| 141 | + data-testid="release_select" |
| 142 | + > |
| 143 | + {releases.get(distribution)} |
| 144 | + </MenuToggle> |
| 145 | + ); |
| 146 | + |
127 | 147 | return (
|
128 | 148 | <FormGroup isRequired={true} label="Release">
|
129 | 149 | <Select
|
130 | 150 | ouiaId="release_select"
|
131 |
| - variant={SelectVariant.single} |
132 |
| - onToggle={() => setIsOpen(!isOpen)} |
133 |
| - onSelect={handleSelect} |
134 |
| - selections={releases.get(distribution)} |
135 | 151 | isOpen={isOpen}
|
136 |
| - {...(!showDevelopmentOptions && |
137 |
| - // Hide this for on-prem since the host |
138 |
| - // could be centos or fedora |
139 |
| - !process.env.IS_ON_PREMISE && { |
140 |
| - loadingVariant: { |
141 |
| - text: 'Show options for further development of RHEL', |
142 |
| - onClick: handleExpand, |
143 |
| - }, |
144 |
| - })} |
| 152 | + selected={releases.get(distribution)} |
| 153 | + onSelect={handleSelect} |
| 154 | + toggle={toggle} |
| 155 | + shouldFocusToggleOnSelect |
145 | 156 | >
|
146 |
| - {setSelectOptions()} |
| 157 | + <SelectList> |
| 158 | + {setSelectOptions()} |
| 159 | + {!showDevelopmentOptions && |
| 160 | + // Hide this for on-prem since the host |
| 161 | + // could be centos or fedora |
| 162 | + !process.env.IS_ON_PREMISE && ( |
| 163 | + <SelectOption onClick={handleExpand} value="loader" isLoadButton> |
| 164 | + Show options for further development of RHEL |
| 165 | + </SelectOption> |
| 166 | + )} |
| 167 | + </SelectList> |
147 | 168 | </Select>
|
148 | 169 | </FormGroup>
|
149 | 170 | );
|
|
0 commit comments