From bbf9c13952e95312bce3b660fd80da85b76b5a84 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Mon, 13 Jan 2020 12:10:36 -0500 Subject: [PATCH] update select-based items to utilize labels --- awx/ui_next/src/components/Search/Search.jsx | 20 ++++++++++++------- .../InventoryGroups/InventoryGroupsList.jsx | 6 +++++- awx/ui_next/src/types.js | 4 ++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/awx/ui_next/src/components/Search/Search.jsx b/awx/ui_next/src/components/Search/Search.jsx index 094ee52e78..94fae17e35 100644 --- a/awx/ui_next/src/components/Search/Search.jsx +++ b/awx/ui_next/src/components/Search/Search.jsx @@ -210,7 +210,7 @@ class Search extends React.Component { {searchColumnName} )} - {columns.map(({ key, name, options, isBoolean }) => ( + {columns.map(({ key, name, options, isBoolean, booleanLabels = {} }) => ( { @@ -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]) => ( - + {options.map(([optionKey, optionLabel]) => ( + + {optionLabel} + ))} @@ -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 */} - - + + {booleanLabels.true || i18n._(t`Yes`)} + + + {booleanLabels.false || i18n._(t`No`)} + )) || ( diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx index 307138de01..cd0139ff04 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx @@ -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)`), diff --git a/awx/ui_next/src/types.js b/awx/ui_next/src/types.js index 0f263524cf..586ca80ca4 100644 --- a/awx/ui_next/src/types.js +++ b/awx/ui_next/src/types.js @@ -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)), }) );