mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 02:31:03 -03:30
make name default searchColumn for ProjectJobTemplatesList. also add helpful error message to tell you this is the issue
This commit is contained in:
committed by
John Mitchell
parent
f24654fb26
commit
f8bd8abc82
@@ -43,7 +43,17 @@ function Search({
|
|||||||
}) {
|
}) {
|
||||||
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
|
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
|
||||||
const [searchKey, setSearchKey] = useState(
|
const [searchKey, setSearchKey] = useState(
|
||||||
columns.find(col => col.isDefault).key
|
(() => {
|
||||||
|
const defaultColumn = columns.filter(col => col.isDefault);
|
||||||
|
|
||||||
|
if (defaultColumn.length !== 1) {
|
||||||
|
throw new Error(
|
||||||
|
'One (and only one) searchColumn must be marked isDefault: true'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultColumn[0]?.key;
|
||||||
|
})()
|
||||||
);
|
);
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
const [isFilterDropdownOpen, setIsFilterDropdownOpen] = useState(false);
|
const [isFilterDropdownOpen, setIsFilterDropdownOpen] = useState(false);
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ function ProjectJobTemplatesList({ i18n }) {
|
|||||||
qsConfig={QS_CONFIG}
|
qsConfig={QS_CONFIG}
|
||||||
onRowClick={handleSelect}
|
onRowClick={handleSelect}
|
||||||
toolbarSearchColumns={[
|
toolbarSearchColumns={[
|
||||||
|
{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name__icontains',
|
||||||
|
isDefault: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: i18n._(t`Created By (Username)`),
|
name: i18n._(t`Created By (Username)`),
|
||||||
key: 'created_by__username__icontains',
|
key: 'created_by__username__icontains',
|
||||||
|
|||||||
Reference in New Issue
Block a user