@bigbinary/neeto-webhooks-frontend 2.0.0 → 2.0.2

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/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import React, { useState, useRef, useEffect, useCallback } from 'react';
2
+ import { prop, pluck, assoc, mergeRight } from 'ramda';
2
3
  import { useRouteMatch, useHistory, useParams, Switch as Switch$1, Route } from 'react-router-dom';
3
4
  import { isNotPresent, isPresent, removeBy, isNotEmpty, removeById, findBy } from '@bigbinary/neeto-cist';
4
- import { DEFAULT_STALE_TIME, SINGULAR, DEFAULT_PAGE_SIZE, PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
5
- import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
5
+ import { DEFAULT_STALE_TIME, SINGULAR, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_INDEX, PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
6
+ import { useQueryParams, useMutationWithInvalidation, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
6
7
  import Container from '@bigbinary/neeto-molecules/Container';
7
8
  import Header$2 from '@bigbinary/neeto-molecules/Header';
9
+ import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
8
10
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
9
11
  import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
10
12
  import NoData from '@bigbinary/neetoui/NoData';
@@ -21,11 +23,9 @@ import Typography from '@bigbinary/neetoui/Typography';
21
23
  import Tab from '@bigbinary/neetoui/Tab';
22
24
  import Tag from '@bigbinary/neetoui/Tag';
23
25
  import { t as t$1 } from 'i18next';
24
- import { prop, pluck, assoc } from 'ramda';
26
+ import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
25
27
  import Alert from '@bigbinary/neetoui/Alert';
26
- import { useMutationWithInvalidation, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
27
28
  import Plus from '@bigbinary/neeto-icons/Plus';
28
- import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
29
29
  import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
30
30
  import Spinner from '@bigbinary/neetoui/Spinner';
31
31
  import Input from '@bigbinary/neetoui/formik/Input';
@@ -36,6 +36,12 @@ import Switch from '@bigbinary/neetoui/formik/Switch';
36
36
  import Textarea from '@bigbinary/neetoui/formik/Textarea';
37
37
  import * as yup from 'yup';
38
38
 
39
+ var HELP_LINK_URLS = {
40
+ webhook: "https://neetocalhelp.neetokb.com/p/a-4bb6c2a2",
41
+ secrets: "https://neetocalhelp.neetokb.com/p/a-80de90bd",
42
+ deliveries: "https://help.neetocal.com/articles/managing-webhook-deliveries"
43
+ };
44
+
39
45
  var getDeliveriesPath = function getDeliveriesPath(webhooksPath) {
40
46
  return "".concat(webhooksPath, "/:webhookId/deliveries");
41
47
  };
@@ -74,46 +80,6 @@ function _toConsumableArray(arr) {
74
80
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
75
81
  }
76
82
 
77
- function _arrayWithHoles(arr) {
78
- if (Array.isArray(arr)) return arr;
79
- }
80
-
81
- function _iterableToArrayLimit(r, l) {
82
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
83
- if (null != t) {
84
- var e,
85
- n,
86
- i,
87
- u,
88
- a = [],
89
- f = !0,
90
- o = !1;
91
- try {
92
- if (i = (t = t.call(r)).next, 0 === l) {
93
- if (Object(t) !== t) return;
94
- f = !1;
95
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
96
- } catch (r) {
97
- o = !0, n = r;
98
- } finally {
99
- try {
100
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
101
- } finally {
102
- if (o) throw n;
103
- }
104
- }
105
- return a;
106
- }
107
- }
108
-
109
- function _nonIterableRest() {
110
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
111
- }
112
-
113
- function _slicedToArray(arr, i) {
114
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
115
- }
116
-
117
83
  function _typeof$1(o) {
118
84
  "@babel/helpers - typeof";
119
85
 
@@ -627,6 +593,46 @@ try {
627
593
 
628
594
  var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
629
595
 
596
+ function _arrayWithHoles(arr) {
597
+ if (Array.isArray(arr)) return arr;
598
+ }
599
+
600
+ function _iterableToArrayLimit(r, l) {
601
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
602
+ if (null != t) {
603
+ var e,
604
+ n,
605
+ i,
606
+ u,
607
+ a = [],
608
+ f = !0,
609
+ o = !1;
610
+ try {
611
+ if (i = (t = t.call(r)).next, 0 === l) {
612
+ if (Object(t) !== t) return;
613
+ f = !1;
614
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
615
+ } catch (r) {
616
+ o = !0, n = r;
617
+ } finally {
618
+ try {
619
+ if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
620
+ } finally {
621
+ if (o) throw n;
622
+ }
623
+ }
624
+ return a;
625
+ }
626
+ }
627
+
628
+ function _nonIterableRest() {
629
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
630
+ }
631
+
632
+ function _slicedToArray(arr, i) {
633
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
634
+ }
635
+
630
636
  var DELIVERY_TAB = {
631
637
  response: "response",
632
638
  request: "request"
@@ -910,11 +916,8 @@ var buildColumns$1 = function buildColumns(_ref) {
910
916
 
911
917
  var Deliveries = function Deliveries(_ref) {
912
918
  var webhooksUrl = _ref.webhooksUrl,
913
- hostBreadcrumbs = _ref.breadcrumbs;
914
- var _useState = useState(1),
915
- _useState2 = _slicedToArray(_useState, 2),
916
- pageNumber = _useState2[0],
917
- setPageNumber = _useState2[1];
919
+ hostBreadcrumbs = _ref.breadcrumbs,
920
+ helpLink = _ref.helpLink;
918
921
  var _useRouteMatch = useRouteMatch(),
919
922
  deliveriesUrl = _useRouteMatch.url;
920
923
  var history = useHistory();
@@ -923,10 +926,12 @@ var Deliveries = function Deliveries(_ref) {
923
926
  var _useParams = useParams(),
924
927
  webhookId = _useParams.webhookId,
925
928
  deliveryId = _useParams.deliveryId;
926
- var deliveriesPath = getDeliveriesPath(webhooksUrl);
929
+ var _useQueryParams = useQueryParams(),
930
+ _useQueryParams$page = _useQueryParams.page,
931
+ page = _useQueryParams$page === void 0 ? DEFAULT_PAGE_INDEX : _useQueryParams$page;
927
932
  var deliveryDetailsPath = getDeliveryDetailsPath(deliveriesUrl);
928
933
  var _useFetchDeliveries = useFetchDeliveries(webhookId, {
929
- page: pageNumber,
934
+ page: page,
930
935
  pageSize: DEFAULT_PAGE_SIZE
931
936
  }),
932
937
  isLoading = _useFetchDeliveries.isLoading,
@@ -947,17 +952,21 @@ var Deliveries = function Deliveries(_ref) {
947
952
  link: window.location.pathname,
948
953
  text: endpoint
949
954
  }]);
950
- var handleClose = function handleClose() {
951
- history.push(buildUrl(deliveriesPath, {
952
- webhookId: webhookId
953
- }));
954
- };
955
955
  if (isLoading) return /*#__PURE__*/jsx(PageLoader, {});
956
956
  return /*#__PURE__*/jsxs(Container, {
957
957
  className: "w-full",
958
958
  children: [/*#__PURE__*/jsx(Header$2, {
959
959
  breadcrumbs: breadcrumbs,
960
- title: t("neetoWebhooks.delivery.title")
960
+ title: /*#__PURE__*/jsxs("div", {
961
+ className: "flex items-center gap-x-2",
962
+ children: [t("neetoWebhooks.delivery.title"), /*#__PURE__*/jsx(HelpPopover, {
963
+ description: t("neetoWebhooks.delivery.helpDescription"),
964
+ helpLinkProps: {
965
+ href: helpLink
966
+ },
967
+ title: t("neetoWebhooks.delivery.title")
968
+ })]
969
+ })
961
970
  }), isNotEmpty(deliveries) ? /*#__PURE__*/jsx(TableWrapper, {
962
971
  hasPagination: totalCount > DEFAULT_PAGE_SIZE,
963
972
  children: /*#__PURE__*/jsx(Table, {
@@ -966,9 +975,8 @@ var Deliveries = function Deliveries(_ref) {
966
975
  columnData: buildColumns$1({
967
976
  deliveryDetailsPath: deliveryDetailsPath
968
977
  }),
969
- currentPageNumber: pageNumber,
978
+ currentPageNumber: page,
970
979
  defaultPageSize: DEFAULT_PAGE_SIZE,
971
- handlePageChange: setPageNumber,
972
980
  loading: isFetching,
973
981
  rowData: deliveries
974
982
  })
@@ -981,7 +989,9 @@ var Deliveries = function Deliveries(_ref) {
981
989
  }), /*#__PURE__*/jsx(Details, {
982
990
  deliveryId: deliveryId,
983
991
  webhookSid: webhookId,
984
- onClose: handleClose
992
+ onClose: function onClose() {
993
+ return history.goBack();
994
+ }
985
995
  })]
986
996
  });
987
997
  };
@@ -1068,9 +1078,6 @@ var useDestroyWebhook = function useDestroyWebhook(options) {
1068
1078
  });
1069
1079
  };
1070
1080
 
1071
- var WEBHOOK_HELP_URL = "https://neetocalhelp.neetokb.com/p/a-4bb6c2a2";
1072
- var WEBHOOK_SECRETS_HELP_URL = "https://neetocalhelp.neetokb.com/p/a-80de90bd";
1073
-
1074
1081
  var baseUrl = "/webhooks/events/all";
1075
1082
  var all = function all() {
1076
1083
  return axios.get(baseUrl);
@@ -1275,7 +1282,9 @@ var AddWebhookPane = function AddWebhookPane(_ref) {
1275
1282
  isOpen = _ref.isOpen,
1276
1283
  onClose = _ref.onClose,
1277
1284
  onCreate = _ref.onCreate,
1278
- webhooks = _ref.webhooks;
1285
+ webhooks = _ref.webhooks,
1286
+ webhookHelpLink = _ref.webhookHelpLink,
1287
+ secretsHelpLink = _ref.secretsHelpLink;
1279
1288
  var _useTranslation = useTranslation(),
1280
1289
  t = _useTranslation.t;
1281
1290
  var _useState = useState(false),
@@ -1355,7 +1364,7 @@ var AddWebhookPane = function AddWebhookPane(_ref) {
1355
1364
  }), /*#__PURE__*/jsx(HelpPopover, {
1356
1365
  description: t("neetoWebhooks.webhook.helpDescription"),
1357
1366
  helpLinkProps: {
1358
- href: WEBHOOK_HELP_URL
1367
+ href: webhookHelpLink
1359
1368
  },
1360
1369
  title: t("neetoWebhooks.webhook.title")
1361
1370
  })]
@@ -1403,7 +1412,7 @@ var AddWebhookPane = function AddWebhookPane(_ref) {
1403
1412
  className: "flex items-center gap-x-2",
1404
1413
  children: [t("neetoWebhooks.webhook.secret"), /*#__PURE__*/jsx(HelpPopover, {
1405
1414
  helpLinkProps: {
1406
- href: WEBHOOK_SECRETS_HELP_URL
1415
+ href: secretsHelpLink
1407
1416
  },
1408
1417
  description: t("neetoWebhooks.webhook.secretkeyHelpDescription"),
1409
1418
  title: t("neetoWebhooks.webhook.secretkeyHelpTitle")
@@ -1461,7 +1470,8 @@ var Header = withT(function (_ref) {
1461
1470
  breadcrumbs = _ref.breadcrumbs,
1462
1471
  title = _ref.title,
1463
1472
  setIsAddWebhookPaneOpen = _ref.setIsAddWebhookPaneOpen,
1464
- headerSize = _ref.headerSize;
1473
+ headerSize = _ref.headerSize,
1474
+ webhookHelpLink = _ref.webhookHelpLink;
1465
1475
  return /*#__PURE__*/jsxs(Fragment, {
1466
1476
  children: [/*#__PURE__*/jsx(Header$2, {
1467
1477
  breadcrumbs: breadcrumbs,
@@ -1478,7 +1488,7 @@ var Header = withT(function (_ref) {
1478
1488
  children: [t("neetoWebhooks.webhook.title"), /*#__PURE__*/jsx(HelpPopover, {
1479
1489
  description: t("neetoWebhooks.webhook.helpDescription"),
1480
1490
  helpLinkProps: {
1481
- href: WEBHOOK_HELP_URL
1491
+ href: webhookHelpLink
1482
1492
  },
1483
1493
  title: t("neetoWebhooks.webhook.title")
1484
1494
  })]
@@ -1504,7 +1514,9 @@ var Webhooks = function Webhooks(_ref) {
1504
1514
  onDelete = _ref.onDelete,
1505
1515
  headerSize = _ref.headerSize,
1506
1516
  _ref$containerClassNa = _ref.containerClassName,
1507
- containerClassName = _ref$containerClassNa === void 0 ? "" : _ref$containerClassNa;
1517
+ containerClassName = _ref$containerClassNa === void 0 ? "" : _ref$containerClassNa,
1518
+ webhookHelpLink = _ref.webhookHelpLink,
1519
+ secretsHelpLink = _ref.secretsHelpLink;
1508
1520
  var _useState = useState(null),
1509
1521
  _useState2 = _slicedToArray(_useState, 2),
1510
1522
  editingWebhookId = _useState2[0],
@@ -1521,15 +1533,14 @@ var Webhooks = function Webhooks(_ref) {
1521
1533
  _useState8 = _slicedToArray(_useState7, 2),
1522
1534
  isDeleteAlertOpen = _useState8[0],
1523
1535
  setIsDeleteAlertOpen = _useState8[1];
1524
- var _useState9 = useState(1),
1525
- _useState10 = _slicedToArray(_useState9, 2),
1526
- pageNumber = _useState10[0],
1527
- setPageNumber = _useState10[1];
1528
1536
  var _useTranslation = useTranslation(),
1529
1537
  t = _useTranslation.t;
1538
+ var _useQueryParams = useQueryParams(),
1539
+ _useQueryParams$page = _useQueryParams.page,
1540
+ page = _useQueryParams$page === void 0 ? DEFAULT_PAGE_INDEX : _useQueryParams$page;
1530
1541
  var _useFetchWebhooks = useFetchWebhooks({
1531
1542
  entityId: entityId,
1532
- page: pageNumber,
1543
+ page: page,
1533
1544
  pageSize: DEFAULT_PAGE_SIZE
1534
1545
  }),
1535
1546
  isLoading = _useFetchWebhooks.isLoading,
@@ -1569,15 +1580,15 @@ var Webhooks = function Webhooks(_ref) {
1569
1580
  breadcrumbs: breadcrumbs,
1570
1581
  headerSize: headerSize,
1571
1582
  setIsAddWebhookPaneOpen: setIsAddWebhookPaneOpen,
1572
- title: title
1583
+ title: title,
1584
+ webhookHelpLink: webhookHelpLink
1573
1585
  }), isNotEmpty(webhooks) ? /*#__PURE__*/jsx(TableWrapper, {
1574
1586
  hasPagination: totalCount > DEFAULT_PAGE_SIZE,
1575
1587
  children: /*#__PURE__*/jsx(Table, {
1576
1588
  totalCount: totalCount,
1577
1589
  fixedHeight: true,
1578
- currentPageNumber: pageNumber,
1590
+ currentPageNumber: page,
1579
1591
  defaultPageSize: DEFAULT_PAGE_SIZE,
1580
- handlePageChange: setPageNumber,
1581
1592
  loading: isFetching,
1582
1593
  rowData: webhooks,
1583
1594
  columnData: buildColumns({
@@ -1591,7 +1602,7 @@ var Webhooks = function Webhooks(_ref) {
1591
1602
  children: /*#__PURE__*/jsx(NoData, {
1592
1603
  title: t("neetoWebhooks.webhook.empty"),
1593
1604
  helpText: /*#__PURE__*/jsx(Button, {
1594
- href: WEBHOOK_HELP_URL,
1605
+ href: webhookHelpLink,
1595
1606
  label: t("neetoWebhooks.webhook.emptyHelpText"),
1596
1607
  rel: "noreferrer",
1597
1608
  style: "link",
@@ -1609,6 +1620,8 @@ var Webhooks = function Webhooks(_ref) {
1609
1620
  entityId: entityId,
1610
1621
  entityType: entityType,
1611
1622
  onCreate: onCreate,
1623
+ secretsHelpLink: secretsHelpLink,
1624
+ webhookHelpLink: webhookHelpLink,
1612
1625
  webhooks: webhooks,
1613
1626
  isOpen: isAddWebhookPaneOpen,
1614
1627
  onClose: handlePaneClose
@@ -1644,12 +1657,15 @@ var NeetoWebhooks = function NeetoWebhooks(_ref) {
1644
1657
  onCreate = _ref.onCreate,
1645
1658
  onDelete = _ref.onDelete,
1646
1659
  headerSize = _ref.headerSize,
1660
+ _ref$helpLinkUrls = _ref.helpLinkUrls,
1661
+ helpLinkUrls = _ref$helpLinkUrls === void 0 ? {} : _ref$helpLinkUrls,
1647
1662
  containerClassName = _ref.containerClassName;
1648
1663
  var _useRouteMatch = useRouteMatch(),
1649
1664
  webhooksPath = _useRouteMatch.path,
1650
1665
  webhooksUrl = _useRouteMatch.url;
1651
1666
  var deliveriesPath = getDeliveriesPath(webhooksUrl);
1652
1667
  var deliveryDetailsPath = getDeliveryDetailsPath(deliveriesPath);
1668
+ var helpLinks = mergeRight(HELP_LINK_URLS, helpLinkUrls);
1653
1669
  return /*#__PURE__*/jsxs(Switch$1, {
1654
1670
  children: [/*#__PURE__*/jsx(Route, {
1655
1671
  exact: true,
@@ -1664,7 +1680,9 @@ var NeetoWebhooks = function NeetoWebhooks(_ref) {
1664
1680
  headerSize: headerSize,
1665
1681
  onCreate: onCreate,
1666
1682
  onDelete: onDelete,
1667
- title: title
1683
+ title: title,
1684
+ secretsHelpLink: helpLinks.secrets,
1685
+ webhookHelpLink: helpLinks.webhook
1668
1686
  });
1669
1687
  }
1670
1688
  }), /*#__PURE__*/jsx(Route, {
@@ -1673,17 +1691,19 @@ var NeetoWebhooks = function NeetoWebhooks(_ref) {
1673
1691
  render: function render() {
1674
1692
  return /*#__PURE__*/jsx(Deliveries$1, {
1675
1693
  breadcrumbs: breadcrumbs,
1676
- webhooksUrl: webhooksUrl
1694
+ webhooksUrl: webhooksUrl,
1695
+ helpLink: helpLinks.deliveries
1677
1696
  });
1678
1697
  }
1679
1698
  }), /*#__PURE__*/jsx(Route, {
1699
+ path: deliveriesPath,
1680
1700
  component: function component() {
1681
1701
  return /*#__PURE__*/jsx(Deliveries$1, {
1682
1702
  breadcrumbs: breadcrumbs,
1683
- webhooksUrl: webhooksUrl
1703
+ webhooksUrl: webhooksUrl,
1704
+ helpLink: helpLinks.deliveries
1684
1705
  });
1685
- },
1686
- path: deliveriesPath
1706
+ }
1687
1707
  })]
1688
1708
  });
1689
1709
  };