From c343bab43a7104f2ed1a34538f1e67263e9f62c3 Mon Sep 17 00:00:00 2001 From: ronronscelestes Date: Mon, 13 Sep 2021 17:08:41 +0200 Subject: [PATCH] Email plugin DS migration --- packages/core/admin/admin/src/plugins.js | 4 +- .../admin/src/pages/Settings/components.js | 16 - .../Settings/components/Configuration.js | 108 ++ .../pages/Settings/components/EmailHeader.js | 33 + .../email/admin/src/pages/Settings/index.js | 315 +++--- .../src/pages/Settings/tests/index.test.js | 931 ++++++++++++++++++ .../src/pages/Settings/tests/utils/server.js | 21 + .../admin/src/pages/Settings/utils/api.js | 13 + .../core/email/admin/src/translations/en.json | 36 +- 9 files changed, 1277 insertions(+), 200 deletions(-) delete mode 100644 packages/core/email/admin/src/pages/Settings/components.js create mode 100644 packages/core/email/admin/src/pages/Settings/components/Configuration.js create mode 100644 packages/core/email/admin/src/pages/Settings/components/EmailHeader.js create mode 100644 packages/core/email/admin/src/pages/Settings/tests/index.test.js create mode 100644 packages/core/email/admin/src/pages/Settings/tests/utils/server.js create mode 100644 packages/core/email/admin/src/pages/Settings/utils/api.js diff --git a/packages/core/admin/admin/src/plugins.js b/packages/core/admin/admin/src/plugins.js index a4f31b5db4..46c786c9ea 100644 --- a/packages/core/admin/admin/src/plugins.js +++ b/packages/core/admin/admin/src/plugins.js @@ -5,14 +5,14 @@ import i18nPlugin from '../../../../plugins/i18n/admin/src'; // import sentryPlugin from '../../../../plugins/sentry/admin/src'; import usersPermissionsPlugin from '../../../../plugins/users-permissions/admin/src'; import ctbPlugin from '../../../content-type-builder/admin/src'; -// import emailPlugin from '../../../email/admin/src'; +import emailPlugin from '../../../email/admin/src'; import uploadPlugin from '../../../upload/admin/src'; const plugins = { '@strapi/plugin-content-type-builder': ctbPlugin, // '@strapi/plugin-documentation': documentationPlugin, '@strapi/plugin-i18n': i18nPlugin, - // '@strapi/plugin-email': emailPlugin, + '@strapi/plugin-email': emailPlugin, '@strapi/plugin-upload': uploadPlugin, // '@strapi/plugin-graphql': graphqlPlugin, // '@strapi/plugin-sentry': sentryPlugin, diff --git a/packages/core/email/admin/src/pages/Settings/components.js b/packages/core/email/admin/src/pages/Settings/components.js deleted file mode 100644 index 600c089021..0000000000 --- a/packages/core/email/admin/src/pages/Settings/components.js +++ /dev/null @@ -1,16 +0,0 @@ -import styled from 'styled-components'; -import { Button, Text as TextBase } from '@buffetjs/core'; - -const Text = styled(TextBase)` - width: 100%; - padding: 0 15px 17px 15px; -`; - -const AlignedButton = styled(Button)` - height: 34px; - padding-top: 3px; - margin: 29px 15px 0 15px; - min-width: unset; -`; - -export { Text, AlignedButton }; diff --git a/packages/core/email/admin/src/pages/Settings/components/Configuration.js b/packages/core/email/admin/src/pages/Settings/components/Configuration.js new file mode 100644 index 0000000000..fe2538640d --- /dev/null +++ b/packages/core/email/admin/src/pages/Settings/components/Configuration.js @@ -0,0 +1,108 @@ +/* eslint-disable no-useless-escape */ + +import React from 'react'; +import PropTypes from 'prop-types'; +import { useIntl } from 'react-intl'; +import { Stack } from '@strapi/parts/Stack'; +import { Grid, GridItem } from '@strapi/parts/Grid'; +import { H3, Text } from '@strapi/parts/Text'; +import { TextInput } from '@strapi/parts/TextInput'; +import { Select, Option } from '@strapi/parts/Select'; +import getTrad from '../../../utils/getTrad'; + +const Configuration = ({ config }) => { + const { formatMessage } = useIntl(); + + return ( + + +

