@bigbinary/neeto-custom-domains-frontend 3.3.1 → 3.3.3

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.
Files changed (62) hide show
  1. package/app/javascript/src/translations/ar.json +5 -1
  2. package/app/javascript/src/translations/bg.json +5 -1
  3. package/app/javascript/src/translations/ca.json +5 -1
  4. package/app/javascript/src/translations/cs.json +5 -1
  5. package/app/javascript/src/translations/da.json +5 -1
  6. package/app/javascript/src/translations/de.json +5 -1
  7. package/app/javascript/src/translations/en.json +4 -0
  8. package/app/javascript/src/translations/es-MX.json +5 -1
  9. package/app/javascript/src/translations/es.json +5 -1
  10. package/app/javascript/src/translations/et.json +5 -1
  11. package/app/javascript/src/translations/fi.json +5 -1
  12. package/app/javascript/src/translations/fil.json +5 -1
  13. package/app/javascript/src/translations/fr.json +5 -1
  14. package/app/javascript/src/translations/he.json +5 -1
  15. package/app/javascript/src/translations/hi.json +5 -1
  16. package/app/javascript/src/translations/hr.json +5 -1
  17. package/app/javascript/src/translations/hu.json +4 -0
  18. package/app/javascript/src/translations/id.json +5 -1
  19. package/app/javascript/src/translations/it.json +5 -1
  20. package/app/javascript/src/translations/ja.json +5 -1
  21. package/app/javascript/src/translations/ko.json +5 -1
  22. package/app/javascript/src/translations/nl.json +5 -1
  23. package/app/javascript/src/translations/pl.json +5 -1
  24. package/app/javascript/src/translations/pt-BR.json +5 -1
  25. package/app/javascript/src/translations/pt.json +5 -1
  26. package/app/javascript/src/translations/ro.json +5 -1
  27. package/app/javascript/src/translations/ru.json +5 -1
  28. package/app/javascript/src/translations/sk.json +5 -1
  29. package/app/javascript/src/translations/sl.json +5 -1
  30. package/app/javascript/src/translations/sv.json +5 -1
  31. package/app/javascript/src/translations/th.json +5 -1
  32. package/app/javascript/src/translations/tr.json +5 -1
  33. package/app/javascript/src/translations/uk.json +5 -1
  34. package/app/javascript/src/translations/vi.json +5 -1
  35. package/app/javascript/src/translations/zh-CN.json +5 -1
  36. package/app/javascript/src/translations/zh-TW.json +5 -1
  37. package/dist/.ready +1 -1
  38. package/dist/CustomDomain.js +60 -733
  39. package/dist/CustomDomain.js.map +1 -1
  40. package/dist/application-Dwn9zjMI.js +719 -0
  41. package/dist/application-Dwn9zjMI.js.map +1 -0
  42. package/dist/application-kZuSmUKo.js +711 -0
  43. package/dist/application-kZuSmUKo.js.map +1 -0
  44. package/dist/cjs/CustomDomain.js +66 -739
  45. package/dist/cjs/CustomDomain.js.map +1 -1
  46. package/dist/cjs/index.js +6 -5
  47. package/dist/cjs/index.js.map +1 -1
  48. package/dist/cjs/v2/CustomDomain.js +1429 -0
  49. package/dist/cjs/v2/CustomDomain.js.map +1 -0
  50. package/dist/cjs/v2/WelcomeScreen.js +14 -0
  51. package/dist/cjs/v2/WelcomeScreen.js.map +1 -0
  52. package/dist/cjs/v2/index.js +37 -0
  53. package/dist/cjs/v2/index.js.map +1 -0
  54. package/dist/index.js +6 -5
  55. package/dist/index.js.map +1 -1
  56. package/dist/v2/CustomDomain.js +1408 -0
  57. package/dist/v2/CustomDomain.js.map +1 -0
  58. package/dist/v2/WelcomeScreen.js +12 -0
  59. package/dist/v2/WelcomeScreen.js.map +1 -0
  60. package/dist/v2/index.js +30 -0
  61. package/dist/v2/index.js.map +1 -0
  62. package/package.json +28 -16
