@bigbinary/neeto-email-delivery-frontend 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -6
- package/app/javascript/src/translations/en.json +24 -0
- package/dist/EmailDeliveryScreen.js +225 -45
- package/dist/EmailDeliveryScreen.js.map +1 -1
- package/dist/SparkpostDomainSetup.js +2 -2
- package/dist/SparkpostDomainVerify.js +2 -2
- package/dist/cjs/EmailDeliveryScreen.js +245 -46
- package/dist/cjs/EmailDeliveryScreen.js.map +1 -1
- package/dist/cjs/SparkpostDomainSetup.js +2 -2
- package/dist/cjs/SparkpostDomainVerify.js +2 -2
- package/dist/cjs/hooks.js +7 -2
- package/dist/cjs/hooks.js.map +1 -1
- package/dist/cjs/index.js +13 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/hooks.js +7 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/dist/{useOutlookIntegrationApi-CtHj_BzG.js → useOutlookIntegrationApi-BC-RPHmJ.js} +59 -2
- package/dist/useOutlookIntegrationApi-BC-RPHmJ.js.map +1 -0
- package/dist/{useOutlookIntegrationApi-ZgRWrUQN.js → useOutlookIntegrationApi-b_mNVfRE.js} +58 -4
- package/dist/useOutlookIntegrationApi-b_mNVfRE.js.map +1 -0
- package/dist/{useSparkpostApi-pa64NIl6.js → useSparkpostApi-D9NOjTNA.js} +18 -2
- package/dist/useSparkpostApi-D9NOjTNA.js.map +1 -0
- package/dist/{useSparkpostApi-W7XibjIp.js → useSparkpostApi-qpRhsK7H.js} +17 -3
- package/dist/useSparkpostApi-qpRhsK7H.js.map +1 -0
- package/dist/{useSparkpostDomain-CK-k6Xrr.js → useSparkpostDomain-Brk7SmL4.js} +3 -15
- package/dist/useSparkpostDomain-Brk7SmL4.js.map +1 -0
- package/dist/{useSparkpostDomain-DDI4pHcZ.js → useSparkpostDomain-CuX-Gl5a.js} +3 -14
- package/dist/useSparkpostDomain-CuX-Gl5a.js.map +1 -0
- package/package.json +7 -7
- package/dist/useOutlookIntegrationApi-CtHj_BzG.js.map +0 -1
- package/dist/useOutlookIntegrationApi-ZgRWrUQN.js.map +0 -1
- package/dist/useSparkpostApi-W7XibjIp.js.map +0 -1
- package/dist/useSparkpostApi-pa64NIl6.js.map +0 -1
- package/dist/useSparkpostDomain-CK-k6Xrr.js.map +0 -1
- package/dist/useSparkpostDomain-DDI4pHcZ.js.map +0 -1
package/README.md
CHANGED
|
@@ -64,13 +64,18 @@ class ApplicationMailer < NeetoCommonsBackend::ApplicationMailer
|
|
|
64
64
|
# ...
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
6. Include NeetoEmailDeliveryEngine::HasEmailIntegrations in the host's owner model
|
|
67
|
+
6. Include NeetoEmailDeliveryEngine::HasEmailIntegrations in the host's owner model and override the `email_delivery_redirect_url` method
|
|
68
68
|
|
|
69
69
|
```diff
|
|
70
70
|
class Form < ApplicationRecord
|
|
71
71
|
# ...
|
|
72
72
|
+ include NeetoEmailDeliveryEngine::HasEmailIntegrations
|
|
73
73
|
# ...
|
|
74
|
+
|
|
75
|
+
def email_delivery_redirect_url
|
|
76
|
+
# "/admin/..."
|
|
77
|
+
end
|
|
78
|
+
|
|
74
79
|
end
|
|
75
80
|
````
|
|
76
81
|
|
|
@@ -81,7 +86,58 @@ end
|
|
|
81
86
|
NeetoEmailDeliveryEngine.owner_class = "Form"
|
|
82
87
|
```
|
|
83
88
|
|
|
84
|
-
8.
|
|
89
|
+
8. Override the `load_owner` private method by adding the following files.
|
|
90
|
+
|
|
91
|
+
- app/overrides/controllers/neeto_email_delivery_engine/integrations/sparkpost_domains_controller_override.rb
|
|
92
|
+
- app/overrides/controllers/neeto_email_delivery_engine/gmail_controller_override.rb
|
|
93
|
+
- app/overrides/controllers/neeto_email_delivery_engine/outlook_controller_override.rb
|
|
94
|
+
|
|
95
|
+
Example:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
NeetoEmailDeliveryEngine::Api::V1::GmailController.class_eval do
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
def load_owner
|
|
102
|
+
# @owner = current_user
|
|
103
|
+
# OR
|
|
104
|
+
# @owner = @organization.forms.find(params[:owner_id])
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
9. Override the `send_disconnection_email` private method -
|
|
110
|
+
|
|
111
|
+
- app/overrides/services/neeto_email_delivery_engine/gmail/send_email_service_override.rb
|
|
112
|
+
- app/overrides/services/neeto_email_delivery_engine/outlook/send_email_service_override.rb
|
|
113
|
+
|
|
114
|
+
Example:
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
NeetoEmailDeliveryEngine::Gmail::SendEmailService.class_eval do
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
def send_disconnection_email
|
|
122
|
+
organization = @gmail_account.organization
|
|
123
|
+
# DisconnectionMailer
|
|
124
|
+
# .with(organization_id: organization.id)
|
|
125
|
+
# .send_email(user: @gmail_account.integrable, type: "gmail")
|
|
126
|
+
# .deliver_later
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
10. Add mailgun ingress config in application.rb
|
|
132
|
+
|
|
133
|
+
```ruby
|
|
134
|
+
config.action_mailbox.ingress = :mailgun
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
11. Add `:gmail` and `:outlook` to omniauth_providers in
|
|
138
|
+
config/initializers/extend_user_omniauth.rb.
|
|
139
|
+
|
|
140
|
+
12. The following env variables need to be added to the host application.
|
|
85
141
|
|
|
86
142
|
```
|
|
87
143
|
GOOGLE_OAUTH_CLIENT_ID
|
|
@@ -97,10 +153,25 @@ CONNECT_PUBLIC_KEY
|
|
|
97
153
|
MAILGUN_INGRESS_SIGNING_KEY (needed for our custom logic to verify the Outlook account.)
|
|
98
154
|
```
|
|
99
155
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
156
|
+
13. In secrets.yml add
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
sparkpost:
|
|
160
|
+
sending_domains_key: <%= ENV['SPARKPOST_SENDING_DOMAINS_KEY'] %>
|
|
161
|
+
sending_domains_user_name: SMTP_Injection
|
|
162
|
+
sending_domains_address: smtp.sparkpostmail.com
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
14. Ensure that the domain `<app-name>email.com` (production) and
|
|
166
|
+
`<app-name>email.net` (staging) is correctly setup in Mailgun to accept
|
|
167
|
+
incoming emails. Example: For NeetoForm it would be neetoformemail.com
|
|
168
|
+
(production) and neetoformemail.net (staging).
|
|
169
|
+
|
|
170
|
+
15. Add the following to ApplicationMailbox
|
|
171
|
+
|
|
172
|
+
```ruby
|
|
173
|
+
routing /neetoemaildelivery/i => "neeto_email_delivery_engine/inbound"
|
|
174
|
+
```
|
|
104
175
|
|
|
105
176
|
### Frontend package
|
|
106
177
|
|
|
@@ -20,6 +20,30 @@
|
|
|
20
20
|
"shadowAccountMessage": "Looks like Outlook mailbox is not configured for your email address - {{email}}. Please configure your Outlook mailbox by logging in to your Outlook account and then try again.",
|
|
21
21
|
"cancel": "Cancel"
|
|
22
22
|
},
|
|
23
|
+
"smtp": {
|
|
24
|
+
"title": "SMTP",
|
|
25
|
+
"description": "Add your SMTP server details so that all emails are sent from your SMTP provider and not from Neeto.",
|
|
26
|
+
"connectSmtp": "Connect SMTP",
|
|
27
|
+
"smtpConfigured": "SMTP is configured for sending emails.",
|
|
28
|
+
"setup": {
|
|
29
|
+
"title": "Setup SMTP for outgoing emails",
|
|
30
|
+
"saveAndActivate": "Save & activate",
|
|
31
|
+
"note": "Note: Ensure that the SMTP credentials you provide have permission to send emails from the configured from email.",
|
|
32
|
+
"hostLabel": "SMTP host",
|
|
33
|
+
"portLabel": "SMTP port",
|
|
34
|
+
"usernameLabel": "Username",
|
|
35
|
+
"passwordLabel": "Password",
|
|
36
|
+
"emailLabel": "Email",
|
|
37
|
+
"encryptionLabel": "Encryption",
|
|
38
|
+
"noneLabel": "None",
|
|
39
|
+
"starttlsLabel": "StartTLS",
|
|
40
|
+
"sslLabel": "SSL",
|
|
41
|
+
"displayNameLabel": "Display name",
|
|
42
|
+
"disconnect": "Disconnect SMTP",
|
|
43
|
+
"requiredField": "{{field}} is required",
|
|
44
|
+
"emailInvalid": "Invalid email"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
23
47
|
"sparkpost": {
|
|
24
48
|
"ownDomainConfigured": "Own domain is configured for sending emails.",
|
|
25
49
|
"customDomain": "Custom domain",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import { useState } from 'react';
|
|
1
3
|
import { isPresent, humanize } from '@bigbinary/neeto-cist';
|
|
2
4
|
import { useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
3
|
-
import {
|
|
5
|
+
import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
|
|
4
6
|
import MailSend from '@bigbinary/neeto-icons/MailSend';
|
|
5
7
|
import GmailIcon from '@bigbinary/neeto-icons/misc/Gmail';
|
|
6
8
|
import OutlookIcon from '@bigbinary/neeto-icons/misc/Outlook';
|
|
@@ -10,20 +12,162 @@ import Toastr from '@bigbinary/neetoui/Toastr';
|
|
|
10
12
|
import { prop } from 'ramda';
|
|
11
13
|
import { useTranslation } from 'react-i18next';
|
|
12
14
|
import { useHistory } from 'react-router-dom';
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
15
|
+
import { i as invalidateAllIntegrationQueries, f as GMAIL_OAUTH_CONNECT_URL, g as OUTLOOK_OAUTH_CONNECT_URL } from './useSparkpostApi-qpRhsK7H.js';
|
|
16
|
+
import Pane from '@bigbinary/neetoui/Pane';
|
|
17
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
18
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
19
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
20
|
+
import Radio from '@bigbinary/neetoui/formik/Radio';
|
|
21
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
22
|
+
import { c as useCreateSmtp, u as useFetchGmail, d as useDestroyGmail, a as useFetchOutlook, e as useDestroyOutlook, b as useFetchSmtp, f as useDestroySmtp } from './useOutlookIntegrationApi-b_mNVfRE.js';
|
|
19
23
|
import { t } from 'i18next';
|
|
24
|
+
import * as yup from 'yup';
|
|
25
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
26
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
27
|
+
import { u as useSparkpostDomain } from './useSparkpostDomain-CuX-Gl5a.js';
|
|
20
28
|
import Button from '@bigbinary/neetoui/Button';
|
|
21
29
|
import Tag from '@bigbinary/neetoui/Tag';
|
|
22
|
-
import Typography from '@bigbinary/neetoui/Typography';
|
|
23
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
24
30
|
import '@babel/runtime/helpers/defineProperty';
|
|
25
31
|
import 'axios';
|
|
26
32
|
|
|
33
|
+
var ENCRYPTION_OPTIONS = [{
|
|
34
|
+
label: "None",
|
|
35
|
+
value: "none"
|
|
36
|
+
}, {
|
|
37
|
+
label: "StartTLS",
|
|
38
|
+
value: "starttls"
|
|
39
|
+
}, {
|
|
40
|
+
label: "SSL",
|
|
41
|
+
value: "ssl"
|
|
42
|
+
}];
|
|
43
|
+
var SMTP_ACCOUNT_INITIAL_VALUES = {
|
|
44
|
+
host: "",
|
|
45
|
+
port: 587,
|
|
46
|
+
username: "",
|
|
47
|
+
password: "",
|
|
48
|
+
email: "",
|
|
49
|
+
encryption: "starttls",
|
|
50
|
+
display_name: ""
|
|
51
|
+
};
|
|
52
|
+
var SMTP_ACCOUNT_VALIDATION_SCHEMA = yup.object().shape({
|
|
53
|
+
host: yup.string().trim().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
54
|
+
field: t("neetoEmailDelivery.smtp.setup.hostLabel")
|
|
55
|
+
})),
|
|
56
|
+
port: yup.number().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
57
|
+
field: t("neetoEmailDelivery.smtp.setup.portLabel")
|
|
58
|
+
})),
|
|
59
|
+
username: yup.string().trim().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
60
|
+
field: t("neetoEmailDelivery.smtp.setup.usernameLabel")
|
|
61
|
+
})),
|
|
62
|
+
password: yup.string().trim().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
63
|
+
field: t("neetoEmailDelivery.smtp.setup.passwordLabel")
|
|
64
|
+
})),
|
|
65
|
+
email: yup.string().trim().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
66
|
+
field: t("neetoEmailDelivery.smtp.setup.emailLabel")
|
|
67
|
+
})).email(t("neetoEmailDelivery.smtp.setup.emailInvalid")),
|
|
68
|
+
displayName: yup.string().trim().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
69
|
+
field: t("neetoEmailDelivery.smtp.setup.displayNameLabel")
|
|
70
|
+
})),
|
|
71
|
+
encryption: yup.string().trim().required(t("neetoEmailDelivery.smtp.setup.requiredField", {
|
|
72
|
+
field: t("neetoEmailDelivery.smtp.setup.encryptionLabel")
|
|
73
|
+
}))
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
var SmtpSetup = function SmtpSetup(_ref) {
|
|
77
|
+
var ownerId = _ref.ownerId,
|
|
78
|
+
onDone = _ref.onDone,
|
|
79
|
+
onCancel = _ref.onCancel;
|
|
80
|
+
var _useTranslation = useTranslation(),
|
|
81
|
+
t = _useTranslation.t;
|
|
82
|
+
var _useCreateSmtp = useCreateSmtp({
|
|
83
|
+
ownerId: ownerId
|
|
84
|
+
}),
|
|
85
|
+
isCreating = _useCreateSmtp.isPending,
|
|
86
|
+
createSmtp = _useCreateSmtp.mutate;
|
|
87
|
+
var handleSubmit = function handleSubmit(values) {
|
|
88
|
+
createSmtp({
|
|
89
|
+
smtp_account: values
|
|
90
|
+
}, {
|
|
91
|
+
onSuccess: onDone
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
95
|
+
isOpen: true,
|
|
96
|
+
size: "lg",
|
|
97
|
+
onClose: onCancel,
|
|
98
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
99
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
100
|
+
style: "h2",
|
|
101
|
+
weight: "semibold",
|
|
102
|
+
children: t("neetoEmailDelivery.smtp.setup.title")
|
|
103
|
+
})
|
|
104
|
+
}), /*#__PURE__*/jsxs(Form, {
|
|
105
|
+
className: "w-full",
|
|
106
|
+
formikProps: {
|
|
107
|
+
initialValues: SMTP_ACCOUNT_INITIAL_VALUES,
|
|
108
|
+
validationSchema: SMTP_ACCOUNT_VALIDATION_SCHEMA,
|
|
109
|
+
onSubmit: handleSubmit
|
|
110
|
+
},
|
|
111
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
112
|
+
className: "space-y-4",
|
|
113
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
114
|
+
className: "flex flex-col gap-6",
|
|
115
|
+
children: [/*#__PURE__*/jsx(Callout, {
|
|
116
|
+
style: "warning",
|
|
117
|
+
children: t("neetoEmailDelivery.smtp.setup.note")
|
|
118
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
119
|
+
required: true,
|
|
120
|
+
label: t("neetoEmailDelivery.smtp.setup.hostLabel"),
|
|
121
|
+
name: "host"
|
|
122
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
123
|
+
required: true,
|
|
124
|
+
label: t("neetoEmailDelivery.smtp.setup.portLabel"),
|
|
125
|
+
name: "port",
|
|
126
|
+
type: "number"
|
|
127
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
128
|
+
required: true,
|
|
129
|
+
label: t("neetoEmailDelivery.smtp.setup.usernameLabel"),
|
|
130
|
+
name: "username"
|
|
131
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
132
|
+
required: true,
|
|
133
|
+
label: t("neetoEmailDelivery.smtp.setup.passwordLabel"),
|
|
134
|
+
name: "password",
|
|
135
|
+
type: "password"
|
|
136
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
137
|
+
required: true,
|
|
138
|
+
label: t("neetoEmailDelivery.smtp.setup.emailLabel"),
|
|
139
|
+
name: "email",
|
|
140
|
+
type: "email"
|
|
141
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
142
|
+
required: true,
|
|
143
|
+
label: t("neetoEmailDelivery.smtp.setup.displayNameLabel"),
|
|
144
|
+
name: "displayName"
|
|
145
|
+
}), /*#__PURE__*/jsx(Radio, {
|
|
146
|
+
label: t("neetoEmailDelivery.smtp.setup.encryptionLabel"),
|
|
147
|
+
name: "encryption",
|
|
148
|
+
children: ENCRYPTION_OPTIONS.map(function (option) {
|
|
149
|
+
return /*#__PURE__*/jsx(Radio.Item, {
|
|
150
|
+
label: option.label,
|
|
151
|
+
value: option.value
|
|
152
|
+
}, option.value);
|
|
153
|
+
})
|
|
154
|
+
})]
|
|
155
|
+
})
|
|
156
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
157
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
158
|
+
cancelButtonProps: {
|
|
159
|
+
onClick: onCancel
|
|
160
|
+
},
|
|
161
|
+
isSubmitting: isCreating,
|
|
162
|
+
submitButtonProps: {
|
|
163
|
+
label: t("neetoEmailDelivery.smtp.setup.saveAndActivate")
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
})]
|
|
167
|
+
})]
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
|
|
27
171
|
var useGmail = function useGmail(_ref) {
|
|
28
172
|
var ownerId = _ref.ownerId,
|
|
29
173
|
indexRoute = _ref.indexRoute,
|
|
@@ -39,8 +183,7 @@ var useGmail = function useGmail(_ref) {
|
|
|
39
183
|
}),
|
|
40
184
|
isLoading = _useFetchGmail.isLoading,
|
|
41
185
|
_useFetchGmail$data = _useFetchGmail.data,
|
|
42
|
-
data = _useFetchGmail$data === void 0 ? {} : _useFetchGmail$data
|
|
43
|
-
isGmailFetched = _useFetchGmail.isSuccess;
|
|
186
|
+
data = _useFetchGmail$data === void 0 ? {} : _useFetchGmail$data;
|
|
44
187
|
var _useDestroyGmail = useDestroyGmail({
|
|
45
188
|
ownerId: ownerId
|
|
46
189
|
}),
|
|
@@ -52,25 +195,12 @@ var useGmail = function useGmail(_ref) {
|
|
|
52
195
|
var onDisconnect = function onDisconnect() {
|
|
53
196
|
destroyIntegration(false, {
|
|
54
197
|
onSuccess: function onSuccess() {
|
|
55
|
-
showThumbsUpToastr();
|
|
56
198
|
setIsDisconnectAlertOpen(false);
|
|
57
199
|
invalidateAllIntegrationQueries(queryClient, ownerId);
|
|
58
200
|
history.replace(indexRoute);
|
|
59
201
|
}
|
|
60
202
|
});
|
|
61
203
|
};
|
|
62
|
-
useEffect(function () {
|
|
63
|
-
if (isGmailFetched) {
|
|
64
|
-
queryClient.invalidateQueries({
|
|
65
|
-
predicate: function predicate(query) {
|
|
66
|
-
var _query$queryKey = _slicedToArray(query.queryKey, 2),
|
|
67
|
-
key = _query$queryKey[0],
|
|
68
|
-
id = _query$queryKey[1];
|
|
69
|
-
return key === QUERY_KEYS.INTEGRATION_GMAIL && id !== ownerId;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}, [isGmailFetched, queryClient, ownerId]);
|
|
74
204
|
return {
|
|
75
205
|
data: data,
|
|
76
206
|
isLoading: isLoading,
|
|
@@ -100,8 +230,7 @@ var useOutlook = function useOutlook(_ref) {
|
|
|
100
230
|
}),
|
|
101
231
|
isLoading = _useFetchOutlook.isLoading,
|
|
102
232
|
_useFetchOutlook$data = _useFetchOutlook.data,
|
|
103
|
-
data = _useFetchOutlook$data === void 0 ? {} : _useFetchOutlook$data
|
|
104
|
-
isOutlookFetched = _useFetchOutlook.isSuccess;
|
|
233
|
+
data = _useFetchOutlook$data === void 0 ? {} : _useFetchOutlook$data;
|
|
105
234
|
var _useDestroyOutlook = useDestroyOutlook({
|
|
106
235
|
ownerId: ownerId
|
|
107
236
|
}),
|
|
@@ -113,25 +242,12 @@ var useOutlook = function useOutlook(_ref) {
|
|
|
113
242
|
var onDisconnect = function onDisconnect() {
|
|
114
243
|
destroyIntegration(false, {
|
|
115
244
|
onSuccess: function onSuccess() {
|
|
116
|
-
showThumbsUpToastr();
|
|
117
245
|
setIsDisconnectAlertOpen(false);
|
|
118
246
|
invalidateAllIntegrationQueries(queryClient, ownerId);
|
|
119
247
|
history.replace(indexRoute);
|
|
120
248
|
}
|
|
121
249
|
});
|
|
122
250
|
};
|
|
123
|
-
useEffect(function () {
|
|
124
|
-
if (isOutlookFetched) {
|
|
125
|
-
queryClient.invalidateQueries({
|
|
126
|
-
predicate: function predicate(query) {
|
|
127
|
-
var _query$queryKey = _slicedToArray(query.queryKey, 2),
|
|
128
|
-
key = _query$queryKey[0],
|
|
129
|
-
id = _query$queryKey[1];
|
|
130
|
-
return key === QUERY_KEYS.INTEGRATION_OUTLOOK && id !== ownerId;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}, [isOutlookFetched, queryClient, ownerId]);
|
|
135
251
|
return {
|
|
136
252
|
data: data,
|
|
137
253
|
isLoading: isLoading,
|
|
@@ -149,6 +265,30 @@ var useOutlook = function useOutlook(_ref) {
|
|
|
149
265
|
};
|
|
150
266
|
};
|
|
151
267
|
|
|
268
|
+
var useSmtp = function useSmtp(_ref) {
|
|
269
|
+
var ownerId = _ref.ownerId,
|
|
270
|
+
canManageIntegrations = _ref.canManageIntegrations;
|
|
271
|
+
var _useFetchSmtp = useFetchSmtp(ownerId, {
|
|
272
|
+
enabled: canManageIntegrations
|
|
273
|
+
}),
|
|
274
|
+
isLoading = _useFetchSmtp.isLoading,
|
|
275
|
+
_useFetchSmtp$data = _useFetchSmtp.data,
|
|
276
|
+
data = _useFetchSmtp$data === void 0 ? {} : _useFetchSmtp$data;
|
|
277
|
+
var _useDestroySmtp = useDestroySmtp({
|
|
278
|
+
ownerId: ownerId
|
|
279
|
+
}),
|
|
280
|
+
isDestroying = _useDestroySmtp.isPending,
|
|
281
|
+
onDisconnect = _useDestroySmtp.mutate;
|
|
282
|
+
return {
|
|
283
|
+
data: data,
|
|
284
|
+
isConnected: data === null || data === void 0 ? void 0 : data.connected,
|
|
285
|
+
isLoading: isLoading,
|
|
286
|
+
isDestroying: isDestroying,
|
|
287
|
+
onDisconnect: onDisconnect,
|
|
288
|
+
exists: data === null || data === void 0 ? void 0 : data.exists
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
|
|
152
292
|
var ERROR_MESSAGES = {
|
|
153
293
|
gmail_permission_not_given: t("neetoEmailDelivery.gmail.permissionNotGiven"),
|
|
154
294
|
outlook_permission_not_given: t("neetoEmailDelivery.outlook.permissionNotGiven"),
|
|
@@ -228,6 +368,10 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
228
368
|
var _useTranslation = useTranslation(),
|
|
229
369
|
t = _useTranslation.t;
|
|
230
370
|
var history = useHistory();
|
|
371
|
+
var _useState = useState(false),
|
|
372
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
373
|
+
isSmtpPaneOpen = _useState2[0],
|
|
374
|
+
setIsSmtpPaneOpen = _useState2[1];
|
|
231
375
|
var _useQueryParams = useQueryParams(),
|
|
232
376
|
error = _useQueryParams.error,
|
|
233
377
|
errorDescription = _useQueryParams.errorDescription;
|
|
@@ -254,6 +398,10 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
254
398
|
ownerId: ownerId,
|
|
255
399
|
canManageIntegrations: canManageIntegrations
|
|
256
400
|
});
|
|
401
|
+
var smtpIntegration = useSmtp({
|
|
402
|
+
ownerId: ownerId,
|
|
403
|
+
canManageIntegrations: canManageIntegrations
|
|
404
|
+
});
|
|
257
405
|
var _gmailIntegration$dat = gmailIntegration.data,
|
|
258
406
|
gmailData = _gmailIntegration$dat === void 0 ? {} : _gmailIntegration$dat,
|
|
259
407
|
isGmailConnected = gmailIntegration.isConnected,
|
|
@@ -277,11 +425,19 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
277
425
|
onSparkpostDisconnect = sparkpostIntegration.onDisconnect,
|
|
278
426
|
isSparkpostDisconnecting = sparkpostIntegration.isDestroying,
|
|
279
427
|
isSparkpostExists = sparkpostIntegration.exists;
|
|
280
|
-
var
|
|
281
|
-
|
|
428
|
+
var _smtpIntegration$data = smtpIntegration.data,
|
|
429
|
+
smtpData = _smtpIntegration$data === void 0 ? {} : _smtpIntegration$data,
|
|
430
|
+
isSmtpConnected = smtpIntegration.isConnected,
|
|
431
|
+
isSmtpLoading = smtpIntegration.isLoading,
|
|
432
|
+
isSmtpDisconnecting = smtpIntegration.isDestroying,
|
|
433
|
+
onSmtpDisconnect = smtpIntegration.onDisconnect,
|
|
434
|
+
isSmtpExists = smtpIntegration.exists;
|
|
435
|
+
var isLoading = isGmailLoading || isOutlookLoading || isSparkpostLoading || isSmtpLoading;
|
|
436
|
+
var noneExists = !isGmailExists && !isOutlookExists && !isSparkpostExists && !isSmtpExists;
|
|
282
437
|
var showGmail = noneExists || isGmailExists;
|
|
283
438
|
var showOutlook = noneExists || isOutlookExists;
|
|
284
439
|
var showSparkpost = noneExists || isSparkpostExists;
|
|
440
|
+
var showSmtp = noneExists || isSmtpExists;
|
|
285
441
|
var handleGmailConnect = function handleGmailConnect() {
|
|
286
442
|
window.location.href = buildUrl(GMAIL_OAUTH_CONNECT_URL, {
|
|
287
443
|
ownerId: ownerId
|
|
@@ -295,9 +451,16 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
295
451
|
var handleOwnDomainConnect = function handleOwnDomainConnect() {
|
|
296
452
|
history.push(ownDomainSetupRoute);
|
|
297
453
|
};
|
|
454
|
+
var handleSmtpConnect = function handleSmtpConnect() {
|
|
455
|
+
setIsSmtpPaneOpen(true);
|
|
456
|
+
};
|
|
457
|
+
var handleSmtpPaneClose = function handleSmtpPaneClose() {
|
|
458
|
+
setIsSmtpPaneOpen(false);
|
|
459
|
+
};
|
|
298
460
|
var gmailEmail = prop("email", gmailData);
|
|
299
461
|
var outlookEmail = prop("email", outlookData);
|
|
300
462
|
var sparkpostEmail = prop("email", sparkpostData);
|
|
463
|
+
var smtpEmail = prop("email", smtpData);
|
|
301
464
|
var gmailTitle = t("neetoEmailDelivery.gmail.title");
|
|
302
465
|
var gmailDescription = isGmailConnected ? t("neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail", {
|
|
303
466
|
email: gmailEmail
|
|
@@ -310,16 +473,20 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
310
473
|
var ownDomainDescription = isSparkpostConnected ? t("neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail", {
|
|
311
474
|
email: sparkpostEmail
|
|
312
475
|
}) : t("neetoEmailDelivery.sparkpost.emailDelivery.ownDomainDescription");
|
|
476
|
+
var smtpTitle = t("neetoEmailDelivery.smtp.title");
|
|
477
|
+
var smtpDescription = isSmtpConnected ? t("neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail", {
|
|
478
|
+
email: smtpEmail
|
|
479
|
+
}) : t("neetoEmailDelivery.smtp.description");
|
|
313
480
|
if (isLoading) {
|
|
314
481
|
return /*#__PURE__*/jsx("div", {
|
|
315
482
|
className: "flex grow items-center justify-center w-full",
|
|
316
483
|
children: /*#__PURE__*/jsx(Spinner, {})
|
|
317
484
|
});
|
|
318
485
|
}
|
|
319
|
-
var activeMessage = isGmailConnected && t("neetoEmailDelivery.gmail.gmailConfigured") || isOutlookConnected && t("neetoEmailDelivery.outlook.outlookConfigured") || isSparkpostConnected && t("neetoEmailDelivery.sparkpost.ownDomainConfigured");
|
|
320
|
-
return /*#__PURE__*/
|
|
486
|
+
var activeMessage = isGmailConnected && t("neetoEmailDelivery.gmail.gmailConfigured") || isOutlookConnected && t("neetoEmailDelivery.outlook.outlookConfigured") || isSparkpostConnected && t("neetoEmailDelivery.sparkpost.ownDomainConfigured") || isSmtpConnected && t("neetoEmailDelivery.smtp.smtpConfigured");
|
|
487
|
+
return /*#__PURE__*/jsxs("div", {
|
|
321
488
|
className: "min-h-0 w-full grow",
|
|
322
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
489
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
323
490
|
className: "@container mx-auto space-y-6",
|
|
324
491
|
children: [/*#__PURE__*/jsxs("div", {
|
|
325
492
|
className: "grid grid-cols-1 gap-3 py-1 @lg:grid-cols-2 @lg:gap-6 @3xl:grid-cols-3 @7xl:grid-cols-4",
|
|
@@ -351,6 +518,15 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
351
518
|
title: ownDomainTitle,
|
|
352
519
|
onConnect: handleOwnDomainConnect,
|
|
353
520
|
onDisconnect: onSparkpostDisconnect
|
|
521
|
+
}), showSmtp && /*#__PURE__*/jsx(IntegrationCard, {
|
|
522
|
+
connectButtonText: "neetoEmailDelivery.smtp.connectSmtp",
|
|
523
|
+
description: smtpDescription,
|
|
524
|
+
icon: MailSend,
|
|
525
|
+
isConnected: isSmtpConnected,
|
|
526
|
+
isDisconnecting: isSmtpDisconnecting,
|
|
527
|
+
title: smtpTitle,
|
|
528
|
+
onConnect: handleSmtpConnect,
|
|
529
|
+
onDisconnect: onSmtpDisconnect
|
|
354
530
|
})]
|
|
355
531
|
}), activeMessage && /*#__PURE__*/jsx(Callout, {
|
|
356
532
|
style: "success",
|
|
@@ -366,7 +542,11 @@ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
|
|
|
366
542
|
email: outlookEmail
|
|
367
543
|
})
|
|
368
544
|
})]
|
|
369
|
-
})
|
|
545
|
+
}), isSmtpPaneOpen && /*#__PURE__*/jsx(SmtpSetup, {
|
|
546
|
+
ownerId: ownerId,
|
|
547
|
+
onCancel: handleSmtpPaneClose,
|
|
548
|
+
onDone: handleSmtpPaneClose
|
|
549
|
+
})]
|
|
370
550
|
});
|
|
371
551
|
};
|
|
372
552
|
|