Merge pull request #12078 from AlexSCorey/12058-CleanUpReactWarnings

Cleans up some console warnings.
This commit is contained in:
JST 2022-05-02 13:13:20 -03:00 committed by GitHub
commit 213983a322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 13 deletions

View File

@ -49,9 +49,8 @@ function CredentialList() {
CredentialsAPI.readOptions(),
]);
const searchKeys = getSearchableKeys(credActions.data.actions?.GET);
const item = searchKeys.indexOf('type');
if (item) {
searchKeys[item] = 'credential_type__kind';
if (credActions.data.actions?.GET.type) {
searchKeys.push({ key: 'credential_type__kind', type: 'string' });
}
return {
credentials: creds.data.results,

View File

@ -14,6 +14,7 @@ import PaginatedTable, {
ToolbarAddButton,
ToolbarDeleteButton,
ToolbarSyncSourceButton,
getSearchableKeys,
} from 'components/PaginatedTable';
import useSelected from 'hooks/useSelected';
import DatalistToolbar from 'components/DataListToolbar';
@ -57,9 +58,7 @@ function InventorySourceList() {
sourceCount: results[0].data.count,
sourceChoices: results[1].data.actions.GET.source.choices,
sourceChoicesOptions: results[1].data.actions,
searchableKeys: Object.keys(results[1].data.actions?.GET || {}).filter(
(key) => results[1].data.actions?.GET[key].filterable
),
searchableKeys: getSearchableKeys(results[1].data.actions?.GET),
relatedSearchableKeys: (
results[1]?.data?.related_search_fields || []
).map((val) => val.slice(0, -8)),

View File

@ -115,8 +115,8 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
const [jobStatus, setJobStatus] = useState(job.status ?? 'waiting');
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 [onReadyEvents, setOnReadyEvents] = useState([]);

View File

@ -49,6 +49,7 @@ export default function useJobEvents(callbacks, jobId, isFlatMode) {
useEffect(() => {
if (isFlatMode) {
callbacks.setJobTreeReady();
return;
}

View File

@ -5,7 +5,6 @@ import useJobEvents, {
jobEventsReducer,
ADD_EVENTS,
TOGGLE_NODE_COLLAPSED,
SET_EVENT_NUM_CHILDREN,
} from './useJobEvents';
function Child() {
@ -16,6 +15,7 @@ function HookTest({
fetchChildrenSummary = () => {},
setForceFlatMode = () => {},
setJobTreeReady = () => {},
jobId = 1,
isFlatMode = false,
}) {
const hookFuncs = useJobEvents(
@ -25,6 +25,7 @@ function HookTest({
setForceFlatMode,
setJobTreeReady,
},
jobId,
isFlatMode
);
return <Child id="test" {...hookFuncs} />;
@ -1295,18 +1296,24 @@ describe('useJobEvents', () => {
describe('getTotalNumChildren', () => {
let wrapper;
beforeEach(() => {
test('should not make call to get child events, because there are none for this job type', () => {
wrapper = shallow(<HookTest />);
wrapper.find('#test').prop('addEvents')(eventsList);
expect(callbacks.fetchChildrenSummary).not.toBeCalled();
});
test('should get basic number of children', () => {
wrapper = shallow(<HookTest />);
wrapper.find('#test').prop('addEvents')(eventsList);
expect(
wrapper.find('#test').prop('getTotalNumChildren')('abc-002')
).toEqual(3);
});
test('should get total number of nested children', () => {
wrapper = shallow(<HookTest />);
wrapper.find('#test').prop('addEvents')(eventsList);
expect(
wrapper.find('#test').prop('getTotalNumChildren')('abc-001')
).toEqual(8);

View File

@ -5,6 +5,7 @@ import { t } from '@lingui/macro';
import PaginatedTable, {
HeaderRow,
HeaderCell,
getSearchableKeys,
} from 'components/PaginatedTable';
import useRequest from 'hooks/useRequest';
import { UsersAPI } from 'api';
@ -40,9 +41,7 @@ function UserOrganizationList() {
UsersAPI.readOrganizationOptions(id),
]);
return {
searchableKeys: Object.keys(actions.data.actions?.GET || {}).filter(
(key) => actions.data.actions?.GET[key].filterable
),
searchableKeys: getSearchableKeys(actions.data.actions?.GET),
relatedSearchableKeys: (actions?.data?.related_search_fields || []).map(
(val) => val.slice(0, -8)
),