@bigbinary/neeto-custom-domains-frontend 1.1.0 → 1.2.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -2,50 +2,557 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var CustomDomainDashboard = require('./CustomDomainDashboard.js');
5
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
+ var react = require('react');
7
+ var neetoCist = require('@bigbinary/neeto-cist');
8
+ var Container = require('@bigbinary/neeto-molecules/Container');
9
+ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
10
+ var CustomDomainDashboard = require('../index-6d441e24.js');
11
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
12
+ var Alert = require('@bigbinary/neetoui/Alert');
13
+ var reactI18next = require('react-i18next');
14
+ var jsxRuntime = require('react/jsx-runtime');
15
+ var constants = require('@bigbinary/neeto-commons-frontend/constants');
16
+ var general = require('@bigbinary/neeto-commons-frontend/utils/general');
17
+ var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
18
+ var Button = require('@bigbinary/neetoui/Button');
19
+ var Typography = require('@bigbinary/neetoui/Typography');
20
+ var Tag = require('@bigbinary/neetoui/Tag');
21
+ var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
22
+ var Pane = require('@bigbinary/neetoui/Pane');
23
+ var Stepper = require('@bigbinary/neetoui/Stepper');
24
+ var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
25
+ var Input = require('@bigbinary/neetoui/formik/Input');
26
+ var FormikForm = require('@bigbinary/neetoui/formik/Form');
27
+ var i18next = require('i18next');
28
+ var Yup = require('yup');
29
+ var Table = require('@bigbinary/neetoui/Table');
30
+ var Toastr = require('@bigbinary/neetoui/Toastr');
31
+ var Callout = require('@bigbinary/neetoui/Callout');
32
+ var CopyToClipboardButton = require('@bigbinary/neeto-molecules/CopyToClipboardButton');
33
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
34
+ var withT = require('@bigbinary/neeto-commons-frontend/react-utils/withT');
35
+ var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
6
36
  var WelcomeScreen = require('./WelcomeScreen.js');
7
- require('@babel/runtime/helpers/slicedToArray');
8
- require('react');
9
- require('@bigbinary/neeto-cist');
10
37
  require('@bigbinary/neeto-commons-frontend/react-utils/useDebounce');
11
- require('@bigbinary/neeto-molecules/Container');
12
- require('@bigbinary/neeto-molecules/PageLoader');
13
38
  require('@bigbinary/neeto-molecules/SubHeader');
14
39
  require('@bigbinary/neeto-molecules/TableWrapper');
15
- require('@bigbinary/neetoui/Table');
16
- require('@bigbinary/neetoui/Typography');
17
40
  require('@bigbinary/neetoui/NoData');
18
- require('@bigbinary/neetoui/Button');
19
- require('react-i18next');
20
- require('@babel/runtime/helpers/defineProperty');
21
41
  require('@tanstack/react-query');
22
42
  require('@bigbinary/neeto-commons-frontend/react-utils/useMutationWithInvalidation');
23
43
  require('axios');
24
- require('@bigbinary/neeto-commons-frontend/react-utils');
25
- require('@bigbinary/neetoui/Alert');
26
- require('react/jsx-runtime');
27
- require('@bigbinary/neeto-commons-frontend/constants');
28
- require('@bigbinary/neeto-commons-frontend/react-utils/withT');
29
- require('@bigbinary/neeto-commons-frontend/utils/general');
30
- require('@bigbinary/neeto-molecules/Header');
31
- require('@bigbinary/neetoui/Pane');
32
- require('@bigbinary/neetoui/formik/ActionBlock');
33
- require('@bigbinary/neetoui/formik/Input');
34
- require('@bigbinary/neetoui/formik/Form');
35
- require('i18next');
36
- require('yup');
37
44
  require('@bigbinary/neetoui/Checkbox');
38
- require('@bigbinary/neetoui/Callout');
39
- require('@bigbinary/neetoui/Stepper');
40
- require('@bigbinary/neeto-molecules/CopyToClipboardButton');
41
- require('@bigbinary/neetoui/Tag');
42
- require('@bigbinary/neeto-commons-frontend/initializers');
43
- require('@bigbinary/neetoui/Toastr');
44
- require('@bigbinary/neeto-molecules/MoreDropdown');
45
45
  require('classnames');
