From 2c953ed7d0e4dc481809e3902bef60e2d00f3c6b Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 18 Dec 2019 17:02:37 -0500 Subject: [PATCH] add keys to search on lookups --- .../components/Lookup/CredentialLookup.jsx | 23 +++++++++ .../Lookup/InstanceGroupsLookup.jsx | 9 ++-- .../src/components/Lookup/InventoryLookup.jsx | 9 ++-- .../Lookup/MultiCredentialsLookup.jsx | 17 +++++-- .../components/Lookup/OrganizationLookup.jsx | 16 +++--- .../src/components/Lookup/ProjectLookup.jsx | 50 +++++++++++++++++++ .../Lookup/shared/OptionsList.test.jsx | 6 ++- 7 files changed, 110 insertions(+), 20 deletions(-) diff --git a/awx/ui_next/src/components/Lookup/CredentialLookup.jsx b/awx/ui_next/src/components/Lookup/CredentialLookup.jsx index 6b61b3c486..7596a8a5a1 100644 --- a/awx/ui_next/src/components/Lookup/CredentialLookup.jsx +++ b/awx/ui_next/src/components/Lookup/CredentialLookup.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { bool, func, number, string, oneOfType } from 'prop-types'; import { withRouter } from 'react-router-dom'; import { withI18n } from '@lingui/react'; +import { t } from '@lingui/macro'; import { CredentialsAPI } from '@api'; import { Credential } from '@types'; import { getQSConfig, parseQueryString, mergeParams } from '@util/qs'; @@ -26,6 +27,7 @@ function CredentialLookup({ credentialTypeId, value, history, + i18n }) { const [credentials, setCredentials] = useState([]); const [count, setCount] = useState(0); @@ -48,6 +50,8 @@ function CredentialLookup({ })(); }, [credentialTypeId, history.location.search]); + // TODO: replace credential type search with REST-based grabbing of cred types + return ( dispatch({ type: 'SELECT_ITEM', item })} deselectItem={item => dispatch({ type: 'DESELECT_ITEM', item })} diff --git a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx index 129eaf89d1..11e6f34f2a 100644 --- a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx +++ b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx @@ -68,14 +68,15 @@ function InstanceGroupsLookup(props) { { name: i18n._(t`Name`), key: 'name', + isDefault: true }, { - name: i18n._(t`Modified`), - key: 'modified', + name: i18n._(t`Created by (username)`), + key: 'created_by__username', }, { - name: i18n._(t`Created`), - key: 'created', + name: i18n._(t`Modified by (username)`), + key: 'modified_by__username', }, ]} sortColumns={[{ diff --git a/awx/ui_next/src/components/Lookup/InventoryLookup.jsx b/awx/ui_next/src/components/Lookup/InventoryLookup.jsx index 67cd6bc965..3be88878d6 100644 --- a/awx/ui_next/src/components/Lookup/InventoryLookup.jsx +++ b/awx/ui_next/src/components/Lookup/InventoryLookup.jsx @@ -72,14 +72,15 @@ function InventoryLookup({ { name: i18n._(t`Name`), key: 'name', + isDefault: true }, { - name: i18n._(t`Modified`), - key: 'modified', + name: i18n._(t`Created by (username)`), + key: 'created_by__username', }, { - name: i18n._(t`Created`), - key: 'created', + name: i18n._(t`Modified by (username)`), + key: 'modified_by__username', }, ]} sortColumns={[{ diff --git a/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx b/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx index 1effa9282d..c7d360cc4e 100644 --- a/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx +++ b/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx @@ -122,14 +122,25 @@ function MultiCredentialsLookup(props) { value={state.selectedItems} options={credentials} optionCount={credentialsCount} - columns={[ + searchColumns={[ { name: i18n._(t`Name`), key: 'name', - isSortable: true, - isSearchable: true, + 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' + }]} multiple={isMultiple} header={i18n._(t`Credentials`)} name="credentials" diff --git a/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx b/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx index 87c7ec3275..1d747f88b1 100644 --- a/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx +++ b/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx @@ -77,16 +77,18 @@ function OrganizationLookup({ isDefault: true }, { - name: i18n._(t`Team name`), - key: 'teams__name', - } - ]} - sortColumns={[ + name: i18n._(t`Created by (username)`), + key: 'created_by__username', + }, { - name: i18n._(t`Name`), - key: 'name', + name: i18n._(t`Modified by (username)`), + key: 'modified_by__username', }, ]} + sortColumns={[{ + name: i18n._(t`Name`), + key: 'name' + }]} readOnly={!canDelete} selectItem={item => dispatch({ type: 'SELECT_ITEM', item })} deselectItem={item => dispatch({ type: 'DESELECT_ITEM', item })} diff --git a/awx/ui_next/src/components/Lookup/ProjectLookup.jsx b/awx/ui_next/src/components/Lookup/ProjectLookup.jsx index 983a214661..e2577ab29f 100644 --- a/awx/ui_next/src/components/Lookup/ProjectLookup.jsx +++ b/awx/ui_next/src/components/Lookup/ProjectLookup.jsx @@ -70,6 +70,56 @@ function ProjectLookup({ renderOptionsList={({ state, dispatch, canDelete }) => ( ', () => { value={[]} options={options} optionCount={3} - columns={[]} + searchColumns={[]} + sortColumns={[]} qsConfig={qsConfig} selectItem={() => {}} deselectItem={() => {}} @@ -39,7 +40,8 @@ describe('', () => { value={[options[1]]} options={options} optionCount={3} - columns={[]} + searchColumns={[]} + sortColumns={[]} qsConfig={qsConfig} selectItem={() => {}} deselectItem={() => {}}