Skip to content

Commit 10ec53d

Browse files
authored
feat: use type ahead dropdown (#3165)
* starting to use typeahead dropdown * now getting the selected item too
1 parent 00b82a7 commit 10ec53d

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

src/shared/components/cells/CellCloneOverlay.tsx

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {useDispatch, useSelector} from 'react-redux'
55
import {OverlayContext} from 'src/overlays/components/OverlayController'
66
// Clockface
77
import {
8-
Dropdown,
98
Button,
109
Overlay,
1110
ComponentColor,
1211
InputLabel,
1312
SlideToggle,
1413
Form,
1514
ComponentStatus,
15+
TypeAheadDropDown,
16+
SelectableItem,
1617
} from '@influxdata/clockface'
1718

1819
// Actions
@@ -136,45 +137,34 @@ const CellCloneOverlay: FC = () => {
136137

137138
const selectedDashboard = otherDashboards.find(
138139
d => d.id === destinationDashboardID
139-
)?.name
140+
)
141+
142+
const dashItems = otherDashboards as SelectableItem[]
143+
144+
const onDashSelection = item => {
145+
setDestinationDashboardID(item?.id)
146+
}
147+
148+
const typeAheadDropdown = (
149+
<TypeAheadDropDown
150+
items={dashItems}
151+
onSelect={onDashSelection}
152+
buttonTestId="clone-to-other-dashboard"
153+
menuTestID="copy-dashboard-cell--dropdown-menu"
154+
itemTestIdPrefix="other-dashboard"
155+
sortNames={true}
156+
selectedOption={selectedDashboard as SelectableItem}
157+
placeholderText="Choose a Destination Dashboard"
158+
defaultNameText="Name this Dashboard"
159+
/>
160+
)
140161

141162
return (
142163
<Overlay.Container maxWidth={400}>
143164
<Overlay.Header title="Move Cell" onDismiss={onClose} />
144165
<Overlay.Body className="dashboard-clonecell--overlayopen">
145166
<Form.Element label="" className="dashboard-clonecell--dropdownopen">
146-
<Dropdown
147-
className="dashboard-clonecell--dropdownopen"
148-
button={(active, onClick) => (
149-
<Dropdown.Button
150-
active={active}
151-
onClick={onClick}
152-
testID="clone-to-other-dashboard"
153-
>
154-
{selectedDashboard ?? 'Choose a Destination Dashboard'}
155-
</Dropdown.Button>
156-
)}
157-
menu={onCollapse => (
158-
<Dropdown.Menu
159-
onCollapse={onCollapse}
160-
testID="copy-dashboard-cell--dropdown-menu"
161-
>
162-
{otherDashboards.map(d => {
163-
return (
164-
<Dropdown.Item
165-
key={d.id}
166-
value={d.id}
167-
onClick={id => setDestinationDashboardID(id)}
168-
selected={d.id === destinationDashboardID}
169-
testID={`other-dashboard-${d.id}`}
170-
>
171-
{d.name ?? 'Name this Dashboard'}
172-
</Dropdown.Item>
173-
)
174-
})}
175-
</Dropdown.Menu>
176-
)}
177-
/>
167+
{typeAheadDropdown}
178168
</Form.Element>
179169
<Form.Element label="" className="dashboard-clonecell--removecurrent">
180170
<span className="dashboard-clonecell--movetype">Move type: </span>

0 commit comments

Comments
 (0)