@@ -0,0 +1,1429 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var React = require('react');
5
+ var neetoCist = require('@bigbinary/neeto-cist');
6
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
7
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
8
+ var reactI18next = require('react-i18next');
9
+ var application = require('../../application-Dwn9zjMI.js');
10
+ var Container = require('@bigbinary/neeto-molecules/v2/Container');
11
+ var CheckCircle = require('@bigbinary/neeto-icons/CheckCircle');
12
+ var Warning2 = require('@bigbinary/neeto-icons/Warning2');
13
+ var CloseCircle = require('@bigbinary/neeto-icons/CloseCircle');
14
+ var jsxRuntime = require('react/jsx-runtime');
15
+ var classNames = require('classnames');
16
+ var constants = require('@bigbinary/neeto-commons-frontend/v2/constants');
17
+ var CustomDomain$1 = require('@bigbinary/neeto-icons/CustomDomain');
18
+ var ExternalLink = require('@bigbinary/neeto-icons/ExternalLink');
19
+ var CardLayout = require('@bigbinary/neeto-molecules/v2/CardLayout');
20
+ var MoreDropdown = require('@bigbinary/neeto-molecules/v2/MoreDropdown');
21
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
22
+ var formik = require('@bigbinary/neeto-atoms/formik');
23
+ var i18next = require('i18next');
24
+ var Yup = require('yup');
25
+ var reactQuery = require('@tanstack/react-query');
26
+ var CopyToClipboardButton = require('@bigbinary/neeto-molecules/v2/CopyToClipboardButton');
27
+ var NeetoHeader = require('@bigbinary/neeto-molecules/v2/Header');
28
+ require('@bigbinary/neeto-commons-frontend/react-utils/useMutationWithInvalidation');
29
+ require('axios');
30
+
31
+ function _interopNamespaceDefault(e) {
32
+ var n = Object.create(null);
33
+ if (e) {
34
+ Object.keys(e).forEach(function (k) {
35
+ if (k !== 'default') {
36
+ var d = Object.getOwnPropertyDescriptor(e, k);
37
+ Object.defineProperty(n, k, d.get ? d : {
38
+ enumerable: true,
39
+ get: function () { return e[k]; }
40
+ });
41
+ }
42
+ });
43
+ }
44
+ n.default = e;
45
+ return Object.freeze(n);
46
+ }
47
+
48
+ var Yup__namespace = /*#__PURE__*/_interopNamespaceDefault(Yup);
49
+
50
+ var STATUS_TAG_STYLES = {
51
+ active: "success",
52
+ pending: "warning",
53
+ failed: "danger"
54
+ };
55
+ var STATUS_ICON = {
56
+ active: CheckCircle,
57
+ pending: Warning2,
58
+ failed: CloseCircle
59
+ };
60
+ var DNS_TARGETS = {
61
+ staging: {
62
+ cname: "staging.neetodeployapp.com",
63
+ ip: "98.89.128.226"
64
+ },
65
+ production: {
66
+ cname: "dns.neetodeployapp.com",
67
+ ip: "34.233.85.113"
68
+ },
69
+ development: {
70
+ cname: "dns.neetodeployapp.com",
71
+ ip: "34.233.85.113"
72
+ }
73
+ };
74
+ var NEETO_CUSTOM_DOMAINS_NANO_README_URL = "https://github.com/neetozone/neeto-custom-domains-nano#env-variables";
75
+
76
+ var DeleteAlert = reactUtils.withT(function (_ref) {
77
+ var t = _ref.t,
78
+ onClose = _ref.onClose,
79
+ onSubmit = _ref.onSubmit,
80
+ isOpen = _ref.isOpen,
81
+ isSubmitting = _ref.isSubmitting,
82
+ hostname = _ref.hostname;
83
+ return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Alert, {
84
+ isOpen: isOpen,
85
+ isSubmitting: isSubmitting,
86
+ onClose: onClose,
87
+ onSubmit: onSubmit,
88
+ cancelButtonLabel: t("neetoCustomDomains.actions.cancel"),
89
+ submitButtonLabel: t("neetoCustomDomains.actions.delete"),
90
+ title: t("neetoCustomDomains.delete"),
91
+ message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
92
+ i18nKey: "neetoCustomDomains.alertMessage",
93
+ values: {
94
+ hostname: hostname
95
+ }
96
+ })
97
+ });
98
+ });
99
+
100
+ var Domain = function Domain(_ref) {
101
+ var isCustomDomainAdded = _ref.isCustomDomainAdded,
102
+ disconnectedIntegrationCardDescription = _ref.disconnectedIntegrationCardDescription,
103
+ connectedIntegrationCardDescription = _ref.connectedIntegrationCardDescription,
104
+ openPane = _ref.openPane,
105
+ customDomains = _ref.customDomains,
106
+ openDeleteAlert = _ref.openDeleteAlert,
107
+ helpDocUrl = _ref.helpDocUrl,
108
+ setSelectedCustomDomain = _ref.setSelectedCustomDomain;
109
+ var _useTranslation = reactI18next.useTranslation(),
110
+ t = _useTranslation.t;
111
+ var handleEditClick = function handleEditClick(customDomain) {
112
+ setSelectedCustomDomain(customDomain);
113
+ openPane();
114
+ };
115
+ var handleDeleteClick = function handleDeleteClick(customDomain) {
116
+ setSelectedCustomDomain(customDomain);
117
+ openDeleteAlert();
118
+ };
119
+ return isCustomDomainAdded ? /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
120
+ actionBlock: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
121
+ content: t("neetoCustomDomains.tooltipContent"),
122
+ position: "top",
123
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
124
+ className: "inline-block",
125
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
126
+ "data-testid": "add-custom-domain-button",
127
+ disabled: isCustomDomainAdded,
128
+ label: t("neetoCustomDomains.actions.add", {
129
+ what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
130
+ }),
131
+ onClick: openPane
132
+ })
133
+ })
134
+ }),
135
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
136
+ className: "flex flex-col gap-y-6 divide-y divide-gray-200",
137
+ children: customDomains === null || customDomains === void 0 ? void 0 : customDomains.map(function (customDomain, index) {
138
+ var _customDomain$redirec;
139
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
140
+ className: "flex items-center gap-x-3 pb-6 last:pb-0",
141
+ "data-testid": "custom-domain-item",
142
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
143
+ className: classNames("rounded-lg flex items-center justify-center p-2", {
144
+ "bg-success": (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "active",
145
+ "bg-warning": (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "pending",
146
+ "bg-error": (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "failed"
147
+ }),
148
+ children: function () {
149
+ var IconComponent = STATUS_ICON[customDomain === null || customDomain === void 0 ? void 0 : customDomain.status] || CustomDomain$1;
150
+ return /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
151
+ size: 32,
152
+ className: classNames({
153
+ "text-success-foreground": (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "active",
154
+ "text-warning-foreground": (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "pending",
155
+ "text-error-foreground": (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "failed"
156
+ })
157
+ });
158
+ }()
159
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
160
+ className: "flex flex-col gap-y-1",
161
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
162
+ className: "flex items-center gap-x-3",
163
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
164
+ className: "hover:text-primary flex cursor-pointer items-center gap-x-2",
165
+ onClick: function onClick() {
166
+ return window.open("https://".concat(customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname), "_blank", "noopener,noreferrer");
167
+ },
168
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
169
+ className: "hover:text-primary",
170
+ variant: "h4",
171
+ weight: "medium",
172
+ children: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname
173
+ }), (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "active" && /*#__PURE__*/jsxRuntime.jsx(ExternalLink, {
174
+ size: 16
175
+ })]
176
+ }), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
177
+ isRounded: true,
178
+ dropdownButtonProps: {
179
+ "data-testid": "custom-domains-more-dropdown-button",
180
+ size: "sm"
181
+ },
182
+ dropdownProps: {
183
+ position: "bottom-end",
184
+ strategy: "fixed",
185
+ autoWidth: true
186
+ },
187
+ menuItems: [{
188
+ label: t("neetoCustomDomains.actions.edit"),
189
+ onClick: function onClick() {
190
+ return handleEditClick(customDomain);
191
+ },
192
+ key: "edit-custom-domain-button",
193
+ "data-testid": "edit-custom-domain-button"
194
+ }, {
195
+ label: t("neetoCustomDomains.actions.delete"),
196
+ onClick: function onClick() {
197
+ return handleDeleteClick(customDomain);
198
+ },
199
+ key: "delete-custom-domain",
200
+ "data-testid": "delete-custom-domain-button"
201
+ }]
202
+ })]
203
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
204
+ children: [/*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Typography, {
205
+ className: "text-muted-foreground",
206
+ variant: "body2",
207
+ children: [(customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "active" && (customDomain === null || customDomain === void 0 ? void 0 : customDomain.redirection) && /*#__PURE__*/jsxRuntime.jsxs("span", {
208
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
209
+ components: {
210
+ b: /*#__PURE__*/jsxRuntime.jsx("b", {})
211
+ },
212
+ i18nKey: "neetoCustomDomains.redirectionTooltipDescription",
213
+ values: {
214
+ fromDomain: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname,
215
+ toDomain: customDomain === null || customDomain === void 0 || (_customDomain$redirec = customDomain.redirection) === null || _customDomain$redirec === void 0 ? void 0 : _customDomain$redirec.toHostname
216
+ }
217
+ }), " ", connectedIntegrationCardDescription || ""]
218
+ }), (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "active" && !(customDomain !== null && customDomain !== void 0 && customDomain.redirection) && /*#__PURE__*/jsxRuntime.jsxs("span", {
219
+ children: [t("neetoCustomDomains.activeTooltipDescription"), " ", connectedIntegrationCardDescription || ""]
220
+ }), (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "pending" && t("neetoCustomDomains.pendingTooltipDescription"), (customDomain === null || customDomain === void 0 ? void 0 : customDomain.status) === "failed" && t("neetoCustomDomains.failedTooltipDescription")]
221
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
222
+ className: "text-muted-foreground mt-2",
223
+ variant: "body2",
224
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
225
+ i18nKey: "neetoCustomDomains.noData.helpTextConnected",
226
+ components: {
227
+ Link: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
228
+ href: helpDocUrl,
229
+ rel: "noreferrer",
230
+ variant: "link",
231
+ target: "_blank"
232
+ })
233
+ }
234
+ })
235
+ })]
236
+ })]
237
+ })]
238
+ }, index);
239
+ })
240
+ })
241
+ }) : /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
242
+ actionBlock: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
243
+ "data-testid": "add-new-custom-domain-button",
244
+ label: t("neetoCustomDomains.actions.add", {
245
+ what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
246
+ }),
247
+ onClick: openPane
248
+ }),
249
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
250
+ className: "flex h-full w-full items-center gap-x-3",
251
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
252
+ className: "bg-muted rounded-lg flex items-center justify-center p-2",
253
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomDomain$1, {
254
+ className: "text-muted-foreground",
255
+ size: 32
256
+ })
257
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
258
+ className: "flex flex-col gap-y-1",
259
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
260
+ variant: "h4",
261
+ weight: "medium",
262
+ children: t("neetoCustomDomains.noData.title")
263
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
264
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
265
+ className: "text-muted-foreground",
266
+ variant: "body2",
267
+ children: disconnectedIntegrationCardDescription || t("neetoCustomDomains.noData.helpTextDefault")
268
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
269
+ className: "text-muted-foreground mt-2",
270
+ variant: "body2",
271
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
272
+ i18nKey: "neetoCustomDomains.noData.helpTextDisconnected",
273
+ components: {
274
+ Link: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
275
+ href: helpDocUrl,
276
+ rel: "noreferrer",
277
+ variant: "link",
278
+ target: "_blank"
279
+ })
280
+ }
281
+ })
282
+ })]
283
+ })]
284
+ })]
285
+ })
286
+ });
287
+ };
288
+
289
+ var HOSTNAME_REGEX = /^(https?:\/\/)?([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}(\/\S*)?$/;
290
+ var INITIAL_VALUES = {
291
+ hostname: ""
292
+ };
293
+ var CURRENT_STEP = {
294
+ notAdded: 0,
295
+ strategy: 1,
296
+ pending: 2,
297
+ failed: 2,
298
+ active: 3
299
+ };
300
+ var STEPS = [{
301
+ id: 1,
302
+ label: "Add domain"
303
+ }, {
304
+ id: 2,
305
+ label: "Strategy"
306
+ }, {
307
+ id: 3,
308
+ label: "Validate domain"
309
+ }];
310
+ var STRATEGY_INITIAL_VALUES = {
311
+ strategy: "rootToWww"
312
+ };
313
+
314
+ var isRootLevelDomain = function isRootLevelDomain(hostname) {
315
+ return !application.parse(hostname).subdomain;
316
+ };
317
+ var getCustomDomainValidationSchema = function getCustomDomainValidationSchema() {
318
+ return Yup__namespace.object().shape({
319
+ hostname: Yup__namespace.string().required(i18next.t("neetoCustomDomains.formikValidation.required")).matches(HOSTNAME_REGEX, i18next.t("neetoCustomDomains.formikValidation.valid"))
320
+ });
321
+ };
322
+ var strategyValidationSchema = Yup__namespace.object().shape({
323
+ strategy: Yup__namespace.string().required()
324
+ });
325
+ var strategyOptions = [{
326
+ value: "rootToWww",
327
+ label: "neetoCustomDomains.validation.strategy.rootToWww",
328
+ additionalLabelContent: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
329
+ content: i18next.t("neetoCustomDomains.validation.strategy.recommendedDescription"),
330
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Badge, {
331
+ label: i18next.t("neetoCustomDomains.validation.strategy.recommended"),
332
+ variant: "blue-subtle"
333
+ })
334
+ })
335
+ }, {
336
+ value: "wwwToRoot",
337
+ label: "neetoCustomDomains.validation.strategy.wwwToRoot"
338
+ }, {
339
+ value: "onlyAddRoot",
340
+ label: "neetoCustomDomains.validation.strategy.onlyAddRoot"
341
+ }];
342
+
343
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
344
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
345
+ var Strategy = reactUtils.withT(function (_ref) {
346
+ var t = _ref.t,
347
+ hostname = _ref.hostname,
348
+ subdomainPlaceholder = _ref.subdomainPlaceholder,
349
+ handleSubmit = _ref.handleSubmit,
350
+ errorData = _ref.errorData,
351
+ isSubmitting = _ref.isSubmitting,
352
+ setPrimaryDomain = _ref.setPrimaryDomain,
353
+ onClose = _ref.onClose;
354
+ return /*#__PURE__*/jsxRuntime.jsxs(formik.Form, {
355
+ formikProps: {
356
+ initialValues: STRATEGY_INITIAL_VALUES,
357
+ validationSchema: strategyValidationSchema,
358
+ onSubmit: handleSubmit,
359
+ onReset: function onReset() {
360
+ setPrimaryDomain({});
361
+ onClose();
362
+ }
363
+ },
364
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Body, {
365
+ className: "space-y-4",
366
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
367
+ className: "space-y-4",
368
+ children: [/*#__PURE__*/jsxRuntime.jsx(formik.RadioGroup, {
369
+ stacked: true,
370
+ name: "strategy",
371
+ children: strategyOptions.map(function (_ref2, index) {
372
+ var value = _ref2.value,
373
+ label = _ref2.label,
374
+ AdditionalLabelContent = _ref2.additionalLabelContent;
375
+ return /*#__PURE__*/React.createElement(formik.RadioGroup.Item, {
376
+ value: value,
377
+ key: index,
378
+ name: "strategy",
379
+ label: /*#__PURE__*/jsxRuntime.jsxs("span", {
380
+ className: "flex items-center gap-1",
381
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
382
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
383
+ i18nKey: label,
384
+ values: {
385
+ hostname: hostname
386
+ }
387
+ })
388
+ }), AdditionalLabelContent]
389
+ })
390
+ });
391
+ })
392
+ }), (errorData === null || errorData === void 0 ? void 0 : errorData.key) && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
393
+ variant: "warning",
394
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
395
+ variant: "body2",
396
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
397
+ i18nKey: errorData === null || errorData === void 0 ? void 0 : errorData.key,
398
+ values: _objectSpread$1(_objectSpread$1({}, errorData), {}, {
399
+ subdomainPlaceholder: subdomainPlaceholder
400
+ }),
401
+ components: {
402
+ Link: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
403
+ href: errorData === null || errorData === void 0 ? void 0 : errorData.pageUrl,
404
+ rel: "noreferrer",
405
+ variant: "link",
406
+ target: "_blank"
407
+ })
408
+ }
409
+ })
410
+ })
411
+ })]
412
+ })
413
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Footer, {
414
+ children: /*#__PURE__*/jsxRuntime.jsx(formik.ActionBlock, {
415
+ isSubmitting: isSubmitting,
416
+ cancelButtonProps: {
417
+ label: t("neetoCustomDomains.actions.cancel")
418
+ },
419
+ submitButtonProps: {
420
+ label: t("neetoCustomDomains.actions.continue"),
421
+ disabled: false,
422
+ "data-testid": "custom-domain-strategy-continue-button"
423
+ }
424
+ })
425
+ })]
426
+ });
427
+ });
428
+
429
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
430
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
431
+ var DomainField = function DomainField(_ref) {
432
+ var onCreate = _ref.onCreate,
433
+ url = _ref.url,
434
+ onClose = _ref.onClose,
435
+ subdomainPlaceholder = _ref.subdomainPlaceholder,
436
+ setPrimaryDomain = _ref.setPrimaryDomain,
437
+ errorData = _ref.errorData,
438
+ setErrorData = _ref.setErrorData;
439
+ var _useTranslation = reactI18next.useTranslation(),
440
+ t = _useTranslation.t;
441
+ var _useState = React.useState(""),
442
+ _useState2 = _slicedToArray(_useState, 2),
443
+ hostname = _useState2[0],
444
+ setHostname = _useState2[1];
445
+ var wwwHostname = "www.".concat(hostname);
446
+ var _useCreateCustomDomai = application.useCreateCustomDomain(url, {
447
+ onError: function onError(_ref2) {
448
+ var response = _ref2.response;
449
+ setPrimaryDomain();
450
+ setErrorData(response.data);
451
+ }
452
+ }),
453
+ createCustomDomain = _useCreateCustomDomai.mutate,
454
+ isCreatingCustomDomain = _useCreateCustomDomai.isPending;
455
+ var handleDomainCreation = function handleDomainCreation(payload) {
456
+ return createCustomDomain(payload, {
457
+ onSuccess: function onSuccess(values) {
458
+ onCreate === null || onCreate === void 0 || onCreate(values);
459
+ }
460
+ });
461
+ };
462
+ var handleStrategy = {
463
+ rootToWww: {
464
+ hostname: hostname,
465
+ toHostname: wwwHostname
466
+ },
467
+ wwwToRoot: {
468
+ hostname: wwwHostname,
469
+ toHostname: hostname
470
+ },
471
+ onlyAddRoot: {
472
+ hostname: hostname
473
+ }
474
+ };
475
+ var handleSubmit = function handleSubmit(_ref3) {
476
+ var strategy = _ref3.strategy;
477
+ return handleDomainCreation(handleStrategy[strategy]);
478
+ };
479
+ var getHostname = function getHostname(hostname) {
480
+ var url = hostname.includes("://") ? hostname : "https://".concat(hostname);
481
+ try {
482
+ var parsedUrl = new URL(url);
483
+ return parsedUrl.hostname;
484
+ } catch (_unused) {
485
+ return url;
486
+ }
487
+ };
488
+ var handleDomainSubmission = function handleDomainSubmission(_ref4) {
489
+ var hostname = _ref4.hostname;
490
+ setErrorData({});
491
+ var parsedHostname = getHostname(hostname);
492
+ setPrimaryDomain({
493
+ hostname: parsedHostname
494
+ });
495
+ if (isRootLevelDomain(hostname)) {
496
+ return setHostname(parsedHostname);
497
+ }
498
+ return handleDomainCreation({
499
+ hostname: parsedHostname
500
+ });
501
+ };
502
+ var handleCancel = function handleCancel() {
503
+ setPrimaryDomain();
504
+ onClose();
505
+ };
506
+ if (hostname) {
507
+ return /*#__PURE__*/jsxRuntime.jsx(Strategy, {
508
+ errorData: errorData,
509
+ handleSubmit: handleSubmit,
510
+ hostname: hostname,
511
+ onClose: onClose,
512
+ onCreate: onCreate,
513
+ setPrimaryDomain: setPrimaryDomain,
514
+ subdomainPlaceholder: subdomainPlaceholder,
515
+ url: url,
516
+ isSubmitting: isCreatingCustomDomain
517
+ });
518
+ }
519
+ return /*#__PURE__*/jsxRuntime.jsx(formik.Form, {
520
+ className: "flex-col space-y-6",
521
+ formikProps: {
522
+ initialValues: INITIAL_VALUES,
523
+ validationSchema: getCustomDomainValidationSchema(),
524
+ onSubmit: handleDomainSubmission
525
+ },
526
+ children: function children(_ref5) {
527
+ var dirty = _ref5.dirty;
528
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
529
+ className: "w-full",
530
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Body, {
531
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
532
+ className: "w-full space-y-4",
533
+ children: [/*#__PURE__*/jsxRuntime.jsx(formik.Input, {
534
+ required: true,
535
+ className: "w-full",
536
+ "data-testid": "custom-domain-input-field",
537
+ label: t("neetoCustomDomains.label"),
538
+ name: "hostname",
539
+ placeholder: t("neetoCustomDomains.placeholder", {
540
+ subdomainPlaceholder: subdomainPlaceholder
541
+ })
542
+ }), (errorData === null || errorData === void 0 ? void 0 : errorData.key) && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
543
+ variant: "warning",
544
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
545
+ variant: "body2",
546
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
547
+ i18nKey: errorData === null || errorData === void 0 ? void 0 : errorData.key,
548
+ values: _objectSpread(_objectSpread({}, errorData), {}, {
549
+ subdomainPlaceholder: subdomainPlaceholder
550
+ }),
551
+ components: {
552
+ Link: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
553
+ href: errorData === null || errorData === void 0 ? void 0 : errorData.pageUrl,
554
+ rel: "noreferrer",
555
+ variant: "link",
556
+ target: "_blank"
557
+ })
558
+ }
559
+ })
560
+ })
561
+ })]
562
+ })
563
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Footer, {
564
+ children: /*#__PURE__*/jsxRuntime.jsx(formik.ActionBlock, {
565
+ cancelButtonProps: {
566
+ onClick: handleCancel
567
+ },
568
+ submitButtonProps: {
569
+ label: t("neetoCustomDomains.actions.continue"),
570
+ "data-testid": "submit-custom-domain-button",
571
+ disabled: !dirty
572
+ }
573
+ })
574
+ })]
575
+ });
576
+ }
577
+ });
578
+ };
579
+
580
+ var getDnsProviderData = function getDnsProviderData(dnsProvider) {
581
+ var hostname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unknown";
582
+ var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "production";
583
+ return dnsProviderData(hostname, environment)[dnsProvider];
584
+ };
585
+ var commonColumnData = function commonColumnData(dnsProvider) {
586
+ var dnsProviderInfo = getDnsProviderData(dnsProvider);
587
+ return [{
588
+ header: dnsProviderInfo.header.type,
589
+ id: "type",
590
+ accessorKey: "type"
591
+ }, {
592
+ header: dnsProviderInfo.header.name,
593
+ id: "name",
594
+ accessorKey: "name",
595
+ cell: function cell(_ref) {
596
+ var row = _ref.row;
597
+ var name = row.getValue("name");
598
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
599
+ className: "flex items-center justify-between gap-1",
600
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
601
+ className: "min-w-0 truncate",
602
+ variant: "body2",
603
+ children: name
604
+ }), /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton, {
605
+ className: "flex-shrink-0",
606
+ size: "sm",
607
+ variant: "outline",
608
+ value: name
609
+ })]
610
+ });
611
+ }
612
+ }, {
613
+ header: dnsProviderInfo.header.target,
614
+ id: "target",
615
+ accessorKey: "target",
616
+ cell: function cell(_ref2) {
617
+ var row = _ref2.row;
618
+ var value = row.getValue("target");
619
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
620
+ className: "flex items-center justify-between gap-1",
621
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
622
+ className: "min-w-0 truncate",
623
+ variant: "body2",
624
+ children: neetoCist.truncate(value, 30)
625
+ }), /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton, {
626
+ className: "flex-shrink-0",
627
+ size: "sm",
628
+ variant: "outline",
629
+ value: value
630
+ })]
631
+ });
632
+ }
633
+ }, {
634
+ header: dnsProviderInfo.header.ttl,
635
+ id: "ttl",
636
+ accessorKey: "ttl"
637
+ }];
638
+ };
639
+ var columnData = function columnData(dnsProvider) {
640
+ var commonColumns = commonColumnData(dnsProvider);
641
+ var cloudflareProxyColumn = {
642
+ header: "Proxy",
643
+ id: "proxy",
644
+ accessorKey: "proxy",
645
+ cell: function cell() {
646
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
647
+ className: "flex items-center justify-between gap-1",
648
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
649
+ src: application.img
650
+ })
651
+ });
652
+ }
653
+ };
654
+ var networkSolutionsRefersToColumn = {
655
+ header: "Refers to",
656
+ id: "refersTo",
657
+ accessorKey: "proxy",
658
+ cell: function cell() {
659
+ return /*#__PURE__*/jsxRuntime.jsx("p", {
660
+ children: "Other Host"
661
+ });
662
+ }
663
+ };
664
+ dnsProvider === "cloudflare" && commonColumns.splice(3, 0, cloudflareProxyColumn);
665
+ dnsProvider === "networksolutions" && commonColumns.splice(1, 0, networkSolutionsRefersToColumn);
666
+ return commonColumns;
667
+ };
668
+ var rowData = function rowData(dnsProvider, hostname, dnsTarget, environment) {
669
+ var _dnsProviderInfo$valu, _dnsProviderInfo$valu2;
670
+ var subdomain = application.parse(hostname).subdomain;
671
+ var hostnameType = neetoCist.isPresent(subdomain) ? "subdomain" : "rootDomain";
672
+ var dnsProviderInfo = getDnsProviderData(dnsProvider, hostname, environment);
673
+ return [{
674
+ type: dnsProviderInfo.values.type[hostnameType],
675
+ name: dnsProviderInfo.values.name[hostnameType],
676
+ target: (_dnsProviderInfo$valu = dnsProviderInfo === null || dnsProviderInfo === void 0 || (_dnsProviderInfo$valu2 = dnsProviderInfo.values) === null || _dnsProviderInfo$valu2 === void 0 || (_dnsProviderInfo$valu2 = _dnsProviderInfo$valu2.target) === null || _dnsProviderInfo$valu2 === void 0 ? void 0 : _dnsProviderInfo$valu2[hostnameType]) !== null && _dnsProviderInfo$valu !== void 0 ? _dnsProviderInfo$valu : dnsTarget,
677
+ ttl: dnsProviderInfo.values.ttl[hostnameType]
678
+ }];
679
+ };
680
+ var dnsProviderData = function dnsProviderData(hostname) {
681
+ var environment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "production";
682
+ var _parse = application.parse(hostname),
683
+ subdomain = _parse.subdomain,
684
+ domain = _parse.domain;
685
+ return {
686
+ cloudflare: {
687
+ name: "Cloudflare",
688
+ loginUrl: "https://dash.cloudflare.com/login",
689
+ header: {
690
+ type: "Type",
691
+ name: "Name",
692
+ target: "Target",
693
+ ttl: "TTL"
694
+ },
695
+ values: {
696
+ ttl: {
697
+ rootDomain: "1 min",
698
+ subdomain: "1 min"
699
+ },
700
+ type: {
701
+ rootDomain: "CNAME",
702
+ subdomain: "CNAME"
703
+ },
704
+ name: {
705
+ rootDomain: "@",
706
+ subdomain: subdomain
707
+ }
708
+ },
709
+ hasRootLevelDomainSupport: true
710
+ },
711
+ namecheap: {
712
+ name: "Namecheap",
713
+ loginUrl: "https://www.namecheap.com/myaccount/login",
714
+ header: {
715
+ type: "Type",
716
+ name: "Host",
717
+ target: "Value",
718
+ ttl: "TTL"
719
+ },
720
+ values: {
721
+ ttl: {
722
+ rootDomain: "1 min",
723
+ subdomain: "1 min"
724
+ },
725
+ type: {
726
+ rootDomain: "ALIAS",
727
+ subdomain: "CNAME"
728
+ },
729
+ name: {
730
+ rootDomain: "@",
731
+ subdomain: subdomain
732
+ }
733
+ },
734
+ hasRootLevelDomainSupport: true
735
+ },
736
+ hostinger: {
737
+ name: "Hostinger",
738
+ loginUrl: "https://auth.hostinger.com/login",
739
+ header: {
740
+ type: "Type",
741
+ name: "Name",
742
+ target: "Target",
743
+ ttl: "TTL"
744
+ },
745
+ values: {
746
+ ttl: {
747
+ rootDomain: "60",
748
+ subdomain: "60"
749
+ },
750
+ type: {
751
+ rootDomain: "CNAME",
752
+ subdomain: "CNAME"
753
+ },
754
+ name: {
755
+ rootDomain: "@",
756
+ subdomain: subdomain
757
+ }
758
+ },
759
+ hasRootLevelDomainSupport: true
760
+ },
761
+ digitalocean: {
762
+ name: "DigitalOcean",
763
+ loginUrl: "https://cloud.digitalocean.com/login",
764
+ header: {
765
+ type: "Type",
766
+ name: "Hostname",
767
+ target: "Is an alias of",
768
+ ttl: "TTL"
769
+ },
770
+ values: {
771
+ ttl: {
772
+ rootDomain: "60",
773
+ subdomain: "60"
774
+ },
775
+ type: {
776
+ rootDomain: "A",
777
+ subdomain: "CNAME"
778
+ },
779
+ name: {
780
+ rootDomain: "@",
781
+ subdomain: subdomain
782
+ },
783
+ target: {
784
+ rootDomain: DNS_TARGETS[environment].ip,
785
+ subdomain: DNS_TARGETS[environment].cname
786
+ }
787
+ },
788
+ hasRootLevelDomainSupport: true
789
+ },
790
+ godaddy: {
791
+ name: "GoDaddy",
792
+ loginUrl: "https://sso.godaddy.com/",
793
+ header: {
794
+ type: "Type",
795
+ name: "Name",
796
+ target: "Value",
797
+ ttl: "TTL"
798
+ },
799
+ values: {
800
+ ttl: {
801
+ rootDomain: "1/2 Hour",
802
+ subdomain: "1/2 Hour"
803
+ },
804
+ type: {
805
+ rootDomain: "A",
806
+ subdomain: "CNAME"
807
+ },
808
+ name: {
809
+ rootDomain: "@",
810
+ subdomain: subdomain
811
+ },
812
+ target: {
813
+ rootDomain: DNS_TARGETS[environment].ip,
814
+ subdomain: DNS_TARGETS[environment].cname
815
+ }
816
+ },
817
+ hasRootLevelDomainSupport: true
818
+ },
819
+ squarespace: {
820
+ name: "Squarespace",
821
+ loginUrl: "https://login.squarespace.com/",
822
+ header: {
823
+ type: "Type",
824
+ name: "Host",
825
+ target: "Data",
826
+ ttl: "Priority"
827
+ },
828
+ values: {
829
+ ttl: {
830
+ rootDomain: "-",
831
+ subdomain: "-"
832
+ },
833
+ type: {
834
+ rootDomain: "ALIAS",
835
+ subdomain: "CNAME"
836
+ },
837
+ name: {
838
+ rootDomain: "@",
839
+ subdomain: subdomain
840
+ }
841
+ },
842
+ hasRootLevelDomainSupport: true
843
+ },
844
+ wix: {
845
+ name: "Wix",
846
+ helpDocUrl: "https://help.neetocal.com/articles/how-to-add-dns-record-in-wix",
847
+ loginUrl: "https://users.wix.com/signin",
848
+ header: {
849
+ type: "Type",
850
+ name: "HostName",
851
+ target: "Value",
852
+ ttl: "TTL"
853
+ },
854
+ values: {
855
+ ttl: {
856
+ rootDomain: "30 minutes",
857
+ subdomain: "30 minutes"
858
+ },
859
+ type: {
860
+ rootDomain: "A",
861
+ subdomain: "CNAME"
862
+ },
863
+ name: {
864
+ rootDomain: "",
865
+ subdomain: subdomain
866
+ },
867
+ target: {
868
+ rootDomain: DNS_TARGETS[environment].ip,
869
+ subdomain: DNS_TARGETS[environment].cname
870
+ }
871
+ },
872
+ hasRootLevelDomainSupport: true
873
+ },
874
+ porkbun: {
875
+ name: "Porkbun",
876
+ loginUrl: "https://porkbun.com/account/login",
877
+ header: {
878
+ type: "Type",
879
+ name: "Host",
880
+ target: "Answer/Value",
881
+ ttl: "TTL"
882
+ },
883
+ values: {
884
+ ttl: {
885
+ rootDomain: "60",
886
+ subdomain: "60"
887
+ },
888
+ type: {
889
+ rootDomain: "ALIAS",
890
+ subdomain: "CNAME"
891
+ },
892
+ name: {
893
+ rootDomain: domain,
894
+ subdomain: subdomain
895
+ }
896
+ },
897
+ hasRootLevelDomainSupport: true
898
+ },
899
+ networksolutions: {
900
+ name: "Network Solutions",
901
+ loginUrl: "https://www.networksolutions.com/my-account/login",
902
+ header: {
903
+ type: "Type",
904
+ name: "Host Name",
905
+ target: "Alias to",
906
+ ttl: "TTL"
907
+ },
908
+ values: {
909
+ ttl: {
910
+ rootDomain: "15 minutes",
911
+ subdomain: "15 minutes"
912
+ },
913
+ type: {
914
+ rootDomain: "CNAME",
915
+ subdomain: "CNAME"
916
+ },
917
+ name: {
918
+ rootDomain: "@",
919
+ subdomain: subdomain
920
+ }
921
+ },
922
+ hasRootLevelDomainSupport: true
923
+ },
924
+ aws: {
925
+ name: "AWS",
926
+ loginUrl: "https://aws.amazon.com",
927
+ header: {
928
+ type: "Record Type",
929
+ name: "Record Name",
930
+ target: "Value",
931
+ ttl: "TTL"
932
+ },
933
+ values: {
934
+ ttl: {
935
+ rootDomain: "60",
936
+ subdomain: "60"
937
+ },
938
+ type: {
939
+ rootDomain: "A",
940
+ subdomain: "CNAME"
941
+ },
942
+ name: {
943
+ rootDomain: "",
944
+ subdomain: subdomain
945
+ },
946
+ target: {
947
+ rootDomain: DNS_TARGETS[environment].ip,
948
+ subdomain: DNS_TARGETS[environment].cname
949
+ }
950
+ },
951
+ hasRootLevelDomainSupport: true
952
+ },
953
+ strato: {
954
+ name: "Strato",
955
+ loginUrl: "https://www.strato.de/apps/CustomerService",
956
+ header: {
957
+ type: "Type",
958
+ name: "Prefix",
959
+ target: "Value"
960
+ },
961
+ values: {
962
+ type: {
963
+ rootDomain: "A",
964
+ subdomain: "CNAME"
965
+ },
966
+ ttl: {
967
+ rootDomain: "-",
968
+ subdomain: "-"
969
+ },
970
+ name: {
971
+ rootDomain: hostname,
972
+ subdomain: subdomain
973
+ },
974
+ target: {
975
+ rootDomain: DNS_TARGETS[environment].ip,
976
+ subdomain: DNS_TARGETS[environment].cname
977
+ }
978
+ },
979
+ hasRootLevelDomainSupport: true
980
+ },
981
+ microsoft: {
982
+ name: "Microsoft 365",
983
+ loginUrl: "https://admin.microsoft.com",
984
+ header: {
985
+ type: "Type",
986
+ name: "Host name or Alias",
987
+ target: "Points to address / IP address",
988
+ ttl: "TTL"
989
+ },
990
+ values: {
991
+ type: {
992
+ rootDomain: "A (Address)",
993
+ subdomain: "CNAME (ALIAS)"
994
+ },
995
+ ttl: {
996
+ rootDomain: "1/2 hour",
997
+ subdomain: "1/2 hour"
998
+ },
999
+ name: {
1000
+ rootDomain: "@",
1001
+ subdomain: subdomain
1002
+ },
1003
+ target: {
1004
+ rootDomain: DNS_TARGETS[environment].ip,
1005
+ subdomain: DNS_TARGETS[environment].cname
1006
+ }
1007
+ },
1008
+ hasRootLevelDomainSupport: true
1009
+ },
1010
+ unknown: {
1011
+ name: "this provider",
1012
+ loginUrl: "https://dash.cloudflare.com/login",
1013
+ header: {
1014
+ type: "Type",
1015
+ name: "Name",
1016
+ target: "Target",
1017
+ ttl: "TTL"
1018
+ },
1019
+ values: {
1020
+ ttl: {
1021
+ rootDomain: "1m",
1022
+ subdomain: "1m"
1023
+ },
1024
+ type: {
1025
+ rootDomain: "A",
1026
+ subdomain: "CNAME"
1027
+ },
1028
+ name: {
1029
+ rootDomain: "@",
1030
+ subdomain: subdomain
1031
+ },
1032
+ target: {
1033
+ rootDomain: DNS_TARGETS[environment].ip,
1034
+ subdomain: DNS_TARGETS[environment].cname
1035
+ }
1036
+ },
1037
+ hasRootLevelDomainSupport: true
1038
+ }
1039
+ };
1040
+ };
1041
+
1042
+ var Validation = function Validation(_ref) {
1043
+ var customDomains = _ref.customDomains,
1044
+ onClose = _ref.onClose,
1045
+ url = _ref.url,
1046
+ dnsHelpDocs = _ref.dnsHelpDocs,
1047
+ primaryDomain = _ref.primaryDomain,
1048
+ environment = _ref.environment;
1049
+ var _useTranslation = reactI18next.useTranslation(),
1050
+ t = _useTranslation.t;
1051
+ var hostname = primaryDomain.hostname,
1052
+ status = primaryDomain.status,
1053
+ dnsProvider = primaryDomain.dnsProvider;
1054
+ var queryClient = reactQuery.useQueryClient();
1055
+ var _useState = React.useState(""),
1056
+ _useState2 = _slicedToArray(_useState, 2),
1057
+ errorKey = _useState2[0],
1058
+ setErrorKey = _useState2[1];
1059
+ var isDomainValidated = status === "active";
1060
+ var dnsProviderInfo = getDnsProviderData(dnsProvider, hostname, environment);
1061
+ var domainType = isRootLevelDomain(hostname) ? "rootDomain" : "subdomain";
1062
+ var _useValidateDomain = application.useValidateDomain(url, {
1063
+ onError: function onError(_ref2) {
1064
+ var response = _ref2.response;
1065
+ setErrorKey(response.data.error);
1066
+ queryClient.invalidateQueries({
1067
+ queryKey: [application.DOMAIN_QUERY_KEY]
1068
+ });
1069
+ if (response.data.error === "neetoCustomDomains.jobInProgress") {
1070
+ setTimeout(validateDomain, 10000);
1071
+ }
1072
+ },
1073
+ onSuccess: function onSuccess() {
1074
+ neetoAtoms.Toastr.success(t("neetoCustomDomains.validation.successMessage"));
1075
+ onClose();
1076
+ }
1077
+ }),
1078
+ validateDomain = _useValidateDomain.mutate,
1079
+ isValidating = _useValidateDomain.isPending;
1080
+ var HelpUrlLink = function HelpUrlLink(_ref3) {
1081
+ var _dnsHelpDocs$dnsProvi, _dnsHelpDocs$dnsProvi2, _dnsHelpDocs$unknown;
1082
+ var children = _ref3.children;
1083
+ return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1084
+ label: children,
1085
+ rel: "noreferrer",
1086
+ variant: "link",
1087
+ target: "_blank",
1088
+ href: (_dnsHelpDocs$dnsProvi = (_dnsHelpDocs$dnsProvi2 = dnsHelpDocs[dnsProvider]) === null || _dnsHelpDocs$dnsProvi2 === void 0 ? void 0 : _dnsHelpDocs$dnsProvi2[domainType]) !== null && _dnsHelpDocs$dnsProvi !== void 0 ? _dnsHelpDocs$dnsProvi : (_dnsHelpDocs$unknown = dnsHelpDocs.unknown) === null || _dnsHelpDocs$unknown === void 0 ? void 0 : _dnsHelpDocs$unknown[domainType]
1089
+ });
1090
+ };
1091
+ var LoginLink = function LoginLink(_ref4) {
1092
+ var children = _ref4.children;
1093
+ return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1094
+ href: dnsProviderInfo === null || dnsProviderInfo === void 0 ? void 0 : dnsProviderInfo.loginUrl,
1095
+ label: children,
1096
+ rel: "noreferrer",
1097
+ variant: "link",
1098
+ target: "_blank"
1099
+ });
1100
+ };
1101
+ var components = {
1102
+ Login: /*#__PURE__*/jsxRuntime.jsx(LoginLink, {}),
1103
+ Link: /*#__PURE__*/jsxRuntime.jsx(HelpUrlLink, {}),
1104
+ br: /*#__PURE__*/jsxRuntime.jsx("br", {})
1105
+ };
1106
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
1107
+ children: [/*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Sheet.Body, {
1108
+ className: "space-y-4",
1109
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1110
+ className: "space-y-2",
1111
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1112
+ variant: "h4",
1113
+ weight: "medium",
1114
+ children: t("neetoCustomDomains.domainValidationTitle")
1115
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1116
+ variant: "body2",
1117
+ children: dnsProvider !== "unknown" ? /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1118
+ components: components,
1119
+ i18nKey: "neetoCustomDomains.dnsProviderCnameRecordInfo",
1120
+ values: {
1121
+ dnsProvider: dnsProviderInfo === null || dnsProviderInfo === void 0 ? void 0 : dnsProviderInfo.name
1122
+ }
1123
+ }) : /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1124
+ components: components,
1125
+ i18nKey: "neetoCustomDomains.cnameRecordInfo"
1126
+ })
1127
+ })]
1128
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1129
+ className: "space-y-1",
1130
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.DataTable, {
1131
+ allowRowClick: false,
1132
+ columnDefs: columnData(dnsProvider),
1133
+ data: customDomains.map(function (_ref5) {
1134
+ var hostname = _ref5.hostname,
1135
+ dnsTarget = _ref5.dnsTarget,
1136
+ dnsProvider = _ref5.dnsProvider;
1137
+ return rowData(dnsProvider, hostname, dnsTarget, environment);
1138
+ }).flat()
1139
+ })
1140
+ }), status === "failed" && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
1141
+ variant: STATUS_TAG_STYLES[status],
1142
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1143
+ variant: "body2",
1144
+ children: dnsProvider !== "unknown" ? /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1145
+ components: components,
1146
+ i18nKey: "neetoCustomDomains.domainValidationFailedForKnownProvider",
1147
+ values: {
1148
+ dnsProvider: dnsProviderInfo.name
1149
+ }
1150
+ }) : /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1151
+ components: components,
1152
+ i18nKey: "neetoCustomDomains.domainValidationFailedForUnknownProvider",
1153
+ values: {
1154
+ dnsProvider: dnsProviderInfo.name
1155
+ }
1156
+ })
1157
+ })
1158
+ }), neetoCist.isNotEmpty(errorKey) && status === "pending" && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
1159
+ variant: STATUS_TAG_STYLES[status],
1160
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1161
+ variant: "body2",
1162
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1163
+ components: components,
1164
+ i18nKey: errorKey
1165
+ })
1166
+ })
1167
+ })]
1168
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Footer, {
1169
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1170
+ className: "flex items-center gap-2",
1171
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1172
+ "data-testid": "validate-domain-button",
1173
+ disabled: isValidating || isDomainValidated,
1174
+ loading: isValidating,
1175
+ label: t("neetoCustomDomains.validation.buttonLabel.iHaveAddedTheRecords"),
1176
+ onClick: validateDomain
1177
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1178
+ "data-testid": "cancel-button",
1179
+ label: t("neetoCustomDomains.actions.cancel"),
1180
+ variant: "ghost",
1181
+ onClick: onClose
1182
+ })]
1183
+ })
1184
+ })]
1185
+ });
1186
+ };
1187
+
1188
+ var DomainPane = function DomainPane(_ref) {
1189
+ var customDomains = _ref.customDomains,
1190
+ isOpen = _ref.isOpen,
1191
+ onClose = _ref.onClose,
1192
+ onCreate = _ref.onCreate,
1193
+ url = _ref.url,
1194
+ helpDocUrl = _ref.helpDocUrl,
1195
+ dnsHelpDocs = _ref.dnsHelpDocs,
1196
+ subdomainPlaceholder = _ref.subdomainPlaceholder,
1197
+ environment = _ref.environment;
1198
+ var _useTranslation = reactI18next.useTranslation(),
1199
+ t = _useTranslation.t;
1200
+ var _useState = React.useState(customDomains[0]),
1201
+ _useState2 = _slicedToArray(_useState, 2),
1202
+ primaryDomain = _useState2[0],
1203
+ setPrimaryDomain = _useState2[1];
1204
+ var _useState3 = React.useState({}),
1205
+ _useState4 = _slicedToArray(_useState3, 2),
1206
+ errorData = _useState4[0],
1207
+ setErrorData = _useState4[1];
1208
+ var _useFetchCustomDomain = application.useFetchCustomDomain(url),
1209
+ isLoading = _useFetchCustomDomain.isLoading;
1210
+ React.useEffect(function () {
1211
+ var domain = customDomains.find(function (_ref2) {
1212
+ var hostname = _ref2.hostname;
1213
+ return isRootLevelDomain(hostname);
1214
+ }) || customDomains[0];
1215
+ setPrimaryDomain(domain);
1216
+ }, [customDomains]);
1217
+ var getCurrentStep = function getCurrentStep(domain) {
1218
+ if (!domain) return "notAdded";
1219
+ if (domain !== null && domain !== void 0 && domain.hostname && !(domain !== null && domain !== void 0 && domain.status)) return "strategy";
1220
+ return domain === null || domain === void 0 ? void 0 : domain.status;
1221
+ };
1222
+ return /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Sheet, {
1223
+ isOpen: isOpen,
1224
+ onClose: onClose,
1225
+ className: "flex flex-col",
1226
+ size: "large",
1227
+ children: [/*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Sheet.Header, {
1228
+ className: "space-y-2",
1229
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Title, {
1230
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1231
+ variant: "h2",
1232
+ children: t("neetoCustomDomains.addNew")
1233
+ })
1234
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1235
+ className: "neeto_custom_domain_stepper -ml-2",
1236
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Stepper, {
1237
+ activeIndex: CURRENT_STEP[getCurrentStep(primaryDomain)],
1238
+ setActiveIndex: neetoCist.noop,
1239
+ steps: STEPS
1240
+ })
1241
+ })]
1242
+ }), function (_primaryDomain$hostna) {
1243
+ var currentStep = getCurrentStep(primaryDomain);
1244
+ var isStrategyStep = CURRENT_STEP[currentStep] === 1;
1245
+ var isSubdomain = !isRootLevelDomain((_primaryDomain$hostna = primaryDomain === null || primaryDomain === void 0 ? void 0 : primaryDomain.hostname) !== null && _primaryDomain$hostna !== void 0 ? _primaryDomain$hostna : "");
1246
+ var shouldShowLoader = isLoading || isStrategyStep && isSubdomain;
1247
+ if (shouldShowLoader) {
1248
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1249
+ className: "flex w-full grow items-center justify-center",
1250
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {})
1251
+ });
1252
+ }
1253
+ if (CURRENT_STEP[getCurrentStep(primaryDomain)] > 1) {
1254
+ return /*#__PURE__*/jsxRuntime.jsx(Validation, {
1255
+ customDomains: customDomains,
1256
+ dnsHelpDocs: dnsHelpDocs,
1257
+ environment: environment,
1258
+ helpDocUrl: helpDocUrl,
1259
+ onClose: onClose,
1260
+ onCreate: onCreate,
1261
+ primaryDomain: primaryDomain,
1262
+ subdomainPlaceholder: subdomainPlaceholder,
1263
+ url: url
1264
+ });
1265
+ }
1266
+ return /*#__PURE__*/jsxRuntime.jsx(DomainField, {
1267
+ errorData: errorData,
1268
+ onClose: onClose,
1269
+ onCreate: onCreate,
1270
+ setErrorData: setErrorData,
1271
+ setPrimaryDomain: setPrimaryDomain,
1272
+ subdomainPlaceholder: subdomainPlaceholder,
1273
+ url: url
1274
+ });
1275
+ }()]
1276
+ });
1277
+ };
1278
+
1279
+ var Header = function Header(_ref) {
1280
+ _ref.openPane;
1281
+ var breadcrumbs = _ref.breadcrumbs;
1282
+ _ref.isCustomDomainAdded;
1283
+ _ref.setSelectedCustomDomain;
1284
+ var helpDocUrl = _ref.helpDocUrl,
1285
+ _ref$size = _ref.size,
1286
+ size = _ref$size === void 0 ? "large" : _ref$size;
1287
+ var _useTranslation = reactI18next.useTranslation(),
1288
+ t = _useTranslation.t;
1289
+ return /*#__PURE__*/jsxRuntime.jsx(NeetoHeader, {
1290
+ breadcrumbs: breadcrumbs,
1291
+ size: size,
1292
+ "data-testid": "custom-domain-header",
1293
+ title: t("neetoCustomDomains.customDomain", constants.SINGULAR),
1294
+ titleHelpPopoverProps: {
1295
+ title: t("neetoCustomDomains.customDomain", constants.SINGULAR),
1296
+ description: t("neetoCustomDomains.toolTips.customDomain"),
1297
+ helpLinkProps: {
1298
+ href: helpDocUrl
1299
+ }
1300
+ }
1301
+ });
1302
+ };
1303
+ var Header$1 = /*#__PURE__*/React.memo(Header);
1304
+
1305
+ var CustomDomain = function CustomDomain(_ref) {
1306
+ var breadcrumbs = _ref.breadcrumbs,
1307
+ url = _ref.url,
1308
+ onCreate = _ref.onCreate,
1309
+ helpDocUrl = _ref.helpDocUrl,
1310
+ headerSize = _ref.headerSize,
1311
+ dnsHelpDocs = _ref.dnsHelpDocs,
1312
+ subdomainPlaceholder = _ref.subdomainPlaceholder,
1313
+ disconnectedIntegrationCardDescription = _ref.disconnectedIntegrationCardDescription,
1314
+ connectedIntegrationCardDescription = _ref.connectedIntegrationCardDescription,
1315
+ appName = _ref.appName,
1316
+ _ref$environment = _ref.environment,
1317
+ environment = _ref$environment === void 0 ? "production" : _ref$environment;
1318
+ var _useQueryParams = reactUtils.useQueryParams(),
1319
+ pane = _useQueryParams.pane;
1320
+ var _useState = React.useState(pane === "open"),
1321
+ _useState2 = _slicedToArray(_useState, 2),
1322
+ isPaneOpen = _useState2[0],
1323
+ setIsPaneOpen = _useState2[1];
1324
+ var _useState3 = React.useState(false),
1325
+ _useState4 = _slicedToArray(_useState3, 2),
1326
+ isAlertOpen = _useState4[0],
1327
+ setIsAlertOpen = _useState4[1];
1328
+ var _useState5 = React.useState({}),
1329
+ _useState6 = _slicedToArray(_useState5, 2),
1330
+ selectedCustomDomain = _useState6[0],
1331
+ setSelectedCustomDomain = _useState6[1];
1332
+ var _useFetchCustomDomain = application.useFetchCustomDomain(url),
1333
+ _useFetchCustomDomain2 = _useFetchCustomDomain.data,
1334
+ _useFetchCustomDomain3 = _useFetchCustomDomain2 === void 0 ? {} : _useFetchCustomDomain2,
1335
+ _useFetchCustomDomain4 = _useFetchCustomDomain3.customDomains,
1336
+ customDomains = _useFetchCustomDomain4 === void 0 ? [] : _useFetchCustomDomain4,
1337
+ isLoading = _useFetchCustomDomain.isLoading;
1338
+ var _useDeleteCustomDomai = application.useDeleteCustomDomain(url, selectedCustomDomain === null || selectedCustomDomain === void 0 ? void 0 : selectedCustomDomain.hostname, {
1339
+ onSettled: function onSettled() {
1340
+ setIsAlertOpen(false);
1341
+ }
1342
+ }),
1343
+ deleteCustomDomain = _useDeleteCustomDomai.mutate,
1344
+ isDeleting = _useDeleteCustomDomai.isPending;
1345
+ var openPane = function openPane() {
1346
+ return setIsPaneOpen(true);
1347
+ };
1348
+ var closePane = function closePane() {
1349
+ return setIsPaneOpen(false);
1350
+ };
1351
+ var openDeleteAlert = function openDeleteAlert() {
1352
+ return setIsAlertOpen(true);
1353
+ };
1354
+ var isCustomDomainAdded = neetoCist.isNotEmpty(customDomains);
1355
+ if (isLoading) {
1356
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1357
+ className: "flex h-screen w-full items-center justify-center",
1358
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {})
1359
+ });
1360
+ }
1361
+ var isDevelopment = environment === "development";
1362
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
1363
+ children: [/*#__PURE__*/jsxRuntime.jsxs(Container, {
1364
+ children: [/*#__PURE__*/jsxRuntime.jsx(Header$1, {
1365
+ breadcrumbs: breadcrumbs,
1366
+ helpDocUrl: helpDocUrl,
1367
+ isCustomDomainAdded: isCustomDomainAdded,
1368
+ openPane: openPane,
1369
+ setSelectedCustomDomain: setSelectedCustomDomain,
1370
+ size: headerSize
1371
+ }), isDevelopment && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
1372
+ className: "mb-4",
1373
+ variant: "warning",
1374
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1375
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1376
+ components: {
1377
+ Link: /*#__PURE__*/jsxRuntime.jsx("a", {
1378
+ className: "underline",
1379
+ href: NEETO_CUSTOM_DOMAINS_NANO_README_URL,
1380
+ rel: "noreferrer",
1381
+ target: "_blank"
1382
+ })
1383
+ },
1384
+ i18nKey: "neetoCustomDomains.developmentBanner.message"
1385
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1386
+ className: "mt-2 text-xs opacity-75",
1387
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1388
+ i18nKey: "neetoCustomDomains.developmentBanner.footnote"
1389
+ })
1390
+ })]
1391
+ })
1392
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1393
+ className: "flex h-full w-full justify-center",
1394
+ children: /*#__PURE__*/jsxRuntime.jsx(Domain, {
1395
+ connectedIntegrationCardDescription: connectedIntegrationCardDescription,
1396
+ customDomains: customDomains,
1397
+ disconnectedIntegrationCardDescription: disconnectedIntegrationCardDescription,
1398
+ helpDocUrl: helpDocUrl,
1399
+ isCustomDomainAdded: isCustomDomainAdded,
1400
+ openDeleteAlert: openDeleteAlert,
1401
+ openPane: openPane,
1402
+ setSelectedCustomDomain: setSelectedCustomDomain
1403
+ })
1404
+ })]
1405
+ }), /*#__PURE__*/jsxRuntime.jsx(DomainPane, {
1406
+ customDomains: customDomains,
1407
+ dnsHelpDocs: dnsHelpDocs,
1408
+ environment: environment,
1409
+ helpDocUrl: helpDocUrl,
1410
+ onCreate: onCreate,
1411
+ url: url,
1412
+ customDomain: selectedCustomDomain,
1413
+ isOpen: isPaneOpen,
1414
+ subdomainPlaceholder: subdomainPlaceholder || appName,
1415
+ onClose: closePane
1416
+ }), /*#__PURE__*/jsxRuntime.jsx(DeleteAlert, {
1417
+ hostname: selectedCustomDomain === null || selectedCustomDomain === void 0 ? void 0 : selectedCustomDomain.hostname,
1418
+ isOpen: isAlertOpen,
1419
+ isSubmitting: isDeleting,
1420
+ onClose: function onClose() {
1421
+ return setIsAlertOpen(false);
1422
+ },
1423
+ onSubmit: deleteCustomDomain
1424
+ })]
1425
+ });
1426
+ };
1427
+
1428
+ module.exports = CustomDomain;
1429
+ //# sourceMappingURL=CustomDomain.js.map