46
46
 
47
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
47
48
 
49
+ function _interopNamespace(e) {
50
+ if (e && e.__esModule) return e;
51
+ var n = Object.create(null);
52
+ if (e) {
53
+ Object.keys(e).forEach(function (k) {
54
+ if (k !== 'default') {
55
+ var d = Object.getOwnPropertyDescriptor(e, k);
56
+ Object.defineProperty(n, k, d.get ? d : {
57
+ enumerable: true,
58
+ get: function () { return e[k]; }
59
+ });
60
+ }
61
+ });
62
+ }
63
+ n["default"] = e;
64
+ return Object.freeze(n);
65
+ }
48
66
 
49
- exports.CustomDomainDashboard = CustomDomainDashboard;
67
+ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
68
+ var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
69
+ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
70
+ var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
71
+ var MoreDropdown__default = /*#__PURE__*/_interopDefaultLegacy(MoreDropdown);
72
+ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
73
+ var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
74
+ var Tag__default = /*#__PURE__*/_interopDefaultLegacy(Tag);
75
+ var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
76
+ var Stepper__default = /*#__PURE__*/_interopDefaultLegacy(Stepper);
77
+ var ActionBlock__default = /*#__PURE__*/_interopDefaultLegacy(ActionBlock);
78
+ var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
79
+ var FormikForm__default = /*#__PURE__*/_interopDefaultLegacy(FormikForm);
80
+ var Yup__namespace = /*#__PURE__*/_interopNamespace(Yup);
81
+ var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
82
+ var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
83
+ var Callout__default = /*#__PURE__*/_interopDefaultLegacy(Callout);
84
+ var CopyToClipboardButton__default = /*#__PURE__*/_interopDefaultLegacy(CopyToClipboardButton);
85
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
86
+ var withT__default = /*#__PURE__*/_interopDefaultLegacy(withT);
87
+ var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
88
+
89
+ var DeleteAlert = reactUtils.withT(function (_ref) {
90
+ var t = _ref.t,
91
+ onClose = _ref.onClose,
92
+ onSubmit = _ref.onSubmit,
93
+ isOpen = _ref.isOpen,
94
+ isSubmitting = _ref.isSubmitting,
95
+ hostname = _ref.hostname;
96
+ return /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
97
+ isOpen: isOpen,
98
+ isSubmitting: isSubmitting,
99
+ onClose: onClose,
100
+ onSubmit: onSubmit,
101
+ cancelButtonLabel: t("neetoCustomDomains.actions.cancel"),
102
+ submitButtonLabel: t("neetoCustomDomains.actions.delete"),
103
+ title: t("neetoCustomDomains.delete"),
104
+ message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
105
+ i18nKey: "neetoCustomDomains.alertMessage",
106
+ values: {
107
+ hostname: hostname
108
+ }
109
+ })
110
+ });
111
+ });
112
+
113
+ var HELP_DOC_URL = "https://help.".concat(initializers.globalProps.appName.toLowerCase(), ".com/articles/custom-domains");
114
+ var STATUS_TAG_STYLES = {
115
+ active: "success",
116
+ pending: "warning"
117
+ };
118
+
119
+ var Domain = reactUtils.withT(function (_ref) {
120
+ var t = _ref.t,
121
+ isCustomDomainAdded = _ref.isCustomDomainAdded,
122
+ openPane = _ref.openPane,
123
+ customDomain = _ref.customDomain,
124
+ openDeleteAlert = _ref.openDeleteAlert;
125
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
126
+ className: "neeto-ui-border-gray-300 neeto-ui-rounded w-1/2 space-y-2 space-y-4 border p-6",
127
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
128
+ style: "h2",
129
+ children: t("neetoCustomDomains.connectionTitle")
130
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
131
+ className: "space-y-1",
132
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
133
+ className: "neeto-ui-border-gray-200 neeto-ui-rounded neeto-ui-bg-gray-50 flex items-center justify-between border border p-2",
134
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
135
+ className: "flex items-center space-x-2",
136
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
137
+ style: "body2",
138
+ children: isCustomDomainAdded ? customDomain.hostname : t("neetoCustomDomains.noDomainConnected")
139
+ }), isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(Tag__default["default"], {
140
+ "data-cy": "".concat(general.hyphenize(customDomain.status), "-tag-container"),
141
+ style: STATUS_TAG_STYLES[customDomain.status],
142
+ label: t("neetoCustomDomains.status.domain.".concat(customDomain.status))
143
+ })]
144
+ }), isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
145
+ dropdownButtonProps: {
146
+ "data-testid": "nui-dropdown-icon-".concat(customDomain.id)
147
+ },
148
+ dropdownProps: {
149
+ position: "bottom-end",
150
+ strategy: "fixed",
151
+ autoWidth: true
152
+ },
153
+ menuItems: [{
154
+ label: t("neetoCustomDomains.actions.edit"),
155
+ onClick: openPane,
156
+ key: "edit-custom-domain-button"
157
+ }, {
158
+ label: t("neetoCustomDomains.actions.delete"),
159
+ onClick: openDeleteAlert,
160
+ key: "delete-custom-domain"
161
+ }]
162
+ })]
163
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
164
+ style: "body3",
165
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
166
+ i18nKey: "neetoCustomDomains.readHelpArticle",
167
+ components: {
168
+ Link: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
169
+ href: HELP_DOC_URL,
170
+ rel: "noreferrer",
171
+ style: "link",
172
+ target: "_blank"
173
+ })
174
+ }
175
+ })
176
+ })]
177
+ }), !isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
178
+ label: t("neetoCustomDomains.actions.add", {
179
+ what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
180
+ }),
181
+ onClick: openPane
182
+ })]
183
+ });
184
+ });
185
+
186
+ var HOSTNAME_REGEX = /^(https?:\/\/)?([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}(\/\S*)?$/;
187
+ var INITIAL_VALUES = {
188
+ hostname: ""
189
+ };
190
+ var CURRENT_STEP = {
191
+ notAdded: 0,
192
+ pending: 1,
193
+ active: 2
194
+ };
195
+ var STEPS = [{
196
+ id: 1,
197
+ label: "Add domain"
198
+ }, {
199
+ id: 2,
200
+ label: "Validate domain"
201
+ }];
202
+
203
+ var getCustomDomainValidationSchema = function getCustomDomainValidationSchema() {
204
+ return Yup__namespace.object().shape({
205
+ hostname: Yup__namespace.string().required(i18next.t("neetoCustomDomains.formikValidation.required")).matches(HOSTNAME_REGEX, i18next.t("neetoCustomDomains.formikValidation.valid"))
206
+ });
207
+ };
208
+
209
+ var DomainField = function DomainField(_ref) {
210
+ var customDomain = _ref.customDomain,
211
+ onCreate = _ref.onCreate,
212
+ url = _ref.url,
213
+ onClose = _ref.onClose;
214
+ var _useTranslation = reactI18next.useTranslation(),
215
+ t = _useTranslation.t;
216
+ var _useCreateCustomDomai = CustomDomainDashboard.useCreateCustomDomain(url),
217
+ createCustomDomain = _useCreateCustomDomai.mutate,
218
+ isCreating = _useCreateCustomDomai.isPending;
219
+ var getHostname = function getHostname(url) {
220
+ try {
221
+ var parsedUrl = new URL(url);
222
+ return parsedUrl.hostname;
223
+ } catch (_unused) {
224
+ return url;
225
+ }
226
+ };
227
+ var handleSubmit = function handleSubmit(_ref2) {
228
+ var hostname = _ref2.hostname;
229
+ var parsedHostname = getHostname(hostname);
230
+ var payload = {
231
+ hostname: parsedHostname
232
+ };
233
+ createCustomDomain(payload, {
234
+ onSuccess: function onSuccess(values) {
235
+ onCreate === null || onCreate === void 0 ? void 0 : onCreate(values);
236
+ }
237
+ });
238
+ };
239
+ return /*#__PURE__*/jsxRuntime.jsx(FormikForm__default["default"], {
240
+ className: "flex-col space-y-6",
241
+ formikProps: {
242
+ enableReinitialize: true,
243
+ initialValues: customDomain || INITIAL_VALUES,
244
+ validationSchema: getCustomDomainValidationSchema(),
245
+ onSubmit: handleSubmit
246
+ },
247
+ children: function children(_ref3) {
248
+ var dirty = _ref3.dirty;
249
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
250
+ className: "w-full",
251
+ children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
252
+ children: /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
253
+ required: true,
254
+ className: "w-full",
255
+ "data-cy": "custom-domain-input-field",
256
+ disabled: neetoCist.isNotEmpty(customDomain),
257
+ label: t("neetoCustomDomains.label"),
258
+ name: "hostname",
259
+ placeholder: t("neetoCustomDomains.placeholder")
260
+ })
261
+ }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
262
+ children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
263
+ cancelButtonProps: {
264
+ onClick: onClose
265
+ },
266
+ isSubmitting: isCreating,
267
+ submitButtonProps: {
268
+ label: t("neetoCustomDomains.actions.continue"),
269
+ "data-cy": "submit-custom-domain-button",
270
+ "data-testid": "submit-custom-domain-button",
271
+ disabled: !dirty || isCreating
272
+ }
273
+ })
274
+ })]
275
+ });
276
+ }
277
+ });
278
+ };
279
+
280
+ var columnData = function columnData() {
281
+ return [{
282
+ title: i18next.t("neetoCustomDomains.common.record"),
283
+ key: "record",
284
+ dataIndex: "record",
285
+ width: "18%",
286
+ render: function render() {
287
+ return /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
288
+ style: "body2",
289
+ children: i18next.t("neetoCustomDomains.cname")
290
+ });
291
+ }
292
+ }, {
293
+ title: i18next.t("neetoCustomDomains.common.name"),
294
+ dataIndex: "name",
295
+ width: "35%",
296
+ key: "name",
297
+ render: function render(name, _) {
298
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
299
+ className: "flex items-center justify-between gap-1",
300
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
301
+ className: "min-w-0 truncate",
302
+ style: "body2",
303
+ children: name
304
+ }), /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton__default["default"], {
305
+ className: "flex-shrink-0",
306
+ size: "small",
307
+ style: "secondary",
308
+ value: name
309
+ })]
310
+ });
311
+ }
312
+ }, {
313
+ title: i18next.t("neetoCustomDomains.common.value"),
314
+ dataIndex: "value",
315
+ width: "35%",
316
+ key: "value",
317
+ render: function render(value, _) {
318
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
319
+ className: "flex items-center justify-between gap-1",
320
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
321
+ className: "min-w-0 truncate",
322
+ style: "body2",
323
+ children: neetoCist.truncate(value, 20)
324
+ }), /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton__default["default"], {
325
+ value: value,
326
+ className: "flex-shrink-0",
327
+ size: "small",
328
+ style: "secondary"
329
+ })]
330
+ });
331
+ }
332
+ }];
333
+ };
334
+
335
+ var Validation = function Validation(_ref) {
336
+ var customDomain = _ref.customDomain,
337
+ onClose = _ref.onClose,
338
+ url = _ref.url;
339
+ var hostname = customDomain.hostname,
340
+ dnsTarget = customDomain.dnsTarget,
341
+ status = customDomain.status;
342
+ var _useTranslation = reactI18next.useTranslation(),
343
+ t = _useTranslation.t;
344
+ var isDomainValidated = status === "active";
345
+ var _useState = react.useState(""),
346
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
347
+ errorKey = _useState2[0],
348
+ setErrorKey = _useState2[1];
349
+ var _useValidateDomain = CustomDomainDashboard.useValidateDomain(url, {
350
+ onError: function onError(_ref2) {
351
+ var response = _ref2.response;
352
+ setErrorKey(response.data.error);
353
+ },
354
+ onSuccess: function onSuccess() {
355
+ Toastr__default["default"].success(t("neetoCustomDomains.validation.successMessage"));
356
+ onClose();
357
+ }
358
+ }),
359
+ validateDomain = _useValidateDomain.mutate,
360
+ isValidating = _useValidateDomain.isPending;
361
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
362
+ children: [/*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Body, {
363
+ className: "space-y-4",
364
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
365
+ className: "space-y-2",
366
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
367
+ style: "h4",
368
+ weight: "medium",
369
+ children: t("neetoCustomDomains.cnameRecordTitle")
370
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
371
+ style: "body2",
372
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
373
+ i18nKey: "neetoCustomDomains.cnameRecordInfo",
374
+ components: {
375
+ Link: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
376
+ href: HELP_DOC_URL,
377
+ rel: "noreferrer",
378
+ style: "link",
379
+ target: "_blank"
380
+ })
381
+ },
382
+ values: {
383
+ proxyMessage: t("neetoCustomDomains.proxyMessage")
384
+ }
385
+ })
386
+ })]
387
+ }), /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
388
+ allowRowClick: false,
389
+ columnData: columnData(),
390
+ rowData: [{
391
+ name: hostname,
392
+ value: dnsTarget
393
+ }],
394
+ rowSelection: false
395
+ }), neetoCist.isNotEmpty(errorKey) && /*#__PURE__*/jsxRuntime.jsx(Callout__default["default"], {
396
+ style: STATUS_TAG_STYLES[status],
397
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
398
+ style: "body2",
399
+ children: t(errorKey)
400
+ })
401
+ })]
402
+ }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
403
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
404
+ className: "flex items-center gap-2",
405
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
406
+ "data-cy": "validate-domain-button",
407
+ disabled: isValidating || isDomainValidated,
408
+ label: t("neetoCustomDomains.validation.buttonLabel.domain"),
409
+ loading: isValidating,
410
+ onClick: validateDomain
411
+ }), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
412
+ label: t("neetoCustomDomains.actions.cancel"),
413
+ style: "text",
414
+ onClick: onClose
415
+ })]
416
+ })
417
+ })]
418
+ });
419
+ };
420
+
421
+ var DomainPane = function DomainPane(_ref) {
422
+ var customDomain = _ref.customDomain,
423
+ isOpen = _ref.isOpen,
424
+ onClose = _ref.onClose,
425
+ onCreate = _ref.onCreate,
426
+ url = _ref.url,
427
+ isCustomDomainAdded = _ref.isCustomDomainAdded;
428
+ var _useTranslation = reactI18next.useTranslation(),
429
+ t = _useTranslation.t;
430
+ var _customDomain$status = customDomain.status,
431
+ status = _customDomain$status === void 0 ? "notAdded" : _customDomain$status;
432
+ return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
433
+ isOpen: isOpen,
434
+ onClose: onClose,
435
+ size: "large",
436
+ children: [/*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Header, {
437
+ className: "space-y-2",
438
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
439
+ style: "h2",
440
+ children: t("neetoCustomDomains.addNew")
441
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
442
+ className: "-ml-2",
443
+ children: /*#__PURE__*/jsxRuntime.jsx(Stepper__default["default"], {
444
+ activeIndex: CURRENT_STEP[status],
445
+ steps: STEPS
446
+ })
447
+ })]
448
+ }), isCustomDomainAdded ? /*#__PURE__*/jsxRuntime.jsx(Validation, {
449
+ customDomain: customDomain,
450
+ onClose: onClose,
451
+ url: url
452
+ }) : /*#__PURE__*/jsxRuntime.jsx(DomainField, {
453
+ customDomain: customDomain,
454
+ onClose: onClose,
455
+ onCreate: onCreate,
456
+ url: url
457
+ })]
458
+ });
459
+ };
460
+
461
+ 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; }
462
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](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; }
463
+ var Header = withT__default["default"](function (_ref) {
464
+ var t = _ref.t,
465
+ openPane = _ref.openPane,
466
+ headerProps = _ref.headerProps,
467
+ isCustomDomainAdded = _ref.isCustomDomainAdded;
468
+ return /*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], _objectSpread({
469
+ "data-testid": "custom-domain-header",
470
+ title: t("neetoCustomDomains.customDomain", constants.SINGULAR),
471
+ actionBlock: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
472
+ "data-cy": "add-new-custom-domain-button",
473
+ disabled: isCustomDomainAdded,
474
+ label: t("neetoCustomDomains.actions.add", {
475
+ what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
476
+ }),
477
+ onClick: openPane
478
+ })
479
+ }, headerProps));
480
+ });
481
+ var Header$1 = /*#__PURE__*/react.memo(Header);
482
+
483
+ var CustomDomain = function CustomDomain(_ref) {
484
+ var headerProps = _ref.headerProps,
485
+ url = _ref.url,
486
+ onCreate = _ref.onCreate;
487
+ var _useState = react.useState(false),
488
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
489
+ isPaneOpen = _useState2[0],
490
+ setIsPaneOpen = _useState2[1];
491
+ var _useState3 = react.useState(false),
492
+ _useState4 = _slicedToArray__default["default"](_useState3, 2),
493
+ isAlertOpen = _useState4[0],
494
+ setIsAlertOpen = _useState4[1];
495
+ var _useFetchCustomDomain = CustomDomainDashboard.useFetchCustomDomain(url),
496
+ customDomain = _useFetchCustomDomain.data,
497
+ isLoading = _useFetchCustomDomain.isLoading;
498
+ var _useDeleteCustomDomai = CustomDomainDashboard.useDeleteCustomDomain(url, {
499
+ onSettled: function onSettled() {
500
+ setIsAlertOpen(false);
501
+ }
502
+ }),
503
+ deleteCustomDomain = _useDeleteCustomDomai.mutate,
504
+ isDeleting = _useDeleteCustomDomai.isPending;
505
+ var openPane = function openPane() {
506
+ return setIsPaneOpen(true);
507
+ };
508
+ var closePane = function closePane() {
509
+ return setIsPaneOpen(false);
510
+ };
511
+ var openDeleteAlert = function openDeleteAlert() {
512
+ return setIsAlertOpen(true);
513
+ };
514
+ var isCustomDomainAdded = neetoCist.isNotEmpty(customDomain);
515
+ if (isLoading) {
516
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
517
+ className: "h-screen w-full",
518
+ children: /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {})
519
+ });
520
+ }
521
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
522
+ children: [/*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
523
+ children: [/*#__PURE__*/jsxRuntime.jsx(Header$1, {
524
+ headerProps: headerProps,
525
+ isCustomDomainAdded: isCustomDomainAdded,
526
+ openPane: openPane
527
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
528
+ className: "mt-10 flex w-full justify-center",
529
+ children: /*#__PURE__*/jsxRuntime.jsx(Domain, {
530
+ customDomain: customDomain,
531
+ isCustomDomainAdded: isCustomDomainAdded,
532
+ openDeleteAlert: openDeleteAlert,
533
+ openPane: openPane
534
+ })
535
+ })]
536
+ }), /*#__PURE__*/jsxRuntime.jsx(DomainPane, {
537
+ customDomain: customDomain,
538
+ isCustomDomainAdded: isCustomDomainAdded,
539
+ onCreate: onCreate,
540
+ url: url,
541
+ isOpen: isPaneOpen,
542
+ onClose: closePane
543
+ }), /*#__PURE__*/jsxRuntime.jsx(DeleteAlert, {
544
+ hostname: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname,
545
+ isOpen: isAlertOpen,
546
+ isSubmitting: isDeleting,
547
+ onClose: function onClose() {
548
+ return setIsAlertOpen(false);
549
+ },
550
+ onSubmit: deleteCustomDomain
551
+ })]
552
+ });
553
+ };
554
+
555
+ exports.CustomDomainDashboard = CustomDomainDashboard.CustomDomainDashboard;
50
556
  exports.WelcomeScreen = WelcomeScreen;
557
+ exports.CustomDomain = CustomDomain;
51
558
  //# sourceMappingURL=index.js.map