@bigbinary/neeto-molecules 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/BrowserSupport.cjs.js +1468 -0
- package/dist/BrowserSupport.js +1462 -0
- package/dist/Columns.cjs.js +183 -0
- package/dist/Columns.js +177 -0
- package/dist/CustomDomain.cjs.js +758 -0
- package/dist/CustomDomain.js +732 -0
- package/dist/DateRangeFilter.cjs.js +214 -0
- package/dist/DateRangeFilter.js +207 -0
- package/dist/EmailPreview.cjs.js +32409 -0
- package/dist/EmailPreview.js +32383 -0
- package/dist/ErrorPage.cjs.js +135 -0
- package/dist/ErrorPage.js +111 -0
- package/dist/IpRestriction.cjs.js +3578 -0
- package/dist/IpRestriction.js +3552 -0
- package/dist/KeyboardShortcuts.cjs.js +2212 -0
- package/dist/KeyboardShortcuts.js +2205 -0
- package/dist/LoginPage.cjs.js +598 -0
- package/dist/LoginPage.js +573 -0
- package/dist/NeetoWidget.cjs.js +86969 -0
- package/dist/NeetoWidget.js +86943 -0
- package/dist/PublishBlock.cjs.js +188 -0
- package/dist/PublishBlock.js +182 -0
- package/dist/Schedule.cjs.js +949 -0
- package/dist/Schedule.js +918 -0
- package/dist/ShareViaLink.cjs.js +1247 -0
- package/dist/ShareViaLink.js +1241 -0
- package/dist/Sidebar.cjs.js +222 -0
- package/dist/Sidebar.js +195 -0
- package/package.json +149 -0
- package/src/translations/en.json +244 -0
- package/types/BrowserSupport.d.ts +20 -0
- package/types/Columns.d.ts +22 -0
- package/types/CustomDomain.d.ts +7 -0
- package/types/DateRangeFilter.d.ts +17 -0
- package/types/EmailPreview.d.ts +11 -0
- package/types/ErrorPage.d.ts +8 -0
- package/types/IpRestriction.d.ts +5 -0
- package/types/KeyboardShortcuts.d.ts +21 -0
- package/types/LoginPage.d.ts +12 -0
- package/types/NeetoWidget.d.ts +17 -0
- package/types/PublishBlock.d.ts +20 -0
- package/types/Schedule.d.ts +15 -0
- package/types/ShareViaLink.d.ts +17 -0
- package/types/Sidebar.d.ts +28 -0
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { snakeToCamelCase, isNotEmpty } from '@bigbinary/neeto-commons-frontend/pure';
|
|
3
|
+
import { useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
4
|
+
import { Tag, Button, Dropdown, Callout, Input, Pane, Typography, Label, PageLoader, Table, NoData, Alert } from '@bigbinary/neetoui';
|
|
5
|
+
import { Container, Header, SubHeader } from '@bigbinary/neetoui/layouts';
|
|
6
|
+
import { useTranslation, Trans } from 'react-i18next';
|
|
7
|
+
import { MenuHorizontal, Info, Copy, Check } from '@bigbinary/neeto-icons';
|
|
8
|
+
import { Input as Input$1 } from '@bigbinary/neetoui/formik';
|
|
9
|
+
import { Formik, Form } from 'formik';
|
|
10
|
+
import { joinHyphenCase, copyToClipboard, timeFormat } from '@bigbinary/neeto-commons-frontend/utils';
|
|
11
|
+
import { t } from 'i18next';
|
|
12
|
+
import * as Yup from 'yup';
|
|
13
|
+
import { useQueryClient, useMutation, useQuery } from 'react-query';
|
|
14
|
+
import axios from 'axios';
|
|
15
|
+
|
|
16
|
+
function _extends() {
|
|
17
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
18
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
19
|
+
var source = arguments[i];
|
|
20
|
+
for (var key in source) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
+
target[key] = source[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return target;
|
|
27
|
+
};
|
|
28
|
+
return _extends.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _arrayWithHoles(arr) {
|
|
32
|
+
if (Array.isArray(arr)) return arr;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _iterableToArrayLimit(arr, i) {
|
|
36
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
37
|
+
if (null != _i) {
|
|
38
|
+
var _s,
|
|
39
|
+
_e,
|
|
40
|
+
_x,
|
|
41
|
+
_r,
|
|
42
|
+
_arr = [],
|
|
43
|
+
_n = !0,
|
|
44
|
+
_d = !1;
|
|
45
|
+
try {
|
|
46
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
47
|
+
if (Object(_i) !== _i) return;
|
|
48
|
+
_n = !1;
|
|
49
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_d = !0, _e = err;
|
|
52
|
+
} finally {
|
|
53
|
+
try {
|
|
54
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
55
|
+
} finally {
|
|
56
|
+
if (_d) throw _e;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return _arr;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _arrayLikeToArray(arr, len) {
|
|
64
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
65
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
66
|
+
return arr2;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
70
|
+
if (!o) return;
|
|
71
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
72
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
73
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
74
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
75
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function _nonIterableRest() {
|
|
79
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function _slicedToArray(arr, i) {
|
|
83
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var DEFAULT_STALE_TIME = 60 * 60 * 1000;
|
|
87
|
+
var DOMAIN_QUERY_KEY = "custom-domain";
|
|
88
|
+
var ENTITY_COUNT = {
|
|
89
|
+
singular: 1,
|
|
90
|
+
plural: 2
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var HOSTNAME_REGEX = /^(?!-)[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+/;
|
|
94
|
+
var INITIAL_VALUES = {
|
|
95
|
+
hostname: ""
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var classnames$1 = {exports: {}};
|
|
99
|
+
|
|
100
|
+
/*!
|
|
101
|
+
Copyright (c) 2018 Jed Watson.
|
|
102
|
+
Licensed under the MIT License (MIT), see
|
|
103
|
+
http://jedwatson.github.io/classnames
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
(function (module) {
|
|
107
|
+
/* global define */
|
|
108
|
+
|
|
109
|
+
(function () {
|
|
110
|
+
|
|
111
|
+
var hasOwn = {}.hasOwnProperty;
|
|
112
|
+
|
|
113
|
+
function classNames() {
|
|
114
|
+
var classes = [];
|
|
115
|
+
|
|
116
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
117
|
+
var arg = arguments[i];
|
|
118
|
+
if (!arg) continue;
|
|
119
|
+
|
|
120
|
+
var argType = typeof arg;
|
|
121
|
+
|
|
122
|
+
if (argType === 'string' || argType === 'number') {
|
|
123
|
+
classes.push(arg);
|
|
124
|
+
} else if (Array.isArray(arg)) {
|
|
125
|
+
if (arg.length) {
|
|
126
|
+
var inner = classNames.apply(null, arg);
|
|
127
|
+
if (inner) {
|
|
128
|
+
classes.push(inner);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} else if (argType === 'object') {
|
|
132
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
133
|
+
classes.push(arg.toString());
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (var key in arg) {
|
|
138
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
139
|
+
classes.push(key);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return classes.join(' ');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (module.exports) {
|
|
149
|
+
classNames.default = classNames;
|
|
150
|
+
module.exports = classNames;
|
|
151
|
+
} else {
|
|
152
|
+
window.classNames = classNames;
|
|
153
|
+
}
|
|
154
|
+
}());
|
|
155
|
+
} (classnames$1));
|
|
156
|
+
|
|
157
|
+
var classnames = classnames$1.exports;
|
|
158
|
+
|
|
159
|
+
var TagBlock = function TagBlock(_ref) {
|
|
160
|
+
var status = _ref.status,
|
|
161
|
+
isCnameRecordsAdded = _ref.isCnameRecordsAdded,
|
|
162
|
+
_ref$stacked = _ref.stacked,
|
|
163
|
+
stacked = _ref$stacked === void 0 ? false : _ref$stacked,
|
|
164
|
+
handleValidateCname = _ref.handleValidateCname;
|
|
165
|
+
var _useTranslation = useTranslation(),
|
|
166
|
+
t = _useTranslation.t;
|
|
167
|
+
var isTxtValidated = status === "active" || status === "pending_cname_validation";
|
|
168
|
+
var camelCasedStatus = snakeToCamelCase(status || "");
|
|
169
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
className: classnames("flex gap-2", {
|
|
171
|
+
"flex-col items-start": stacked
|
|
172
|
+
})
|
|
173
|
+
}, status === "failed" ? /*#__PURE__*/React.createElement(Tag, {
|
|
174
|
+
indicatorStyle: "danger",
|
|
175
|
+
label: t("neetoMolecules.customDomain.status.".concat(camelCasedStatus)),
|
|
176
|
+
style: "secondary"
|
|
177
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tag, {
|
|
178
|
+
indicatorStyle: isTxtValidated ? "success" : "warning",
|
|
179
|
+
style: "secondary",
|
|
180
|
+
label: t("neetoMolecules.customDomain.status.txt.".concat(camelCasedStatus))
|
|
181
|
+
}), isTxtValidated && /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
className: classnames("flex items-center justify-between gap-2", {
|
|
183
|
+
"w-full": stacked
|
|
184
|
+
})
|
|
185
|
+
}, /*#__PURE__*/React.createElement(Tag, {
|
|
186
|
+
indicatorStyle: status === "active" ? "success" : "warning",
|
|
187
|
+
style: "secondary",
|
|
188
|
+
label: t("neetoMolecules.customDomain.status.cname.".concat(camelCasedStatus))
|
|
189
|
+
}), isCnameRecordsAdded && status === "pending_cname_validation" && /*#__PURE__*/React.createElement(Button, {
|
|
190
|
+
className: "text-xs",
|
|
191
|
+
style: "link",
|
|
192
|
+
label: t("neetoMolecules.customDomain.validation.buttonLabel.cnameCheck"),
|
|
193
|
+
onClick: handleValidateCname
|
|
194
|
+
}))));
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
var Menu = Dropdown.Menu,
|
|
198
|
+
MenuItem = Dropdown.MenuItem;
|
|
199
|
+
var renderColumnData = function renderColumnData(enableManagePane, enableDeleteAlert) {
|
|
200
|
+
return [{
|
|
201
|
+
title: t("neetoMolecules.customDomain.customDomain", {
|
|
202
|
+
count: ENTITY_COUNT.singular
|
|
203
|
+
}),
|
|
204
|
+
dataIndex: "hostname",
|
|
205
|
+
key: "hostname"
|
|
206
|
+
}, {
|
|
207
|
+
title: t("neetoMolecules.common.status"),
|
|
208
|
+
dataIndex: "status",
|
|
209
|
+
key: "status",
|
|
210
|
+
render: function render(status) {
|
|
211
|
+
return /*#__PURE__*/React.createElement(TagBlock, {
|
|
212
|
+
status: status
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
width: "40%"
|
|
216
|
+
}, {
|
|
217
|
+
id: "actions",
|
|
218
|
+
width: "10%",
|
|
219
|
+
render: function render(_, customDomain) {
|
|
220
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
221
|
+
onClick: function onClick(e) {
|
|
222
|
+
return e.stopPropagation();
|
|
223
|
+
}
|
|
224
|
+
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
225
|
+
autoWidth: true,
|
|
226
|
+
buttonProps: {
|
|
227
|
+
style: "text"
|
|
228
|
+
},
|
|
229
|
+
icon: MenuHorizontal,
|
|
230
|
+
position: "bottom-end",
|
|
231
|
+
strategy: "fixed"
|
|
232
|
+
}, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem.Button, {
|
|
233
|
+
onClick: function onClick() {
|
|
234
|
+
return enableManagePane(customDomain);
|
|
235
|
+
}
|
|
236
|
+
}, t("neetoMolecules.common.actions.edit")), /*#__PURE__*/React.createElement(MenuItem.Button, {
|
|
237
|
+
onClick: function onClick() {
|
|
238
|
+
return enableDeleteAlert(customDomain);
|
|
239
|
+
}
|
|
240
|
+
}, t("neetoMolecules.common.actions.delete")))));
|
|
241
|
+
}
|
|
242
|
+
}];
|
|
243
|
+
};
|
|
244
|
+
var recordData = function recordData(customDomain) {
|
|
245
|
+
var status = customDomain.status,
|
|
246
|
+
hostname = customDomain.hostname,
|
|
247
|
+
dnsTarget = customDomain.dnsTarget,
|
|
248
|
+
txtValue = customDomain.txtValue;
|
|
249
|
+
var isTxtValidated = status === "active" || status === "pending_cname_validation";
|
|
250
|
+
var recordName = isTxtValidated ? hostname : "_acme-challenge.".concat(hostname);
|
|
251
|
+
var recordValue = isTxtValidated ? dnsTarget : txtValue;
|
|
252
|
+
var recordType = isTxtValidated ? "CNAME" : "TXT";
|
|
253
|
+
var recordDescription = t("neetoMolecules.customDomain.validation.desc", {
|
|
254
|
+
record: recordType
|
|
255
|
+
});
|
|
256
|
+
var recordNameLabel = t("neetoMolecules.customDomain.validation.record", {
|
|
257
|
+
record: recordType,
|
|
258
|
+
type: t("neetoMolecules.common.name")
|
|
259
|
+
});
|
|
260
|
+
var recordValueLabel = t("neetoMolecules.customDomain.validation.record", {
|
|
261
|
+
record: recordType,
|
|
262
|
+
type: t("neetoMolecules.common.value")
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
recordName: recordName,
|
|
266
|
+
recordValue: recordValue,
|
|
267
|
+
recordDescription: recordDescription,
|
|
268
|
+
recordNameLabel: recordNameLabel,
|
|
269
|
+
recordValueLabel: recordValueLabel
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
var Record = function Record(_ref) {
|
|
274
|
+
var customDomain = _ref.customDomain;
|
|
275
|
+
var _recordData = recordData(customDomain),
|
|
276
|
+
recordName = _recordData.recordName,
|
|
277
|
+
recordValue = _recordData.recordValue,
|
|
278
|
+
recordDescription = _recordData.recordDescription,
|
|
279
|
+
recordNameLabel = _recordData.recordNameLabel,
|
|
280
|
+
recordValueLabel = _recordData.recordValueLabel;
|
|
281
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
282
|
+
className: "grid gap-4 mt-6"
|
|
283
|
+
}, customDomain.status !== "active" && /*#__PURE__*/React.createElement(Callout, {
|
|
284
|
+
icon: Info,
|
|
285
|
+
style: "info"
|
|
286
|
+
}, recordDescription), /*#__PURE__*/React.createElement(Input, {
|
|
287
|
+
disabled: true,
|
|
288
|
+
"data-cy": joinHyphenCase(recordNameLabel),
|
|
289
|
+
label: recordNameLabel,
|
|
290
|
+
value: recordName,
|
|
291
|
+
suffix: /*#__PURE__*/React.createElement(Button, {
|
|
292
|
+
icon: Copy,
|
|
293
|
+
style: "text",
|
|
294
|
+
onClick: function onClick() {
|
|
295
|
+
return copyToClipboard(recordName);
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
299
|
+
disabled: true,
|
|
300
|
+
"data-cy": joinHyphenCase(recordValueLabel),
|
|
301
|
+
label: recordValueLabel,
|
|
302
|
+
value: recordValue,
|
|
303
|
+
suffix: /*#__PURE__*/React.createElement(Button, {
|
|
304
|
+
icon: Copy,
|
|
305
|
+
style: "text",
|
|
306
|
+
onClick: function onClick() {
|
|
307
|
+
return copyToClipboard(recordValue);
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
}));
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
var CustomDomainInfo = function CustomDomainInfo(_ref) {
|
|
314
|
+
var time = _ref.time;
|
|
315
|
+
var _useTranslation = useTranslation(),
|
|
316
|
+
t = _useTranslation.t;
|
|
317
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
318
|
+
className: "space-y-6"
|
|
319
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
320
|
+
className: "p-4 neeto-ui-rounded neeto-ui-bg-gray-100 space-y-3 neeto-ui-text-gray-700"
|
|
321
|
+
}, /*#__PURE__*/React.createElement(Trans, {
|
|
322
|
+
i18nKey: "neetoMolecules.customDomain.messageBlock.dnsStatus"
|
|
323
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
324
|
+
href: "mailto:support@neeto.com",
|
|
325
|
+
label: "support@neeto.com",
|
|
326
|
+
style: "link"
|
|
327
|
+
})), /*#__PURE__*/React.createElement(Callout, {
|
|
328
|
+
icon: Info,
|
|
329
|
+
style: "info"
|
|
330
|
+
}, t("neetoMolecules.customDomain.messageBlock.cnameAddedTime", {
|
|
331
|
+
time: timeFormat.fromNow(time)
|
|
332
|
+
})));
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
var getCustomDomainValidationSchema = function getCustomDomainValidationSchema() {
|
|
336
|
+
return Yup.object().shape({
|
|
337
|
+
hostname: Yup.string().required(t("neetoMolecules.customDomain.formikValidation.required")).matches(HOSTNAME_REGEX, t("neetoMolecules.customDomain.formikValidation.valid"))
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
function _typeof(obj) {
|
|
342
|
+
"@babel/helpers - typeof";
|
|
343
|
+
|
|
344
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
345
|
+
return typeof obj;
|
|
346
|
+
} : function (obj) {
|
|
347
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
348
|
+
}, _typeof(obj);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function _toPrimitive(input, hint) {
|
|
352
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
353
|
+
var prim = input[Symbol.toPrimitive];
|
|
354
|
+
if (prim !== undefined) {
|
|
355
|
+
var res = prim.call(input, hint || "default");
|
|
356
|
+
if (_typeof(res) !== "object") return res;
|
|
357
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
358
|
+
}
|
|
359
|
+
return (hint === "string" ? String : Number)(input);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function _toPropertyKey(arg) {
|
|
363
|
+
var key = _toPrimitive(arg, "string");
|
|
364
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function _defineProperty(obj, key, value) {
|
|
368
|
+
key = _toPropertyKey(key);
|
|
369
|
+
if (key in obj) {
|
|
370
|
+
Object.defineProperty(obj, key, {
|
|
371
|
+
value: value,
|
|
372
|
+
enumerable: true,
|
|
373
|
+
configurable: true,
|
|
374
|
+
writable: true
|
|
375
|
+
});
|
|
376
|
+
} else {
|
|
377
|
+
obj[key] = value;
|
|
378
|
+
}
|
|
379
|
+
return obj;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
var customDomainsUrl = "custom_domains/domains";
|
|
383
|
+
var fetchCustomDomains = function fetchCustomDomains(payload) {
|
|
384
|
+
return axios.get(customDomainsUrl, {
|
|
385
|
+
params: payload
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
var updateCustomDomain = function updateCustomDomain(id) {
|
|
389
|
+
return axios.patch("".concat(customDomainsUrl, "/").concat(id));
|
|
390
|
+
};
|
|
391
|
+
var createCustomDomain = function createCustomDomain(payload) {
|
|
392
|
+
return axios.post(customDomainsUrl, payload);
|
|
393
|
+
};
|
|
394
|
+
var deleteCustomDomain = function deleteCustomDomain(id) {
|
|
395
|
+
return axios["delete"]("".concat(customDomainsUrl, "/").concat(id));
|
|
396
|
+
};
|
|
397
|
+
var validateTxt = function validateTxt(id) {
|
|
398
|
+
return axios.patch("".concat(customDomainsUrl, "/").concat(id, "/validate_txt"));
|
|
399
|
+
};
|
|
400
|
+
var validateCname = function validateCname(id) {
|
|
401
|
+
return axios.patch("".concat(customDomainsUrl, "/").concat(id, "/validate_cname"));
|
|
402
|
+
};
|
|
403
|
+
var customDomainApi = {
|
|
404
|
+
createCustomDomain: createCustomDomain,
|
|
405
|
+
deleteCustomDomain: deleteCustomDomain,
|
|
406
|
+
validateTxt: validateTxt,
|
|
407
|
+
fetchCustomDomains: fetchCustomDomains,
|
|
408
|
+
validateCname: validateCname,
|
|
409
|
+
updateCustomDomain: updateCustomDomain
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
413
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
414
|
+
var useCreateCustomDomain = function useCreateCustomDomain() {
|
|
415
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
416
|
+
var queryClient = useQueryClient();
|
|
417
|
+
return useMutation(function (payload) {
|
|
418
|
+
return customDomainApi.createCustomDomain(payload);
|
|
419
|
+
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
420
|
+
onSuccess: function onSuccess() {
|
|
421
|
+
return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
|
|
422
|
+
}
|
|
423
|
+
}));
|
|
424
|
+
};
|
|
425
|
+
var useDeleteCustomDomain = function useDeleteCustomDomain() {
|
|
426
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
427
|
+
var queryClient = useQueryClient();
|
|
428
|
+
return useMutation(function (id) {
|
|
429
|
+
return customDomainApi.deleteCustomDomain(id);
|
|
430
|
+
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
431
|
+
onSuccess: function onSuccess(result) {
|
|
432
|
+
var _options$onSuccess;
|
|
433
|
+
(_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, result);
|
|
434
|
+
queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
|
|
435
|
+
}
|
|
436
|
+
}));
|
|
437
|
+
};
|
|
438
|
+
var useFetchCustomDomains = function useFetchCustomDomains(payload) {
|
|
439
|
+
return useQuery([DOMAIN_QUERY_KEY, _objectSpread({}, payload)], function () {
|
|
440
|
+
return customDomainApi.fetchCustomDomains(payload);
|
|
441
|
+
}, {
|
|
442
|
+
staleTime: DEFAULT_STALE_TIME
|
|
443
|
+
});
|
|
444
|
+
};
|
|
445
|
+
var useValidateTxt = function useValidateTxt() {
|
|
446
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
447
|
+
var queryClient = useQueryClient();
|
|
448
|
+
return useMutation(function (id) {
|
|
449
|
+
return customDomainApi.validateTxt(id);
|
|
450
|
+
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
451
|
+
onSuccess: function onSuccess() {
|
|
452
|
+
return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
|
|
453
|
+
}
|
|
454
|
+
}));
|
|
455
|
+
};
|
|
456
|
+
var useValidateCname = function useValidateCname() {
|
|
457
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
458
|
+
var queryClient = useQueryClient();
|
|
459
|
+
return useMutation(function (id) {
|
|
460
|
+
return customDomainApi.validateCname(id);
|
|
461
|
+
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
462
|
+
onSuccess: function onSuccess() {
|
|
463
|
+
return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
|
|
464
|
+
}
|
|
465
|
+
}));
|
|
466
|
+
};
|
|
467
|
+
var useUpdateCustomDomain = function useUpdateCustomDomain() {
|
|
468
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
469
|
+
var queryClient = useQueryClient();
|
|
470
|
+
return useMutation(function (id) {
|
|
471
|
+
return customDomainApi.updateCustomDomain(id);
|
|
472
|
+
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
473
|
+
onSuccess: function onSuccess() {
|
|
474
|
+
return queryClient.invalidateQueries(DOMAIN_QUERY_KEY);
|
|
475
|
+
}
|
|
476
|
+
}));
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
var Manage = function Manage(_ref) {
|
|
480
|
+
var isOpen = _ref.isOpen,
|
|
481
|
+
onClose = _ref.onClose,
|
|
482
|
+
customDomain = _ref.customDomain,
|
|
483
|
+
setCustomDomain = _ref.setCustomDomain;
|
|
484
|
+
var _useTranslation = useTranslation(),
|
|
485
|
+
t = _useTranslation.t;
|
|
486
|
+
var _useCreateCustomDomai = useCreateCustomDomain(),
|
|
487
|
+
createCustomDomain = _useCreateCustomDomai.mutate,
|
|
488
|
+
isCreating = _useCreateCustomDomai.isLoading;
|
|
489
|
+
var _useValidateTxt = useValidateTxt(),
|
|
490
|
+
validateTxt = _useValidateTxt.mutate,
|
|
491
|
+
isValidating = _useValidateTxt.isLoading;
|
|
492
|
+
var _useValidateCname = useValidateCname(),
|
|
493
|
+
validateCname = _useValidateCname.mutate,
|
|
494
|
+
isCnameValidating = _useValidateCname.isLoading;
|
|
495
|
+
var _useUpdateCustomDomai = useUpdateCustomDomain(),
|
|
496
|
+
updateCustomDomain = _useUpdateCustomDomai.mutate,
|
|
497
|
+
isUpdating = _useUpdateCustomDomai.isLoading;
|
|
498
|
+
var handleSubmit = function handleSubmit(values) {
|
|
499
|
+
return createCustomDomain(values, {
|
|
500
|
+
onSuccess: function onSuccess(values) {
|
|
501
|
+
return setCustomDomain(values);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
var handleValidateTxt = function handleValidateTxt() {
|
|
506
|
+
return validateTxt(customDomain.id, {
|
|
507
|
+
onSuccess: function onSuccess(values) {
|
|
508
|
+
return setCustomDomain(values);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
var handleValidateCname = function handleValidateCname() {
|
|
513
|
+
validateCname(customDomain.id, {
|
|
514
|
+
onSuccess: function onSuccess(data) {
|
|
515
|
+
return setCustomDomain(data);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
var handleUpdateCname = function handleUpdateCname() {
|
|
520
|
+
updateCustomDomain(customDomain.id, {
|
|
521
|
+
onSuccess: function onSuccess(data) {
|
|
522
|
+
return setCustomDomain(data);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
};
|
|
526
|
+
return /*#__PURE__*/React.createElement(Pane, {
|
|
527
|
+
isOpen: isOpen,
|
|
528
|
+
onClose: onClose
|
|
529
|
+
}, /*#__PURE__*/React.createElement(Formik, {
|
|
530
|
+
enableReinitialize: true,
|
|
531
|
+
initialValues: customDomain || INITIAL_VALUES,
|
|
532
|
+
validateOnBlur: isCreating,
|
|
533
|
+
validateOnChange: isCreating,
|
|
534
|
+
validationSchema: getCustomDomainValidationSchema(),
|
|
535
|
+
onSubmit: handleSubmit
|
|
536
|
+
}, function (_ref2) {
|
|
537
|
+
var dirty = _ref2.dirty;
|
|
538
|
+
return /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
539
|
+
"data-cy": "add-custom-domain-pane-heading",
|
|
540
|
+
style: "h2",
|
|
541
|
+
weight: "semibold"
|
|
542
|
+
}, customDomain ? t("neetoMolecules.common.actions.editTitle", {
|
|
543
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
544
|
+
count: ENTITY_COUNT.singular
|
|
545
|
+
}).toLocaleLowerCase()
|
|
546
|
+
}) : t("neetoMolecules.common.actions.addNew", {
|
|
547
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
548
|
+
count: ENTITY_COUNT.singular
|
|
549
|
+
}).toLocaleLowerCase()
|
|
550
|
+
}))), /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
|
|
551
|
+
className: "space-y-6 w-full"
|
|
552
|
+
}, !!customDomain && /*#__PURE__*/React.createElement(TagBlock, {
|
|
553
|
+
stacked: true,
|
|
554
|
+
handleValidateCname: handleValidateCname,
|
|
555
|
+
isCnameRecordsAdded: customDomain.addedCnameAt,
|
|
556
|
+
status: customDomain.status
|
|
557
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
558
|
+
className: "space-y-2"
|
|
559
|
+
}, /*#__PURE__*/React.createElement(Label, {
|
|
560
|
+
htmlFor: "hostname"
|
|
561
|
+
}, customDomain ? t("neetoMolecules.customDomain.customDomain", {
|
|
562
|
+
count: ENTITY_COUNT.singular
|
|
563
|
+
}) : t("neetoMolecules.customDomain.label")), /*#__PURE__*/React.createElement("div", {
|
|
564
|
+
className: "flex items-start gap-2"
|
|
565
|
+
}, /*#__PURE__*/React.createElement(Input$1, {
|
|
566
|
+
autoFocus: true,
|
|
567
|
+
"data-cy": "custom-domain-input-field",
|
|
568
|
+
disabled: !!customDomain,
|
|
569
|
+
name: "hostname",
|
|
570
|
+
placeholder: t("neetoMolecules.customDomain.placeholder")
|
|
571
|
+
}), !customDomain && /*#__PURE__*/React.createElement(Button, {
|
|
572
|
+
"data-cy": "submit-custom-domain-button",
|
|
573
|
+
disabled: !dirty || isCreating,
|
|
574
|
+
icon: Check,
|
|
575
|
+
loading: isCreating,
|
|
576
|
+
style: "primary",
|
|
577
|
+
type: "submit"
|
|
578
|
+
}))), !!customDomain && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Record, {
|
|
579
|
+
customDomain: customDomain
|
|
580
|
+
}), customDomain.status === "pending_txt_validation" && /*#__PURE__*/React.createElement(Button, {
|
|
581
|
+
"data-cy": "validate-txt-record-button",
|
|
582
|
+
disabled: isValidating,
|
|
583
|
+
loading: isValidating,
|
|
584
|
+
label: t("neetoMolecules.customDomain.validation.buttonLabel.txt"),
|
|
585
|
+
onClick: handleValidateTxt
|
|
586
|
+
}), customDomain.status === "pending_cname_validation" && !customDomain.addedCnameAt && /*#__PURE__*/React.createElement(Button, {
|
|
587
|
+
"data-cy": "validate-cname-record-button",
|
|
588
|
+
loading: isCnameValidating || isUpdating,
|
|
589
|
+
label: t("neetoMolecules.customDomain.validation.buttonLabel.cnameAdded"),
|
|
590
|
+
onClick: handleUpdateCname
|
|
591
|
+
}), customDomain.status === "pending_cname_validation" && customDomain.addedCnameAt && /*#__PURE__*/React.createElement(CustomDomainInfo, {
|
|
592
|
+
time: customDomain.addedCnameAt
|
|
593
|
+
})))));
|
|
594
|
+
}));
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
var CustomDomain = function CustomDomain(_ref) {
|
|
598
|
+
var _data$customDomains;
|
|
599
|
+
var headerProps = _ref.headerProps;
|
|
600
|
+
var _useState = useState(""),
|
|
601
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
602
|
+
searchTerm = _useState2[0],
|
|
603
|
+
setSearchTerm = _useState2[1];
|
|
604
|
+
var _useState3 = useState(false),
|
|
605
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
606
|
+
isPaneOpen = _useState4[0],
|
|
607
|
+
setIsPaneOpen = _useState4[1];
|
|
608
|
+
var _useState5 = useState(null),
|
|
609
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
610
|
+
customDomain = _useState6[0],
|
|
611
|
+
setCustomDomain = _useState6[1];
|
|
612
|
+
var _useState7 = useState(false),
|
|
613
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
614
|
+
isAlertOpen = _useState8[0],
|
|
615
|
+
setIsAlertOpen = _useState8[1];
|
|
616
|
+
var _useTranslation = useTranslation(),
|
|
617
|
+
t = _useTranslation.t;
|
|
618
|
+
var debouncedSearchTerm = useDebounce(searchTerm, 500);
|
|
619
|
+
var _useFetchCustomDomain = useFetchCustomDomains({
|
|
620
|
+
search: debouncedSearchTerm
|
|
621
|
+
}),
|
|
622
|
+
data = _useFetchCustomDomain.data,
|
|
623
|
+
isLoading = _useFetchCustomDomain.isLoading;
|
|
624
|
+
var _useDeleteCustomDomai = useDeleteCustomDomain({
|
|
625
|
+
onSettled: function onSettled() {
|
|
626
|
+
return setIsAlertOpen(false);
|
|
627
|
+
}
|
|
628
|
+
}),
|
|
629
|
+
deleteCustomDomain = _useDeleteCustomDomai.mutate,
|
|
630
|
+
isDeleting = _useDeleteCustomDomai.isLoading;
|
|
631
|
+
var enableManagePane = function enableManagePane(customDomain) {
|
|
632
|
+
setCustomDomain(customDomain);
|
|
633
|
+
setIsPaneOpen(true);
|
|
634
|
+
};
|
|
635
|
+
var enableDeleteAlert = function enableDeleteAlert(customDomain) {
|
|
636
|
+
setCustomDomain(customDomain);
|
|
637
|
+
setIsAlertOpen(true);
|
|
638
|
+
};
|
|
639
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Header, _extends({
|
|
640
|
+
actionBlock: /*#__PURE__*/React.createElement(Button, {
|
|
641
|
+
"data-cy": "add-new-custom-domain-button",
|
|
642
|
+
label: t("neetoMolecules.common.actions.addNew", {
|
|
643
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
644
|
+
count: ENTITY_COUNT.singular
|
|
645
|
+
}).toLocaleLowerCase()
|
|
646
|
+
}),
|
|
647
|
+
onClick: function onClick() {
|
|
648
|
+
return enableManagePane(null);
|
|
649
|
+
}
|
|
650
|
+
}),
|
|
651
|
+
searchProps: {
|
|
652
|
+
value: searchTerm,
|
|
653
|
+
onChange: function onChange(e) {
|
|
654
|
+
return setSearchTerm(e.target.value);
|
|
655
|
+
},
|
|
656
|
+
placeholder: t("neetoMolecules.common.search", {
|
|
657
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
658
|
+
count: ENTITY_COUNT.plural
|
|
659
|
+
}).toLocaleLowerCase()
|
|
660
|
+
}),
|
|
661
|
+
"data-cy": "custom-domain-search-field"
|
|
662
|
+
},
|
|
663
|
+
title: t("neetoMolecules.customDomain.customDomain", {
|
|
664
|
+
count: ENTITY_COUNT.plural
|
|
665
|
+
})
|
|
666
|
+
}, headerProps)), isLoading && /*#__PURE__*/React.createElement("div", {
|
|
667
|
+
className: "w-full h-screen"
|
|
668
|
+
}, /*#__PURE__*/React.createElement(PageLoader, null)), !isLoading && (isNotEmpty(data === null || data === void 0 ? void 0 : data.customDomains) ? /*#__PURE__*/React.createElement("div", {
|
|
669
|
+
className: "w-full flex-grow"
|
|
670
|
+
}, /*#__PURE__*/React.createElement(SubHeader, {
|
|
671
|
+
leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
|
|
672
|
+
className: "neeto-ui-gray-800 font-semibold",
|
|
673
|
+
component: "h4"
|
|
674
|
+
}, t("neetoMolecules.customDomain.customDomainWithCount", {
|
|
675
|
+
count: data === null || data === void 0 ? void 0 : (_data$customDomains = data.customDomains) === null || _data$customDomains === void 0 ? void 0 : _data$customDomains.length
|
|
676
|
+
}))
|
|
677
|
+
}), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Table, {
|
|
678
|
+
allowRowClick: false,
|
|
679
|
+
rowData: data === null || data === void 0 ? void 0 : data.customDomains,
|
|
680
|
+
rowSelection: false,
|
|
681
|
+
columnData: renderColumnData(enableManagePane, enableDeleteAlert)
|
|
682
|
+
}))) : /*#__PURE__*/React.createElement("div", {
|
|
683
|
+
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
684
|
+
}, /*#__PURE__*/React.createElement(NoData, {
|
|
685
|
+
primaryButtonProps: {
|
|
686
|
+
label: t("neetoMolecules.common.actions.addNew", {
|
|
687
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
688
|
+
count: ENTITY_COUNT.singular
|
|
689
|
+
}).toLocaleLowerCase()
|
|
690
|
+
}),
|
|
691
|
+
onClick: function onClick() {
|
|
692
|
+
return enableManagePane(null);
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
title: t("neetoMolecules.common.notFound.title", {
|
|
696
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
697
|
+
count: ENTITY_COUNT.plural
|
|
698
|
+
}).toLocaleLowerCase()
|
|
699
|
+
})
|
|
700
|
+
})))), /*#__PURE__*/React.createElement(Manage, {
|
|
701
|
+
customDomain: customDomain,
|
|
702
|
+
isOpen: isPaneOpen,
|
|
703
|
+
setCustomDomain: setCustomDomain,
|
|
704
|
+
onClose: function onClose() {
|
|
705
|
+
return setIsPaneOpen(false);
|
|
706
|
+
}
|
|
707
|
+
}), /*#__PURE__*/React.createElement(Alert, {
|
|
708
|
+
cancelButtonLabel: t("neetoMolecules.common.deleteAlert.no"),
|
|
709
|
+
isOpen: isAlertOpen,
|
|
710
|
+
isSubmitting: isDeleting,
|
|
711
|
+
submitButtonLabel: t("neetoMolecules.common.deleteAlert.yes"),
|
|
712
|
+
message: /*#__PURE__*/React.createElement(Trans, {
|
|
713
|
+
i18nKey: "neetoMolecules.customDomain.alertMessage",
|
|
714
|
+
values: {
|
|
715
|
+
hostname: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname
|
|
716
|
+
}
|
|
717
|
+
}),
|
|
718
|
+
title: t("neetoMolecules.common.deleteAlert.title", {
|
|
719
|
+
entity: t("neetoMolecules.customDomain.customDomain", {
|
|
720
|
+
count: ENTITY_COUNT.singular
|
|
721
|
+
}).toLocaleLowerCase()
|
|
722
|
+
}),
|
|
723
|
+
onClose: function onClose() {
|
|
724
|
+
return setIsAlertOpen(false);
|
|
725
|
+
},
|
|
726
|
+
onSubmit: function onSubmit() {
|
|
727
|
+
return deleteCustomDomain(customDomain === null || customDomain === void 0 ? void 0 : customDomain.id);
|
|
728
|
+
}
|
|
729
|
+
}));
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
export { CustomDomain as default };
|