@bigbinary/neeto-custom-domains-frontend 2.0.1 → 2.0.4
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 +10 -0
- package/app/javascript/src/translations/en.json +5 -1
- package/dist/CustomDomain.js +638 -0
- package/dist/CustomDomain.js.map +1 -0
- package/dist/WelcomeScreen.js +4 -5
- package/dist/WelcomeScreen.js.map +1 -1
- package/dist/cjs/CustomDomain.js +659 -0
- package/dist/cjs/CustomDomain.js.map +1 -0
- package/dist/cjs/WelcomeScreen.js +4 -5
- package/dist/cjs/WelcomeScreen.js.map +1 -1
- package/dist/cjs/index.js +31 -578
- package/dist/cjs/index.js.map +1 -1
- package/dist/index.js +30 -537
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/types.d.ts +0 -2
- package/dist/CustomDomainDashboard.js +0 -41
- package/dist/CustomDomainDashboard.js.map +0 -1
- package/dist/cjs/CustomDomainDashboard.js +0 -47
- package/dist/cjs/CustomDomainDashboard.js.map +0 -1
- package/dist/index-6d441e24.js +0 -959
- package/dist/index-6d441e24.js.map +0 -1
- package/dist/index-a5a14202.js +0 -903
- package/dist/index-a5a14202.js.map +0 -1
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
6
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
7
|
+
var Container = require('@bigbinary/neeto-molecules/Container');
|
|
8
|
+
var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
|
|
9
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
+
var reactQuery = require('@tanstack/react-query');
|
|
11
|
+
var useMutationWithInvalidation = require('@bigbinary/neeto-commons-frontend/react-utils/useMutationWithInvalidation');
|
|
12
|
+
var axios = require('axios');
|
|
13
|
+
var Alert = require('@bigbinary/neetoui/Alert');
|
|
14
|
+
var reactI18next = require('react-i18next');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
17
|
+
var general = require('@bigbinary/neeto-commons-frontend/utils/general');
|
|
18
|
+
var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
19
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
20
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
21
|
+
var Tag = require('@bigbinary/neetoui/Tag');
|
|
22
|
+
var Pane = require('@bigbinary/neetoui/Pane');
|
|
23
|
+
var Stepper = require('@bigbinary/neetoui/Stepper');
|
|
24
|
+
var Callout = require('@bigbinary/neetoui/Callout');
|
|
25
|
+
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
26
|
+
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
27
|
+
var FormikForm = require('@bigbinary/neetoui/formik/Form');
|
|
28
|
+
var i18next = require('i18next');
|
|
29
|
+
var Yup = require('yup');
|
|
30
|
+
var Table = require('@bigbinary/neetoui/Table');
|
|
31
|
+
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
32
|
+
var psl = require('psl');
|
|
33
|
+
var CopyToClipboardButton = require('@bigbinary/neeto-molecules/CopyToClipboardButton');
|
|
34
|
+
var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
|
|
35
|
+
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
36
|
+
|
|
37
|
+
function _interopNamespaceDefault(e) {
|
|
38
|
+
var n = Object.create(null);
|
|
39
|
+
if (e) {
|
|
40
|
+
Object.keys(e).forEach(function (k) {
|
|
41
|
+
if (k !== 'default') {
|
|
42
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
43
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return e[k]; }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
n.default = e;
|
|
51
|
+
return Object.freeze(n);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var Yup__namespace = /*#__PURE__*/_interopNamespaceDefault(Yup);
|
|
55
|
+
|
|
56
|
+
var getUrlwithId = function getUrlwithId(url, id) {
|
|
57
|
+
return id ? "".concat(url, "/").concat(id) : url;
|
|
58
|
+
};
|
|
59
|
+
var fetchCustomDomain = function fetchCustomDomain(url) {
|
|
60
|
+
return axios.get(url);
|
|
61
|
+
};
|
|
62
|
+
var updateCustomDomain = function updateCustomDomain(url, id) {
|
|
63
|
+
return axios.patch(getUrlwithId(url, id));
|
|
64
|
+
};
|
|
65
|
+
var createCustomDomain = function createCustomDomain(url, payload) {
|
|
66
|
+
return axios.post(url, payload, {
|
|
67
|
+
showToastr: false
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var deleteCustomDomain = function deleteCustomDomain(url) {
|
|
71
|
+
return axios["delete"](getUrlwithId(url));
|
|
72
|
+
};
|
|
73
|
+
var validateDomain = function validateDomain(url) {
|
|
74
|
+
return axios.patch("".concat(url, "/validate_domain"), undefined, {
|
|
75
|
+
showToastr: false
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
var validateCname = function validateCname(url, id) {
|
|
79
|
+
return axios.patch("".concat(getUrlwithId(url, id), "/validate_cname"));
|
|
80
|
+
};
|
|
81
|
+
var domainsApi = {
|
|
82
|
+
createCustomDomain: createCustomDomain,
|
|
83
|
+
deleteCustomDomain: deleteCustomDomain,
|
|
84
|
+
validateDomain: validateDomain,
|
|
85
|
+
fetchCustomDomain: fetchCustomDomain,
|
|
86
|
+
validateCname: validateCname,
|
|
87
|
+
updateCustomDomain: updateCustomDomain
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var DOMAIN_QUERY_KEY = "custom-domain";
|
|
91
|
+
|
|
92
|
+
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; }
|
|
93
|
+
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(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; }
|
|
94
|
+
var useCreateCustomDomain = function useCreateCustomDomain(url) {
|
|
95
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
96
|
+
return useMutationWithInvalidation(function (payload) {
|
|
97
|
+
return domainsApi.createCustomDomain(url, payload);
|
|
98
|
+
}, _objectSpread({
|
|
99
|
+
keysToInvalidate: [[DOMAIN_QUERY_KEY]]
|
|
100
|
+
}, options));
|
|
101
|
+
};
|
|
102
|
+
var useDeleteCustomDomain = function useDeleteCustomDomain(url) {
|
|
103
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
104
|
+
return useMutationWithInvalidation(function (id) {
|
|
105
|
+
return domainsApi.deleteCustomDomain(url, id);
|
|
106
|
+
}, _objectSpread({
|
|
107
|
+
keysToInvalidate: [[DOMAIN_QUERY_KEY]]
|
|
108
|
+
}, options));
|
|
109
|
+
};
|
|
110
|
+
var useFetchCustomDomain = function useFetchCustomDomain(params) {
|
|
111
|
+
return reactQuery.useQuery({
|
|
112
|
+
queryKey: [DOMAIN_QUERY_KEY, _objectSpread({}, params)],
|
|
113
|
+
queryFn: function queryFn() {
|
|
114
|
+
return domainsApi.fetchCustomDomain(params);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
var useValidateDomain = function useValidateDomain(url) {
|
|
119
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
120
|
+
return useMutationWithInvalidation(function () {
|
|
121
|
+
return domainsApi.validateDomain(url);
|
|
122
|
+
}, _objectSpread({
|
|
123
|
+
keysToInvalidate: [[DOMAIN_QUERY_KEY]]
|
|
124
|
+
}, options));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var DeleteAlert = reactUtils.withT(function (_ref) {
|
|
128
|
+
var t = _ref.t,
|
|
129
|
+
onClose = _ref.onClose,
|
|
130
|
+
onSubmit = _ref.onSubmit,
|
|
131
|
+
isOpen = _ref.isOpen,
|
|
132
|
+
isSubmitting = _ref.isSubmitting,
|
|
133
|
+
hostname = _ref.hostname;
|
|
134
|
+
return /*#__PURE__*/jsxRuntime.jsx(Alert, {
|
|
135
|
+
isOpen: isOpen,
|
|
136
|
+
isSubmitting: isSubmitting,
|
|
137
|
+
onClose: onClose,
|
|
138
|
+
onSubmit: onSubmit,
|
|
139
|
+
cancelButtonLabel: t("neetoCustomDomains.actions.cancel"),
|
|
140
|
+
submitButtonLabel: t("neetoCustomDomains.actions.delete"),
|
|
141
|
+
title: t("neetoCustomDomains.delete"),
|
|
142
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
143
|
+
i18nKey: "neetoCustomDomains.alertMessage",
|
|
144
|
+
values: {
|
|
145
|
+
hostname: hostname
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
var STATUS_TAG_STYLES = {
|
|
152
|
+
active: "success",
|
|
153
|
+
pending: "warning"
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
var Domain = reactUtils.withT(function (_ref) {
|
|
157
|
+
var t = _ref.t,
|
|
158
|
+
isCustomDomainAdded = _ref.isCustomDomainAdded,
|
|
159
|
+
openPane = _ref.openPane,
|
|
160
|
+
customDomain = _ref.customDomain,
|
|
161
|
+
openDeleteAlert = _ref.openDeleteAlert,
|
|
162
|
+
helpDocUrl = _ref.helpDocUrl;
|
|
163
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
164
|
+
className: "neeto-ui-border-gray-300 neeto-ui-rounded w-1/2 space-y-2 space-y-4 border p-6",
|
|
165
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
166
|
+
style: "h2",
|
|
167
|
+
children: t("neetoCustomDomains.connectionTitle")
|
|
168
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
169
|
+
className: "space-y-1",
|
|
170
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
171
|
+
className: "neeto-ui-border-gray-200 neeto-ui-rounded neeto-ui-bg-gray-50 flex items-center justify-between border border p-2",
|
|
172
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
173
|
+
className: "flex items-center space-x-2",
|
|
174
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
175
|
+
style: "body2",
|
|
176
|
+
children: isCustomDomainAdded ? customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname : t("neetoCustomDomains.noDomainConnected")
|
|
177
|
+
}), isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(Tag, {
|
|
178
|
+
"data-cy": "".concat(general.hyphenize(customDomain === null || customDomain === void 0 ? void 0 : customDomain.status), "-tag-container"),
|
|
179
|
+
style: STATUS_TAG_STYLES[customDomain === null || customDomain === void 0 ? void 0 : customDomain.status],
|
|
180
|
+
label: t("neetoCustomDomains.status.domain.".concat(customDomain === null || customDomain === void 0 ? void 0 : customDomain.status))
|
|
181
|
+
})]
|
|
182
|
+
}), isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
|
|
183
|
+
dropdownButtonProps: {
|
|
184
|
+
"data-testid": "nui-dropdown-icon-".concat(customDomain === null || customDomain === void 0 ? void 0 : customDomain.id)
|
|
185
|
+
},
|
|
186
|
+
dropdownProps: {
|
|
187
|
+
position: "bottom-end",
|
|
188
|
+
strategy: "fixed",
|
|
189
|
+
autoWidth: true
|
|
190
|
+
},
|
|
191
|
+
menuItems: [{
|
|
192
|
+
label: t("neetoCustomDomains.actions.edit"),
|
|
193
|
+
onClick: openPane,
|
|
194
|
+
key: "edit-custom-domain-button"
|
|
195
|
+
}, {
|
|
196
|
+
label: t("neetoCustomDomains.actions.delete"),
|
|
197
|
+
onClick: openDeleteAlert,
|
|
198
|
+
key: "delete-custom-domain"
|
|
199
|
+
}]
|
|
200
|
+
})]
|
|
201
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
202
|
+
style: "body3",
|
|
203
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
204
|
+
i18nKey: "neetoCustomDomains.readHelpArticle",
|
|
205
|
+
components: {
|
|
206
|
+
Link: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
207
|
+
href: helpDocUrl,
|
|
208
|
+
rel: "noreferrer",
|
|
209
|
+
style: "link",
|
|
210
|
+
target: "_blank"
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
})]
|
|
215
|
+
}), !isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
216
|
+
label: t("neetoCustomDomains.actions.add", {
|
|
217
|
+
what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
|
|
218
|
+
}),
|
|
219
|
+
onClick: openPane
|
|
220
|
+
})]
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
var HOSTNAME_REGEX = /^(https?:\/\/)?([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}(\/\S*)?$/;
|
|
225
|
+
var INITIAL_VALUES = {
|
|
226
|
+
hostname: ""
|
|
227
|
+
};
|
|
228
|
+
var CURRENT_STEP = {
|
|
229
|
+
notAdded: 0,
|
|
230
|
+
pending: 1,
|
|
231
|
+
active: 2
|
|
232
|
+
};
|
|
233
|
+
var STEPS = [{
|
|
234
|
+
id: 1,
|
|
235
|
+
label: "Add domain"
|
|
236
|
+
}, {
|
|
237
|
+
id: 2,
|
|
238
|
+
label: "Validate domain"
|
|
239
|
+
}];
|
|
240
|
+
|
|
241
|
+
var getCustomDomainValidationSchema = function getCustomDomainValidationSchema() {
|
|
242
|
+
return Yup__namespace.object().shape({
|
|
243
|
+
hostname: Yup__namespace.string().required(i18next.t("neetoCustomDomains.formikValidation.required")).matches(HOSTNAME_REGEX, i18next.t("neetoCustomDomains.formikValidation.valid"))
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
var DomainField = function DomainField(_ref) {
|
|
248
|
+
var customDomain = _ref.customDomain,
|
|
249
|
+
onCreate = _ref.onCreate,
|
|
250
|
+
url = _ref.url,
|
|
251
|
+
onClose = _ref.onClose;
|
|
252
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
253
|
+
t = _useTranslation.t;
|
|
254
|
+
var _useState = react.useState({}),
|
|
255
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
256
|
+
errorData = _useState2[0],
|
|
257
|
+
setErrorData = _useState2[1];
|
|
258
|
+
var _useCreateCustomDomai = useCreateCustomDomain(url, {
|
|
259
|
+
onError: function onError(_ref2) {
|
|
260
|
+
var response = _ref2.response;
|
|
261
|
+
setErrorData(response.data);
|
|
262
|
+
}
|
|
263
|
+
}),
|
|
264
|
+
createCustomDomain = _useCreateCustomDomai.mutate,
|
|
265
|
+
isCreating = _useCreateCustomDomai.isPending;
|
|
266
|
+
var getHostname = function getHostname(url) {
|
|
267
|
+
try {
|
|
268
|
+
var parsedUrl = new URL(url);
|
|
269
|
+
return parsedUrl.hostname;
|
|
270
|
+
} catch (_unused) {
|
|
271
|
+
return url;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var handleSubmit = function handleSubmit(_ref3) {
|
|
275
|
+
var hostname = _ref3.hostname;
|
|
276
|
+
var parsedHostname = getHostname(hostname);
|
|
277
|
+
var payload = {
|
|
278
|
+
hostname: parsedHostname
|
|
279
|
+
};
|
|
280
|
+
createCustomDomain(payload, {
|
|
281
|
+
onSuccess: function onSuccess(values) {
|
|
282
|
+
onCreate === null || onCreate === void 0 ? void 0 : onCreate(values);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
return /*#__PURE__*/jsxRuntime.jsx(FormikForm, {
|
|
287
|
+
className: "flex-col space-y-6",
|
|
288
|
+
formikProps: {
|
|
289
|
+
enableReinitialize: true,
|
|
290
|
+
initialValues: customDomain || INITIAL_VALUES,
|
|
291
|
+
validationSchema: getCustomDomainValidationSchema(),
|
|
292
|
+
onSubmit: handleSubmit
|
|
293
|
+
},
|
|
294
|
+
children: function children(_ref4) {
|
|
295
|
+
var dirty = _ref4.dirty;
|
|
296
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
297
|
+
className: "w-full",
|
|
298
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane.Body, {
|
|
299
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
300
|
+
className: "w-full space-y-4",
|
|
301
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
302
|
+
required: true,
|
|
303
|
+
className: "w-full",
|
|
304
|
+
"data-cy": "custom-domain-input-field",
|
|
305
|
+
disabled: neetoCist.isNotEmpty(customDomain),
|
|
306
|
+
label: t("neetoCustomDomains.label"),
|
|
307
|
+
name: "hostname",
|
|
308
|
+
placeholder: t("neetoCustomDomains.placeholder")
|
|
309
|
+
}), (errorData === null || errorData === void 0 ? void 0 : errorData.key) && /*#__PURE__*/jsxRuntime.jsx(Callout, {
|
|
310
|
+
style: "warning",
|
|
311
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
312
|
+
style: "body2",
|
|
313
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
314
|
+
i18nKey: errorData === null || errorData === void 0 ? void 0 : errorData.key,
|
|
315
|
+
components: {
|
|
316
|
+
Link: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
317
|
+
href: errorData === null || errorData === void 0 ? void 0 : errorData.pageUrl,
|
|
318
|
+
rel: "noreferrer",
|
|
319
|
+
style: "link",
|
|
320
|
+
target: "_blank"
|
|
321
|
+
})
|
|
322
|
+
},
|
|
323
|
+
values: {
|
|
324
|
+
hostname: errorData === null || errorData === void 0 ? void 0 : errorData.hostname,
|
|
325
|
+
workspace: errorData === null || errorData === void 0 ? void 0 : errorData.workspace
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
})
|
|
329
|
+
})]
|
|
330
|
+
})
|
|
331
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
|
|
332
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
|
|
333
|
+
cancelButtonProps: {
|
|
334
|
+
onClick: onClose
|
|
335
|
+
},
|
|
336
|
+
isSubmitting: isCreating,
|
|
337
|
+
submitButtonProps: {
|
|
338
|
+
label: t("neetoCustomDomains.actions.continue"),
|
|
339
|
+
"data-cy": "submit-custom-domain-button",
|
|
340
|
+
"data-testid": "submit-custom-domain-button",
|
|
341
|
+
disabled: !dirty || isCreating
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
})]
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
var columnData = function columnData() {
|
|
351
|
+
return [{
|
|
352
|
+
title: i18next.t("neetoCustomDomains.common.record"),
|
|
353
|
+
key: "record",
|
|
354
|
+
dataIndex: "record",
|
|
355
|
+
width: "18%",
|
|
356
|
+
render: function render() {
|
|
357
|
+
return /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
358
|
+
style: "body2",
|
|
359
|
+
children: i18next.t("neetoCustomDomains.cname")
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
title: i18next.t("neetoCustomDomains.common.name"),
|
|
364
|
+
dataIndex: "name",
|
|
365
|
+
width: "35%",
|
|
366
|
+
key: "name",
|
|
367
|
+
render: function render(name, _) {
|
|
368
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
369
|
+
className: "flex items-center justify-between gap-1",
|
|
370
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
371
|
+
className: "min-w-0 truncate",
|
|
372
|
+
style: "body2",
|
|
373
|
+
children: name
|
|
374
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton, {
|
|
375
|
+
className: "flex-shrink-0",
|
|
376
|
+
size: "small",
|
|
377
|
+
style: "secondary",
|
|
378
|
+
value: name
|
|
379
|
+
})]
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}, {
|
|
383
|
+
title: i18next.t("neetoCustomDomains.common.value"),
|
|
384
|
+
dataIndex: "value",
|
|
385
|
+
width: "35%",
|
|
386
|
+
key: "value",
|
|
387
|
+
render: function render(value, _) {
|
|
388
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
389
|
+
className: "flex items-center justify-between gap-1",
|
|
390
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
391
|
+
className: "min-w-0 truncate",
|
|
392
|
+
style: "body2",
|
|
393
|
+
children: neetoCist.truncate(value, 20)
|
|
394
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton, {
|
|
395
|
+
value: value,
|
|
396
|
+
className: "flex-shrink-0",
|
|
397
|
+
size: "small",
|
|
398
|
+
style: "secondary"
|
|
399
|
+
})]
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}];
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
var Validation = function Validation(_ref) {
|
|
406
|
+
var customDomain = _ref.customDomain,
|
|
407
|
+
onClose = _ref.onClose,
|
|
408
|
+
url = _ref.url,
|
|
409
|
+
helpDocUrl = _ref.helpDocUrl;
|
|
410
|
+
var hostname = customDomain.hostname,
|
|
411
|
+
dnsTarget = customDomain.dnsTarget,
|
|
412
|
+
status = customDomain.status;
|
|
413
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
414
|
+
t = _useTranslation.t;
|
|
415
|
+
var isDomainValidated = status === "active";
|
|
416
|
+
var _useState = react.useState(""),
|
|
417
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
418
|
+
errorKey = _useState2[0],
|
|
419
|
+
setErrorKey = _useState2[1];
|
|
420
|
+
var _useValidateDomain = useValidateDomain(url, {
|
|
421
|
+
onError: function onError(_ref2) {
|
|
422
|
+
var response = _ref2.response;
|
|
423
|
+
setErrorKey(response.data.error);
|
|
424
|
+
},
|
|
425
|
+
onSuccess: function onSuccess() {
|
|
426
|
+
Toastr.success(t("neetoCustomDomains.validation.successMessage"));
|
|
427
|
+
onClose();
|
|
428
|
+
}
|
|
429
|
+
}),
|
|
430
|
+
validateDomain = _useValidateDomain.mutate,
|
|
431
|
+
isValidating = _useValidateDomain.isPending;
|
|
432
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
433
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Pane.Body, {
|
|
434
|
+
className: "space-y-4",
|
|
435
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
436
|
+
className: "space-y-2",
|
|
437
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
438
|
+
style: "h4",
|
|
439
|
+
weight: "medium",
|
|
440
|
+
children: t("neetoCustomDomains.cnameRecordTitle")
|
|
441
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
442
|
+
style: "body2",
|
|
443
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
444
|
+
i18nKey: "neetoCustomDomains.cnameRecordInfo",
|
|
445
|
+
components: {
|
|
446
|
+
Link: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
447
|
+
href: helpDocUrl,
|
|
448
|
+
rel: "noreferrer",
|
|
449
|
+
style: "link",
|
|
450
|
+
target: "_blank"
|
|
451
|
+
})
|
|
452
|
+
},
|
|
453
|
+
values: {
|
|
454
|
+
proxyMessage: t("neetoCustomDomains.proxyMessage")
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
})]
|
|
458
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Table, {
|
|
459
|
+
allowRowClick: false,
|
|
460
|
+
columnData: columnData(),
|
|
461
|
+
rowSelection: false,
|
|
462
|
+
rowData: [{
|
|
463
|
+
name: psl.parse(hostname).subdomain || hostname,
|
|
464
|
+
value: dnsTarget
|
|
465
|
+
}]
|
|
466
|
+
}), neetoCist.isNotEmpty(errorKey) && /*#__PURE__*/jsxRuntime.jsx(Callout, {
|
|
467
|
+
style: STATUS_TAG_STYLES[status],
|
|
468
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
469
|
+
style: "body2",
|
|
470
|
+
children: t(errorKey)
|
|
471
|
+
})
|
|
472
|
+
})]
|
|
473
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
|
|
474
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
475
|
+
className: "flex items-center gap-2",
|
|
476
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
477
|
+
"data-cy": "validate-domain-button",
|
|
478
|
+
disabled: isValidating || isDomainValidated,
|
|
479
|
+
label: t("neetoCustomDomains.validation.buttonLabel.domain"),
|
|
480
|
+
loading: isValidating,
|
|
481
|
+
onClick: validateDomain
|
|
482
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
483
|
+
label: t("neetoCustomDomains.actions.cancel"),
|
|
484
|
+
style: "text",
|
|
485
|
+
onClick: onClose
|
|
486
|
+
})]
|
|
487
|
+
})
|
|
488
|
+
})]
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
var DomainPane = function DomainPane(_ref) {
|
|
493
|
+
var customDomain = _ref.customDomain,
|
|
494
|
+
isOpen = _ref.isOpen,
|
|
495
|
+
onClose = _ref.onClose,
|
|
496
|
+
onCreate = _ref.onCreate,
|
|
497
|
+
url = _ref.url,
|
|
498
|
+
isCustomDomainAdded = _ref.isCustomDomainAdded,
|
|
499
|
+
helpDocUrl = _ref.helpDocUrl;
|
|
500
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
501
|
+
t = _useTranslation.t;
|
|
502
|
+
var _customDomain$status = customDomain.status,
|
|
503
|
+
status = _customDomain$status === void 0 ? "notAdded" : _customDomain$status;
|
|
504
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane, {
|
|
505
|
+
isOpen: isOpen,
|
|
506
|
+
onClose: onClose,
|
|
507
|
+
size: "large",
|
|
508
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Pane.Header, {
|
|
509
|
+
className: "space-y-2",
|
|
510
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
511
|
+
style: "h2",
|
|
512
|
+
children: t("neetoCustomDomains.addNew")
|
|
513
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
514
|
+
className: "-ml-2",
|
|
515
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Stepper, {
|
|
516
|
+
activeIndex: CURRENT_STEP[status],
|
|
517
|
+
setActiveIndex: neetoCist.noop,
|
|
518
|
+
steps: STEPS
|
|
519
|
+
})
|
|
520
|
+
})]
|
|
521
|
+
}), isCustomDomainAdded ? /*#__PURE__*/jsxRuntime.jsx(Validation, {
|
|
522
|
+
customDomain: customDomain,
|
|
523
|
+
helpDocUrl: helpDocUrl,
|
|
524
|
+
onClose: onClose,
|
|
525
|
+
url: url
|
|
526
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(DomainField, {
|
|
527
|
+
customDomain: customDomain,
|
|
528
|
+
onClose: onClose,
|
|
529
|
+
onCreate: onCreate,
|
|
530
|
+
url: url
|
|
531
|
+
})]
|
|
532
|
+
});
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
var Header = function Header(_ref) {
|
|
536
|
+
var openPane = _ref.openPane,
|
|
537
|
+
breadcrumbs = _ref.breadcrumbs,
|
|
538
|
+
isCustomDomainAdded = _ref.isCustomDomainAdded,
|
|
539
|
+
helpDocUrl = _ref.helpDocUrl,
|
|
540
|
+
_ref$size = _ref.size,
|
|
541
|
+
size = _ref$size === void 0 ? "large" : _ref$size;
|
|
542
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
543
|
+
t = _useTranslation.t;
|
|
544
|
+
var title = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
545
|
+
className: "flex items-center gap-x-2",
|
|
546
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
547
|
+
style: "h2",
|
|
548
|
+
children: t("neetoCustomDomains.customDomain", constants.SINGULAR)
|
|
549
|
+
}), /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
|
|
550
|
+
description: t("neetoCustomDomains.toolTips.customDomain"),
|
|
551
|
+
helpLinkProps: {
|
|
552
|
+
href: helpDocUrl
|
|
553
|
+
},
|
|
554
|
+
popoverProps: {
|
|
555
|
+
position: "top"
|
|
556
|
+
},
|
|
557
|
+
title: t("neetoCustomDomains.customDomain", constants.SINGULAR)
|
|
558
|
+
})]
|
|
559
|
+
});
|
|
560
|
+
return /*#__PURE__*/jsxRuntime.jsx(NeetoHeader, {
|
|
561
|
+
breadcrumbs: breadcrumbs,
|
|
562
|
+
size: size,
|
|
563
|
+
title: title,
|
|
564
|
+
"data-testid": "custom-domain-header",
|
|
565
|
+
actionBlock: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
566
|
+
"data-cy": "add-new-custom-domain-button",
|
|
567
|
+
disabled: isCustomDomainAdded,
|
|
568
|
+
label: t("neetoCustomDomains.actions.add", {
|
|
569
|
+
what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
|
|
570
|
+
}),
|
|
571
|
+
onClick: openPane
|
|
572
|
+
})
|
|
573
|
+
});
|
|
574
|
+
};
|
|
575
|
+
var Header$1 = /*#__PURE__*/react.memo(Header);
|
|
576
|
+
|
|
577
|
+
var CustomDomain = function CustomDomain(_ref) {
|
|
578
|
+
var breadcrumbs = _ref.breadcrumbs,
|
|
579
|
+
url = _ref.url,
|
|
580
|
+
onCreate = _ref.onCreate,
|
|
581
|
+
helpDocUrl = _ref.helpDocUrl,
|
|
582
|
+
headerSize = _ref.headerSize;
|
|
583
|
+
var _useQueryParams = reactUtils.useQueryParams(),
|
|
584
|
+
pane = _useQueryParams.pane;
|
|
585
|
+
var _useState = react.useState(pane === "open"),
|
|
586
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
587
|
+
isPaneOpen = _useState2[0],
|
|
588
|
+
setIsPaneOpen = _useState2[1];
|
|
589
|
+
var _useState3 = react.useState(false),
|
|
590
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
591
|
+
isAlertOpen = _useState4[0],
|
|
592
|
+
setIsAlertOpen = _useState4[1];
|
|
593
|
+
var _useFetchCustomDomain = useFetchCustomDomain(url),
|
|
594
|
+
_useFetchCustomDomain2 = _useFetchCustomDomain.data,
|
|
595
|
+
customDomain = _useFetchCustomDomain2 === void 0 ? {} : _useFetchCustomDomain2,
|
|
596
|
+
isLoading = _useFetchCustomDomain.isLoading;
|
|
597
|
+
var _useDeleteCustomDomai = useDeleteCustomDomain(url, {
|
|
598
|
+
onSettled: function onSettled() {
|
|
599
|
+
setIsAlertOpen(false);
|
|
600
|
+
}
|
|
601
|
+
}),
|
|
602
|
+
deleteCustomDomain = _useDeleteCustomDomai.mutate,
|
|
603
|
+
isDeleting = _useDeleteCustomDomai.isPending;
|
|
604
|
+
var openPane = function openPane() {
|
|
605
|
+
return setIsPaneOpen(true);
|
|
606
|
+
};
|
|
607
|
+
var closePane = function closePane() {
|
|
608
|
+
return setIsPaneOpen(false);
|
|
609
|
+
};
|
|
610
|
+
var openDeleteAlert = function openDeleteAlert() {
|
|
611
|
+
return setIsAlertOpen(true);
|
|
612
|
+
};
|
|
613
|
+
var isCustomDomainAdded = neetoCist.isNotEmpty(customDomain);
|
|
614
|
+
if (isLoading) {
|
|
615
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
616
|
+
className: "h-screen w-full",
|
|
617
|
+
children: /*#__PURE__*/jsxRuntime.jsx(PageLoader, {})
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
621
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Container, {
|
|
622
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header$1, {
|
|
623
|
+
breadcrumbs: breadcrumbs,
|
|
624
|
+
helpDocUrl: helpDocUrl,
|
|
625
|
+
isCustomDomainAdded: isCustomDomainAdded,
|
|
626
|
+
openPane: openPane,
|
|
627
|
+
size: headerSize
|
|
628
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
629
|
+
className: "mt-10 flex w-full justify-center",
|
|
630
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Domain, {
|
|
631
|
+
customDomain: customDomain,
|
|
632
|
+
helpDocUrl: helpDocUrl,
|
|
633
|
+
isCustomDomainAdded: isCustomDomainAdded,
|
|
634
|
+
openDeleteAlert: openDeleteAlert,
|
|
635
|
+
openPane: openPane
|
|
636
|
+
})
|
|
637
|
+
})]
|
|
638
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DomainPane, {
|
|
639
|
+
customDomain: customDomain,
|
|
640
|
+
helpDocUrl: helpDocUrl,
|
|
641
|
+
isCustomDomainAdded: isCustomDomainAdded,
|
|
642
|
+
onCreate: onCreate,
|
|
643
|
+
url: url,
|
|
644
|
+
isOpen: isPaneOpen,
|
|
645
|
+
onClose: closePane
|
|
646
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DeleteAlert, {
|
|
647
|
+
hostname: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname,
|
|
648
|
+
isOpen: isAlertOpen,
|
|
649
|
+
isSubmitting: isDeleting,
|
|
650
|
+
onClose: function onClose() {
|
|
651
|
+
return setIsAlertOpen(false);
|
|
652
|
+
},
|
|
653
|
+
onSubmit: deleteCustomDomain
|
|
654
|
+
})]
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
module.exports = CustomDomain;
|
|
659
|
+
//# sourceMappingURL=CustomDomain.js.map
|