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