mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Address errors from type system
This commit is contained in:
parent
d05ffd24f4
commit
6223a78ff4
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect, useContext } from 'react';
|
||||
import { arrayOf, func, object, string } from 'prop-types';
|
||||
import { arrayOf, func, shape, string, oneOfType, number } from 'prop-types';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { Button, Tooltip, DropdownItem } from '@patternfly/react-core';
|
||||
@ -149,7 +149,20 @@ DisassociateButton.defaultProps = {
|
||||
};
|
||||
|
||||
DisassociateButton.propTypes = {
|
||||
itemsToDisassociate: arrayOf(object),
|
||||
itemsToDisassociate: oneOfType([
|
||||
arrayOf(
|
||||
shape({
|
||||
id: number.isRequired,
|
||||
name: string.isRequired,
|
||||
})
|
||||
),
|
||||
arrayOf(
|
||||
shape({
|
||||
id: number.isRequired,
|
||||
hostname: string.isRequired,
|
||||
})
|
||||
),
|
||||
]),
|
||||
modalNote: string,
|
||||
modalTitle: string,
|
||||
onDisassociate: func.isRequired,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import React, { useCallback, useEffect } from 'react';
|
||||
import { arrayOf, string, func, object, bool } from 'prop-types';
|
||||
import { arrayOf, string, func, bool } from 'prop-types';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { FormGroup } from '@patternfly/react-core';
|
||||
import { InstanceGroupsAPI } from '../../api';
|
||||
import { InstanceGroup } from '../../types';
|
||||
import { getQSConfig, parseQueryString } from '../../util/qs';
|
||||
import Popover from '../Popover';
|
||||
import OptionsList from '../OptionsList';
|
||||
@ -120,7 +121,7 @@ function InstanceGroupsLookup(props) {
|
||||
}
|
||||
|
||||
InstanceGroupsLookup.propTypes = {
|
||||
value: arrayOf(object).isRequired,
|
||||
value: arrayOf(InstanceGroup).isRequired,
|
||||
tooltip: string,
|
||||
onChange: func.isRequired,
|
||||
className: string,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { arrayOf, object } from 'prop-types';
|
||||
import { arrayOf } from 'prop-types';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { Link as _Link } from 'react-router-dom';
|
||||
import { Tooltip } from '@patternfly/react-core';
|
||||
@ -8,6 +8,7 @@ import { t } from '@lingui/macro';
|
||||
import StatusIcon from '../StatusIcon';
|
||||
import { formatDateString } from '../../util/dates';
|
||||
import { JOB_TYPE_URL_SEGMENTS } from '../../constants';
|
||||
import { Job } from '../../types';
|
||||
|
||||
/* eslint-disable react/jsx-pascal-case */
|
||||
const Link = styled(props => <_Link {...props} />)`
|
||||
@ -52,7 +53,7 @@ const Sparkline = ({ i18n, jobs }) => {
|
||||
};
|
||||
|
||||
Sparkline.propTypes = {
|
||||
jobs: arrayOf(object),
|
||||
jobs: arrayOf(Job),
|
||||
};
|
||||
Sparkline.defaultProps = {
|
||||
jobs: [],
|
||||
|
||||
@ -47,7 +47,13 @@ describe('<SmartInventoryEdit />', () => {
|
||||
data: { actions: { POST: true } },
|
||||
});
|
||||
InventoriesAPI.readInstanceGroups.mockResolvedValue({
|
||||
data: { count: 0, results: [{ id: 10 }, { id: 20 }] },
|
||||
data: {
|
||||
count: 0,
|
||||
results: [
|
||||
{ id: 10, name: 'instance-group-10' },
|
||||
{ id: 20, name: 'instance-group-20' },
|
||||
],
|
||||
},
|
||||
});
|
||||
history = createMemoryHistory({
|
||||
initialEntries: [`/inventories/smart_inventory/${mockSmartInv.id}/edit`],
|
||||
@ -85,7 +91,10 @@ describe('<SmartInventoryEdit />', () => {
|
||||
await act(async () => {
|
||||
wrapper.find('SmartInventoryForm').invoke('onSubmit')({
|
||||
...mockSmartInv,
|
||||
instance_groups: [{ id: 10 }, { id: 30 }],
|
||||
instance_groups: [
|
||||
{ id: 10, name: 'instance-group-10' },
|
||||
{ id: 30, name: 'instance-group-30' },
|
||||
],
|
||||
});
|
||||
});
|
||||
expect(InventoriesAPI.update).toHaveBeenCalledTimes(1);
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import 'styled-components/macro';
|
||||
import React, { useState, useContext, useEffect } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { func, bool, arrayOf, object } from 'prop-types';
|
||||
import { func, bool, arrayOf } from 'prop-types';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { Button, Radio, DropdownItem } from '@patternfly/react-core';
|
||||
import styled from 'styled-components';
|
||||
import { KebabifiedContext } from '../../../contexts/Kebabified';
|
||||
import { GroupsAPI, InventoriesAPI } from '../../../api';
|
||||
import { Group } from '../../../types';
|
||||
import ErrorDetail from '../../../components/ErrorDetail';
|
||||
import AlertModal from '../../../components/AlertModal';
|
||||
|
||||
@ -158,7 +159,7 @@ const InventoryGroupsDeleteModal = ({
|
||||
|
||||
InventoryGroupsDeleteModal.propTypes = {
|
||||
onAfterDelete: func.isRequired,
|
||||
groups: arrayOf(object),
|
||||
groups: arrayOf(Group),
|
||||
isDisabled: bool.isRequired,
|
||||
};
|
||||
|
||||
|
||||
@ -2,8 +2,9 @@ import React, { useEffect, useCallback } from 'react';
|
||||
import { Formik, useField, useFormikContext } from 'formik';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { func, shape, object, arrayOf } from 'prop-types';
|
||||
import { func, shape, arrayOf } from 'prop-types';
|
||||
import { Form } from '@patternfly/react-core';
|
||||
import { InstanceGroup } from '../../../types';
|
||||
import { VariablesField } from '../../../components/CodeMirrorInput';
|
||||
import ContentError from '../../../components/ContentError';
|
||||
import ContentLoading from '../../../components/ContentLoading';
|
||||
@ -168,7 +169,7 @@ function SmartInventoryForm({
|
||||
}
|
||||
|
||||
SmartInventoryForm.propTypes = {
|
||||
instanceGroups: arrayOf(object),
|
||||
instanceGroups: arrayOf(InstanceGroup),
|
||||
inventory: shape({}),
|
||||
onCancel: func.isRequired,
|
||||
onSubmit: func.isRequired,
|
||||
|
||||
@ -27,7 +27,7 @@ const mockFormValues = {
|
||||
organization: { id: 1, name: 'mock organization' },
|
||||
host_filter:
|
||||
'name__icontains=mock and name__icontains=foo and groups__name__icontains=mock group',
|
||||
instance_groups: [{ id: 123 }],
|
||||
instance_groups: [{ id: 123, name: 'mock instance group' }],
|
||||
variables: '---',
|
||||
};
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ export function mountWithContexts(node, options = {}) {
|
||||
const context = applyDefaultContexts(options.context);
|
||||
const childContextTypes = {
|
||||
linguiPublisher: shape({
|
||||
i18n: object.isRequired,
|
||||
i18n: object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||
}).isRequired,
|
||||
config: shape({
|
||||
ansible_version: string,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user