Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update existing relatedSearchKey requests to new convention and fix U… #7895

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions awx/ui_next/src/components/JobList/JobList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) {
const [selected, setSelected] = useState([]);
const location = useLocation();
const {
result: { results, count, actions, relatedSearchFields },
result: { results, count, relatedSearchableKeys, searchableKeys },
error: contentError,
isLoading,
request: fetchJobs,
Expand All @@ -53,19 +53,21 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) {
return {
results: response.data.results,
count: response.data.count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
},
[location] // eslint-disable-line react-hooks/exhaustive-deps
),
{
results: [],
count: 0,
actions: {},
relatedSearchFields: [],
relatedSearchableKeys: [],
searchableKeys: [],
}
);
useEffect(() => {
Expand Down Expand Up @@ -138,11 +140,6 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) {
}
};

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<>
<Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function CredentialsStep({ i18n }) {
}, [fetchTypes]);

const {
result: { credentials, count, actions, relatedSearchFields },
result: { credentials, count, relatedSearchableKeys, searchableKeys },
error: credentialsError,
isLoading: isCredentialsLoading,
request: fetchCredentials,
Expand All @@ -72,13 +72,15 @@ function CredentialsStep({ i18n }) {
return {
credentials: data.results,
count: data.count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [selectedType, history.location.search]),
{ credentials: [], count: 0, actions: {}, relatedSearchFields: [] }
{ credentials: [], count: 0, relatedSearchableKeys: [], searchableKeys: [] }
);

useEffect(() => {
Expand All @@ -104,11 +106,6 @@ function CredentialsStep({ i18n }) {
/>
);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<>
{types && types.length > 0 && (
Expand Down
17 changes: 7 additions & 10 deletions awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function InventoryStep({ i18n }) {
const {
isLoading,
error,
result: { inventories, count, actions, relatedSearchFields },
result: { inventories, count, relatedSearchableKeys, searchableKeys },
request: fetchInventories,
} = useRequest(
useCallback(async () => {
Expand All @@ -39,29 +39,26 @@ function InventoryStep({ i18n }) {
return {
inventories: data.results,
count: data.count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [history.location]),
{
count: 0,
inventories: [],
actions: {},
relatedSearchFields: [],
relatedSearchableKeys: [],
searchableKeys: [],
}
);

useEffect(() => {
fetchInventories();
}, [fetchInventories]);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

if (isLoading) {
return <ContentLoading />;
}
Expand Down
21 changes: 11 additions & 10 deletions awx/ui_next/src/components/Lookup/ApplicationLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ApplicationLookup({ i18n, onChange, value, label }) {
const location = useLocation();
const {
error,
result: { applications, itemCount, actions, relatedSearchFields },
result: { applications, itemCount, relatedSearchableKeys, searchableKeys },
request: fetchApplications,
} = useRequest(
useCallback(async () => {
Expand All @@ -40,23 +40,24 @@ function ApplicationLookup({ i18n, onChange, value, label }) {
return {
applications: results,
itemCount: count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [location]),
{ applications: [], itemCount: 0, actions: {}, relatedSearchFields: [] }
{
applications: [],
itemCount: 0,
relatedSearchableKeys: [],
searchableKeys: [],
}
);
useEffect(() => {
fetchApplications();
}, [fetchApplications]);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<FormGroup fieldId="application" label={label}>
<Lookup
Expand Down
17 changes: 7 additions & 10 deletions awx/ui_next/src/components/Lookup/CredentialLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function CredentialLookup({
tooltip,
}) {
const {
result: { count, credentials, actions, relatedSearchFields },
result: { count, credentials, relatedSearchableKeys, searchableKeys },
error,
request: fetchCredentials,
} = useRequest(
Expand Down Expand Up @@ -64,10 +64,12 @@ function CredentialLookup({
return {
count: data.count,
credentials: data.results,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [
credentialTypeId,
Expand All @@ -78,20 +80,15 @@ function CredentialLookup({
{
count: 0,
credentials: [],
actions: {},
relatedSearchFields: [],
relatedSearchableKeys: [],
searchableKeys: [],
}
);

useEffect(() => {
fetchCredentials();
}, [fetchCredentials]);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

// TODO: replace credential type search with REST-based grabbing of cred types

return (
Expand Down
20 changes: 11 additions & 9 deletions awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function InstanceGroupsLookup(props) {
} = props;

const {
result: { instanceGroups, count, actions, relatedSearchFields },
result: { instanceGroups, count, relatedSearchableKeys, searchableKeys },
request: fetchInstanceGroups,
error,
isLoading,
Expand All @@ -44,24 +44,26 @@ function InstanceGroupsLookup(props) {
return {
instanceGroups: data.results,
count: data.count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [history.location]),
{ instanceGroups: [], count: 0, actions: {}, relatedSearchFields: [] }
{
instanceGroups: [],
count: 0,
relatedSearchableKeys: [],
searchableKeys: [],
}
);

useEffect(() => {
fetchInstanceGroups();
}, [fetchInstanceGroups]);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<FormGroup
className={className}
Expand Down
15 changes: 6 additions & 9 deletions awx/ui_next/src/components/Lookup/InventoryLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const QS_CONFIG = getQSConfig('inventory', {

function InventoryLookup({ value, onChange, onBlur, required, i18n, history }) {
const {
result: { inventories, count, actions, relatedSearchFields },
result: { inventories, count, relatedSearchableKeys, searchableKeys },
request: fetchInventories,
error,
isLoading,
Expand All @@ -33,24 +33,21 @@ function InventoryLookup({ value, onChange, onBlur, required, i18n, history }) {
return {
inventories: data.results,
count: data.count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [history.location]),
{ inventories: [], count: 0, actions: {}, relatedSearchFields: [] }
{ inventories: [], count: 0, relatedSearchableKeys: [], searchableKeys: [] }
);

useEffect(() => {
fetchInventories();
}, [fetchInventories]);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<>
<Lookup
Expand Down
22 changes: 12 additions & 10 deletions awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ function MultiCredentialsLookup(props) {
}, [fetchTypes]);

const {
result: { credentials, credentialsCount, actions, relatedSearchFields },
result: {
credentials,
credentialsCount,
relatedSearchableKeys,
searchableKeys,
},
request: fetchCredentials,
error: credentialsError,
isLoading: isCredentialsLoading,
Expand All @@ -69,17 +74,19 @@ function MultiCredentialsLookup(props) {
return {
credentials: results,
credentialsCount: count,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [selectedType, history.location]),
{
credentials: [],
credentialsCount: 0,
actions: {},
relatedSearchFields: [],
relatedSearchableKeys: [],
searchableKeys: [],
}
);

Expand All @@ -104,11 +111,6 @@ function MultiCredentialsLookup(props) {

const isVault = selectedType?.kind === 'vault';

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<Lookup
id="multiCredential"
Expand Down
17 changes: 7 additions & 10 deletions awx/ui_next/src/components/Lookup/ProjectLookup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function ProjectLookup({
history,
}) {
const {
result: { projects, count, actions, relatedSearchFields },
result: { projects, count, relatedSearchableKeys, searchableKeys },
request: fetchProjects,
error,
isLoading,
Expand All @@ -49,29 +49,26 @@ function ProjectLookup({
return {
count: data.count,
projects: data.results,
actions: actionsResponse.data.actions,
relatedSearchFields: (
relatedSearchableKeys: (
actionsResponse?.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [history.location.search, autocomplete]),
{
count: 0,
projects: [],
actions: {},
relatedSearchFields: [],
relatedSearchableKeys: [],
searchableKeys: [],
}
);

useEffect(() => {
fetchProjects();
}, [fetchProjects]);

const relatedSearchableKeys = relatedSearchFields || [];
const searchableKeys = Object.keys(actions?.GET || {}).filter(
key => actions.GET[key].filterable
);

return (
<FormGroup
fieldId="project"
Expand Down
Loading