@bigbinary/neeto-api-keys-frontend 1.1.14 → 1.2.0-beta1
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/app/javascript/src/translations/en.json +1 -1
- package/dist/index.cjs.js +301 -278
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +293 -269
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { t } from 'i18next';
|
|
3
|
-
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
|
|
4
3
|
import { isPresent, isNotPresent, isNotEmpty } from '@bigbinary/neeto-cist';
|
|
4
|
+
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
|
|
5
5
|
import { useMutationWithInvalidation, withT, useDebounce, withTitle, useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
6
6
|
import Header from '@bigbinary/neeto-molecules/Header';
|
|
7
7
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
8
8
|
import Button from '@bigbinary/neetoui/Button';
|
|
9
9
|
import { useTranslation, Trans } from 'react-i18next';
|
|
10
|
-
import { useQuery } from 'react-query';
|
|
10
|
+
import { useQuery } from '@tanstack/react-query';
|
|
11
11
|
import axios from 'axios';
|
|
12
12
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
13
13
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
@@ -24,25 +24,52 @@ import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
|
24
24
|
import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardButton';
|
|
25
25
|
import Tag from '@bigbinary/neetoui/Tag';
|
|
26
26
|
import * as yup from 'yup';
|
|
27
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
27
28
|
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
28
29
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
29
30
|
import NeetoUITable from '@bigbinary/neetoui/Table';
|
|
30
31
|
import NoData from '@bigbinary/neetoui/NoData';
|
|
31
32
|
import { useHistory } from 'react-router-dom';
|
|
32
33
|
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
function _typeof(o) {
|
|
35
|
+
"@babel/helpers - typeof";
|
|
36
|
+
|
|
37
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
38
|
+
return typeof o;
|
|
39
|
+
} : function (o) {
|
|
40
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
41
|
+
}, _typeof(o);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _toPrimitive(input, hint) {
|
|
45
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
46
|
+
var prim = input[Symbol.toPrimitive];
|
|
47
|
+
if (prim !== undefined) {
|
|
48
|
+
var res = prim.call(input, hint || "default");
|
|
49
|
+
if (_typeof(res) !== "object") return res;
|
|
50
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
51
|
+
}
|
|
52
|
+
return (hint === "string" ? String : Number)(input);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _toPropertyKey(arg) {
|
|
56
|
+
var key = _toPrimitive(arg, "string");
|
|
57
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _defineProperty(obj, key, value) {
|
|
61
|
+
key = _toPropertyKey(key);
|
|
62
|
+
if (key in obj) {
|
|
63
|
+
Object.defineProperty(obj, key, {
|
|
64
|
+
value: value,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
obj[key] = value;
|
|
71
|
+
}
|
|
72
|
+
return obj;
|
|
46
73
|
}
|
|
47
74
|
|
|
48
75
|
function _arrayWithHoles(arr) {
|
|
@@ -133,12 +160,18 @@ var QUERY_KEYS = {
|
|
|
133
160
|
API_KEYS: "api-keys"
|
|
134
161
|
};
|
|
135
162
|
|
|
163
|
+
function ownKeys$4(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; }
|
|
164
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
136
165
|
var useFetchApiKeys = function useFetchApiKeys(_ref) {
|
|
137
166
|
var params = _ref.params,
|
|
138
|
-
options = _ref.options
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
167
|
+
_ref$options = _ref.options,
|
|
168
|
+
options = _ref$options === void 0 ? {} : _ref$options;
|
|
169
|
+
return useQuery(_objectSpread$4({
|
|
170
|
+
queryKey: [QUERY_KEYS.API_KEYS, params],
|
|
171
|
+
queryFn: function queryFn() {
|
|
172
|
+
return apiKeysApi.fetch(params);
|
|
173
|
+
}
|
|
174
|
+
}, options));
|
|
142
175
|
};
|
|
143
176
|
var useCreateApiKey = function useCreateApiKey(onSuccess) {
|
|
144
177
|
return useMutationWithInvalidation(apiKeysApi.create, {
|
|
@@ -220,23 +253,25 @@ var buildColumnData = function buildColumnData(_ref2) {
|
|
|
220
253
|
dataIndex: "label",
|
|
221
254
|
width: 400,
|
|
222
255
|
render: function render(label, apiKey) {
|
|
223
|
-
return /*#__PURE__*/
|
|
224
|
-
className: "flex items-center justify-between space-x-3"
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
menuItems: getMenuItems({
|
|
232
|
-
onEdit: function onEdit() {
|
|
233
|
-
return handleEdit(apiKey);
|
|
256
|
+
return /*#__PURE__*/jsxs("div", {
|
|
257
|
+
className: "flex items-center justify-between space-x-3",
|
|
258
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
259
|
+
style: "body2",
|
|
260
|
+
children: label
|
|
261
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
262
|
+
dropdownProps: {
|
|
263
|
+
strategy: "fixed"
|
|
234
264
|
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
265
|
+
menuItems: getMenuItems({
|
|
266
|
+
onEdit: function onEdit() {
|
|
267
|
+
return handleEdit(apiKey);
|
|
268
|
+
},
|
|
269
|
+
onDelete: function onDelete() {
|
|
270
|
+
return handleDelete(apiKey);
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
})]
|
|
274
|
+
});
|
|
240
275
|
}
|
|
241
276
|
}, {
|
|
242
277
|
title: t("neetoApiKeys.table.headers.token"),
|
|
@@ -244,14 +279,16 @@ var buildColumnData = function buildColumnData(_ref2) {
|
|
|
244
279
|
dataIndex: "token",
|
|
245
280
|
width: 400,
|
|
246
281
|
render: function render(token) {
|
|
247
|
-
return /*#__PURE__*/
|
|
248
|
-
className: "flex items-center justify-between gap-x-3"
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
282
|
+
return /*#__PURE__*/jsxs("div", {
|
|
283
|
+
className: "flex items-center justify-between gap-x-3",
|
|
284
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
285
|
+
style: "body2",
|
|
286
|
+
children: partlyHideToken(token)
|
|
287
|
+
}), /*#__PURE__*/jsx(CopyToClipboardButton, {
|
|
288
|
+
style: "text",
|
|
289
|
+
value: token
|
|
290
|
+
})]
|
|
291
|
+
});
|
|
255
292
|
}
|
|
256
293
|
}, {
|
|
257
294
|
title: t("neetoApiKeys.table.headers.status"),
|
|
@@ -259,11 +296,13 @@ var buildColumnData = function buildColumnData(_ref2) {
|
|
|
259
296
|
width: 144,
|
|
260
297
|
render: function render(_, _ref3) {
|
|
261
298
|
var expiresAt = _ref3.expiresAt;
|
|
262
|
-
return isPresent(expiresAt) && isInPast(expiresAt) ? /*#__PURE__*/
|
|
263
|
-
style: "warning"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
299
|
+
return isPresent(expiresAt) && isInPast(expiresAt) ? /*#__PURE__*/jsx(Tag, {
|
|
300
|
+
style: "warning",
|
|
301
|
+
children: t("neetoApiKeys.tags.expired")
|
|
302
|
+
}) : /*#__PURE__*/jsx(Tag, {
|
|
303
|
+
style: "success",
|
|
304
|
+
children: t("neetoApiKeys.tags.active")
|
|
305
|
+
});
|
|
267
306
|
}
|
|
268
307
|
}, {
|
|
269
308
|
title: t("neetoApiKeys.table.headers.expiresAt"),
|
|
@@ -271,9 +310,10 @@ var buildColumnData = function buildColumnData(_ref2) {
|
|
|
271
310
|
dataIndex: "expiresAt",
|
|
272
311
|
width: 200,
|
|
273
312
|
render: function render(expiresAt) {
|
|
274
|
-
return isPresent(expiresAt) ? formatExpiry(expiresAt) : /*#__PURE__*/
|
|
275
|
-
style: "body2"
|
|
276
|
-
|
|
313
|
+
return isPresent(expiresAt) ? formatExpiry(expiresAt) : /*#__PURE__*/jsx(Typography, {
|
|
314
|
+
style: "body2",
|
|
315
|
+
children: t("neetoApiKeys.common.never")
|
|
316
|
+
});
|
|
277
317
|
}
|
|
278
318
|
}, {
|
|
279
319
|
title: t("neetoApiKeys.table.headers.createdAt"),
|
|
@@ -281,9 +321,10 @@ var buildColumnData = function buildColumnData(_ref2) {
|
|
|
281
321
|
dataIndex: "createdAt",
|
|
282
322
|
width: 200,
|
|
283
323
|
render: function render(createdAt) {
|
|
284
|
-
return isPresent(createdAt) ? dateFormat.dateTime(createdAt) : /*#__PURE__*/
|
|
285
|
-
style: "body2"
|
|
286
|
-
|
|
324
|
+
return isPresent(createdAt) ? dateFormat.dateTime(createdAt) : /*#__PURE__*/jsx(Typography, {
|
|
325
|
+
style: "body2",
|
|
326
|
+
children: t("neetoApiKeys.common.never")
|
|
327
|
+
});
|
|
287
328
|
}
|
|
288
329
|
}];
|
|
289
330
|
};
|
|
@@ -291,6 +332,8 @@ var getStartOfTime = function getStartOfTime(time, unit) {
|
|
|
291
332
|
return dayjs(time).startOf(unit);
|
|
292
333
|
};
|
|
293
334
|
|
|
335
|
+
function ownKeys$3(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; }
|
|
336
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
294
337
|
var DatePicker = function DatePicker(_ref) {
|
|
295
338
|
var defaultValue = _ref.defaultValue,
|
|
296
339
|
disabledDate = _ref.disabledDate,
|
|
@@ -299,29 +342,30 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
299
342
|
name = _ref.name,
|
|
300
343
|
_ref$disabled = _ref.disabled,
|
|
301
344
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
302
|
-
return /*#__PURE__*/
|
|
303
|
-
name: name
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
345
|
+
return /*#__PURE__*/jsx(Field, {
|
|
346
|
+
name: name,
|
|
347
|
+
children: function children(_ref2) {
|
|
348
|
+
var _globalProps;
|
|
349
|
+
var field = _ref2.field,
|
|
350
|
+
meta = _ref2.meta,
|
|
351
|
+
setFieldValue = _ref2.form.setFieldValue;
|
|
352
|
+
return /*#__PURE__*/jsx(NeetoUIDatePicker, _objectSpread$3(_objectSpread$3({
|
|
353
|
+
disabled: disabled,
|
|
354
|
+
disabledDate: disabledDate,
|
|
355
|
+
label: label,
|
|
356
|
+
placeholder: placeholder,
|
|
357
|
+
defaultValue: defaultValue,
|
|
358
|
+
allowClear: false,
|
|
359
|
+
className: "w-full",
|
|
360
|
+
error: meta.touched && meta.error,
|
|
361
|
+
format: (_globalProps = globalProps) === null || _globalProps === void 0 || (_globalProps = _globalProps.user) === null || _globalProps === void 0 ? void 0 : _globalProps.dateFormat,
|
|
362
|
+
getPopupContainer: prop("parentNode")
|
|
363
|
+
}, field), {}, {
|
|
364
|
+
onChange: function onChange(date) {
|
|
365
|
+
setFieldValue(field.name, getStartOfTime(date, "day"));
|
|
366
|
+
}
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
325
369
|
});
|
|
326
370
|
};
|
|
327
371
|
|
|
@@ -333,50 +377,59 @@ var Form = withT(function (_ref) {
|
|
|
333
377
|
onClose = _ref.onClose,
|
|
334
378
|
onSubmit = _ref.onSubmit,
|
|
335
379
|
initialFocusRef = _ref.initialFocusRef;
|
|
336
|
-
return /*#__PURE__*/
|
|
380
|
+
return /*#__PURE__*/jsx(NeetoUIForm, {
|
|
337
381
|
formikProps: {
|
|
338
382
|
validationSchema: VALIDATION_SCHEMA,
|
|
339
383
|
initialValues: initialValues,
|
|
340
384
|
onSubmit: onSubmit
|
|
385
|
+
},
|
|
386
|
+
children: function children(_ref2) {
|
|
387
|
+
var setFieldValue = _ref2.setFieldValue,
|
|
388
|
+
_ref2$values = _ref2.values,
|
|
389
|
+
_ref2$values2 = _ref2$values === void 0 ? {} : _ref2$values,
|
|
390
|
+
hasNoExpiry = _ref2$values2.hasNoExpiry,
|
|
391
|
+
expiresAt = _ref2$values2.expiresAt;
|
|
392
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
393
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
394
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
395
|
+
className: "w-full space-y-4",
|
|
396
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
397
|
+
autoFocus: true,
|
|
398
|
+
label: t("neetoApiKeys.fields.label"),
|
|
399
|
+
name: "label",
|
|
400
|
+
placeholder: t("neetoApiKeys.placeholders.label"),
|
|
401
|
+
ref: initialFocusRef
|
|
402
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
403
|
+
className: "space-y-2",
|
|
404
|
+
children: [!hasNoExpiry && /*#__PURE__*/jsx(DatePicker, {
|
|
405
|
+
defaultValue: expiresAt,
|
|
406
|
+
disabledDate: function disabledDate(date) {
|
|
407
|
+
return date < NEXT_DAY;
|
|
408
|
+
},
|
|
409
|
+
label: t("neetoApiKeys.fields.expiryDate"),
|
|
410
|
+
name: "expiresAt",
|
|
411
|
+
placeholder: t("neetoApiKeys.placeholders.selectExpiryDate")
|
|
412
|
+
}), /*#__PURE__*/jsx(Checkbox, {
|
|
413
|
+
checked: hasNoExpiry,
|
|
414
|
+
label: t("neetoApiKeys.fields.neverExpire"),
|
|
415
|
+
name: "hasNoExpiry",
|
|
416
|
+
onChange: function onChange() {
|
|
417
|
+
setFieldValue("expiresAt", null);
|
|
418
|
+
setFieldValue("hasNoExpiry", !hasNoExpiry);
|
|
419
|
+
}
|
|
420
|
+
})]
|
|
421
|
+
})]
|
|
422
|
+
})
|
|
423
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
424
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
425
|
+
isSubmitting: isSubmitting,
|
|
426
|
+
cancelButtonProps: {
|
|
427
|
+
onClick: onClose
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
})]
|
|
431
|
+
});
|
|
341
432
|
}
|
|
342
|
-
}, function (_ref2) {
|
|
343
|
-
var setFieldValue = _ref2.setFieldValue,
|
|
344
|
-
_ref2$values = _ref2.values,
|
|
345
|
-
_ref2$values2 = _ref2$values === void 0 ? {} : _ref2$values,
|
|
346
|
-
hasNoExpiry = _ref2$values2.hasNoExpiry,
|
|
347
|
-
expiresAt = _ref2$values2.expiresAt;
|
|
348
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
|
|
349
|
-
className: "w-full space-y-4"
|
|
350
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
351
|
-
autoFocus: true,
|
|
352
|
-
label: t("neetoApiKeys.fields.label"),
|
|
353
|
-
name: "label",
|
|
354
|
-
placeholder: t("neetoApiKeys.placeholders.label"),
|
|
355
|
-
ref: initialFocusRef
|
|
356
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
357
|
-
className: "space-y-2"
|
|
358
|
-
}, !hasNoExpiry && /*#__PURE__*/React.createElement(DatePicker, {
|
|
359
|
-
defaultValue: expiresAt,
|
|
360
|
-
disabledDate: function disabledDate(date) {
|
|
361
|
-
return date < NEXT_DAY;
|
|
362
|
-
},
|
|
363
|
-
label: t("neetoApiKeys.fields.expiryDate"),
|
|
364
|
-
name: "expiresAt",
|
|
365
|
-
placeholder: t("neetoApiKeys.placeholders.selectExpiryDate")
|
|
366
|
-
}), /*#__PURE__*/React.createElement(Checkbox, {
|
|
367
|
-
checked: hasNoExpiry,
|
|
368
|
-
label: t("neetoApiKeys.fields.neverExpire"),
|
|
369
|
-
name: "hasNoExpiry",
|
|
370
|
-
onChange: function onChange() {
|
|
371
|
-
setFieldValue("expiresAt", null);
|
|
372
|
-
setFieldValue("hasNoExpiry", !hasNoExpiry);
|
|
373
|
-
}
|
|
374
|
-
})))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
375
|
-
isSubmitting: isSubmitting,
|
|
376
|
-
cancelButtonProps: {
|
|
377
|
-
onClick: onClose
|
|
378
|
-
}
|
|
379
|
-
})));
|
|
380
433
|
});
|
|
381
434
|
});
|
|
382
435
|
|
|
@@ -386,73 +439,36 @@ var Create = function Create(_ref) {
|
|
|
386
439
|
var initialFocusRef = useRef(null);
|
|
387
440
|
var _useCreateApiKey = useCreateApiKey(onClose),
|
|
388
441
|
createApiKey = _useCreateApiKey.mutate,
|
|
389
|
-
isCreating = _useCreateApiKey.
|
|
442
|
+
isCreating = _useCreateApiKey.isPending;
|
|
390
443
|
var _useTranslation = useTranslation(),
|
|
391
444
|
t = _useTranslation.t;
|
|
392
|
-
return /*#__PURE__*/
|
|
393
|
-
initialFocusRef: initialFocusRef,
|
|
394
|
-
onClose: onClose,
|
|
395
|
-
isOpen: isOpen
|
|
396
|
-
}, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
397
|
-
style: "h2"
|
|
398
|
-
}, t("neetoApiKeys.headers.createApiKey"))), /*#__PURE__*/React.createElement(Form, {
|
|
445
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
399
446
|
initialFocusRef: initialFocusRef,
|
|
447
|
+
isOpen: isOpen,
|
|
400
448
|
onClose: onClose,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
449
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
450
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
451
|
+
style: "h2",
|
|
452
|
+
children: t("neetoApiKeys.headers.createApiKey")
|
|
453
|
+
})
|
|
454
|
+
}), /*#__PURE__*/jsx(Form, {
|
|
455
|
+
initialFocusRef: initialFocusRef,
|
|
456
|
+
onClose: onClose,
|
|
457
|
+
isSubmitting: isCreating,
|
|
458
|
+
onSubmit: createApiKey
|
|
459
|
+
})]
|
|
460
|
+
});
|
|
404
461
|
};
|
|
405
462
|
|
|
406
|
-
function
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
410
|
-
return typeof o;
|
|
411
|
-
} : function (o) {
|
|
412
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
413
|
-
}, _typeof(o);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function _toPrimitive(input, hint) {
|
|
417
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
418
|
-
var prim = input[Symbol.toPrimitive];
|
|
419
|
-
if (prim !== undefined) {
|
|
420
|
-
var res = prim.call(input, hint || "default");
|
|
421
|
-
if (_typeof(res) !== "object") return res;
|
|
422
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
423
|
-
}
|
|
424
|
-
return (hint === "string" ? String : Number)(input);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
function _toPropertyKey(arg) {
|
|
428
|
-
var key = _toPrimitive(arg, "string");
|
|
429
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
function _defineProperty(obj, key, value) {
|
|
433
|
-
key = _toPropertyKey(key);
|
|
434
|
-
if (key in obj) {
|
|
435
|
-
Object.defineProperty(obj, key, {
|
|
436
|
-
value: value,
|
|
437
|
-
enumerable: true,
|
|
438
|
-
configurable: true,
|
|
439
|
-
writable: true
|
|
440
|
-
});
|
|
441
|
-
} else {
|
|
442
|
-
obj[key] = value;
|
|
443
|
-
}
|
|
444
|
-
return obj;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
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; }
|
|
448
|
-
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; }
|
|
463
|
+
function ownKeys$2(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; }
|
|
464
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
449
465
|
var Update = function Update(_ref) {
|
|
450
466
|
var onClose = _ref.onClose,
|
|
451
467
|
apiKey = _ref.apiKey;
|
|
452
468
|
var initialFocusRef = useRef(null);
|
|
453
469
|
var _useUpdateApiKey = useUpdateApiKey(onClose),
|
|
454
470
|
updateApiKey = _useUpdateApiKey.mutate,
|
|
455
|
-
isUpdating = _useUpdateApiKey.
|
|
471
|
+
isUpdating = _useUpdateApiKey.isPending;
|
|
456
472
|
var _useTranslation = useTranslation(),
|
|
457
473
|
t = _useTranslation.t;
|
|
458
474
|
var handleUpdate = function handleUpdate(values) {
|
|
@@ -461,22 +477,26 @@ var Update = function Update(_ref) {
|
|
|
461
477
|
payload: values
|
|
462
478
|
});
|
|
463
479
|
};
|
|
464
|
-
var initialValues = _objectSpread(_objectSpread({}, apiKey), {}, {
|
|
480
|
+
var initialValues = _objectSpread$2(_objectSpread$2({}, apiKey), {}, {
|
|
465
481
|
hasNoExpiry: isNotPresent(apiKey.expiresAt)
|
|
466
482
|
});
|
|
467
|
-
return /*#__PURE__*/
|
|
483
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
468
484
|
initialFocusRef: initialFocusRef,
|
|
469
485
|
onClose: onClose,
|
|
470
|
-
isOpen: isNotEmpty(apiKey)
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
486
|
+
isOpen: isNotEmpty(apiKey),
|
|
487
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
488
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
489
|
+
style: "h2",
|
|
490
|
+
children: t("neetoApiKeys.headers.updateApiKey")
|
|
491
|
+
})
|
|
492
|
+
}), /*#__PURE__*/jsx(Form, {
|
|
493
|
+
initialFocusRef: initialFocusRef,
|
|
494
|
+
initialValues: initialValues,
|
|
495
|
+
onClose: onClose,
|
|
496
|
+
isSubmitting: isUpdating,
|
|
497
|
+
onSubmit: handleUpdate
|
|
498
|
+
})]
|
|
499
|
+
});
|
|
480
500
|
};
|
|
481
501
|
|
|
482
502
|
var getPageFromSearchParams = function getPageFromSearchParams() {
|
|
@@ -531,6 +551,8 @@ var usePagination = function usePagination(_ref) {
|
|
|
531
551
|
};
|
|
532
552
|
};
|
|
533
553
|
|
|
554
|
+
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; }
|
|
555
|
+
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), !0).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; }
|
|
534
556
|
var Table = function Table(_ref) {
|
|
535
557
|
var handleDelete = _ref.handleDelete,
|
|
536
558
|
handleEdit = _ref.handleEdit,
|
|
@@ -553,50 +575,51 @@ var Table = function Table(_ref) {
|
|
|
553
575
|
pageSize: DEFAULT_PAGE_SIZE
|
|
554
576
|
};
|
|
555
577
|
var _useFetchApiKeys = useFetchApiKeys({
|
|
556
|
-
params: queryParams
|
|
557
|
-
options: {
|
|
558
|
-
onSuccess: onFetchSuccess
|
|
559
|
-
}
|
|
578
|
+
params: queryParams
|
|
560
579
|
}),
|
|
561
|
-
|
|
562
|
-
_useFetchApiKeys$data2 = _useFetchApiKeys$data === void 0 ? {} : _useFetchApiKeys$data,
|
|
563
|
-
_useFetchApiKeys$data3 = _useFetchApiKeys$data2.apiKeys,
|
|
564
|
-
apiKeys = _useFetchApiKeys$data3 === void 0 ? [] : _useFetchApiKeys$data3,
|
|
565
|
-
totalCount = _useFetchApiKeys$data2.totalCount,
|
|
580
|
+
data = _useFetchApiKeys.data,
|
|
566
581
|
isLoading = _useFetchApiKeys.isLoading,
|
|
567
582
|
isFetching = _useFetchApiKeys.isFetching;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
583
|
+
useEffect(function () {
|
|
584
|
+
if (!data) return;
|
|
585
|
+
onFetchSuccess(data);
|
|
586
|
+
}, [data]);
|
|
587
|
+
if (isLoading) return /*#__PURE__*/jsx(PageLoader, {});
|
|
588
|
+
if (isEmpty(data === null || data === void 0 ? void 0 : data.apiKeys)) {
|
|
589
|
+
return /*#__PURE__*/jsxs("div", {
|
|
590
|
+
className: "flex h-full w-full items-center justify-center",
|
|
591
|
+
children: [/*#__PURE__*/jsx(NoData, _objectSpread$1({
|
|
592
|
+
className: "w-full",
|
|
593
|
+
title: t("neetoApiKeys.noData.title"),
|
|
594
|
+
primaryButtonProps: {
|
|
595
|
+
label: t("neetoApiKeys.buttons.addApiKey"),
|
|
596
|
+
onClick: function onClick() {
|
|
597
|
+
return setIsCreatePaneOpen(true);
|
|
598
|
+
}
|
|
577
599
|
}
|
|
578
|
-
},
|
|
579
|
-
|
|
580
|
-
title: t("neetoApiKeys.noData.title")
|
|
581
|
-
}, noDataProps)), ";");
|
|
600
|
+
}, noDataProps)), ";"]
|
|
601
|
+
});
|
|
582
602
|
}
|
|
583
|
-
return /*#__PURE__*/
|
|
584
|
-
hasPagination: totalCount > DEFAULT_PAGE_SIZE
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
603
|
+
return /*#__PURE__*/jsx(TableWrapper, {
|
|
604
|
+
hasPagination: (data === null || data === void 0 ? void 0 : data.totalCount) > DEFAULT_PAGE_SIZE,
|
|
605
|
+
children: /*#__PURE__*/jsx(NeetoUITable, {
|
|
606
|
+
handlePageChange: handlePageChange,
|
|
607
|
+
fixedHeight: true,
|
|
608
|
+
columnData: buildColumnData({
|
|
609
|
+
handleDelete: handleDelete,
|
|
610
|
+
handleEdit: handleEdit
|
|
611
|
+
}),
|
|
612
|
+
currentPageNumber: currentPage,
|
|
613
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
614
|
+
loading: isFetching,
|
|
615
|
+
rowData: data === null || data === void 0 ? void 0 : data.apiKeys,
|
|
616
|
+
totalCount: data === null || data === void 0 ? void 0 : data.totalCount
|
|
617
|
+
})
|
|
618
|
+
});
|
|
598
619
|
};
|
|
599
620
|
|
|
621
|
+
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; }
|
|
622
|
+
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; }
|
|
600
623
|
var ApiKeys = function ApiKeys(_ref) {
|
|
601
624
|
var noDataProps = _ref.noDataProps,
|
|
602
625
|
headerProps = _ref.headerProps;
|
|
@@ -621,57 +644,58 @@ var ApiKeys = function ApiKeys(_ref) {
|
|
|
621
644
|
return setApiKeyToBeDeleted({});
|
|
622
645
|
}),
|
|
623
646
|
deleteApiKey = _useDeleteApiKey.mutate,
|
|
624
|
-
isDeleting = _useDeleteApiKey.
|
|
625
|
-
return /*#__PURE__*/
|
|
626
|
-
className: "flex h-full w-full flex-col"
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
647
|
+
isDeleting = _useDeleteApiKey.isPending;
|
|
648
|
+
return /*#__PURE__*/jsxs("div", {
|
|
649
|
+
className: "flex h-full w-full flex-col",
|
|
650
|
+
children: [/*#__PURE__*/jsx(Header, _objectSpread({
|
|
651
|
+
title: t("neetoApiKeys.common.apiKey", PLURAL),
|
|
652
|
+
actionBlock: /*#__PURE__*/jsx(Button, {
|
|
653
|
+
label: t("neetoApiKeys.buttons.addApiKey"),
|
|
654
|
+
onClick: function onClick() {
|
|
655
|
+
return setIsCreatePaneOpen(true);
|
|
656
|
+
}
|
|
657
|
+
}),
|
|
658
|
+
searchProps: {
|
|
659
|
+
placeholder: t("neetoApiKeys.placeholders.search")
|
|
633
660
|
}
|
|
634
|
-
}),
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
661
|
+
}, headerProps)), /*#__PURE__*/jsx(Table, {
|
|
662
|
+
noDataProps: noDataProps,
|
|
663
|
+
searchTerm: searchTerm,
|
|
664
|
+
setIsCreatePaneOpen: setIsCreatePaneOpen,
|
|
665
|
+
handleDelete: setApiKeyToBeDeleted,
|
|
666
|
+
handleEdit: setApiKeyToBeEdited
|
|
667
|
+
}), /*#__PURE__*/jsx(Alert, {
|
|
668
|
+
isOpen: isNotEmpty(apiKeyToBeDeleted),
|
|
669
|
+
isSubmitting: isDeleting,
|
|
670
|
+
submitButtonLabel: t("neetoApiKeys.buttons.delete"),
|
|
671
|
+
title: t("neetoApiKeys.alert.titles.deleteApiKey"),
|
|
672
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
673
|
+
components: {
|
|
674
|
+
bold: /*#__PURE__*/jsx("strong", {})
|
|
675
|
+
},
|
|
676
|
+
i18nKey: "neetoApiKeys.alert.descriptions.deleteApiKey",
|
|
677
|
+
values: {
|
|
678
|
+
name: apiKeyToBeDeleted.label
|
|
679
|
+
}
|
|
680
|
+
}),
|
|
681
|
+
onClose: function onClose() {
|
|
682
|
+
return setApiKeyToBeDeleted({});
|
|
652
683
|
},
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
name: apiKeyToBeDeleted.label
|
|
684
|
+
onSubmit: function onSubmit() {
|
|
685
|
+
return deleteApiKey(apiKeyToBeDeleted.id);
|
|
656
686
|
}
|
|
657
|
-
}),
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}), /*#__PURE__*/React.createElement(Update, {
|
|
670
|
-
apiKey: apiKeyToBeEdited,
|
|
671
|
-
onClose: function onClose() {
|
|
672
|
-
return setApiKeyToBeEdited({});
|
|
673
|
-
}
|
|
674
|
-
}));
|
|
687
|
+
}), /*#__PURE__*/jsx(Create, {
|
|
688
|
+
isOpen: isCreatePaneOpen,
|
|
689
|
+
onClose: function onClose() {
|
|
690
|
+
return setIsCreatePaneOpen(false);
|
|
691
|
+
}
|
|
692
|
+
}), /*#__PURE__*/jsx(Update, {
|
|
693
|
+
apiKey: apiKeyToBeEdited,
|
|
694
|
+
onClose: function onClose() {
|
|
695
|
+
return setApiKeyToBeEdited({});
|
|
696
|
+
}
|
|
697
|
+
})]
|
|
698
|
+
});
|
|
675
699
|
};
|
|
676
700
|
var index = withTitle(ApiKeys, t("neetoApiKeys.common.apiKey", PLURAL));
|
|
677
701
|
|