update select-based items to utilize labels

This commit is contained in:
John Mitchell 2020-01-13 12:10:36 -05:00
parent 04576af6a5
commit bbf9c13952
3 changed files with 22 additions and 8 deletions

View File

@ -210,7 +210,7 @@ class Search extends React.Component {
<NoOptionDropdown>{searchColumnName}</NoOptionDropdown>
)}
</DataToolbarItem>
{columns.map(({ key, name, options, isBoolean }) => (
{columns.map(({ key, name, options, isBoolean, booleanLabels = {} }) => (
<DataToolbarFilter
chips={chipsByKey[key] ? chipsByKey[key].chips : []}
deleteChip={(unusedKey, val) => {
@ -235,10 +235,12 @@ class Search extends React.Component {
}
selections={chipsByKey[key].chips}
isExpanded={isFilterDropdownOpen}
placeholderText={`Filter by ${name.toLowerCase()}`}
placeholderText={`Filter By ${name}`}
>
{options.map(([optionKey]) => (
<SelectOption key={optionKey} value={optionKey} />
{options.map(([optionKey, optionLabel]) => (
<SelectOption key={optionKey} value={optionKey}>
{optionLabel}
</SelectOption>
))}
</Select>
</Fragment>
@ -252,14 +254,18 @@ class Search extends React.Component {
}
selections={chipsByKey[key].chips[0]}
isExpanded={isFilterDropdownOpen}
placeholderText={`Filter by ${name.toLowerCase()}`}
placeholderText={`Filter By ${name}`}
>
{/* TODO: update value to being object
{ actualValue: optionKey, toString: () => label }
currently a pf bug that makes the checked logic
not work with object-based values */}
<SelectOption key="true" value="true" />
<SelectOption key="false" value="false" />
<SelectOption key="true" value="true">
{booleanLabels.true || i18n._(t`Yes`)}
</SelectOption>
<SelectOption key="false" value="false">
{booleanLabels.false || i18n._(t`No`)}
</SelectOption>
</Select>
)) || (
<InputGroup>

View File

@ -184,9 +184,13 @@ function InventoryGroupsList({ i18n, location, match }) {
isDefault: true,
},
{
name: i18n._(t`Is Root Group`),
name: i18n._(t`Group Type`),
key: 'parents__isnull',
isBoolean: true,
booleanLabels: {
"true": i18n._(t`Show Only Root Groups`),
"false": i18n._(t`Show All Groups`)
}
},
{
name: i18n._(t`Created By (Username)`),

View File

@ -257,6 +257,10 @@ export const SearchColumns = arrayOf(
key: string.isRequired,
isDefault: bool,
isBoolean: bool,
booleanLabels: shape({
"true": string.isRequired,
"false": string.isRequired
}),
options: arrayOf(arrayOf(string, string)),
})
);