@bigbinary/neeto-integrations-frontend 1.2.1 → 1.3.0

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
@@ -2,10 +2,10 @@ import * as React from 'react';
2
2
  import React__default, { useContext, useState, useRef, useEffect } from 'react';
3
3
  import classnames from 'classnames';
4
4
  import { noop as noop$1, isNotEmpty } from '@bigbinary/neeto-commons-frontend/pure';
5
- import { Check, MenuVertical, MenuHorizontal, Copy } from '@bigbinary/neeto-icons';
6
- import { Dropdown, Typography, Tag, Button, Modal as Modal$1, Table, Alert, Callout, Spinner } from '@bigbinary/neetoui';
7
- import { isEmpty, isNotNil } from 'ramda';
8
- import { timeFormat, copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils';
5
+ import { joinHyphenCase, timeFormat, copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils';
6
+ import { Dropdown as Dropdown$1, Tag, Tooltip, Typography, Spinner, Button, Modal as Modal$1, Table, Alert, Callout } from '@bigbinary/neetoui';
7
+ import { isNotNil, isEmpty } from 'ramda';
8
+ import { MenuVertical, Warning, Check, MenuHorizontal, Copy } from '@bigbinary/neeto-icons';
9
9
  import { Form, Input } from '@bigbinary/neetoui/formik';
10
10
  import * as Yup from 'yup';
11
11
 
@@ -2782,7 +2782,7 @@ instance.hasLoadedNamespace;
2782
2782
  instance.loadNamespaces;
2783
2783
  instance.loadLanguages;
2784
2784
 
2785
- function _objectWithoutPropertiesLoose(source, excluded) {
2785
+ function _objectWithoutPropertiesLoose$1(source, excluded) {
2786
2786
  if (source == null) return {};
2787
2787
  var target = {};
2788
2788
  var sourceKeys = Object.keys(source);
@@ -2795,9 +2795,9 @@ function _objectWithoutPropertiesLoose(source, excluded) {
2795
2795
  return target;
2796
2796
  }
2797
2797
 
2798
- function _objectWithoutProperties(source, excluded) {
2798
+ function _objectWithoutProperties$1(source, excluded) {
2799
2799
  if (source == null) return {};
2800
- var target = _objectWithoutPropertiesLoose(source, excluded);
2800
+ var target = _objectWithoutPropertiesLoose$1(source, excluded);
2801
2801
  var key, i;
2802
2802
  if (Object.getOwnPropertySymbols) {
2803
2803
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -3181,7 +3181,7 @@ function hasLoadedNamespace(ns, i18n) {
3181
3181
  });
3182
3182
  }
3183
3183
 
3184
- var _excluded = ["format"],
3184
+ var _excluded$1 = ["format"],
3185
3185
  _excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
3186
3186
  function ownKeys$3(object, enumerableOnly) {
3187
3187
  var keys = Object.keys(object);
@@ -3265,7 +3265,7 @@ function nodesToString(children, i18nOptions) {
3265
3265
  warn("Trans: the passed in value is invalid - seems you passed in a null child.");
3266
3266
  } else if (_typeof$1(child) === 'object') {
3267
3267
  var format = child.format,
3268
- clone = _objectWithoutProperties(child, _excluded);
3268
+ clone = _objectWithoutProperties$1(child, _excluded$1);
3269
3269
  var keys = Object.keys(clone);
3270
3270
  if (keys.length === 1) {
3271
3271
  var value = format ? "".concat(keys[0], ", ").concat(format) : keys[0];
@@ -3401,7 +3401,7 @@ function Trans(_ref) {
3401
3401
  i18nFromProps = _ref.i18n,
3402
3402
  tFromProps = _ref.t,
3403
3403
  shouldUnescape = _ref.shouldUnescape,
3404
- additionalProps = _objectWithoutProperties(_ref, _excluded2);
3404
+ additionalProps = _objectWithoutProperties$1(_ref, _excluded2);
3405
3405
  var _ref2 = useContext(I18nContext) || {},
3406
3406
  i18nFromContext = _ref2.i18n,
3407
3407
  defaultNSFromContext = _ref2.defaultNS;
@@ -3612,7 +3612,15 @@ var common = {
3612
3612
  disconnect: "Disconnect",
3613
3613
  finish: "Finish",
3614
3614
  required: "Required",
3615
- "delete": "Delete"
3615
+ "delete": "Delete",
3616
+ tryAgain: "Try Again"
3617
+ };
3618
+ var tags = {
3619
+ connected: "Connected",
3620
+ expired: "Expired"
3621
+ };
3622
+ var tooltip = {
3623
+ integrationNotAvailable: "This integration is not available right now."
3616
3624
  };
3617
3625
  var demo = {
3618
3626
  title: "Check how it behaves",
@@ -3643,6 +3651,8 @@ var zapier = {
3643
3651
  };
3644
3652
  var en = {
3645
3653
  common: common,
3654
+ tags: tags,
3655
+ tooltip: tooltip,
3646
3656
  demo: demo,
3647
3657
  walkthroughModal: walkthroughModal,
3648
3658
  zapier: zapier
@@ -3662,66 +3672,234 @@ instance.use(initReactI18next).init({
3662
3672
  }
3663
3673
  });
3664
3674
 
3665
- var Menu$1 = Dropdown.Menu,
3666
- MenuItem$1 = Dropdown.MenuItem;
3675
+ function _extends$1() {
3676
+ _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
3677
+ for (var i = 1; i < arguments.length; i++) {
3678
+ var source = arguments[i];
3679
+ for (var key in source) {
3680
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3681
+ target[key] = source[key];
3682
+ }
3683
+ }
3684
+ }
3685
+ return target;
3686
+ };
3687
+ return _extends$1.apply(this, arguments);
3688
+ }
3689
+
3690
+ var renderDataCy = function renderDataCy(label, suffix) {
3691
+ return "".concat(label.replace(/\./g, "").toLowerCase(), "-").concat(suffix);
3692
+ };
3693
+
3694
+ var Menu$1 = Dropdown$1.Menu,
3695
+ MenuItem$1 = Dropdown$1.MenuItem;
3696
+ var Dropdown = function Dropdown(_ref) {
3697
+ var _ref$customDropDown = _ref.customDropDown,
3698
+ CustomDropdown = _ref$customDropDown === void 0 ? {} : _ref$customDropDown,
3699
+ _ref$handleManage = _ref.handleManage,
3700
+ handleManage = _ref$handleManage === void 0 ? noop$1 : _ref$handleManage,
3701
+ _ref$hideDisconnect = _ref.hideDisconnect,
3702
+ hideDisconnect = _ref$hideDisconnect === void 0 ? false : _ref$hideDisconnect,
3703
+ _ref$onDisconnect = _ref.onDisconnect,
3704
+ onDisconnect = _ref$onDisconnect === void 0 ? noop$1 : _ref$onDisconnect;
3705
+ var _useTranslation = useTranslation(),
3706
+ t = _useTranslation.t;
3707
+ var isManageable = isNotNil(handleManage);
3708
+ if (isNotNil(CustomDropdown)) {
3709
+ return CustomDropdown;
3710
+ }
3711
+ if (!isManageable && hideDisconnect) {
3712
+ return null;
3713
+ }
3714
+ return /*#__PURE__*/React__default.createElement(Dropdown$1, {
3715
+ buttonProps: {
3716
+ onClick: function onClick(e) {
3717
+ return e.stopPropagation();
3718
+ }
3719
+ },
3720
+ buttonStyle: "text",
3721
+ dropdownProps: {
3722
+ onClick: function onClick(e) {
3723
+ return e.stopPropagation();
3724
+ }
3725
+ },
3726
+ icon: MenuVertical
3727
+ }, /*#__PURE__*/React__default.createElement(Menu$1, null, isManageable && /*#__PURE__*/React__default.createElement(MenuItem$1.Button, {
3728
+ onClick: function onClick() {
3729
+ return handleManage();
3730
+ }
3731
+ }, t("common.manage")), !hideDisconnect && /*#__PURE__*/React__default.createElement(MenuItem$1.Button, {
3732
+ onClick: function onClick() {
3733
+ return onDisconnect();
3734
+ }
3735
+ }, t("common.disconnect"))));
3736
+ };
3737
+
3738
+ var Status = function Status(_ref) {
3739
+ var isExpired = _ref.isExpired;
3740
+ var _useTranslation = useTranslation(),
3741
+ t = _useTranslation.t;
3742
+ var tagProps = isExpired ? {
3743
+ icon: Warning,
3744
+ label: t("tags.expired"),
3745
+ style: "warning"
3746
+ } : {
3747
+ icon: Check,
3748
+ label: t("tags.connected"),
3749
+ style: "success"
3750
+ };
3751
+ return /*#__PURE__*/React__default.createElement(Tag, _extends$1({
3752
+ className: "flex-row-reverse"
3753
+ }, tagProps));
3754
+ };
3755
+
3756
+ function _objectWithoutPropertiesLoose(source, excluded) {
3757
+ if (source == null) return {};
3758
+ var target = {};
3759
+ var sourceKeys = Object.keys(source);
3760
+ var key, i;
3761
+ for (i = 0; i < sourceKeys.length; i++) {
3762
+ key = sourceKeys[i];
3763
+ if (excluded.indexOf(key) >= 0) continue;
3764
+ target[key] = source[key];
3765
+ }
3766
+ return target;
3767
+ }
3768
+
3769
+ function _objectWithoutProperties(source, excluded) {
3770
+ if (source == null) return {};
3771
+ var target = _objectWithoutPropertiesLoose(source, excluded);
3772
+ var key, i;
3773
+ if (Object.getOwnPropertySymbols) {
3774
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3775
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
3776
+ key = sourceSymbolKeys[i];
3777
+ if (excluded.indexOf(key) >= 0) continue;
3778
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3779
+ target[key] = source[key];
3780
+ }
3781
+ }
3782
+ return target;
3783
+ }
3784
+
3785
+ var _excluded = ["disabled", "children"];
3786
+ var TooltipWrapper = function TooltipWrapper(_ref) {
3787
+ var disabled = _ref.disabled,
3788
+ children = _ref.children,
3789
+ tooltipProps = _objectWithoutProperties(_ref, _excluded);
3790
+ return disabled ? /*#__PURE__*/React__default.createElement(Tooltip, tooltipProps, children) : children;
3791
+ };
3792
+
3667
3793
  var Card = function Card(_ref) {
3668
- var label = _ref.label,
3669
- description = _ref.description,
3670
- Icon = _ref.Icon,
3794
+ var Icon = _ref.icon,
3795
+ _ref$subIcons = _ref.subIcons,
3796
+ subIcons = _ref$subIcons === void 0 ? [] : _ref$subIcons,
3797
+ _ref$label = _ref.label,
3798
+ label = _ref$label === void 0 ? "" : _ref$label,
3799
+ _ref$description = _ref.description,
3800
+ description = _ref$description === void 0 ? "" : _ref$description,
3671
3801
  _ref$className = _ref.className,
3672
3802
  className = _ref$className === void 0 ? "" : _ref$className,
3673
- isConnected = _ref.isConnected,
3674
- _ref$isStatusLoading = _ref.isStatusLoading,
3675
- isStatusLoading = _ref$isStatusLoading === void 0 ? false : _ref$isStatusLoading,
3676
- _ref$customDropdown = _ref.customDropdown,
3677
- customDropdown = _ref$customDropdown === void 0 ? null : _ref$customDropdown,
3678
- _ref$onDisconnect = _ref.onDisconnect,
3679
- onDisconnect = _ref$onDisconnect === void 0 ? noop$1 : _ref$onDisconnect,
3680
3803
  _ref$onConnect = _ref.onConnect,
3681
3804
  onConnect = _ref$onConnect === void 0 ? noop$1 : _ref$onConnect,
3805
+ _ref$onDisconnect = _ref.onDisconnect,
3806
+ onDisconnect = _ref$onDisconnect === void 0 ? noop$1 : _ref$onDisconnect,
3682
3807
  _ref$onManage = _ref.onManage,
3683
- onManage = _ref$onManage === void 0 ? noop$1 : _ref$onManage;
3808
+ onManage = _ref$onManage === void 0 ? undefined : _ref$onManage,
3809
+ _ref$isLoading = _ref.isLoading,
3810
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
3811
+ _ref$isConnected = _ref.isConnected,
3812
+ isConnected = _ref$isConnected === void 0 ? false : _ref$isConnected,
3813
+ _ref$isFailed = _ref.isFailed,
3814
+ isFailed = _ref$isFailed === void 0 ? false : _ref$isFailed,
3815
+ _ref$isExpired = _ref.isExpired,
3816
+ isExpired = _ref$isExpired === void 0 ? false : _ref$isExpired,
3817
+ _ref$disabled = _ref.disabled,
3818
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
3819
+ _ref$hidden = _ref.hidden,
3820
+ hidden = _ref$hidden === void 0 ? false : _ref$hidden,
3821
+ _ref$hideDisconnect = _ref.hideDisconnect,
3822
+ hideDisconnect = _ref$hideDisconnect === void 0 ? false : _ref$hideDisconnect,
3823
+ _ref$onClick = _ref.onClick,
3824
+ onCardClick = _ref$onClick === void 0 ? undefined : _ref$onClick,
3825
+ _ref$tooltipProps = _ref.tooltipProps,
3826
+ tooltipProps = _ref$tooltipProps === void 0 ? {} : _ref$tooltipProps,
3827
+ _ref$customDropDown = _ref.customDropDown,
3828
+ customDropDown = _ref$customDropDown === void 0 ? null : _ref$customDropDown,
3829
+ children = _ref.children;
3684
3830
  var _useTranslation = useTranslation(),
3685
3831
  t = _useTranslation.t;
3686
- return /*#__PURE__*/React__default.createElement("div", {
3687
- className: classnames("outline-none neeto-ui-border-gray-300 neeto-ui-shadow-xs hover:neeto-ui-border-gray-500 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex flex-col border p-6 no-underline transition-colors", className)
3832
+ var cardProps = function cardProps() {
3833
+ return isConnected && isNotNil(onCardClick) ? {
3834
+ onClick: onCardClick
3835
+ } : {};
3836
+ };
3837
+ return /*#__PURE__*/React__default.createElement(TooltipWrapper, _extends$1({
3838
+ content: disabled && t("tooltip.integrationNotAvailable"),
3839
+ disabled: disabled,
3840
+ position: "top"
3841
+ }, tooltipProps), /*#__PURE__*/React__default.createElement("div", _extends$1({
3842
+ className: classnames("outline-none neeto-ui-border-gray-300 neeto-ui-shadow-xs hover:neeto-ui-border-gray-500 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex flex-col border p-6 no-underline transition-colors", {
3843
+ "hover:neeto-ui-bg-100 cursor-not-allowed opacity-50": disabled,
3844
+ "cursor-pointer": isConnected && isNotNil(onCardClick),
3845
+ hidden: hidden
3846
+ }, className)
3847
+ }, cardProps()), /*#__PURE__*/React__default.createElement("div", {
3848
+ className: "flex flex-grow justify-between",
3849
+ "data-cy": "integration-tabs"
3688
3850
  }, /*#__PURE__*/React__default.createElement("div", {
3689
- className: "h-full"
3851
+ className: "flex min-w-0 flex-col justify-end"
3690
3852
  }, /*#__PURE__*/React__default.createElement("div", {
3691
- className: "mb-4"
3692
- }, /*#__PURE__*/React__default.createElement(Icon, {
3693
- className: "neeto-ui-text-gray-700",
3853
+ className: "relative mb-4 flex h-8"
3854
+ }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
3855
+ className: "neeto-ui-text-gray-600",
3694
3856
  size: 32
3695
- })), /*#__PURE__*/React__default.createElement(Typography, {
3696
- className: "neeto-ui-text-gray-800 mb-2",
3857
+ })), /*#__PURE__*/React__default.createElement("div", {
3858
+ className: "my-auto"
3859
+ }, /*#__PURE__*/React__default.createElement(Typography, {
3860
+ className: "mb-2",
3861
+ "data-cy": renderDataCy(label, "integration-card-label"),
3697
3862
  style: "h4",
3698
3863
  weight: "semibold"
3699
3864
  }, label), /*#__PURE__*/React__default.createElement(Typography, {
3700
- className: "neeto-ui-text-gray-700",
3865
+ className: "break-words",
3866
+ "data-cy": "".concat(joinHyphenCase(label), "-integration-description"),
3701
3867
  style: "body2"
3702
- }, description)), /*#__PURE__*/React__default.createElement("div", {
3868
+ }, description), children)), isNotEmpty(subIcons) && /*#__PURE__*/React__default.createElement("div", {
3869
+ className: "flex h-24 flex-col gap-2"
3870
+ }, subIcons.map(function (Icon) {
3871
+ return /*#__PURE__*/React__default.createElement(Icon, {
3872
+ className: "neeto-ui-text-gray-600",
3873
+ key: Icon,
3874
+ size: 24
3875
+ });
3876
+ }))), /*#__PURE__*/React__default.createElement("div", {
3703
3877
  className: "neeto-ui-border-gray-300 mt-4 w-full border-t pt-2"
3704
- }, /*#__PURE__*/React__default.createElement("div", {
3878
+ }, isLoading ? /*#__PURE__*/React__default.createElement("div", {
3879
+ className: "mt-3 flex items-center justify-start"
3880
+ }, /*#__PURE__*/React__default.createElement(Spinner, null)) : /*#__PURE__*/React__default.createElement("div", {
3705
3881
  className: "flex h-8 items-center justify-between"
3706
- }, isConnected ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Tag, {
3707
- className: "flex-row-reverse",
3708
- icon: Check,
3709
- label: t("common.connected"),
3710
- size: "small",
3711
- style: "success"
3712
- }), customDropdown || /*#__PURE__*/React__default.createElement(Dropdown, {
3713
- buttonStyle: "text",
3714
- icon: MenuVertical
3715
- }, /*#__PURE__*/React__default.createElement(Menu$1, null, /*#__PURE__*/React__default.createElement(MenuItem$1.Button, {
3716
- onClick: onManage
3717
- }, t("common.manage")), /*#__PURE__*/React__default.createElement(MenuItem$1.Button, {
3718
- onClick: onDisconnect
3719
- }, t("common.disconnect"))))) : /*#__PURE__*/React__default.createElement(Button, {
3720
- label: !isStatusLoading && t("common.connect"),
3721
- loading: isStatusLoading,
3882
+ }, isConnected && /*#__PURE__*/React__default.createElement(Status, {
3883
+ isExpired: isExpired
3884
+ }), isFailed && /*#__PURE__*/React__default.createElement(Button, {
3885
+ className: "neeto-ui-text-warning-500",
3886
+ "data-cy": renderDataCy(label, "connect-button"),
3887
+ disabled: disabled || isLoading,
3888
+ label: t("common.tryAgain"),
3722
3889
  style: "link",
3723
3890
  onClick: onConnect
3724
- }))));
3891
+ }), !isConnected && !isFailed && /*#__PURE__*/React__default.createElement(Button, {
3892
+ "data-cy": renderDataCy(label, "connect-button"),
3893
+ disabled: disabled || isLoading,
3894
+ label: t("common.connect"),
3895
+ style: "link",
3896
+ onClick: onConnect
3897
+ }), (isConnected || isFailed) && /*#__PURE__*/React__default.createElement(Dropdown, {
3898
+ customDropDown: customDropDown,
3899
+ handleManage: onManage,
3900
+ hideDisconnect: hideDisconnect,
3901
+ onDisconnect: onDisconnect
3902
+ })))));
3725
3903
  };
3726
3904
 
3727
3905
  var Stepper = function Stepper(_ref) {
@@ -3790,21 +3968,6 @@ var Modal = function Modal(_ref) {
3790
3968
  }, children)));
