@bigbinary/neeto-redirect-urls-frontend 3.0.4 → 3.0.5
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 +0 -2
- package/dist/.ready +1 -0
- package/dist/RedirectUrls.js +8 -125
- package/dist/RedirectUrls.js.map +1 -1
- package/dist/cjs/RedirectUrls.js +21 -138
- package/dist/cjs/RedirectUrls.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v2/RedirectUrls.js +632 -0
- package/dist/cjs/v2/RedirectUrls.js.map +1 -0
- package/dist/cjs/v2/index.js +34 -0
- package/dist/cjs/v2/index.js.map +1 -0
- package/dist/helpUrls-3axmPbOb.js +86 -0
- package/dist/helpUrls-3axmPbOb.js.map +1 -0
- package/dist/helpUrls-C3F0oNrV.js +77 -0
- package/dist/helpUrls-C3F0oNrV.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/v2/RedirectUrls.js +611 -0
- package/dist/v2/RedirectUrls.js.map +1 -0
- package/dist/v2/index.js +28 -0
- package/dist/v2/index.js.map +1 -0
- package/package.json +41 -32
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var neetoAtoms = require('@bigbinary/neeto-atoms');
|
|
7
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
8
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
|
|
9
|
+
var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
|
|
10
|
+
var Container = require('@bigbinary/neeto-molecules/v2/Container');
|
|
11
|
+
var Header = require('@bigbinary/neeto-molecules/v2/Header');
|
|
12
|
+
var ramda = require('ramda');
|
|
13
|
+
var reactI18next = require('react-i18next');
|
|
14
|
+
var helpUrls = require('../../helpUrls-3axmPbOb.js');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
var formik = require('@bigbinary/neeto-atoms/formik');
|
|
17
|
+
var i18next = require('i18next');
|
|
18
|
+
var constants = require('@bigbinary/neeto-commons-frontend/v2/constants');
|
|
19
|
+
var yup = require('yup');
|
|
20
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
21
|
+
var Edit = require('@bigbinary/neeto-icons/Edit');
|
|
22
|
+
var CardLayout = require('@bigbinary/neeto-molecules/v2/CardLayout');
|
|
23
|
+
var InlineInput = require('@bigbinary/neeto-molecules/v2/InlineInput');
|
|
24
|
+
var MoreDropdown = require('@bigbinary/neeto-molecules/v2/MoreDropdown');
|
|
25
|
+
var TableWrapper = require('@bigbinary/neeto-molecules/v2/TableWrapper');
|
|
26
|
+
require('@tanstack/react-query');
|
|
27
|
+
require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
28
|
+
require('axios');
|
|
29
|
+
|
|
30
|
+
function _interopNamespaceDefault(e) {
|
|
31
|
+
var n = Object.create(null);
|
|
32
|
+
if (e) {
|
|
33
|
+
Object.keys(e).forEach(function (k) {
|
|
34
|
+
if (k !== 'default') {
|
|
35
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
36
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return e[k]; }
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
n.default = e;
|
|
44
|
+
return Object.freeze(n);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
|
|
48
|
+
|
|
49
|
+
var DeleteRedirectUrlModal = function DeleteRedirectUrlModal(_ref) {
|
|
50
|
+
var handleClose = _ref.handleClose,
|
|
51
|
+
handleSubmit = _ref.handleSubmit,
|
|
52
|
+
detailsToDelete = _ref.detailsToDelete,
|
|
53
|
+
isOpen = _ref.isOpen;
|
|
54
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
55
|
+
t = _useTranslation.t;
|
|
56
|
+
if (detailsToDelete === null) return null;
|
|
57
|
+
var id = detailsToDelete.id,
|
|
58
|
+
toPath = detailsToDelete.toPath,
|
|
59
|
+
fromPath = detailsToDelete.fromPath;
|
|
60
|
+
var title = t("neetoRedirectUrls.alerts.delete.title");
|
|
61
|
+
return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Alert, {
|
|
62
|
+
isOpen: isOpen,
|
|
63
|
+
title: title,
|
|
64
|
+
submitButtonLabel: t("neetoRedirectUrls.common.delete"),
|
|
65
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
66
|
+
i18nKey: "neetoRedirectUrls.alerts.delete.confirm",
|
|
67
|
+
values: {
|
|
68
|
+
from_path: fromPath,
|
|
69
|
+
to_path: toPath
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
onClose: handleClose,
|
|
73
|
+
onSubmit: function onSubmit() {
|
|
74
|
+
return handleSubmit(id);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
var SETTINGS_CATEGORIES = {
|
|
80
|
+
GENERAL: "GENERAL"
|
|
81
|
+
};
|
|
82
|
+
var SETTINGS_CATEGORIES_LABELS = _defineProperty({}, SETTINGS_CATEGORIES.GENERAL, i18next.t("neetoRedirectUrls.settings.general.title"));
|
|
83
|
+
var SHOW_TOASTR_CONFIG = {
|
|
84
|
+
showToastr: false
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
var buildSettingsBreadcrumbs = function buildSettingsBreadcrumbs(category, pageTitle) {
|
|
88
|
+
return [{
|
|
89
|
+
link: helpUrls.routes.admin.adminPanel,
|
|
90
|
+
text: i18next.t("neetoRedirectUrls.settings.title")
|
|
91
|
+
}, {
|
|
92
|
+
link: utils.buildUrl(helpUrls.routes.admin.adminPanel, {
|
|
93
|
+
category: category.toLowerCase()
|
|
94
|
+
}),
|
|
95
|
+
text: SETTINGS_CATEGORIES_LABELS[category]
|
|
96
|
+
}].concat(_toConsumableArray(pageTitle ? [{
|
|
97
|
+
text: pageTitle
|
|
98
|
+
}] : []));
|
|
99
|
+
};
|
|
100
|
+
var normalizeURL = function normalizeURL(url) {
|
|
101
|
+
return url ? url.replace(/\/+$/, "") : "";
|
|
102
|
+
};
|
|
103
|
+
var handleError = function handleError(setStatus, error) {
|
|
104
|
+
var response = error.response;
|
|
105
|
+
if (response && response.data && response.data.errors) {
|
|
106
|
+
setStatus(response.data.errors);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var isReservedPath = function isReservedPath(url) {
|
|
110
|
+
var _window$globalProps$o;
|
|
111
|
+
if (!url) return false;
|
|
112
|
+
var domainUrls = ((_window$globalProps$o = window.globalProps.organization) === null || _window$globalProps$o === void 0 || (_window$globalProps$o = _window$globalProps$o.domainUrls) === null || _window$globalProps$o === void 0 ? void 0 : _window$globalProps$o.map(normalizeURL)) || [];
|
|
113
|
+
return domainUrls.some(function (domainUrl) {
|
|
114
|
+
return constants.RESERVED_PATHS.some(function (reservedPath) {
|
|
115
|
+
return normalizeURL(url) === normalizeURL("".concat(domainUrl, "/").concat(reservedPath));
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var REDIRECT_URL_VALIDATION_SCHEMA = yup__namespace.object().shape({
|
|
121
|
+
fromPath: yup__namespace.string().required(i18next.t("neetoRedirectUrls.redirect.validations.required", {
|
|
122
|
+
entity: "Source"
|
|
123
|
+
})).matches(helpUrls.URL_PATHNAME_REGEX, i18next.t("neetoRedirectUrls.redirect.validations.source")),
|
|
124
|
+
toPath: yup__namespace.string().required(i18next.t("neetoRedirectUrls.redirect.validations.required", {
|
|
125
|
+
entity: "Destination"
|
|
126
|
+
})).matches(new RegExp("".concat(constants.VALID_URL_REGEX.source, "|").concat(helpUrls.URL_PATHNAME_REGEX.source)), i18next.t("neetoRedirectUrls.redirect.validations.destination")).test("paths-not-same", i18next.t("neetoRedirectUrls.redirect.validations.samePaths"), function (value, context) {
|
|
127
|
+
var fromPath = context.parent.fromPath;
|
|
128
|
+
if (!value || !fromPath) return true;
|
|
129
|
+
return value !== fromPath;
|
|
130
|
+
}).test("reserved-path", i18next.t("neetoRedirectUrls.redirect.validations.reservedPath"), function (value) {
|
|
131
|
+
return !isReservedPath(value);
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
136
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
137
|
+
var RedirectUrlPane = function RedirectUrlPane(_ref) {
|
|
138
|
+
var handleClose = _ref.handleClose,
|
|
139
|
+
handleSubmit = _ref.handleSubmit,
|
|
140
|
+
_ref$initialValues = _ref.initialValues,
|
|
141
|
+
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
142
|
+
_ref$setInitialFocusF = _ref.setInitialFocusField,
|
|
143
|
+
setInitialFocusField = _ref$setInitialFocusF === void 0 ? neetoCist.noop : _ref$setInitialFocusF;
|
|
144
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
145
|
+
t = _useTranslation.t;
|
|
146
|
+
var redirectUrlId = initialValues === null || initialValues === void 0 ? void 0 : initialValues.id;
|
|
147
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
148
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Header, {
|
|
149
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Title, {
|
|
150
|
+
children: redirectUrlId ? t("neetoRedirectUrls.redirect.edit") : t("neetoRedirectUrls.redirect.add")
|
|
151
|
+
})
|
|
152
|
+
}), /*#__PURE__*/jsxRuntime.jsx(formik.Form, {
|
|
153
|
+
formikProps: {
|
|
154
|
+
initialValues: initialValues || {
|
|
155
|
+
fromPath: "",
|
|
156
|
+
toPath: ""
|
|
157
|
+
},
|
|
158
|
+
validationSchema: REDIRECT_URL_VALIDATION_SCHEMA,
|
|
159
|
+
onSubmit: function onSubmit(values, formikBag) {
|
|
160
|
+
handleSubmit(_objectSpread$1({}, values), formikBag);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
164
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Body, {
|
|
165
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
166
|
+
className: "w-full space-y-4",
|
|
167
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(formik.Input, {
|
|
168
|
+
required: true,
|
|
169
|
+
id: "fromPath",
|
|
170
|
+
label: t("neetoRedirectUrls.redirect.source"),
|
|
171
|
+
name: "fromPath",
|
|
172
|
+
ref: setInitialFocusField,
|
|
173
|
+
placeholder: t("neetoRedirectUrls.common.placeholder.relativeUrl")
|
|
174
|
+
}), /*#__PURE__*/jsxRuntime.jsx(formik.Input, {
|
|
175
|
+
required: true,
|
|
176
|
+
id: "toPath",
|
|
177
|
+
label: t("neetoRedirectUrls.redirect.destination"),
|
|
178
|
+
name: "toPath",
|
|
179
|
+
placeholder: window.location.origin
|
|
180
|
+
})]
|
|
181
|
+
})
|
|
182
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Footer, {
|
|
183
|
+
children: /*#__PURE__*/jsxRuntime.jsx(formik.ActionBlock, {
|
|
184
|
+
cancelButtonProps: {
|
|
185
|
+
onClick: handleClose
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
})]
|
|
189
|
+
})
|
|
190
|
+
})]
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
var DOMAIN_REDIRECTION_VALIDATION_SCHEMA = yup__namespace.object().shape({
|
|
195
|
+
toPath: yup__namespace.string().nullable().when("domainRedirectionActive", {
|
|
196
|
+
is: true,
|
|
197
|
+
then: yup__namespace.string().required(i18next.t("neetoRedirectUrls.redirect.validations.required", {
|
|
198
|
+
entity: "Destination"
|
|
199
|
+
})).matches(constants.VALID_URL_REGEX, i18next.t("neetoRedirectUrls.redirect.validations.destination")).test("not-duplicate-domain", i18next.t("neetoRedirectUrls.redirect.validations.duplicateDomain"), function (value) {
|
|
200
|
+
var _window$globalProps$o;
|
|
201
|
+
if (!value) return true;
|
|
202
|
+
var domainUrls = ((_window$globalProps$o = window.globalProps.organization) === null || _window$globalProps$o === void 0 || (_window$globalProps$o = _window$globalProps$o.domainUrls) === null || _window$globalProps$o === void 0 ? void 0 : _window$globalProps$o.map(normalizeURL)) || [];
|
|
203
|
+
return !domainUrls.includes(normalizeURL(value));
|
|
204
|
+
}).test("reserved-path", i18next.t("neetoRedirectUrls.redirect.validations.reservedPath"), function (value) {
|
|
205
|
+
return !isReservedPath(value);
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
var DomainRedirection = function DomainRedirection(_ref) {
|
|
211
|
+
var domainRedirectUrl = _ref.domainRedirectUrl,
|
|
212
|
+
entity = _ref.entity,
|
|
213
|
+
helpDocUrls = _ref.helpDocUrls;
|
|
214
|
+
var _useState = react.useState(true),
|
|
215
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
216
|
+
isEditingDomainRedirect = _useState2[0],
|
|
217
|
+
setIsEditingDomainRedirect = _useState2[1];
|
|
218
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
219
|
+
t = _useTranslation.t;
|
|
220
|
+
var _useCreateRedirectUrl = helpUrls.useCreateRedirectUrl(),
|
|
221
|
+
createLink = _useCreateRedirectUrl.mutateAsync;
|
|
222
|
+
var _useUpdateRedirectUrl = helpUrls.useUpdateRedirectUrl(),
|
|
223
|
+
updateLink = _useUpdateRedirectUrl.mutateAsync;
|
|
224
|
+
var _useDestroyRedirectUr = helpUrls.useDestroyRedirectUrl(),
|
|
225
|
+
destroyLink = _useDestroyRedirectUr.mutate;
|
|
226
|
+
var initialValues = {
|
|
227
|
+
domainRedirectionActive: neetoCist.isPresent(domainRedirectUrl === null || domainRedirectUrl === void 0 ? void 0 : domainRedirectUrl.toPath),
|
|
228
|
+
toPath: domainRedirectUrl === null || domainRedirectUrl === void 0 ? void 0 : domainRedirectUrl.toPath
|
|
229
|
+
};
|
|
230
|
+
var handleSubmit = function handleSubmit(values) {
|
|
231
|
+
var payload = {
|
|
232
|
+
toPath: values.toPath,
|
|
233
|
+
redirection_type: "domain"
|
|
234
|
+
};
|
|
235
|
+
return domainRedirectUrl ? updateLink({
|
|
236
|
+
id: domainRedirectUrl.id,
|
|
237
|
+
payload: payload
|
|
238
|
+
}) : createLink({
|
|
239
|
+
payload: payload
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
var handleRemoveRedirection = function handleRemoveRedirection(domainLinkActive) {
|
|
243
|
+
if (!(domainLinkActive && domainRedirectUrl)) {
|
|
244
|
+
setIsEditingDomainRedirect(true);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
destroyLink(domainRedirectUrl.id);
|
|
248
|
+
};
|
|
249
|
+
react.useEffect(function () {
|
|
250
|
+
if (neetoCist.isPresent(domainRedirectUrl === null || domainRedirectUrl === void 0 ? void 0 : domainRedirectUrl.toPath)) {
|
|
251
|
+
setIsEditingDomainRedirect(false);
|
|
252
|
+
}
|
|
253
|
+
}, [domainRedirectUrl]);
|
|
254
|
+
return /*#__PURE__*/jsxRuntime.jsx(formik.Form, {
|
|
255
|
+
className: "mb-6 w-full",
|
|
256
|
+
formikProps: {
|
|
257
|
+
initialValues: initialValues,
|
|
258
|
+
validationSchema: DOMAIN_REDIRECTION_VALIDATION_SCHEMA,
|
|
259
|
+
enableReinitialize: true,
|
|
260
|
+
onSubmit: handleSubmit
|
|
261
|
+
},
|
|
262
|
+
children: function children(_ref2) {
|
|
263
|
+
var domainRedirectionActive = _ref2.values.domainRedirectionActive,
|
|
264
|
+
dirty = _ref2.dirty;
|
|
265
|
+
return /*#__PURE__*/jsxRuntime.jsxs(CardLayout, {
|
|
266
|
+
containerClassName: "ms-0",
|
|
267
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
268
|
+
className: "flex items-center justify-between",
|
|
269
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
270
|
+
className: "flex flex-col space-y-2",
|
|
271
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Label, {
|
|
272
|
+
className: "flex items-center gap-2",
|
|
273
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(formik.Switch, {
|
|
274
|
+
"data-testid": "domain-level-redirection-switch",
|
|
275
|
+
name: "domainRedirectionActive",
|
|
276
|
+
onClick: function onClick() {
|
|
277
|
+
return handleRemoveRedirection(domainRedirectionActive);
|
|
278
|
+
}
|
|
279
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
280
|
+
"data-testid": "domain-level-redirection-heading",
|
|
281
|
+
variant: "h5",
|
|
282
|
+
weight: "medium",
|
|
283
|
+
children: t("neetoRedirectUrls.redirect.domainLevelRedirect.label")
|
|
284
|
+
})]
|
|
285
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
286
|
+
variant: "body2",
|
|
287
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
288
|
+
i18nKey: "neetoRedirectUrls.redirect.domainLevelRedirect.description",
|
|
289
|
+
values: {
|
|
290
|
+
entity: entity,
|
|
291
|
+
app: window.globalProps.appName
|
|
292
|
+
},
|
|
293
|
+
components: {
|
|
294
|
+
Link: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
295
|
+
className: "text-sm",
|
|
296
|
+
"data-testid": "domain-level-redirections-help-button",
|
|
297
|
+
target: "_blank",
|
|
298
|
+
variant: "link",
|
|
299
|
+
href: helpDocUrls.domainLevelRedirectUrl || helpUrls.DOMAIN_LEVEL_REDIRECT_HELP_DOC_URL
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
})]
|
|
304
|
+
})
|
|
305
|
+
}), domainRedirectionActive && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
306
|
+
className: "mt-2 flex w-1/2 items-start space-x-3",
|
|
307
|
+
children: isEditingDomainRedirect ? /*#__PURE__*/jsxRuntime.jsx(InlineInput.FormikInlineInput, {
|
|
308
|
+
"data-testid": "domain-level-redirection-link-text-field",
|
|
309
|
+
handleCancel: function handleCancel() {
|
|
310
|
+
return dirty;
|
|
311
|
+
},
|
|
312
|
+
name: "toPath",
|
|
313
|
+
placeholder: t("neetoRedirectUrls.common.placeholder.url"),
|
|
314
|
+
cancelButtonProps: {
|
|
315
|
+
disabled: !dirty,
|
|
316
|
+
"data-testid": "domain-level-redirection-link-cancel-button"
|
|
317
|
+
},
|
|
318
|
+
submitButtonProps: {
|
|
319
|
+
"data-testid": "domain-level-redirection-link-submit-button"
|
|
320
|
+
}
|
|
321
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
322
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(formik.Input, {
|
|
323
|
+
disabled: true,
|
|
324
|
+
name: "toPath"
|
|
325
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
326
|
+
"data-testid": "domain-level-redirection-edit-btn",
|
|
327
|
+
icon: Edit,
|
|
328
|
+
variant: "link",
|
|
329
|
+
onClick: function onClick() {
|
|
330
|
+
return setIsEditingDomainRedirect(true);
|
|
331
|
+
}
|
|
332
|
+
})]
|
|
333
|
+
})
|
|
334
|
+
})]
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
var buildBreadcrumbs = function buildBreadcrumbs(pageTitle) {
|
|
341
|
+
return buildSettingsBreadcrumbs(SETTINGS_CATEGORIES.GENERAL, pageTitle);
|
|
342
|
+
};
|
|
343
|
+
var buildMoreMenuItems = function buildMoreMenuItems(_ref) {
|
|
344
|
+
var redirectUrl = _ref.redirectUrl,
|
|
345
|
+
setUrlDetailsToEdit = _ref.setUrlDetailsToEdit,
|
|
346
|
+
setUrlDetailsToDelete = _ref.setUrlDetailsToDelete;
|
|
347
|
+
var id = redirectUrl.id,
|
|
348
|
+
fromPath = redirectUrl.fromPath,
|
|
349
|
+
toPath = redirectUrl.toPath;
|
|
350
|
+
return [{
|
|
351
|
+
key: "edit-menu",
|
|
352
|
+
"data-testid": "neeto-redirect-url-edit-btn",
|
|
353
|
+
label: i18next.t("neetoRedirectUrls.common.edit"),
|
|
354
|
+
onClick: function onClick() {
|
|
355
|
+
setUrlDetailsToEdit({
|
|
356
|
+
id: id,
|
|
357
|
+
fromPath: fromPath,
|
|
358
|
+
toPath: toPath
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}, {
|
|
362
|
+
key: "delete-menu",
|
|
363
|
+
"data-testid": "neeto-redirect-url-delete-btn",
|
|
364
|
+
label: i18next.t("neetoRedirectUrls.common.delete"),
|
|
365
|
+
onClick: function onClick() {
|
|
366
|
+
setUrlDetailsToDelete({
|
|
367
|
+
id: id,
|
|
368
|
+
fromPath: fromPath,
|
|
369
|
+
toPath: toPath
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}];
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
var RedirectUrlsTable = function RedirectUrlsTable(_ref) {
|
|
376
|
+
var _ref$redirectUrls = _ref.redirectUrls,
|
|
377
|
+
redirectUrls = _ref$redirectUrls === void 0 ? [] : _ref$redirectUrls,
|
|
378
|
+
currentPageNumber = _ref.currentPageNumber,
|
|
379
|
+
setCurrentPageNumber = _ref.setCurrentPageNumber,
|
|
380
|
+
recordsCount = _ref.recordsCount,
|
|
381
|
+
setUrlDetailsToEdit = _ref.setUrlDetailsToEdit,
|
|
382
|
+
setUrlDetailsToDelete = _ref.setUrlDetailsToDelete,
|
|
383
|
+
isFetching = _ref.isFetching;
|
|
384
|
+
var truncateUrl = function truncateUrl(url) {
|
|
385
|
+
var urlString = String(url);
|
|
386
|
+
return urlString.length <= 50 ? urlString : "".concat(urlString.slice(0, 50), "...");
|
|
387
|
+
};
|
|
388
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
389
|
+
t = _useTranslation.t;
|
|
390
|
+
var columns = [{
|
|
391
|
+
header: t("neetoRedirectUrls.redirect.source"),
|
|
392
|
+
accessorKey: "fromPath",
|
|
393
|
+
id: "name",
|
|
394
|
+
size: 300,
|
|
395
|
+
cell: function cell(_ref2) {
|
|
396
|
+
var row = _ref2.row;
|
|
397
|
+
var redirectUrl = row.original;
|
|
398
|
+
var fromPath = redirectUrl.fromPath;
|
|
399
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
400
|
+
className: "flex items-center justify-between gap-x-3",
|
|
401
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
402
|
+
children: fromPath && truncateUrl(fromPath)
|
|
403
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
|
|
404
|
+
dropdownProps: {
|
|
405
|
+
position: "bottom-end"
|
|
406
|
+
},
|
|
407
|
+
menuItems: buildMoreMenuItems({
|
|
408
|
+
redirectUrl: redirectUrl,
|
|
409
|
+
setUrlDetailsToEdit: setUrlDetailsToEdit,
|
|
410
|
+
setUrlDetailsToDelete: setUrlDetailsToDelete
|
|
411
|
+
})
|
|
412
|
+
})]
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
header: t("neetoRedirectUrls.redirect.destination"),
|
|
417
|
+
accessorKey: "toPath",
|
|
418
|
+
id: "toPath",
|
|
419
|
+
size: 300,
|
|
420
|
+
cell: function cell(_ref3) {
|
|
421
|
+
var getValue = _ref3.getValue;
|
|
422
|
+
var toPath = getValue();
|
|
423
|
+
return toPath && truncateUrl(toPath);
|
|
424
|
+
}
|
|
425
|
+
}];
|
|
426
|
+
return /*#__PURE__*/jsxRuntime.jsx(TableWrapper, {
|
|
427
|
+
hasPagination: recordsCount > constants.DEFAULT_PAGE_SIZE,
|
|
428
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.DataTable, {
|
|
429
|
+
columns: columns,
|
|
430
|
+
fixedHeight: true,
|
|
431
|
+
currentPage: currentPageNumber,
|
|
432
|
+
data: redirectUrls,
|
|
433
|
+
loading: isFetching,
|
|
434
|
+
pageSize: constants.DEFAULT_PAGE_SIZE,
|
|
435
|
+
totalCount: recordsCount,
|
|
436
|
+
onPageChange: function onPageChange(page) {
|
|
437
|
+
return setCurrentPageNumber(page);
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
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; }
|
|
444
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
445
|
+
var RedirectUrls = function RedirectUrls(_ref) {
|
|
446
|
+
var entity = _ref.entity,
|
|
447
|
+
_ref$helpDocUrls = _ref.helpDocUrls,
|
|
448
|
+
helpDocUrls = _ref$helpDocUrls === void 0 ? {} : _ref$helpDocUrls;
|
|
449
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
450
|
+
t = _useTranslation.t;
|
|
451
|
+
var _useQueryParams = reactUtils.useQueryParams(),
|
|
452
|
+
_useQueryParams$searc = _useQueryParams.searchTerm,
|
|
453
|
+
searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
|
|
454
|
+
var initialFocusField = react.useRef();
|
|
455
|
+
var _useState = react.useState(1),
|
|
456
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
457
|
+
currentPageNumber = _useState2[0],
|
|
458
|
+
setCurrentPageNumber = _useState2[1];
|
|
459
|
+
var _useState3 = react.useState(null),
|
|
460
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
461
|
+
urlDetailsToDelete = _useState4[0],
|
|
462
|
+
setUrlDetailsToDelete = _useState4[1];
|
|
463
|
+
var _useState5 = react.useState(null),
|
|
464
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
465
|
+
urlDetailsToEdit = _useState6[0],
|
|
466
|
+
setUrlDetailsToEdit = _useState6[1];
|
|
467
|
+
var _useState7 = react.useState(false),
|
|
468
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
469
|
+
isModalOpen = _useState8[0],
|
|
470
|
+
setIsModalOpen = _useState8[1];
|
|
471
|
+
var _useCreateRedirectUrl = helpUrls.useCreateRedirectUrl(),
|
|
472
|
+
createRedirectUrl = _useCreateRedirectUrl.mutate;
|
|
473
|
+
var searchQuery = _objectSpread({
|
|
474
|
+
page: currentPageNumber
|
|
475
|
+
}, ramda.isEmpty(searchTerm) ? {} : {
|
|
476
|
+
searchTerm: searchTerm
|
|
477
|
+
});
|
|
478
|
+
var _useFetchAllRedirectU = helpUrls.useFetchAllRedirectUrls({
|
|
479
|
+
params: searchQuery
|
|
480
|
+
}),
|
|
481
|
+
_useFetchAllRedirectU2 = _useFetchAllRedirectU.data,
|
|
482
|
+
_useFetchAllRedirectU3 = _useFetchAllRedirectU2 === void 0 ? {} : _useFetchAllRedirectU2,
|
|
483
|
+
_useFetchAllRedirectU4 = _useFetchAllRedirectU3.redirectUrls,
|
|
484
|
+
redirectUrls = _useFetchAllRedirectU4 === void 0 ? [] : _useFetchAllRedirectU4,
|
|
485
|
+
domainRedirectUrl = _useFetchAllRedirectU3.domainRedirectUrl,
|
|
486
|
+
isLoading = _useFetchAllRedirectU.isLoading,
|
|
487
|
+
isFetching = _useFetchAllRedirectU.isFetching;
|
|
488
|
+
var isFiltersVisible = (redirectUrls === null || redirectUrls === void 0 ? void 0 : redirectUrls.length) > 0 || neetoCist.isPresent(searchTerm);
|
|
489
|
+
var _useUpdateRedirectUrl = helpUrls.useUpdateRedirectUrl(),
|
|
490
|
+
updateRedirectUrl = _useUpdateRedirectUrl.mutate;
|
|
491
|
+
var _useDestroyRedirectUr = helpUrls.useDestroyRedirectUrl(),
|
|
492
|
+
deleteRedirectUrl = _useDestroyRedirectUr.mutate;
|
|
493
|
+
var handleCreateRedirectUrl = function handleCreateRedirectUrl(redirectUrl, _ref2) {
|
|
494
|
+
var setSubmitting = _ref2.setSubmitting,
|
|
495
|
+
setStatus = _ref2.setStatus;
|
|
496
|
+
createRedirectUrl({
|
|
497
|
+
payload: redirectUrl,
|
|
498
|
+
config: SHOW_TOASTR_CONFIG
|
|
499
|
+
}, {
|
|
500
|
+
onError: function onError(error) {
|
|
501
|
+
handleError(setStatus, error);
|
|
502
|
+
setSubmitting(false);
|
|
503
|
+
},
|
|
504
|
+
onSuccess: function onSuccess() {
|
|
505
|
+
utils.showThumbsUpToastr();
|
|
506
|
+
setIsModalOpen(false);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
};
|
|
510
|
+
var handleRedirectUrlUpdate = function handleRedirectUrlUpdate(redirectUrl, _ref3) {
|
|
511
|
+
var setSubmitting = _ref3.setSubmitting,
|
|
512
|
+
setStatus = _ref3.setStatus;
|
|
513
|
+
updateRedirectUrl({
|
|
514
|
+
id: redirectUrl.id,
|
|
515
|
+
payload: redirectUrl,
|
|
516
|
+
config: SHOW_TOASTR_CONFIG
|
|
517
|
+
}, {
|
|
518
|
+
onError: function onError(error) {
|
|
519
|
+
handleError(setStatus, error);
|
|
520
|
+
setSubmitting(false);
|
|
521
|
+
},
|
|
522
|
+
onSuccess: function onSuccess() {
|
|
523
|
+
utils.showThumbsUpToastr();
|
|
524
|
+
setUrlDetailsToEdit(null);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
var handleRedirectUrlDelete = function handleRedirectUrlDelete(urlId) {
|
|
529
|
+
deleteRedirectUrl(urlId, {
|
|
530
|
+
onSettled: function onSettled() {
|
|
531
|
+
setUrlDetailsToDelete(null);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
var pageTitle = t("neetoRedirectUrls.settings.redirecturl.title");
|
|
536
|
+
var setInitialFocusField = function setInitialFocusField(fieldRef) {
|
|
537
|
+
return initialFocusField.current = fieldRef;
|
|
538
|
+
};
|
|
539
|
+
return /*#__PURE__*/jsxRuntime.jsx(Container, {
|
|
540
|
+
className: "w-full",
|
|
541
|
+
children: isLoading ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
542
|
+
className: "flex h-full w-full items-center justify-center",
|
|
543
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {})
|
|
544
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
545
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
546
|
+
breadcrumbs: buildBreadcrumbs(pageTitle),
|
|
547
|
+
title: pageTitle,
|
|
548
|
+
actionBlock: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
549
|
+
"data-testid": "add-new-redirect-url-button",
|
|
550
|
+
label: t("neetoRedirectUrls.redirect.add"),
|
|
551
|
+
onClick: function onClick() {
|
|
552
|
+
return setIsModalOpen(true);
|
|
553
|
+
}
|
|
554
|
+
}),
|
|
555
|
+
searchProps: isFiltersVisible && {
|
|
556
|
+
placeholder: t("neetoRedirectUrls.redirect.search")
|
|
557
|
+
},
|
|
558
|
+
titleHelpPopoverProps: {
|
|
559
|
+
title: t("neetoRedirectUrls.settings.redirecturl.title"),
|
|
560
|
+
description: t("neetoRedirectUrls.settings.redirecturl.description"),
|
|
561
|
+
helpLinkProps: {
|
|
562
|
+
href: helpDocUrls.createRedirectUrl || helpUrls.CREATE_REDIRECT_URL_HELP_DOC_URL
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
566
|
+
children: [ramda.isEmpty(redirectUrls) ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
567
|
+
className: "flex h-full w-full items-center justify-center",
|
|
568
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Empty, {
|
|
569
|
+
title: t("neetoRedirectUrls.emptyState.redirectURLs.title"),
|
|
570
|
+
description: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
571
|
+
i18nKey: "neetoRedirectUrls.emptyState.redirectURLs.description",
|
|
572
|
+
components: {
|
|
573
|
+
helpLink: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
574
|
+
target: "_blank",
|
|
575
|
+
variant: "link",
|
|
576
|
+
href: helpDocUrls.createRedirectUrl || helpUrls.CREATE_REDIRECT_URL_HELP_DOC_URL
|
|
577
|
+
})
|
|
578
|
+
}
|
|
579
|
+
}),
|
|
580
|
+
primaryButtonProps: {
|
|
581
|
+
label: t("neetoRedirectUrls.redirect.add"),
|
|
582
|
+
onClick: function onClick() {
|
|
583
|
+
return setIsModalOpen(true);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
})
|
|
587
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
588
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
589
|
+
className: "w-full",
|
|
590
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DomainRedirection, {
|
|
591
|
+
domainRedirectUrl: domainRedirectUrl,
|
|
592
|
+
entity: entity,
|
|
593
|
+
helpDocUrls: helpDocUrls
|
|
594
|
+
})
|
|
595
|
+
}), /*#__PURE__*/jsxRuntime.jsx(RedirectUrlsTable, {
|
|
596
|
+
currentPageNumber: currentPageNumber,
|
|
597
|
+
isFetching: isFetching,
|
|
598
|
+
redirectUrls: redirectUrls,
|
|
599
|
+
setCurrentPageNumber: setCurrentPageNumber,
|
|
600
|
+
setUrlDetailsToDelete: setUrlDetailsToDelete,
|
|
601
|
+
setUrlDetailsToEdit: setUrlDetailsToEdit,
|
|
602
|
+
recordsCount: redirectUrls.length
|
|
603
|
+
})]
|
|
604
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DeleteRedirectUrlModal, {
|
|
605
|
+
detailsToDelete: urlDetailsToDelete,
|
|
606
|
+
handleClose: function handleClose() {
|
|
607
|
+
return setUrlDetailsToDelete(null);
|
|
608
|
+
},
|
|
609
|
+
handleSubmit: handleRedirectUrlDelete,
|
|
610
|
+
isOpen: urlDetailsToDelete !== null
|
|
611
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet, {
|
|
612
|
+
isOpen: isModalOpen || ramda.isNotNil(urlDetailsToEdit),
|
|
613
|
+
onClose: function onClose() {
|
|
614
|
+
setIsModalOpen(false);
|
|
615
|
+
setUrlDetailsToEdit(null);
|
|
616
|
+
},
|
|
617
|
+
children: /*#__PURE__*/jsxRuntime.jsx(RedirectUrlPane, {
|
|
618
|
+
setInitialFocusField: setInitialFocusField,
|
|
619
|
+
handleClose: function handleClose() {
|
|
620
|
+
return setIsModalOpen(false);
|
|
621
|
+
},
|
|
622
|
+
initialValues: urlDetailsToEdit !== null && urlDetailsToEdit !== void 0 ? urlDetailsToEdit : {},
|
|
623
|
+
handleSubmit: ramda.isNotNil(urlDetailsToEdit) ? handleRedirectUrlUpdate : handleCreateRedirectUrl
|
|
624
|
+
})
|
|
625
|
+
})]
|
|
626
|
+
})]
|
|
627
|
+
})
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
module.exports = RedirectUrls;
|
|
632
|
+
//# sourceMappingURL=RedirectUrls.js.map
|