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