3791
3969
  };
3792
3970
 
3793
- function _extends$1() {
3794
- _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
3795
- for (var i = 1; i < arguments.length; i++) {
3796
- var source = arguments[i];
3797
- for (var key in source) {
3798
- if (Object.prototype.hasOwnProperty.call(source, key)) {
3799
- target[key] = source[key];
3800
- }
3801
- }
3802
- }
3803
- return target;
3804
- };
3805
- return _extends$1.apply(this, arguments);
3806
- }
3807
-
3808
3971
  var propTypes = {exports: {}};
3809
3972
 
3810
3973
  /**
@@ -4197,14 +4360,14 @@ function _defineProperty(obj, key, value) {
4197
4360
  return obj;
4198
4361
  }
4199
4362
 
4200
- var Menu = Dropdown.Menu,
4201
- MenuItem = Dropdown.MenuItem;
4363
+ var Menu = Dropdown$1.Menu,
4364
+ MenuItem = Dropdown$1.MenuItem;
4202
4365
  var Actions = function Actions(_ref) {
4203
4366
  var apiKey = _ref.apiKey,
4204
4367
  setApiKeyToDelete = _ref.setApiKeyToDelete;
4205
4368
  var _useTranslation = useTranslation(),
4206
4369
  t = _useTranslation.t;
4207
- return /*#__PURE__*/React__default.createElement(Dropdown, {
4370
+ return /*#__PURE__*/React__default.createElement(Dropdown$1, {
4208
4371
  buttonStyle: "text",
4209
4372
  icon: MenuHorizontal,
4210
4373
  strategy: "fixed"