-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #38090 - Add filtering to job invocation hosts table
- Loading branch information
kmalyjur
committed
Jan 21, 2025
1 parent
dbc983d
commit 8096633
Showing
6 changed files
with
222 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
webpack/JobInvocationDetail/JobInvocationHostTableToolbar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import { Select, SelectOption, SelectList } from '@patternfly/react-core/next'; // remove "/next" after switching to PF5 | ||
import { MenuToggle, ToolbarItem } from '@patternfly/react-core'; | ||
import { STATUS_TITLES } from './JobInvocationConstants'; | ||
|
||
const JobInvocationHostTableToolbar = ({ | ||
dropdownFilter, | ||
setDropdownFilter, | ||
}) => { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const onSelect = (_event, itemId) => { | ||
setDropdownFilter(itemId); | ||
setIsOpen(false); | ||
}; | ||
|
||
const toggle = toggleRef => ( | ||
<MenuToggle | ||
ref={toggleRef} | ||
onClick={() => setIsOpen(!isOpen)} | ||
isExpanded={isOpen} | ||
style={{ | ||
width: '200px', | ||
}} | ||
> | ||
{Object.values(STATUS_TITLES).find(status => status.id === dropdownFilter) | ||
?.title || __('All statuses')} | ||
</MenuToggle> | ||
); | ||
|
||
return ( | ||
<ToolbarItem> | ||
<Select | ||
isOpen={isOpen} | ||
selected={dropdownFilter} | ||
onSelect={onSelect} | ||
onOpenChange={newIsOpen => setIsOpen(newIsOpen)} | ||
ouiaId="host-status-select" | ||
toggle={toggle} | ||
> | ||
<SelectList> | ||
{Object.values(STATUS_TITLES).map(result => ( | ||
<SelectOption | ||
key={result.id} | ||
itemId={result.id} | ||
isSelected={result.id === dropdownFilter} | ||
> | ||
{result.title} | ||
</SelectOption> | ||
))} | ||
</SelectList> | ||
</Select> | ||
</ToolbarItem> | ||
); | ||
}; | ||
|
||
JobInvocationHostTableToolbar.propTypes = { | ||
dropdownFilter: PropTypes.string.isRequired, | ||
setDropdownFilter: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default JobInvocationHostTableToolbar; |
Oops, something went wrong.