mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 15:06:02 -03:30
Do not show not as choice for Advanced Search on Smart Inventory
Do not show `not` as choice for Advanced Search on Smart Inventory since this feature is not implemented on the API side yet. See: https://github.com/ansible/awx/issues/2817
This commit is contained in:
@@ -39,6 +39,7 @@ function DataListToolbar({
|
|||||||
additionalControls,
|
additionalControls,
|
||||||
qsConfig,
|
qsConfig,
|
||||||
pagination,
|
pagination,
|
||||||
|
enableNegativeFiltering,
|
||||||
}) {
|
}) {
|
||||||
const showExpandCollapse = onCompact && onExpand;
|
const showExpandCollapse = onCompact && onExpand;
|
||||||
const [isKebabOpen, setIsKebabOpen] = useState(false);
|
const [isKebabOpen, setIsKebabOpen] = useState(false);
|
||||||
@@ -90,6 +91,7 @@ function DataListToolbar({
|
|||||||
onReplaceSearch={onReplaceSearch}
|
onReplaceSearch={onReplaceSearch}
|
||||||
onShowAdvancedSearch={onShowAdvancedSearch}
|
onShowAdvancedSearch={onShowAdvancedSearch}
|
||||||
onRemove={onRemove}
|
onRemove={onRemove}
|
||||||
|
enableNegativeFiltering={enableNegativeFiltering}
|
||||||
/>
|
/>
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
{sortColumns && (
|
{sortColumns && (
|
||||||
@@ -170,6 +172,7 @@ DataListToolbar.propTypes = {
|
|||||||
onSelectAll: PropTypes.func,
|
onSelectAll: PropTypes.func,
|
||||||
onSort: PropTypes.func,
|
onSort: PropTypes.func,
|
||||||
additionalControls: PropTypes.arrayOf(PropTypes.node),
|
additionalControls: PropTypes.arrayOf(PropTypes.node),
|
||||||
|
enableNegativeFiltering: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
DataListToolbar.defaultProps = {
|
DataListToolbar.defaultProps = {
|
||||||
@@ -188,6 +191,7 @@ DataListToolbar.defaultProps = {
|
|||||||
onSelectAll: null,
|
onSelectAll: null,
|
||||||
onSort: null,
|
onSort: null,
|
||||||
additionalControls: [],
|
additionalControls: [],
|
||||||
|
enableNegativeFiltering: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DataListToolbar;
|
export default DataListToolbar;
|
||||||
|
|||||||
@@ -111,13 +111,13 @@ const buildSearchColumns = () => [
|
|||||||
|
|
||||||
function HostFilterLookup({
|
function HostFilterLookup({
|
||||||
helperTextInvalid,
|
helperTextInvalid,
|
||||||
|
|
||||||
isValid,
|
isValid,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
onBlur,
|
onBlur,
|
||||||
onChange,
|
onChange,
|
||||||
organizationId,
|
organizationId,
|
||||||
value,
|
value,
|
||||||
|
enableNegativeFiltering,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -342,7 +342,13 @@ function HostFilterLookup({
|
|||||||
item={{ ...item, url: `/hosts/${item.id}/details` }}
|
item={{ ...item, url: `/hosts/${item.id}/details` }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
renderToolbar={props => <DataListToolbar {...props} fillWidth />}
|
renderToolbar={props => (
|
||||||
|
<DataListToolbar
|
||||||
|
{...props}
|
||||||
|
fillWidth
|
||||||
|
enableNegativeFiltering={enableNegativeFiltering}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
toolbarSearchColumns={searchColumns}
|
toolbarSearchColumns={searchColumns}
|
||||||
toolbarSortColumns={[
|
toolbarSortColumns={[
|
||||||
{
|
{
|
||||||
@@ -374,6 +380,7 @@ HostFilterLookup.propTypes = {
|
|||||||
onChange: func,
|
onChange: func,
|
||||||
organizationId: number,
|
organizationId: number,
|
||||||
value: string,
|
value: string,
|
||||||
|
enableNegativeFiltering: bool,
|
||||||
};
|
};
|
||||||
HostFilterLookup.defaultProps = {
|
HostFilterLookup.defaultProps = {
|
||||||
isValid: true,
|
isValid: true,
|
||||||
@@ -381,6 +388,7 @@ HostFilterLookup.defaultProps = {
|
|||||||
onChange: () => {},
|
onChange: () => {},
|
||||||
organizationId: null,
|
organizationId: null,
|
||||||
value: '',
|
value: '',
|
||||||
|
enableNegativeFiltering: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withRouter(HostFilterLookup);
|
export default withRouter(HostFilterLookup);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ function AdvancedSearch({
|
|||||||
searchableKeys,
|
searchableKeys,
|
||||||
relatedSearchableKeys,
|
relatedSearchableKeys,
|
||||||
maxSelectHeight,
|
maxSelectHeight,
|
||||||
|
enableNegativeFiltering,
|
||||||
}) {
|
}) {
|
||||||
// TODO: blocked by pf bug, eventually separate these into two groups in the select
|
// TODO: blocked by pf bug, eventually separate these into two groups in the select
|
||||||
// for now, I'm spreading set to get rid of duplicate keys...when they are grouped
|
// for now, I'm spreading set to get rid of duplicate keys...when they are grouped
|
||||||
@@ -111,12 +112,14 @@ function AdvancedSearch({
|
|||||||
value="or"
|
value="or"
|
||||||
description={t`Returns results that satisfy this one or any other filters.`}
|
description={t`Returns results that satisfy this one or any other filters.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
{enableNegativeFiltering && (
|
||||||
id="not-option-select"
|
<SelectOption
|
||||||
key="not"
|
id="not-option-select"
|
||||||
value="not"
|
key="not"
|
||||||
description={t`Returns results that have values other than this one as well as other filters.`}
|
value="not"
|
||||||
/>
|
description={t`Returns results that have values other than this one as well as other filters.`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Select>
|
</Select>
|
||||||
<Select
|
<Select
|
||||||
ouiaId="set-key-typeahead"
|
ouiaId="set-key-typeahead"
|
||||||
@@ -299,12 +302,14 @@ AdvancedSearch.propTypes = {
|
|||||||
searchableKeys: PropTypes.arrayOf(PropTypes.string),
|
searchableKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
relatedSearchableKeys: PropTypes.arrayOf(PropTypes.string),
|
relatedSearchableKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
maxSelectHeight: PropTypes.string,
|
maxSelectHeight: PropTypes.string,
|
||||||
|
enableNegativeFiltering: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
AdvancedSearch.defaultProps = {
|
AdvancedSearch.defaultProps = {
|
||||||
searchableKeys: [],
|
searchableKeys: [],
|
||||||
relatedSearchableKeys: [],
|
relatedSearchableKeys: [],
|
||||||
maxSelectHeight: '300px',
|
maxSelectHeight: '300px',
|
||||||
|
enableNegativeFiltering: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AdvancedSearch;
|
export default AdvancedSearch;
|
||||||
|
|||||||
@@ -339,4 +339,28 @@ describe('<AdvancedSearch />', () => {
|
|||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(advancedSearchMock).toBeCalledWith('', 'baz');
|
expect(advancedSearchMock).toBeCalledWith('', 'baz');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Remove not operator from set type', () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<AdvancedSearch
|
||||||
|
onSearch={jest.fn}
|
||||||
|
searchableKeys={['foo', 'bar']}
|
||||||
|
relatedSearchableKeys={['bar', 'baz']}
|
||||||
|
enableNegativeFiltering={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
wrapper
|
||||||
|
.find('Select[aria-label="Set type select"] SelectToggle')
|
||||||
|
.simulate('click');
|
||||||
|
const selectOptions = wrapper.find(
|
||||||
|
'Select[aria-label="Set type select"] SelectOption'
|
||||||
|
);
|
||||||
|
expect(selectOptions).toHaveLength(2);
|
||||||
|
expect(
|
||||||
|
selectOptions.find('SelectOption[id="or-option-select"]').prop('value')
|
||||||
|
).toBe('or');
|
||||||
|
expect(
|
||||||
|
selectOptions.find('SelectOption[id="and-option-select"]').prop('value')
|
||||||
|
).toBe('and');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ const NoOptionDropdown = styled.div`
|
|||||||
|
|
||||||
function Search({
|
function Search({
|
||||||
columns,
|
columns,
|
||||||
|
|
||||||
onSearch,
|
onSearch,
|
||||||
onReplaceSearch,
|
onReplaceSearch,
|
||||||
onRemove,
|
onRemove,
|
||||||
@@ -43,6 +42,7 @@ function Search({
|
|||||||
onShowAdvancedSearch,
|
onShowAdvancedSearch,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
maxSelectHeight,
|
maxSelectHeight,
|
||||||
|
enableNegativeFiltering,
|
||||||
}) {
|
}) {
|
||||||
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
|
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
|
||||||
const [searchKey, setSearchKey] = useState(
|
const [searchKey, setSearchKey] = useState(
|
||||||
@@ -206,6 +206,7 @@ function Search({
|
|||||||
searchableKeys={searchableKeys}
|
searchableKeys={searchableKeys}
|
||||||
relatedSearchableKeys={relatedSearchableKeys}
|
relatedSearchableKeys={relatedSearchableKeys}
|
||||||
maxSelectHeight={maxSelectHeight}
|
maxSelectHeight={maxSelectHeight}
|
||||||
|
enableNegativeFiltering={enableNegativeFiltering}
|
||||||
/>
|
/>
|
||||||
)) ||
|
)) ||
|
||||||
(options && (
|
(options && (
|
||||||
@@ -325,6 +326,7 @@ Search.propTypes = {
|
|||||||
onShowAdvancedSearch: PropTypes.func.isRequired,
|
onShowAdvancedSearch: PropTypes.func.isRequired,
|
||||||
isDisabled: PropTypes.bool,
|
isDisabled: PropTypes.bool,
|
||||||
maxSelectHeight: PropTypes.string,
|
maxSelectHeight: PropTypes.string,
|
||||||
|
enableNegativeFiltering: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
Search.defaultProps = {
|
Search.defaultProps = {
|
||||||
@@ -332,6 +334,7 @@ Search.defaultProps = {
|
|||||||
onRemove: null,
|
onRemove: null,
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
maxSelectHeight: '300px',
|
maxSelectHeight: '300px',
|
||||||
|
enableNegativeFiltering: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withRouter(Search);
|
export default withRouter(Search);
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ const SmartInventoryFormFields = ({ inventory }) => {
|
|||||||
onBlur={() => hostFilterHelpers.setTouched()}
|
onBlur={() => hostFilterHelpers.setTouched()}
|
||||||
isValid={!hostFilterMeta.touched || !hostFilterMeta.error}
|
isValid={!hostFilterMeta.touched || !hostFilterMeta.error}
|
||||||
isDisabled={!organizationField.value}
|
isDisabled={!organizationField.value}
|
||||||
|
enableNegativeFiltering={false}
|
||||||
/>
|
/>
|
||||||
<InstanceGroupsLookup
|
<InstanceGroupsLookup
|
||||||
value={instanceGroupsField.value}
|
value={instanceGroupsField.value}
|
||||||
|
|||||||
Reference in New Issue
Block a user