+ {formatMessage({ + id: getTrad('Settings.email.plugin.title.config'), + defaultMessage: 'Configuration', + })} +

+ + {formatMessage( + { + id: getTrad('Settings.email.plugin.text.configuration'), + defaultMessage: 'Configuration', + }, + { + file: './config/plugins.js', + link: ( + + link + + ), + } + )} + +
+ + + `, + })} + disabled + onChange={() => {}} + value={config.settings.defaultFrom} + /> + + + `, + })} + disabled + onChange={() => {}} + value={config.settings.defaultReplyTo} + /> + + + + + +
+ ); +}; + +Configuration.propTypes = { + config: PropTypes.shape({ + provider: PropTypes.string, + settings: PropTypes.shape({ + defaultFrom: PropTypes.string, + defaultReplyTo: PropTypes.string, + }), + }).isRequired, +}; + +export default Configuration; diff --git a/packages/core/email/admin/src/pages/Settings/components/EmailHeader.js b/packages/core/email/admin/src/pages/Settings/components/EmailHeader.js new file mode 100644 index 0000000000..c285219523 --- /dev/null +++ b/packages/core/email/admin/src/pages/Settings/components/EmailHeader.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { useIntl } from 'react-intl'; +import { SettingsPageTitle } from '@strapi/helper-plugin'; +import { HeaderLayout } from '@strapi/parts/Layout'; +import getTrad from '../../../utils/getTrad'; + +const EmailHeader = () => { + const { formatMessage } = useIntl(); + + return ( + <> + + + + ); +}; + +export default EmailHeader; diff --git a/packages/core/email/admin/src/pages/Settings/index.js b/packages/core/email/admin/src/pages/Settings/index.js index db9a2428d9..055d15b06a 100644 --- a/packages/core/email/admin/src/pages/Settings/index.js +++ b/packages/core/email/admin/src/pages/Settings/index.js @@ -1,23 +1,29 @@ -import React, { useState, useEffect, useRef } from 'react'; -import { useIntl, FormattedMessage } from 'react-intl'; +import React, { useState, useEffect } from 'react'; +import { useIntl } from 'react-intl'; import { get } from 'lodash'; -import { Header } from '@buffetjs/custom'; -import { Envelope } from '@buffetjs/icons'; -import { colors } from '@buffetjs/styles'; import { - FormBloc, - request, - SettingsPageTitle, - SizedInput, getYupInnerErrors, - BaselineAlignment, CheckPagePermissions, useNotification, + LoadingIndicatorPage, + useOverlayBlocker, + useFocusWhenNavigate, } from '@strapi/helper-plugin'; -import getTrad from '../../utils/getTrad'; -import { AlignedButton, Text } from './components'; +import { Main } from '@strapi/parts/Main'; +import { ContentLayout } from '@strapi/parts/Layout'; +import { Stack } from '@strapi/parts/Stack'; +import { Box } from '@strapi/parts/Box'; +import { Grid, GridItem } from '@strapi/parts/Grid'; +import { H3 } from '@strapi/parts/Text'; +import { TextInput } from '@strapi/parts/TextInput'; +import { Button } from '@strapi/parts/Button'; +import CheckIcon from '@strapi/icons/CheckIcon'; +import Configuration from './components/Configuration'; import schema from '../../utils/schema'; import pluginPermissions from '../../permissions'; +import { fetchEmailSettings, postEmailTest } from './utils/api'; +import EmailHeader from './components/EmailHeader'; +import getTrad from '../../utils/getTrad'; const ProtectedSettingsPage = () => ( @@ -28,185 +34,170 @@ const ProtectedSettingsPage = () => ( const SettingsPage = () => { const toggleNotification = useNotification(); const { formatMessage } = useIntl(); + const { lockApp, unlockApp } = useOverlayBlocker(); + useFocusWhenNavigate(); + const [formErrors, setFormErrors] = useState({}); - const [isTestButtonLoading, setIsTestButtonLoading] = useState(false); - const [showLoader, setShowLoader] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [isSubmitting, setIsSubmitting] = useState(false); + const [testAddress, setTestAddress] = useState(''); const [config, setConfig] = useState({ provider: '', settings: { defaultFrom: '', defaultReplyTo: '', testAddress: '' }, }); - const [providers, setProviders] = useState([]); - const [testAddress, setTestAddress] = useState(); - const [testSuccess, setTestSuccess] = useState(false); - const isMounted = useRef(true); - const title = formatMessage({ id: getTrad('Settings.title') }); + const handleChange = e => { + setTestAddress(() => e.target.value); + }; const handleSubmit = async event => { event.preventDefault(); - let errors = {}; try { await schema.validate({ email: testAddress }, { abortEarly: false }); - try { - setIsTestButtonLoading(true); + setIsSubmitting(true); + lockApp(); - await request('/email/test', { - method: 'POST', - body: { to: testAddress }, + postEmailTest({ to: testAddress }) + .then(() => { + toggleNotification({ + type: 'success', + message: formatMessage( + { + id: getTrad('Settings.email.plugin.notification.test.success'), + defaultMessage: 'Email test succeeded, check the {to} mailbox', + }, + { to: testAddress } + ), + }); + }) + .catch(() => { + toggleNotification({ + type: 'warning', + message: formatMessage( + { + id: getTrad('Settings.email.plugin.notification.test.error'), + defaultMessage: 'Failed to send a test mail to {to}', + }, + { to: testAddress } + ), + }); + }) + .finally(() => { + setIsSubmitting(false); + unlockApp(); }); - - setTestSuccess(true); - const message = formatMessage( - { id: getTrad('Settings.notification.test.success') }, - { to: testAddress } - ); - toggleNotification({ type: 'success', message }); - } catch (err) { - const message = formatMessage( - { id: getTrad('Settings.notification.test.error') }, - { to: testAddress } - ); - toggleNotification({ type: 'warning', message }); - } finally { - if (isMounted.current) { - setIsTestButtonLoading(false); - } - } } catch (error) { - errors = getYupInnerErrors(error); - setFormErrors(errors); - console.log(errors); + setFormErrors(getYupInnerErrors(error)); } }; useEffect(() => { - const fetchEmailSettings = () => { - setShowLoader(true); + setIsLoading(true); - request('/email/settings', { - method: 'GET', + fetchEmailSettings() + .then(config => { + setConfig(config); + + const testAddressFound = get(config, 'settings.testAddress'); + + if (testAddressFound) { + setTestAddress(testAddressFound); + } }) - .then(data => { - setConfig(data.config); - setProviders([data.config.provider]); - setTestAddress(get(data, 'config.settings.testAddress')); + .catch(() => + toggleNotification({ + type: 'warning', + message: formatMessage({ + id: getTrad('Settings.email.plugin.notification.config.error'), + defaultMessage: 'Failed to retrieve the email config', + }), }) - .catch(() => - toggleNotification({ - type: 'warning', - message: { id: getTrad('Settings.notification.config.error') }, - }) - ) - .finally(() => setShowLoader(false)); - }; - - fetchEmailSettings(); + ) + .finally(() => setIsLoading(false)); }, [formatMessage, toggleNotification]); - useEffect(() => { - return () => { - isMounted.current = false; - }; - }, []); + if (isLoading) { + return ( +
+ + + + +
+ ); + } return ( - <> - - -
-
-
- - + + + + + - - ./config/plugins.js, - link: ( - - link - - ), - }} - /> - - - - - - - + + - setTestAddress(event.target.value)} - size={{ xs: 6 }} - type="email" - value={testAddress} - error={formErrors.email} - /> - - } - isLoading={isTestButtonLoading} - style={{ fontWeight: 600 }} - type="submit" - > - {formatMessage({ id: getTrad('Settings.button.test-email') })} - - - -
-
- + +

+ {formatMessage({ + id: getTrad('Settings.email.plugin.title.test'), + defaultMessage: 'Send a test mail', + })} +

+ + + + + + {/* to replace with envelope icon */} + + + +
+ + + + + ); }; diff --git a/packages/core/email/admin/src/pages/Settings/tests/index.test.js b/packages/core/email/admin/src/pages/Settings/tests/index.test.js new file mode 100644 index 0000000000..aba723588e --- /dev/null +++ b/packages/core/email/admin/src/pages/Settings/tests/index.test.js @@ -0,0 +1,931 @@ +import React from 'react'; +import { render, waitFor, screen } from '@testing-library/react'; +import { IntlProvider } from 'react-intl'; +import { ThemeProvider, lightTheme } from '@strapi/parts'; +import server from './utils/server'; +import ProtectedSettingsPage from '../index'; + +jest.mock('@strapi/helper-plugin', () => ({ + ...jest.requireActual('@strapi/helper-plugin'), + useNotification: jest.fn(), + useFocusWhenNavigate: jest.fn(), + CheckPagePermissions: ({ children }) => children, + useOverlayBlocker: jest.fn(() => ({ + lockApp: jest.fn(), + unlockApp: jest.fn(), + })), +})); + +const App = ( + + + + + +); + +describe('Email | Pages | Settings', () => { + beforeAll(() => server.listen()); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + afterEach(() => server.resetHandlers()); + + afterAll(() => { + server.close(); + jest.resetAllMocks(); + }); + + it('renders and matches the snapshot', async () => { + const { container } = render(App); + + await waitFor(() => { + expect(screen.getByText('Test delivery email address')).toBeInTheDocument(); + }); + + expect(container.firstChild).toMatchInlineSnapshot(` + .c42 { + font-weight: 500; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c40 { + padding-right: 8px; + } + + .c37 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + cursor: pointer; + padding: 8px; + border-radius: 4px; + background: #ffffff; + border: 1px solid #dcdce4; + } + + .c37 svg { + height: 12px; + width: 12px; + } + + .c37 svg > g, + .c37 svg path { + fill: #ffffff; + } + + .c37[aria-disabled='true'] { + pointer-events: none; + } + + .c38 { + padding: 8px 16px; + background: #4945ff; + border: none; + border: 1px solid #4945ff; + background: #4945ff; + } + + .c38 .c39 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c38 .c41 { + color: #ffffff; + } + + .c38[aria-disabled='true'] { + border: 1px solid #dcdce4; + background: #eaeaef; + } + + .c38[aria-disabled='true'] .c41 { + color: #666687; + } + + .c38[aria-disabled='true'] svg > g, + .c38[aria-disabled='true'] svg path { + fill: #666687; + } + + .c38[aria-disabled='true']:active { + border: 1px solid #dcdce4; + background: #eaeaef; + } + + .c38[aria-disabled='true']:active .c41 { + color: #666687; + } + + .c38[aria-disabled='true']:active svg > g, + .c38[aria-disabled='true']:active svg path { + fill: #666687; + } + + .c38:hover { + border: 1px solid #7b79ff; + background: #7b79ff; + } + + .c38:active { + border: 1px solid #4945ff; + background: #4945ff; + } + + .c1 { + background: #f6f6f9; + padding-top: 56px; + padding-right: 56px; + padding-bottom: 56px; + padding-left: 56px; + } + + .c7 { + padding-right: 56px; + padding-left: 56px; + } + + .c2 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c3 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c4 { + font-weight: 600; + font-size: 2rem; + line-height: 1.25; + color: #32324d; + } + + .c5 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #666687; + } + + .c6 { + font-size: 1rem; + line-height: 1.5; + } + + .c8 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c8 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c8 > * + * { + margin-top: 32px; + } + + .c10 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c10 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c10 > * + * { + margin-top: 16px; + } + + .c11 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c11 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c11 > * + * { + margin-top: 4px; + } + + .c12 { + font-weight: 500; + font-size: 1rem; + line-height: 1.25; + color: #32324d; + } + + .c13 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #32324d; + } + + .c19 { + font-weight: 500; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c18 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c20 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c22 { + border: none; + padding-left: 16px; + padding-right: 16px; + color: #32324d; + font-weight: 400; + font-size: 0.875rem; + display: block; + width: 100%; + height: 2.5rem; + } + + .c22::-webkit-input-placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c22::-moz-placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c22:-ms-input-placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c22::placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c22:disabled { + background: inherit; + color: inherit; + } + + .c22:focus { + outline: none; + } + + .c21 { + border: 1px solid #dcdce4; + border-radius: 4px; + background: #ffffff; + overflow: hidden; + color: #666687; + background: #eaeaef; + } + + .c21:focus-within { + border: 1px solid #4945ff; + } + + .c35 { + border: 1px solid #dcdce4; + border-radius: 4px; + background: #ffffff; + overflow: hidden; + } + + .c35:focus-within { + border: 1px solid #4945ff; + } + + .c17 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c17 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c17 > * + * { + margin-top: 4px; + } + + .c16 textarea { + height: 5rem; + } + + .c0 { + outline: none; + } + + .c9 { + background: #ffffff; + padding-top: 24px; + padding-right: 32px; + padding-bottom: 24px; + padding-left: 32px; + border-radius: 4px; + box-shadow: 0px 1px 4px rgba(33,33,52,0.1); + } + + .c14 { + display: grid; + grid-template-columns: repeat(12,1fr); + gap: 20px; + } + + .c15 { + grid-column: span 6; + word-break: break-all; + } + + .c36 { + grid-column: span 7; + word-break: break-all; + } + + .c26 { + position: absolute; + left: 0; + right: 0; + bottom: 0; + top: 0; + width: 100%; + background: transparent; + border: none; + } + + .c26:focus { + outline: none; + } + + .c24 { + font-weight: 500; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c31 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #666687; + } + + .c30 { + padding-right: 16px; + padding-left: 16px; + } + + .c32 { + padding-left: 12px; + } + + .c27 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c29 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c23 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c23 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c23 > * + * { + margin-top: 4px; + } + + .c25 { + position: relative; + border: 1px solid #dcdce4; + padding-right: 12px; + border-radius: 4px; + background: #ffffff; + overflow: hidden; + color: #666687; + background: #eaeaef; + } + + .c25:focus-within { + border: 1px solid #4945ff; + } + + .c33 { + background: transparent; + border: none; + position: relative; + z-index: 1; + } + + .c33 svg { + height: 0.6875rem; + width: 0.6875rem; + } + + .c33 svg path { + fill: #666687; + } + + .c34 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + background: none; + border: none; + } + + .c34 svg { + width: 0.375rem; + } + + .c28 { + min-height: 2.5rem; + } + + @media (max-width:68.75rem) { + .c15 { + grid-column: span 12; + } + } + + @media (max-width:34.375rem) { + .c15 { + grid-column: span; + } + } + + @media (max-width:68.75rem) { + .c36 { + grid-column: span 12; + } + } + + @media (max-width:34.375rem) { + .c36 { + grid-column: span; + } + } + +
+
+
+
+
+

+ Email settings +

+
+
+

+ Test the settings for the email plugin +

+
+
+
+
+
+
+
+
+

+ Configuration +

+ + Configuration + +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+ + Email provider + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+

+ Send a test mail +

+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + +
+ `); + }); +}); diff --git a/packages/core/email/admin/src/pages/Settings/tests/utils/server.js b/packages/core/email/admin/src/pages/Settings/tests/utils/server.js new file mode 100644 index 0000000000..d0b707eb0d --- /dev/null +++ b/packages/core/email/admin/src/pages/Settings/tests/utils/server.js @@ -0,0 +1,21 @@ +import { setupServer } from 'msw/node'; +import { rest } from 'msw'; + +const handlers = [ + rest.get('*/email/settings', (req, res, ctx) => { + return res( + ctx.delay(100), + ctx.status(200), + ctx.json({ + config: { + provider: '', + settings: { defaultFrom: '', defaultReplyTo: '', testAddress: '' }, + }, + }) + ); + }), +]; + +const server = setupServer(...handlers); + +export default server; diff --git a/packages/core/email/admin/src/pages/Settings/utils/api.js b/packages/core/email/admin/src/pages/Settings/utils/api.js new file mode 100644 index 0000000000..e9d5f7c37f --- /dev/null +++ b/packages/core/email/admin/src/pages/Settings/utils/api.js @@ -0,0 +1,13 @@ +import { axiosInstance } from '../../../../../../admin/admin/src/core/utils'; + +const fetchEmailSettings = async () => { + const { data } = await axiosInstance.get('/email/settings'); + + return data.config; +}; + +const postEmailTest = async body => { + await axiosInstance.post('/email/test', body); +}; + +export { fetchEmailSettings, postEmailTest }; diff --git a/packages/core/email/admin/src/translations/en.json b/packages/core/email/admin/src/translations/en.json index 69fb4620dc..72882c7e07 100644 --- a/packages/core/email/admin/src/translations/en.json +++ b/packages/core/email/admin/src/translations/en.json @@ -1,22 +1,18 @@ { - "Settings.button.test-email": "Test email", - "Settings.form.label.defaultFrom": "Default shipper email", - "Settings.form.label.defaultReplyTo": "Default response email", - "Settings.form.label.provider": "Email provider", - "Settings.form.label.testAddress": "Test delivery email address", - "Settings.form.placeholder.defaultFrom": "ex: Strapi No-Reply ", - "Settings.form.placeholder.defaultReplyTo": "ex: Strapi ", - "Settings.form.placeholder.testAddress": "ex: developer@example.com", - "Settings.form.text.configuration": "The plugin is configured through the {file} file, checkout this {link} for the documentation.", - "Settings.form.title.config": "Configuration", - "Settings.form.title.test": "Send a test email", - "Settings.notification.config.error": "Failed to retrieve the email config", - "Settings.notification.test.error": "Failed to send a test mail to {to}", - "Settings.notification.test.success": "Email test succeeded, check the {to} mailbox", - "Settings.subTitle": "Test the settings for the email plugin", - "Settings.title": "Email settings", - "SettingsNav.link.settings": "Email settings", - "SettingsNav.section-label": "Email plugin", - "plugin.description.long": "Send emails.", - "plugin.description.short": "Send emails." + "Settings.email.plugin.button.test-email": "Test email", + "Settings.email.plugin.label.defaultFrom": "Default shipper email", + "Settings.email.plugin.label.defaultReplyTo": "Default response email", + "Settings.email.plugin.label.provider": "Email provider", + "Settings.email.plugin.label.testAddress": "Test delivery email address", + "Settings.email.plugin.placeholder.defaultFrom": "ex: Strapi No-Reply ", + "Settings.email.plugin.placeholder.defaultReplyTo": "ex: Strapi ", + "Settings.email.plugin.placeholder.testAddress": "ex: developer@example.com", + "Settings.email.plugin.text.configuration": "The plugin is configured through the {file} file, checkout this {link} for the documentation.", + "Settings.email.plugin.title.config": "Configuration", + "Settings.email.plugin.title.test": "Send a test email", + "Settings.email.plugin.notification.config.error": "Failed to retrieve the email config", + "Settings.email.plugin.notification.test.error": "Failed to send a test mail to {to}", + "Settings.email.plugin.notification.test.success": "Email test succeeded, check the {to} mailbox", + "Settings.email.plugin.subTitle": "Test the settings for the email plugin", + "Settings.email.plugin.title": "Email settings" }