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