@bigbinary/neeto-integrations-frontend 2.10.2 → 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,23 +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/utils';
15
- import '@bigbinary/neeto-icons/misc';
15
+ import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
16
16
  import { Button, Typography } from '@bigbinary/neetoui';
17
17
  import { Form as Form$2, Input } from '@bigbinary/neetoui/formik';
18
18
  import 'ramda';
19
19
  import * as yup from 'yup';
20
20
  import classnames from 'classnames';
21
+ import { Check } from '@bigbinary/neeto-icons';
21
22
 
22
23
  function _arrayWithHoles(arr) {
23
24
  if (Array.isArray(arr)) return arr;
@@ -277,6 +278,7 @@ var Form = function Form(_ref) {
277
278
  i18nKey: "neetoIntegrations.daily.helpDoc",
278
279
  components: {
279
280
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
281
+ "data-cy": "api-key-help-doc-link",
280
282
  href: helpDocUrl,
281
283
  rel: "noreferrer",
282
284
  target: "_blank"
@@ -307,7 +309,8 @@ var Form = function Form(_ref) {
307
309
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
308
310
 
309
311
  var Manage$1 = function Manage$1(_ref) {
310
- var onDisconnect = _ref.onDisconnect;
312
+ var description = _ref.description,
313
+ onDisconnect = _ref.onDisconnect;
311
314
  var _useState = useState(false),
312
315
  _useState2 = _slicedToArray(_useState, 2),
313
316
  isDisconnectAlertOpen = _useState2[0],
@@ -317,7 +320,7 @@ var Manage$1 = function Manage$1(_ref) {
317
320
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
318
321
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
319
322
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
320
- isLoading = _useFetchDaily.isLoading;
323
+ isFetching = _useFetchDaily.isFetching;
321
324
  var _ref2 = metadata || {},
322
325
  _ref2$apiKey = _ref2.apiKey,
323
326
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -331,24 +334,33 @@ var Manage$1 = function Manage$1(_ref) {
331
334
  }),
332
335
  destroyIntegration = _useDestroyDaily.mutate,
333
336
  isDisconnecting = _useDestroyDaily.isLoading;
337
+ var isConnected = isPresent(apiKey);
334
338
  var handleDisconnect = function handleDisconnect() {
335
339
  return destroyIntegration("daily");
336
340
  };
337
- if (isLoading || isDisconnecting) {
338
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
339
- }
340
- if (isNotPresent(apiKey)) {
341
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
342
- }
341
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
343
342
  return /*#__PURE__*/React__default.createElement(Manage, {
343
+ isConnected: isConnected,
344
344
  isDisconnectAlertOpen: isDisconnectAlertOpen,
345
345
  isDisconnecting: isDisconnecting,
346
346
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
347
- description: t("neetoIntegrations.daily.yourApiKey", {
348
- apiKey: apiKey
347
+ Icon: Daily$1,
348
+ connectPath: buildUrl(window.location.pathname, {
349
+ connect: true
349
350
  }),
350
351
  integration: "daily",
351
- 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"),
352
364
  onClose: function onClose() {
353
365
  return setIsDisconnectAlertOpen(false);
354
366
  },
@@ -363,10 +375,14 @@ var Daily = function Daily(_ref) {
363
375
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
364
376
  _ref$videoUrl = _ref.videoUrl,
365
377
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
378
+ _ref$description = _ref.description,
379
+ description = _ref$description === void 0 ? "" : _ref$description,
366
380
  _ref$onConnect = _ref.onConnect,
367
381
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
368
382
  _ref$onDisconnect = _ref.onDisconnect,
369
383
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
384
+ var _useQueryParams = useQueryParams(),
385
+ connect = _useQueryParams.connect;
370
386
  var _useFetchDaily = useFetchDaily(),
371
387
  _useFetchDaily$data = _useFetchDaily.data,
372
388
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -375,8 +391,9 @@ var Daily = function Daily(_ref) {
375
391
  var _ref2 = metadata || {},
376
392
  _ref2$apiKey = _ref2.apiKey,
377
393
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
378
- if (isPresent(apiKey) && !isOnboarding) {
394
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
379
395
  return /*#__PURE__*/React__default.createElement(Manage$1, {
396
+ description: description,
380
397
  onDisconnect: onDisconnect
381
398
  });
382
399
  }
@@ -659,39 +676,110 @@ n(css,{});
659
676
 
660
677
  var Manage = withT(function (_ref) {
661
678
  var t = _ref.t,
662
- title = _ref.title,
663
- description = _ref.description,
664
- integration = _ref.integration,
665
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
666
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
667
- isDisconnecting = _ref.isDisconnecting,
668
- onDisconnect = _ref.onDisconnect,
669
- 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;
670
715
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
671
- 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"
672
724
  }, /*#__PURE__*/React__default.createElement("div", {
673
- className: "mt-10 w-full space-y-4"
725
+ className: "flex items-center space-x-4"
674
726
  }, /*#__PURE__*/React__default.createElement(Typography, {
675
727
  className: "neeto-ui-text-gray-800 mb-0.5",
676
- style: "h3",
728
+ style: "h2",
677
729
  weight: "semibold"
678
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
679
- 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",
680
736
  style: "body1",
681
737
  weight: "normal"
682
- }, description), /*#__PURE__*/React__default.createElement(Button, {
683
- 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, {
684
761
  style: "danger",
762
+ label: t("settings.integrations.common.disconnectIntegration", {
763
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
764
+ }),
685
765
  onClick: function onClick() {
686
766
  return setIsDisconnectAlertOpen(true);
687
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
+ })
688
776
  }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
689
777
  isDisconnecting: isDisconnecting,
690
778
  onClose: onClose,
691
779
  onDisconnect: onDisconnect,
692
780
  isOpen: isDisconnectAlertOpen,
693
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
694
- 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"))
695
783
  }));
696
784
  });
697
785
 
@@ -726,7 +814,11 @@ var useDestroyZoom = function useDestroyZoom(_ref) {
726
814
  };
727
815
 
728
816
  var Zoom = function Zoom(_ref) {
729
- 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,
730
822
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
731
823
  var _useTranslation = useTranslation(),
732
824
  t = _useTranslation.t;
@@ -750,24 +842,31 @@ var Zoom = function Zoom(_ref) {
750
842
  }),
751
843
  destroyIntegration = _useDestroyZoom.mutate,
752
844
  isDisconnecting = _useDestroyZoom.isLoading;
845
+ var isConnected = isPresent(email);
753
846
  var handleDisconnect = function handleDisconnect() {
754
847
  return destroyIntegration("zoom");
755
848
  };
756
- if (isLoading) {
757
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
758
- }
759
- if (isNotPresent(email)) {
760
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
761
- }
849
+ if (isLoading) return /*#__PURE__*/React__default.createElement(PageLoader, null);
762
850
  return /*#__PURE__*/React__default.createElement(Manage, {
851
+ connectUrl: connectUrl,
852
+ isConnected: isConnected,
763
853
  isDisconnectAlertOpen: isDisconnectAlertOpen,
764
854
  isDisconnecting: isDisconnecting,
765
855
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
766
- description: t("neetoIntegrations.zoom.account", {
767
- email: email
768
- }),
856
+ Icon: Zoom$1,
769
857
  integration: "zoom",
770
- 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"),
771
870
  onClose: function onClose() {
772
871
  return setIsDisconnectAlertOpen(false);
773
872
  },