mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 07:56:06 -03:30
Cleans up some console warnings.
This commit is contained in:
@@ -49,9 +49,8 @@ function CredentialList() {
|
|||||||
CredentialsAPI.readOptions(),
|
CredentialsAPI.readOptions(),
|
||||||
]);
|
]);
|
||||||
const searchKeys = getSearchableKeys(credActions.data.actions?.GET);
|
const searchKeys = getSearchableKeys(credActions.data.actions?.GET);
|
||||||
const item = searchKeys.indexOf('type');
|
if (credActions.data.actions?.GET.type) {
|
||||||
if (item) {
|
searchKeys.push({ key: 'credential_type__kind', type: 'string' });
|
||||||
searchKeys[item] = 'credential_type__kind';
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
credentials: creds.data.results,
|
credentials: creds.data.results,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import PaginatedTable, {
|
|||||||
ToolbarAddButton,
|
ToolbarAddButton,
|
||||||
ToolbarDeleteButton,
|
ToolbarDeleteButton,
|
||||||
ToolbarSyncSourceButton,
|
ToolbarSyncSourceButton,
|
||||||
|
getSearchableKeys,
|
||||||
} from 'components/PaginatedTable';
|
} from 'components/PaginatedTable';
|
||||||
import useSelected from 'hooks/useSelected';
|
import useSelected from 'hooks/useSelected';
|
||||||
import DatalistToolbar from 'components/DataListToolbar';
|
import DatalistToolbar from 'components/DataListToolbar';
|
||||||
@@ -57,9 +58,7 @@ function InventorySourceList() {
|
|||||||
sourceCount: results[0].data.count,
|
sourceCount: results[0].data.count,
|
||||||
sourceChoices: results[1].data.actions.GET.source.choices,
|
sourceChoices: results[1].data.actions.GET.source.choices,
|
||||||
sourceChoicesOptions: results[1].data.actions,
|
sourceChoicesOptions: results[1].data.actions,
|
||||||
searchableKeys: Object.keys(results[1].data.actions?.GET || {}).filter(
|
searchableKeys: getSearchableKeys(results[1].data.actions?.GET),
|
||||||
(key) => results[1].data.actions?.GET[key].filterable
|
|
||||||
),
|
|
||||||
relatedSearchableKeys: (
|
relatedSearchableKeys: (
|
||||||
results[1]?.data?.related_search_fields || []
|
results[1]?.data?.related_search_fields || []
|
||||||
).map((val) => val.slice(0, -8)),
|
).map((val) => val.slice(0, -8)),
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
|
|||||||
|
|
||||||
const [jobStatus, setJobStatus] = useState(job.status ?? 'waiting');
|
const [jobStatus, setJobStatus] = useState(job.status ?? 'waiting');
|
||||||
const [forceFlatMode, setForceFlatMode] = useState(false);
|
const [forceFlatMode, setForceFlatMode] = useState(false);
|
||||||
const isFlatMode = isJobRunning(jobStatus) || location.search.length > 1;
|
const isFlatMode =
|
||||||
|
isJobRunning(jobStatus) || location.search.length > 1 || job.type !== 'job';
|
||||||
const [isTreeReady, setIsTreeReady] = useState(false);
|
const [isTreeReady, setIsTreeReady] = useState(false);
|
||||||
const [onReadyEvents, setOnReadyEvents] = useState([]);
|
const [onReadyEvents, setOnReadyEvents] = useState([]);
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ export default function useJobEvents(callbacks, jobId, isFlatMode) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isFlatMode) {
|
if (isFlatMode) {
|
||||||
|
callbacks.setJobTreeReady();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import useJobEvents, {
|
|||||||
jobEventsReducer,
|
jobEventsReducer,
|
||||||
ADD_EVENTS,
|
ADD_EVENTS,
|
||||||
TOGGLE_NODE_COLLAPSED,
|
TOGGLE_NODE_COLLAPSED,
|
||||||
SET_EVENT_NUM_CHILDREN,
|
|
||||||
} from './useJobEvents';
|
} from './useJobEvents';
|
||||||
|
|
||||||
function Child() {
|
function Child() {
|
||||||
@@ -16,6 +15,7 @@ function HookTest({
|
|||||||
fetchChildrenSummary = () => {},
|
fetchChildrenSummary = () => {},
|
||||||
setForceFlatMode = () => {},
|
setForceFlatMode = () => {},
|
||||||
setJobTreeReady = () => {},
|
setJobTreeReady = () => {},
|
||||||
|
jobId = 1,
|
||||||
isFlatMode = false,
|
isFlatMode = false,
|
||||||
}) {
|
}) {
|
||||||
const hookFuncs = useJobEvents(
|
const hookFuncs = useJobEvents(
|
||||||
@@ -25,6 +25,7 @@ function HookTest({
|
|||||||
setForceFlatMode,
|
setForceFlatMode,
|
||||||
setJobTreeReady,
|
setJobTreeReady,
|
||||||
},
|
},
|
||||||
|
jobId,
|
||||||
isFlatMode
|
isFlatMode
|
||||||
);
|
);
|
||||||
return <Child id="test" {...hookFuncs} />;
|
return <Child id="test" {...hookFuncs} />;
|
||||||
@@ -1295,18 +1296,24 @@ describe('useJobEvents', () => {
|
|||||||
|
|
||||||
describe('getTotalNumChildren', () => {
|
describe('getTotalNumChildren', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
beforeEach(() => {
|
|
||||||
|
test('should not make call to get child events, because there are none for this job type', () => {
|
||||||
wrapper = shallow(<HookTest />);
|
wrapper = shallow(<HookTest />);
|
||||||
wrapper.find('#test').prop('addEvents')(eventsList);
|
wrapper.find('#test').prop('addEvents')(eventsList);
|
||||||
|
expect(callbacks.fetchChildrenSummary).not.toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should get basic number of children', () => {
|
test('should get basic number of children', () => {
|
||||||
|
wrapper = shallow(<HookTest />);
|
||||||
|
wrapper.find('#test').prop('addEvents')(eventsList);
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('#test').prop('getTotalNumChildren')('abc-002')
|
wrapper.find('#test').prop('getTotalNumChildren')('abc-002')
|
||||||
).toEqual(3);
|
).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should get total number of nested children', () => {
|
test('should get total number of nested children', () => {
|
||||||
|
wrapper = shallow(<HookTest />);
|
||||||
|
wrapper.find('#test').prop('addEvents')(eventsList);
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('#test').prop('getTotalNumChildren')('abc-001')
|
wrapper.find('#test').prop('getTotalNumChildren')('abc-001')
|
||||||
).toEqual(8);
|
).toEqual(8);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { t } from '@lingui/macro';
|
|||||||
import PaginatedTable, {
|
import PaginatedTable, {
|
||||||
HeaderRow,
|
HeaderRow,
|
||||||
HeaderCell,
|
HeaderCell,
|
||||||
|
getSearchableKeys,
|
||||||
} from 'components/PaginatedTable';
|
} from 'components/PaginatedTable';
|
||||||
import useRequest from 'hooks/useRequest';
|
import useRequest from 'hooks/useRequest';
|
||||||
import { UsersAPI } from 'api';
|
import { UsersAPI } from 'api';
|
||||||
@@ -40,9 +41,7 @@ function UserOrganizationList() {
|
|||||||
UsersAPI.readOrganizationOptions(id),
|
UsersAPI.readOrganizationOptions(id),
|
||||||
]);
|
]);
|
||||||
return {
|
return {
|
||||||
searchableKeys: Object.keys(actions.data.actions?.GET || {}).filter(
|
searchableKeys: getSearchableKeys(actions.data.actions?.GET),
|
||||||
(key) => actions.data.actions?.GET[key].filterable
|
|
||||||
),
|
|
||||||
relatedSearchableKeys: (actions?.data?.related_search_fields || []).map(
|
relatedSearchableKeys: (actions?.data?.related_search_fields || []).map(
|
||||||
(val) => val.slice(0, -8)
|
(val) => val.slice(0, -8)
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user