diff --git a/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx b/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx index b2fcffa999..39943f88b4 100644 --- a/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx +++ b/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx @@ -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, diff --git a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx index c35ca1b91d..40d7b87d33 100644 --- a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx +++ b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx @@ -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, diff --git a/awx/ui_next/src/components/Sparkline/Sparkline.jsx b/awx/ui_next/src/components/Sparkline/Sparkline.jsx index 306d73204b..c087705953 100644 --- a/awx/ui_next/src/components/Sparkline/Sparkline.jsx +++ b/awx/ui_next/src/components/Sparkline/Sparkline.jsx @@ -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: [], diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx index dea1b1e1ba..90ed4abb6f 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryEdit/SmartInventoryEdit.test.jsx @@ -47,7 +47,13 @@ describe('', () => { 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('', () => { 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); diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryGroupsDeleteModal.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryGroupsDeleteModal.jsx index 908d9d36ce..b371cc31b5 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventoryGroupsDeleteModal.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventoryGroupsDeleteModal.jsx @@ -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, }; diff --git a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx index f6670c3c19..9b82b25a8b 100644 --- a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx @@ -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, diff --git a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx index f7815ec5c6..1f3c1127cc 100644 --- a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.test.jsx @@ -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: '---', }; diff --git a/awx/ui_next/testUtils/enzymeHelpers.jsx b/awx/ui_next/testUtils/enzymeHelpers.jsx index c9077ac006..1e950dc251 100644 --- a/awx/ui_next/testUtils/enzymeHelpers.jsx +++ b/awx/ui_next/testUtils/enzymeHelpers.jsx @@ -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,