From 590199baff52d590f5c5fa342634c0a9bce8ce2e Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Tue, 11 Feb 2020 16:11:47 -0500 Subject: [PATCH] Remove ListActionButton component --- .../ClipboardCopyButton.jsx | 16 +- .../ListActionButton/ListActionButton.jsx | 11 - .../ListActionButton.test.jsx | 10 - .../src/components/ListActionButton/index.js | 1 - .../NotificationList.test.jsx | 12 +- .../NotificationListItem.test.jsx.snap | 441 ++++++------------ .../CredentialList/CredentialListItem.jsx | 8 +- .../screens/Host/HostList/HostListItem.jsx | 10 +- .../InventoryGroups/InventoryGroupItem.jsx | 12 +- .../InventoryHosts/InventoryHostItem.jsx | 14 +- .../InventoryHosts/InventoryHostList.test.jsx | 8 +- .../InventoryList/InventoryListItem.jsx | 8 +- .../src/screens/Job/JobList/JobListItem.jsx | 9 +- .../OrganizationList/OrganizationListItem.jsx | 8 +- .../Project/ProjectList/ProjectListItem.jsx | 16 +- .../shared/ProjectSubForms/ManualSubForm.jsx | 20 +- .../screens/Team/TeamList/TeamListItem.jsx | 8 +- .../TemplateList/TemplateListItem.jsx | 12 +- .../screens/User/UserList/UserListItem.jsx | 8 +- 19 files changed, 226 insertions(+), 406 deletions(-) delete mode 100644 awx/ui_next/src/components/ListActionButton/ListActionButton.jsx delete mode 100644 awx/ui_next/src/components/ListActionButton/ListActionButton.test.jsx delete mode 100644 awx/ui_next/src/components/ListActionButton/index.js diff --git a/awx/ui_next/src/components/ClipboardCopyButton/ClipboardCopyButton.jsx b/awx/ui_next/src/components/ClipboardCopyButton/ClipboardCopyButton.jsx index 9bd91fbac3..8fcac00468 100644 --- a/awx/ui_next/src/components/ClipboardCopyButton/ClipboardCopyButton.jsx +++ b/awx/ui_next/src/components/ClipboardCopyButton/ClipboardCopyButton.jsx @@ -3,18 +3,6 @@ import PropTypes from 'prop-types'; import { Button, Tooltip } from '@patternfly/react-core'; import { CopyIcon } from '@patternfly/react-icons'; -import styled from 'styled-components'; - -const CopyButton = styled(Button)` - padding: 2px 4px; - margin-left: 8px; - border: none; - &:hover { - background-color: #0066cc; - color: white; - } -`; - export const clipboardCopyFunc = (event, text) => { const clipboard = event.currentTarget.parentElement; const el = document.createElement('input'); @@ -62,13 +50,13 @@ class ClipboardCopyButton extends React.Component { trigger="mouseenter focus click" content={copied ? clickTip : hoverTip} > - - + ); } diff --git a/awx/ui_next/src/components/ListActionButton/ListActionButton.jsx b/awx/ui_next/src/components/ListActionButton/ListActionButton.jsx deleted file mode 100644 index 3081b4637f..0000000000 --- a/awx/ui_next/src/components/ListActionButton/ListActionButton.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import { Button } from '@patternfly/react-core'; -import styled from 'styled-components'; - -export default styled(Button)` - padding: 5px 8px; - border: none; - &:hover { - background-color: #0066cc; - color: white; - } -`; diff --git a/awx/ui_next/src/components/ListActionButton/ListActionButton.test.jsx b/awx/ui_next/src/components/ListActionButton/ListActionButton.test.jsx deleted file mode 100644 index cab3534a69..0000000000 --- a/awx/ui_next/src/components/ListActionButton/ListActionButton.test.jsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import ListActionButton from './ListActionButton'; - -describe('ListActionButton', () => { - test('renders the expected content', () => { - const wrapper = mount(); - expect(wrapper).toHaveLength(1); - }); -}); diff --git a/awx/ui_next/src/components/ListActionButton/index.js b/awx/ui_next/src/components/ListActionButton/index.js deleted file mode 100644 index de229f6c76..0000000000 --- a/awx/ui_next/src/components/ListActionButton/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ListActionButton'; diff --git a/awx/ui_next/src/components/NotificationList/NotificationList.test.jsx b/awx/ui_next/src/components/NotificationList/NotificationList.test.jsx index bbc0a603b8..b0485542a3 100644 --- a/awx/ui_next/src/components/NotificationList/NotificationList.test.jsx +++ b/awx/ui_next/src/components/NotificationList/NotificationList.test.jsx @@ -123,7 +123,7 @@ describe('', () => { const items = wrapper.find('NotificationListItem'); items .at(1) - .find('PFSwitch[aria-label="Toggle notification success"]') + .find('Switch[aria-label="Toggle notification success"]') .prop('onChange')(); expect(MockModelAPI.associateNotificationTemplate).toHaveBeenCalledWith( 1, @@ -150,7 +150,7 @@ describe('', () => { const items = wrapper.find('NotificationListItem'); items .at(0) - .find('PFSwitch[aria-label="Toggle notification failure"]') + .find('Switch[aria-label="Toggle notification failure"]') .prop('onChange')(); expect(MockModelAPI.associateNotificationTemplate).toHaveBeenCalledWith( 1, @@ -178,7 +178,7 @@ describe('', () => { const items = wrapper.find('NotificationListItem'); items .at(0) - .find('PFSwitch[aria-label="Toggle notification start"]') + .find('Switch[aria-label="Toggle notification start"]') .prop('onChange')(); expect(MockModelAPI.associateNotificationTemplate).toHaveBeenCalledWith( 1, @@ -205,7 +205,7 @@ describe('', () => { const items = wrapper.find('NotificationListItem'); items .at(0) - .find('PFSwitch[aria-label="Toggle notification success"]') + .find('Switch[aria-label="Toggle notification success"]') .prop('onChange')(); expect(MockModelAPI.disassociateNotificationTemplate).toHaveBeenCalledWith( 1, @@ -232,7 +232,7 @@ describe('', () => { const items = wrapper.find('NotificationListItem'); items .at(1) - .find('PFSwitch[aria-label="Toggle notification failure"]') + .find('Switch[aria-label="Toggle notification failure"]') .prop('onChange')(); expect(MockModelAPI.disassociateNotificationTemplate).toHaveBeenCalledWith( 1, @@ -259,7 +259,7 @@ describe('', () => { const items = wrapper.find('NotificationListItem'); items .at(2) - .find('PFSwitch[aria-label="Toggle notification start"]') + .find('Switch[aria-label="Toggle notification start"]') .prop('onChange')(); expect(MockModelAPI.disassociateNotificationTemplate).toHaveBeenCalledWith( 1, diff --git a/awx/ui_next/src/components/NotificationList/__snapshots__/NotificationListItem.test.jsx.snap b/awx/ui_next/src/components/NotificationList/__snapshots__/NotificationListItem.test.jsx.snap index 7f6acb15b1..c531e44c0c 100644 --- a/awx/ui_next/src/components/NotificationList/__snapshots__/NotificationListItem.test.jsx.snap +++ b/awx/ui_next/src/components/NotificationList/__snapshots__/NotificationListItem.test.jsx.snap @@ -63,7 +63,7 @@ exports[` initially renders succe - initially renders succe labelOff="Start" onChange={[Function]} /> - initially renders succe labelOff="Success" onChange={[Function]} /> - initially renders succe className="pf-c-data-list__cell NotificationListItem__DataListCell-w674ng-0 dXsFLF" righthalf="true" > - initially renders succe labelOff="Start" onChange={[Function]} > - - - + - - - - + + + + + + initially renders succe labelOff="Success" onChange={[Function]} > - - - + - - - - + + + + + + initially renders succe labelOff="Failure" onChange={[Function]} > - - - + - - - + Failure + + + + + + diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx index c1f1a7d095..937dde8607 100644 --- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx @@ -4,6 +4,7 @@ import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { + Button, DataListItem, DataListItemRow, DataListItemCells as _DataListItemCells, @@ -13,7 +14,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; import styled from 'styled-components'; import { Credential } from '@types'; @@ -58,16 +58,16 @@ function CredentialListItem({ {credential.summary_fields.credential_type.name} , - + {canEdit && ( - - + )} , diff --git a/awx/ui_next/src/screens/Host/HostList/HostListItem.jsx b/awx/ui_next/src/screens/Host/HostList/HostListItem.jsx index a9420a7032..cb81224fd3 100644 --- a/awx/ui_next/src/screens/Host/HostList/HostListItem.jsx +++ b/awx/ui_next/src/screens/Host/HostList/HostListItem.jsx @@ -3,6 +3,7 @@ import { string, bool, func } from 'prop-types'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -14,7 +15,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import { Sparkline } from '@components/Sparkline'; import VerticalSeparator from '@components/VerticalSeparator'; import { Host } from '@types'; @@ -82,7 +82,7 @@ class HostListItem extends React.Component { )} , - + , - + {host.summary_fields.user_capabilities.edit && ( - - + )} , diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupItem.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupItem.jsx index 95dcb0eabc..94c4edb7f4 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupItem.jsx @@ -5,6 +5,7 @@ import { t } from '@lingui/macro'; import { Group } from '@types'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -15,7 +16,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; function InventoryGroupItem({ @@ -46,16 +46,12 @@ function InventoryGroupItem({ {group.name} , - + {group.summary_fields.user_capabilities.edit && ( - + )} , diff --git a/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostItem.jsx b/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostItem.jsx index 9d737af3b3..305fdfca92 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostItem.jsx @@ -3,6 +3,7 @@ import { string, bool, func } from 'prop-types'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -14,7 +15,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import { Sparkline } from '@components/Sparkline'; import VerticalSeparator from '@components/VerticalSeparator'; import { Host } from '@types'; @@ -58,7 +58,7 @@ function InventoryHostItem(props) { , - + , - + {host.summary_fields.user_capabilities?.edit && ( - + )} , diff --git a/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostList.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostList.test.jsx index e5d01c256d..0a60a71ada 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostList.test.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHosts/InventoryHostList.test.jsx @@ -154,14 +154,14 @@ describe('', () => { HostsAPI.update.mockResolvedValueOnce({ data: { ...mockHosts[1], enabled: false }, }); - expect(wrapper.find('PFSwitch[id="host-2-toggle"]').props().isChecked).toBe( + expect(wrapper.find('Switch[id="host-2-toggle"]').props().isChecked).toBe( true ); await act(async () => { - wrapper.find('PFSwitch[id="host-2-toggle"]').invoke('onChange')(); + wrapper.find('Switch[id="host-2-toggle"]').invoke('onChange')(); }); wrapper.update(); - expect(wrapper.find('PFSwitch[id="host-2-toggle"]').props().isChecked).toBe( + expect(wrapper.find('Switch[id="host-2-toggle"]').props().isChecked).toBe( false ); expect(HostsAPI.update).toHaveBeenCalledTimes(1); @@ -170,7 +170,7 @@ describe('', () => { test('should show error modal if host is not successfully toggled', async () => { HostsAPI.update.mockImplementationOnce(() => Promise.reject(new Error())); await act(async () => { - wrapper.find('PFSwitch[id="host-2-toggle"]').invoke('onChange')(); + wrapper.find('Switch[id="host-2-toggle"]').invoke('onChange')(); }); wrapper.update(); await waitForElement( diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx index 3eef420580..168ac9e61b 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryListItem.jsx @@ -2,6 +2,7 @@ import React from 'react'; import { string, bool, func } from 'prop-types'; import { withI18n } from '@lingui/react'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -13,7 +14,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; import { Inventory } from '@types'; @@ -54,10 +54,10 @@ class InventoryListItem extends React.Component { ? i18n._(t`Smart Inventory`) : i18n._(t`Inventory`)} , - + {inventory.summary_fields.user_capabilities.edit && ( - - + )} , diff --git a/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx b/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx index 51ec77b57c..47acd95865 100644 --- a/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx +++ b/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx @@ -4,6 +4,7 @@ import styled from 'styled-components'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { + Button, DataListCell, DataListCheck, DataListItem, @@ -13,7 +14,6 @@ import { } from '@patternfly/react-core'; import { RocketIcon } from '@patternfly/react-icons'; import LaunchButton from '@components/LaunchButton'; -import ListActionButton from '@components/ListActionButton'; import { StatusIcon } from '@components/Sparkline'; import { toTitleCase } from '@util/strings'; import { formatDateString } from '@util/dates'; @@ -60,12 +60,9 @@ class JobListItem extends Component { {({ handleRelaunch }) => ( - + )} diff --git a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx index f376ae8bb4..261dee5700 100644 --- a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx +++ b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationListItem.jsx @@ -4,6 +4,7 @@ import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Badge as PFBadge, + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -15,7 +16,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; import { Organization } from '@types'; @@ -84,16 +84,16 @@ function OrganizationListItem({ , - + {organization.summary_fields.user_capabilities.edit && ( - - + )} , diff --git a/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.jsx b/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.jsx index 4348fe7da5..10626c5c70 100644 --- a/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.jsx +++ b/awx/ui_next/src/screens/Project/ProjectList/ProjectListItem.jsx @@ -2,6 +2,7 @@ import React, { Fragment } from 'react'; import { string, bool, func } from 'prop-types'; import { withI18n } from '@lingui/react'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -14,7 +15,6 @@ import { PencilAltIcon, SyncIcon } from '@patternfly/react-icons'; import ClipboardCopyButton from '@components/ClipboardCopyButton'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import ProjectSyncButton from '../shared/ProjectSyncButton'; import { StatusIcon } from '@components/Sparkline'; import VerticalSeparator from '@components/VerticalSeparator'; @@ -105,7 +105,7 @@ class ProjectListItem extends React.Component { ? i18n._(t`Manual`) : toTitleCase(project.scm_type)} , - + {project.scm_revision.substring(0, 7)} {project.scm_revision ? ( ) : null} , - + {project.summary_fields.user_capabilities.start && ( {handleSync => ( - + )} )} , - + {project.summary_fields.user_capabilities.edit && ( - - + )} , diff --git a/awx/ui_next/src/screens/Project/shared/ProjectSubForms/ManualSubForm.jsx b/awx/ui_next/src/screens/Project/shared/ProjectSubForms/ManualSubForm.jsx index 688d3eecc9..94a624b380 100644 --- a/awx/ui_next/src/screens/Project/shared/ProjectSubForms/ManualSubForm.jsx +++ b/awx/ui_next/src/screens/Project/shared/ProjectSubForms/ManualSubForm.jsx @@ -37,22 +37,22 @@ const ManualSubForm = ({ return ( <> - {/* {options.length === 1 && ( */} - - {i18n._(t` + {options.length === 1 && ( + + {i18n._(t` There are no available playbook directories in ${project_base_dir}. Either that directory is empty, or all of the contents are already assigned to other projects. Create a new directory there and make sure the playbook files can be read by the "awx" system user, or have ${brandName} directly retrieve your playbooks from source control using the SCM Type option above.`)} - - {/* )} */} + + )} )} , - + {team.summary_fields.user_capabilities.edit && ( - - + )} , diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx index 73f5991ff9..b3742dc574 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -17,7 +18,6 @@ import { import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; import LaunchButton from '@components/LaunchButton'; -import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; import { Sparkline } from '@components/Sparkline'; import { toTitleCase } from '@util/strings'; @@ -76,24 +76,24 @@ function TemplateListItem({ i18n, template, isSelected, onSelect, detailUrl }) { {({ handleLaunch }) => ( - + )} )} , - + {template.summary_fields.user_capabilities.edit && ( - - + )} , diff --git a/awx/ui_next/src/screens/User/UserList/UserListItem.jsx b/awx/ui_next/src/screens/User/UserList/UserListItem.jsx index e856564222..cf9ee9a382 100644 --- a/awx/ui_next/src/screens/User/UserList/UserListItem.jsx +++ b/awx/ui_next/src/screens/User/UserList/UserListItem.jsx @@ -3,6 +3,7 @@ import { string, bool, func } from 'prop-types'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { + Button, DataListItem, DataListItemRow, DataListItemCells, @@ -13,7 +14,6 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '@components/DataListCell'; import DataListCheck from '@components/DataListCheck'; -import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; import { User } from '@types'; @@ -61,16 +61,16 @@ class UserListItem extends React.Component { )} , - + {user.summary_fields.user_capabilities.edit && ( - - + )} ,