mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
add keys to search on lookups
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import { bool, func, number, string, oneOfType } from 'prop-types';
|
import { bool, func, number, string, oneOfType } from 'prop-types';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
import { CredentialsAPI } from '@api';
|
import { CredentialsAPI } from '@api';
|
||||||
import { Credential } from '@types';
|
import { Credential } from '@types';
|
||||||
import { getQSConfig, parseQueryString, mergeParams } from '@util/qs';
|
import { getQSConfig, parseQueryString, mergeParams } from '@util/qs';
|
||||||
@@ -26,6 +27,7 @@ function CredentialLookup({
|
|||||||
credentialTypeId,
|
credentialTypeId,
|
||||||
value,
|
value,
|
||||||
history,
|
history,
|
||||||
|
i18n
|
||||||
}) {
|
}) {
|
||||||
const [credentials, setCredentials] = useState([]);
|
const [credentials, setCredentials] = useState([]);
|
||||||
const [count, setCount] = useState(0);
|
const [count, setCount] = useState(0);
|
||||||
@@ -48,6 +50,8 @@ function CredentialLookup({
|
|||||||
})();
|
})();
|
||||||
}, [credentialTypeId, history.location.search]);
|
}, [credentialTypeId, history.location.search]);
|
||||||
|
|
||||||
|
// TODO: replace credential type search with REST-based grabbing of cred types
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
fieldId="credential"
|
fieldId="credential"
|
||||||
@@ -71,6 +75,25 @@ function CredentialLookup({
|
|||||||
optionCount={count}
|
optionCount={count}
|
||||||
header={label}
|
header={label}
|
||||||
qsConfig={QS_CONFIG}
|
qsConfig={QS_CONFIG}
|
||||||
|
searchColumns={[
|
||||||
|
{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name',
|
||||||
|
isDefault: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Created by (username)`),
|
||||||
|
key: 'created_by__username',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Modified by (username)`),
|
||||||
|
key: 'modified_by__username',
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
sortColumns={[{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name'
|
||||||
|
}]}
|
||||||
readOnly={!canDelete}
|
readOnly={!canDelete}
|
||||||
selectItem={item => dispatch({ type: 'SELECT_ITEM', item })}
|
selectItem={item => dispatch({ type: 'SELECT_ITEM', item })}
|
||||||
deselectItem={item => dispatch({ type: 'DESELECT_ITEM', item })}
|
deselectItem={item => dispatch({ type: 'DESELECT_ITEM', item })}
|
||||||
|
|||||||
@@ -68,14 +68,15 @@ function InstanceGroupsLookup(props) {
|
|||||||
{
|
{
|
||||||
name: i18n._(t`Name`),
|
name: i18n._(t`Name`),
|
||||||
key: 'name',
|
key: 'name',
|
||||||
|
isDefault: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: i18n._(t`Modified`),
|
name: i18n._(t`Created by (username)`),
|
||||||
key: 'modified',
|
key: 'created_by__username',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: i18n._(t`Created`),
|
name: i18n._(t`Modified by (username)`),
|
||||||
key: 'created',
|
key: 'modified_by__username',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
sortColumns={[{
|
sortColumns={[{
|
||||||
|
|||||||
@@ -72,14 +72,15 @@ function InventoryLookup({
|
|||||||
{
|
{
|
||||||
name: i18n._(t`Name`),
|
name: i18n._(t`Name`),
|
||||||
key: 'name',
|
key: 'name',
|
||||||
|
isDefault: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: i18n._(t`Modified`),
|
name: i18n._(t`Created by (username)`),
|
||||||
key: 'modified',
|
key: 'created_by__username',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: i18n._(t`Created`),
|
name: i18n._(t`Modified by (username)`),
|
||||||
key: 'created',
|
key: 'modified_by__username',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
sortColumns={[{
|
sortColumns={[{
|
||||||
|
|||||||
@@ -122,14 +122,25 @@ function MultiCredentialsLookup(props) {
|
|||||||
value={state.selectedItems}
|
value={state.selectedItems}
|
||||||
options={credentials}
|
options={credentials}
|
||||||
optionCount={credentialsCount}
|
optionCount={credentialsCount}
|
||||||
columns={[
|
searchColumns={[
|
||||||
{
|
{
|
||||||
name: i18n._(t`Name`),
|
name: i18n._(t`Name`),
|
||||||
key: 'name',
|
key: 'name',
|
||||||
isSortable: true,
|
isDefault: true
|
||||||
isSearchable: true,
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Created by (username)`),
|
||||||
|
key: 'created_by__username',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Modified by (username)`),
|
||||||
|
key: 'modified_by__username',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
sortColumns={[{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name'
|
||||||
|
}]}
|
||||||
multiple={isMultiple}
|
multiple={isMultiple}
|
||||||
header={i18n._(t`Credentials`)}
|
header={i18n._(t`Credentials`)}
|
||||||
name="credentials"
|
name="credentials"
|
||||||
|
|||||||
@@ -77,16 +77,18 @@ function OrganizationLookup({
|
|||||||
isDefault: true
|
isDefault: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: i18n._(t`Team name`),
|
name: i18n._(t`Created by (username)`),
|
||||||
key: 'teams__name',
|
key: 'created_by__username',
|
||||||
}
|
},
|
||||||
]}
|
|
||||||
sortColumns={[
|
|
||||||
{
|
{
|
||||||
name: i18n._(t`Name`),
|
name: i18n._(t`Modified by (username)`),
|
||||||
key: 'name',
|
key: 'modified_by__username',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
sortColumns={[{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name'
|
||||||
|
}]}
|
||||||
readOnly={!canDelete}
|
readOnly={!canDelete}
|
||||||
selectItem={item => dispatch({ type: 'SELECT_ITEM', item })}
|
selectItem={item => dispatch({ type: 'SELECT_ITEM', item })}
|
||||||
deselectItem={item => dispatch({ type: 'DESELECT_ITEM', item })}
|
deselectItem={item => dispatch({ type: 'DESELECT_ITEM', item })}
|
||||||
|
|||||||
@@ -70,6 +70,56 @@ function ProjectLookup({
|
|||||||
renderOptionsList={({ state, dispatch, canDelete }) => (
|
renderOptionsList={({ state, dispatch, canDelete }) => (
|
||||||
<OptionsList
|
<OptionsList
|
||||||
value={state.selectedItems}
|
value={state.selectedItems}
|
||||||
|
searchColumns={[
|
||||||
|
{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name',
|
||||||
|
isDefault: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Type`),
|
||||||
|
options: [
|
||||||
|
[
|
||||||
|
``,
|
||||||
|
i18n._(t`Manual`)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`git`,
|
||||||
|
i18n._(t`Git`)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`hg`,
|
||||||
|
i18n._(t`Mercurial`)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`svn`,
|
||||||
|
i18n._(t`Subversion`)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`insights`,
|
||||||
|
i18n._(t`Red Hat Insights`)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`SCM URL`),
|
||||||
|
key: 'scm_url',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Modified by (username)`),
|
||||||
|
key: 'modified_by__username',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n._(t`Created by (username)`),
|
||||||
|
key: 'created_by__username',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
sortColumns={[
|
||||||
|
{
|
||||||
|
name: i18n._(t`Name`),
|
||||||
|
key: 'name',
|
||||||
|
}
|
||||||
|
]}
|
||||||
options={projects}
|
options={projects}
|
||||||
optionCount={count}
|
optionCount={count}
|
||||||
multiple={state.multiple}
|
multiple={state.multiple}
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ describe('<OptionsList />', () => {
|
|||||||
value={[]}
|
value={[]}
|
||||||
options={options}
|
options={options}
|
||||||
optionCount={3}
|
optionCount={3}
|
||||||
columns={[]}
|
searchColumns={[]}
|
||||||
|
sortColumns={[]}
|
||||||
qsConfig={qsConfig}
|
qsConfig={qsConfig}
|
||||||
selectItem={() => {}}
|
selectItem={() => {}}
|
||||||
deselectItem={() => {}}
|
deselectItem={() => {}}
|
||||||
@@ -39,7 +40,8 @@ describe('<OptionsList />', () => {
|
|||||||
value={[options[1]]}
|
value={[options[1]]}
|
||||||
options={options}
|
options={options}
|
||||||
optionCount={3}
|
optionCount={3}
|
||||||
columns={[]}
|
searchColumns={[]}
|
||||||
|
sortColumns={[]}
|
||||||
qsConfig={qsConfig}
|
qsConfig={qsConfig}
|
||||||
selectItem={() => {}}
|
selectItem={() => {}}
|
||||||
deselectItem={() => {}}
|
deselectItem={() => {}}
|
||||||
|
|||||||
Reference in New Issue
Block a user