@bigbinary/neeto-integrations-frontend 2.10.1 → 2.10.3

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/Zoom.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useState } from 'react';
3
- import { isNotPresent, isPresent, noop, isNotEmpty } from '@bigbinary/neeto-cist';
3
+ import { isPresent, noop, isNotEmpty, humanize } from '@bigbinary/neeto-cist';
4
+ import { Daily as Daily$1, Zoom as Zoom$1 } from '@bigbinary/neeto-icons/misc';
4
5
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
5
6
  import { useTranslation, Trans } from 'react-i18next';
6
7
  import '@bigbinary/neeto-molecules/IntegrationCard';
7
8
  import DisconnectAlert from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
8
9
  import WalkthroughModal from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
9
10
  import i18next, { t as t$1 } from 'i18next';
10
- import { useMutationWithInvalidation, withTitle, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
11
+ import { useMutationWithInvalidation, withTitle, useQueryParams, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
11
12
  import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
12
13
  import { useQuery } from 'react-query';
13
14
  import axios from 'axios';
14
- import '@bigbinary/neeto-commons-frontend/pure';
15
- import '@bigbinary/neeto-commons-frontend/utils';
16
- import '@bigbinary/neeto-icons/misc';
15
+ import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
17
16
  import { Button, Typography } from '@bigbinary/neetoui';
18
17
  import { Form as Form$2, Input } from '@bigbinary/neetoui/formik';
19
18
  import 'ramda';
20
19
  import * as yup from 'yup';
21
20
  import classnames from 'classnames';
21
+ import { Check } from '@bigbinary/neeto-icons';
22
22
 
23
23
  function _arrayWithHoles(arr) {
24
24
  if (Array.isArray(arr)) return arr;
@@ -278,6 +278,7 @@ var Form = function Form(_ref) {
278
278
  i18nKey: "neetoIntegrations.daily.helpDoc",
279
279
  components: {
280
280
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
281
+ "data-cy": "api-key-help-doc-link",
281
282
  href: helpDocUrl,
282
283
  rel: "noreferrer",
283
284
  target: "_blank"
@@ -308,7 +309,8 @@ var Form = function Form(_ref) {
308
309
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
309
310
 
310
311
  var Manage$1 = function Manage$1(_ref) {
311
- var onDisconnect = _ref.onDisconnect;
312
+ var description = _ref.description,
313
+ onDisconnect = _ref.onDisconnect;
312
314
  var _useState = useState(false),
313
315
  _useState2 = _slicedToArray(_useState, 2),
314
316
  isDisconnectAlertOpen = _useState2[0],
@@ -318,7 +320,7 @@ var Manage$1 = function Manage$1(_ref) {
318
320
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
319
321
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
320
322
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
321
- isLoading = _useFetchDaily.isLoading;
323
+ isFetching = _useFetchDaily.isFetching;
322
324
  var _ref2 = metadata || {},
323
325
  _ref2$apiKey = _ref2.apiKey,
324
326
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -332,24 +334,33 @@ var Manage$1 = function Manage$1(_ref) {
332
334
  }),
333
335
  destroyIntegration = _useDestroyDaily.mutate,
334
336
  isDisconnecting = _useDestroyDaily.isLoading;
337
+ var isConnected = isPresent(apiKey);
335
338
  var handleDisconnect = function handleDisconnect() {
336
339
  return destroyIntegration("daily");
337
340
  };
338
- if (isLoading || isDisconnecting) {
339
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
340
- }
341
- if (isNotPresent(apiKey)) {
342
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
343
- }
341
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
344
342
  return /*#__PURE__*/React__default.createElement(Manage, {
343
+ isConnected: isConnected,
345
344
  isDisconnectAlertOpen: isDisconnectAlertOpen,
346
345
  isDisconnecting: isDisconnecting,
347
346
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
348
- description: t("neetoIntegrations.daily.yourApiKey", {
349
- apiKey: apiKey
347
+ Icon: Daily$1,
348
+ connectPath: buildUrl(window.location.pathname, {
349
+ connect: true
350
350
  }),
351
351
  integration: "daily",
352
- title: t("neetoIntegrations.daily.connected"),
352
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
353
+ components: {
354
+ underline: /*#__PURE__*/React__default.createElement("u", {
355
+ className: "font-medium"
356
+ })
357
+ },
358
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
359
+ values: {
360
+ apiKey: apiKey
361
+ }
362
+ }) : description,
363
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
353
364
  onClose: function onClose() {
354
365
  return setIsDisconnectAlertOpen(false);
355
366
  },
@@ -364,10 +375,14 @@ var Daily = function Daily(_ref) {
364
375
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
365
376
  _ref$videoUrl = _ref.videoUrl,
366
377
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
378
+ _ref$description = _ref.description,
379
+ description = _ref$description === void 0 ? "" : _ref$description,
367
380
  _ref$onConnect = _ref.onConnect,
368
381
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
369
382
  _ref$onDisconnect = _ref.onDisconnect,
370
383
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
384
+ var _useQueryParams = useQueryParams(),
385
+ connect = _useQueryParams.connect;
371
386
  var _useFetchDaily = useFetchDaily(),
372
387
  _useFetchDaily$data = _useFetchDaily.data,
373
388
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -376,8 +391,9 @@ var Daily = function Daily(_ref) {
376
391
  var _ref2 = metadata || {},
377
392
  _ref2$apiKey = _ref2.apiKey,
378
393
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
379
- if (isPresent(apiKey) && !isOnboarding) {
394
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
380
395
  return /*#__PURE__*/React__default.createElement(Manage$1, {
396
+ description: description,
381
397
  onDisconnect: onDisconnect
382
398
  });
383
399
  }
@@ -660,39 +676,110 @@ n(css,{});
660
676
 
661
677
  var Manage = withT(function (_ref) {
662
678
  var t = _ref.t,
663
- title = _ref.title,
664
- description = _ref.description,
665
- integration = _ref.integration,
666
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
667
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
668
- isDisconnecting = _ref.isDisconnecting,
669
- onDisconnect = _ref.onDisconnect,
670
- onClose = _ref.onClose;
679
+ _ref$title = _ref.title,
680
+ title = _ref$title === void 0 ? "" : _ref$title,
681
+ _ref$description = _ref.description,
682
+ description = _ref$description === void 0 ? "" : _ref$description,
683
+ _ref$integration = _ref.integration,
684
+ integration = _ref$integration === void 0 ? "" : _ref$integration,
685
+ _ref$isDisconnectAler = _ref.isDisconnectAlertOpen,
686
+ isDisconnectAlertOpen = _ref$isDisconnectAler === void 0 ? false : _ref$isDisconnectAler,
687
+ _ref$setIsDisconnectA = _ref.setIsDisconnectAlertOpen,
688
+ setIsDisconnectAlertOpen = _ref$setIsDisconnectA === void 0 ? noop : _ref$setIsDisconnectA,
689
+ _ref$isDisconnecting = _ref.isDisconnecting,
690
+ isDisconnecting = _ref$isDisconnecting === void 0 ? false : _ref$isDisconnecting,
691
+ _ref$onDisconnect = _ref.onDisconnect,
692
+ onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect,
693
+ _ref$onClose = _ref.onClose,
694
+ onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
695
+ _ref$Icon = _ref.Icon,
696
+ Icon = _ref$Icon === void 0 ? null : _ref$Icon,
697
+ _ref$isConnected = _ref.isConnected,
698
+ isConnected = _ref$isConnected === void 0 ? false : _ref$isConnected,
699
+ _ref$connectPath = _ref.connectPath,
700
+ connectPath = _ref$connectPath === void 0 ? "" : _ref$connectPath,
701
+ _ref$connectUrl = _ref.connectUrl,
702
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
703
+ _ref$helpDocUrl = _ref.helpDocUrl,
704
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
705
+ _ref$managePath = _ref.managePath,
706
+ managePath = _ref$managePath === void 0 ? "" : _ref$managePath,
707
+ _ref$integrationName = _ref.integrationName,
708
+ integrationName = _ref$integrationName === void 0 ? "" : _ref$integrationName,
709
+ _ref$disconnectMessag = _ref.disconnectMessage,
710
+ disconnectMessage = _ref$disconnectMessag === void 0 ? "" : _ref$disconnectMessag,
711
+ _ref$isConnectDisable = _ref.isConnectDisabled,
712
+ isConnectDisabled = _ref$isConnectDisable === void 0 ? false : _ref$isConnectDisable,
713
+ _ref$connectTooltipPr = _ref.connectTooltipProps,
714
+ connectTooltipProps = _ref$connectTooltipPr === void 0 ? null : _ref$connectTooltipPr;
671
715
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
672
- className: "mx-auto w-full max-w-md"
716
+ className: "mx-auto w-full max-w-3xl"
717
+ }, /*#__PURE__*/React__default.createElement("div", {
718
+ className: "neeto-ui-border-gray-300 neeto-ui-rounded-xl mt-10 w-full space-y-4 border p-6"
719
+ }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
720
+ className: "neeto-ui-text-gray-600",
721
+ size: 60
722
+ }), /*#__PURE__*/React__default.createElement("div", {
723
+ className: "space-y-2"
673
724
  }, /*#__PURE__*/React__default.createElement("div", {
674
- className: "mt-10 w-full space-y-4"
725
+ className: "flex items-center space-x-4"
675
726
  }, /*#__PURE__*/React__default.createElement(Typography, {
676
727
  className: "neeto-ui-text-gray-800 mb-0.5",
677
- style: "h3",
728
+ style: "h2",
678
729
  weight: "semibold"
679
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
680
- className: "neeto-ui-text-gray-600 break-all",
730
+ }, title), isConnected && /*#__PURE__*/React__default.createElement("div", {
731
+ className: "neeto-ui-bg-success-500 neeto-ui-text-white neeto-ui-rounded-full flex items-center justify-center p-1"
732
+ }, /*#__PURE__*/React__default.createElement(Check, {
733
+ size: 24
734
+ }))), /*#__PURE__*/React__default.createElement(Typography, {
735
+ className: "neeto-ui-text-gray-800 break-all",
681
736
  style: "body1",
682
737
  weight: "normal"
683
- }, description), /*#__PURE__*/React__default.createElement(Button, {
684
- label: t("neetoIntegrations.common.disconnect"),
738
+ }, description), helpDocUrl && /*#__PURE__*/React__default.createElement(Typography, {
739
+ className: "neeto-ui-text-gray-800 break-all",
740
+ style: "body2",
741
+ weight: "normal"
742
+ }, /*#__PURE__*/React__default.createElement(Trans, {
743
+ i18nKey: "settings.integrations.common.helpDocUrl",
744
+ components: {
745
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
746
+ href: helpDocUrl,
747
+ style: "link"
748
+ })
749
+ },
750
+ values: {
751
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
752
+ }
753
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
754
+ className: "space-x-2"
755
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
756
+ to: managePath,
757
+ label: t("settings.integrations.common.manageIntegration", {
758
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
759
+ })
760
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
685
761
  style: "danger",
762
+ label: t("settings.integrations.common.disconnectIntegration", {
763
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
764
+ }),
686
765
  onClick: function onClick() {
687
766
  return setIsDisconnectAlertOpen(true);
688
767
  }
768
+ })) : /*#__PURE__*/React__default.createElement(Button, {
769
+ disabled: isConnectDisabled,
770
+ href: connectUrl,
771
+ to: connectPath,
772
+ tooltipProps: connectTooltipProps,
773
+ label: t("settings.integrations.common.connectIntegration", {
774
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
775
+ })
689
776
  }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
690
777
  isDisconnecting: isDisconnecting,
691
778
  onClose: onClose,
692
779
  onDisconnect: onDisconnect,
693
780
  isOpen: isDisconnectAlertOpen,
694
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
695
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
781
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
782
+ message: disconnectMessage !== null && disconnectMessage !== void 0 ? disconnectMessage : t("settings.integrations.".concat(integration, ".disconnect.message"))
696
783
  }));
697
784
  });
698
785
 
@@ -727,7 +814,11 @@ var useDestroyZoom = function useDestroyZoom(_ref) {
727
814
  };
728
815
 
729
816
  var Zoom = function Zoom(_ref) {
730
- var _ref$onDisconnect = _ref.onDisconnect,
817
+ var _ref$connectUrl = _ref.connectUrl,
818
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
819
+ _ref$description = _ref.description,
820
+ description = _ref$description === void 0 ? "" : _ref$description,
821
+ _ref$onDisconnect = _ref.onDisconnect,
731
822
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
732
823
  var _useTranslation = useTranslation(),
733
824
  t = _useTranslation.t;
@@ -751,24 +842,31 @@ var Zoom = function Zoom(_ref) {
751
842
  }),
752
843
  destroyIntegration = _useDestroyZoom.mutate,
753
844
  isDisconnecting = _useDestroyZoom.isLoading;
845
+ var isConnected = isPresent(email);
754
846
  var handleDisconnect = function handleDisconnect() {
755
847
  return destroyIntegration("zoom");
756
848
  };
757
- if (isLoading) {
758
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
759
- }
760
- if (isNotPresent(email)) {
761
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
762
- }
849
+ if (isLoading) return /*#__PURE__*/React__default.createElement(PageLoader, null);
763
850
  return /*#__PURE__*/React__default.createElement(Manage, {
851
+ connectUrl: connectUrl,
852
+ isConnected: isConnected,
764
853
  isDisconnectAlertOpen: isDisconnectAlertOpen,
765
854
  isDisconnecting: isDisconnecting,
766
855
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
767
- description: t("neetoIntegrations.zoom.account", {
768
- email: email
769
- }),
856
+ Icon: Zoom$1,
770
857
  integration: "zoom",
771
- title: t("neetoIntegrations.zoom.connected"),
858
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
859
+ components: {
860
+ underline: /*#__PURE__*/React__default.createElement("u", {
861
+ className: "font-medium"
862
+ })
863
+ },
864
+ i18nKey: "neetoIntegrations.zoom.account",
865
+ values: {
866
+ email: email
867
+ }
868
+ }) : description,
869
+ title: isConnected ? t("neetoIntegrations.zoom.connected") : t("neetoIntegrations.zoom.connect"),
772
870
  onClose: function onClose() {
773
871
  return setIsDisconnectAlertOpen(false);
774
872
  },