diff --git a/public/locales/en.json b/public/locales/en.json index 6186fad9..b18545cb 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -9,7 +9,20 @@ "ui-version": "UI Version", "username": "Username" }, + "form-dialog": { + "label_cancel": "Cancel", + "label_close": "Close", + "label_submit": "Submit", + "label_submit_confirmation": "Confirm", + "label_submit_create-credential": "Save", + "label_submit_create-scan": "Scan", + "label_submit_merge-reports": "Merge" + }, "modal": { "aria-label-default": "Application modal" + }, + "view": { + "loading": "Loading...", + "loading_credentials": "Loading credentials..." } } diff --git a/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap b/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap index 50e85f91..e02ba140 100644 --- a/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap +++ b/src/components/authentication/__tests__/__snapshots__/authentication.test.js.snap @@ -183,43 +183,26 @@ exports[`Authentication Component should render a non-connected component error: exports[`Authentication Component should render a non-connected component pending: non-connected pending 1`] = ` - +
-
-
- Logging in... -
- + Logging in... +
`; diff --git a/src/components/authentication/authentication.js b/src/components/authentication/authentication.js index e4df0ea5..37ef665c 100644 --- a/src/components/authentication/authentication.js +++ b/src/components/authentication/authentication.js @@ -1,7 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { Alert, EmptyState, Modal } from 'patternfly-react'; +import { Alert, EmptyState } from 'patternfly-react'; +import { Modal, ModalVariant } from '../modal/modal'; import { reduxActions } from '../../redux'; import helpers from '../../common/helpers'; import { PageLayout } from '../pageLayout/pageLayout'; @@ -24,11 +25,9 @@ class Authentication extends React.Component { if (session.pending) { return ( - - -
-
Logging in...
- + +
+
Logging in...
); } diff --git a/src/components/confirmationModal/__tests__/__snapshots__/confirmationModal.test.js.snap b/src/components/confirmationModal/__tests__/__snapshots__/confirmationModal.test.js.snap index a593f4d1..ebf3774b 100644 --- a/src/components/confirmationModal/__tests__/__snapshots__/confirmationModal.test.js.snap +++ b/src/components/confirmationModal/__tests__/__snapshots__/confirmationModal.test.js.snap @@ -4,82 +4,121 @@ exports[`Confirmation Modal Component should NOT display a confirmation modal: h exports[`Confirmation Modal Component should display a confirmation modal: show 1`] = ` diff --git a/src/components/confirmationModal/__tests__/confirmationModal.test.js b/src/components/confirmationModal/__tests__/confirmationModal.test.js index 68913aad..08e98e0f 100644 --- a/src/components/confirmationModal/__tests__/confirmationModal.test.js +++ b/src/components/confirmationModal/__tests__/confirmationModal.test.js @@ -1,7 +1,7 @@ import React from 'react'; import configureMockStore from 'redux-mock-store'; import { Provider } from 'react-redux'; -import { mount, shallow } from 'enzyme'; +import { shallow } from 'enzyme'; import { ConnectedConfirmationModal, ConfirmationModal } from '../confirmationModal'; describe('Confirmation Modal Component', () => { @@ -28,7 +28,7 @@ describe('Confirmation Modal Component', () => { expect(component.find(ConnectedConfirmationModal)).toMatchSnapshot('connected'); }); - it('should display a confirmation modal', () => { + it('should display a confirmation modal', async () => { const onCancel = jest.fn(); const props = { show: true, @@ -41,21 +41,19 @@ describe('Confirmation Modal Component', () => { onCancel }; - const component = mount(); - + const component = await mountHookComponent(); expect(component.render()).toMatchSnapshot('show'); - component.find('button[className="btn btn-default"]').simulate('click'); + component.find('button[className="pf-c-button pf-m-secondary"]').simulate('click'); expect(onCancel).toHaveBeenCalledTimes(1); }); - it('should NOT display a confirmation modal', () => { + it('should NOT display a confirmation modal', async () => { const props = { show: false }; - const component = mount(); - + const component = await mountHookComponent(); expect(component.render()).toMatchSnapshot('hidden'); }); }); diff --git a/src/components/confirmationModal/confirmationModal.js b/src/components/confirmationModal/confirmationModal.js index f96c996a..aee1f6f8 100644 --- a/src/components/confirmationModal/confirmationModal.js +++ b/src/components/confirmationModal/confirmationModal.js @@ -1,8 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { MessageDialog, Icon } from 'patternfly-react'; +import { Alert, AlertVariant, Button, ButtonVariant, Title } from '@patternfly/react-core'; +import { Modal } from '../modal/modal'; import { connect, store, reduxTypes } from '../../redux'; -import helpers from '../../common/helpers'; +import { translate } from '../i18n/i18n'; const ConfirmationModal = ({ show, @@ -13,7 +14,8 @@ const ConfirmationModal = ({ confirmButtonText, cancelButtonText, onConfirm, - onCancel + onCancel, + t }) => { const cancel = () => { if (onCancel) { @@ -25,19 +27,43 @@ const ConfirmationModal = ({ } }; + const setActions = () => { + const actions = []; + + if (onConfirm) { + actions.push( + + ); + } + + actions.push( + + ); + + return actions; + }; + return ( - {heading}

} - secondaryContent={

{body}

} - /> + {title || t('form-dialog.label', { context: ['submit', 'confirmation'] })} + } + disableFocusTrap + > + + {body &&

{body}

} +
+
); }; @@ -50,18 +76,20 @@ ConfirmationModal.propTypes = { confirmButtonText: PropTypes.string, cancelButtonText: PropTypes.string, onConfirm: PropTypes.func, - onCancel: PropTypes.func + onCancel: PropTypes.func, + t: PropTypes.func }; ConfirmationModal.defaultProps = { - title: 'Confirm', + title: null, heading: null, body: null, - icon: , - confirmButtonText: 'Confirm', - cancelButtonText: '', - onConfirm: helpers.noop, - onCancel: null + icon: AlertVariant.warning, + confirmButtonText: null, + cancelButtonText: null, + onConfirm: null, + onCancel: null, + t: translate }; const mapStateToProps = state => ({ ...state.confirmationModal }); diff --git a/src/components/createCredentialDialog/__tests__/__snapshots__/createCredentialDialog.test.js.snap b/src/components/createCredentialDialog/__tests__/__snapshots__/createCredentialDialog.test.js.snap index 7cc8ee11..ca4a2d72 100644 --- a/src/components/createCredentialDialog/__tests__/__snapshots__/createCredentialDialog.test.js.snap +++ b/src/components/createCredentialDialog/__tests__/__snapshots__/createCredentialDialog.test.js.snap @@ -2,47 +2,64 @@ exports[`CreateCredentialDialog Component should render a connected component: connected 1`] = `