@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/index.js CHANGED
@@ -6,21 +6,130 @@ export { default as WalkthroughModal } from '@bigbinary/neeto-molecules/Integrat
6
6
  import * as React from 'react';
7
7
  import React__default, { useState, useEffect, useRef } from 'react';
8
8
  import i18next, { t as t$1 } from 'i18next';
9
- import { isNotPresent, isPresent, noop, keysToSnakeCase, _findBy, isNotEmpty } from '@bigbinary/neeto-cist';
10
- import { useMutationWithInvalidation, withTitle, withT, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
9
+ import { humanize, noop, isPresent, keysToSnakeCase, _findBy, isNotEmpty } from '@bigbinary/neeto-cist';
10
+ import { withT, useMutationWithInvalidation, withTitle, useQueryParams, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
11
11
  import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
12
12
  import { useQuery } from 'react-query';
13
13
  import axios from 'axios';
14
- import { isPresent as isPresent$1 } from '@bigbinary/neeto-commons-frontend/pure';
15
- import { getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
16
- import { GoogleCalendar as GoogleCalendar$1, Google } from '@bigbinary/neeto-icons/misc';
17
- import { Button, Typography, Callout, Modal as Modal$1 } from '@bigbinary/neetoui';
18
- import { useTranslation, Trans } from 'react-i18next';
14
+ import { buildUrl, getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
15
+ import { Daily as Daily$1, GoogleCalendar as GoogleCalendar$1, Google, Zoom as Zoom$1 } from '@bigbinary/neeto-icons/misc';
16
+ import { Typography, Button, Callout, Modal as Modal$1 } from '@bigbinary/neetoui';
17
+ import { Trans, useTranslation } from 'react-i18next';
19
18
  import { Form as Form$2, Input, Select, ActionBlock } from '@bigbinary/neetoui/formik';
20
19
  import { prop, equals, isEmpty } from 'ramda';
21
20
  import * as yup from 'yup';
22
21
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
23
22
  import classnames from 'classnames';
23
+ import { Check } from '@bigbinary/neeto-icons';
24
+
25
+ var Manage$1 = withT(function (_ref) {
26
+ var t = _ref.t,
27
+ _ref$title = _ref.title,
28
+ title = _ref$title === void 0 ? "" : _ref$title,
29
+ _ref$description = _ref.description,
30
+ description = _ref$description === void 0 ? "" : _ref$description,
31
+ _ref$integration = _ref.integration,
32
+ integration = _ref$integration === void 0 ? "" : _ref$integration,
33
+ _ref$isDisconnectAler = _ref.isDisconnectAlertOpen,
34
+ isDisconnectAlertOpen = _ref$isDisconnectAler === void 0 ? false : _ref$isDisconnectAler,
35
+ _ref$setIsDisconnectA = _ref.setIsDisconnectAlertOpen,
36
+ setIsDisconnectAlertOpen = _ref$setIsDisconnectA === void 0 ? noop : _ref$setIsDisconnectA,
37
+ _ref$isDisconnecting = _ref.isDisconnecting,
38
+ isDisconnecting = _ref$isDisconnecting === void 0 ? false : _ref$isDisconnecting,
39
+ _ref$onDisconnect = _ref.onDisconnect,
40
+ onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect,
41
+ _ref$onClose = _ref.onClose,
42
+ onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
43
+ _ref$Icon = _ref.Icon,
44
+ Icon = _ref$Icon === void 0 ? null : _ref$Icon,
45
+ _ref$isConnected = _ref.isConnected,
46
+ isConnected = _ref$isConnected === void 0 ? false : _ref$isConnected,
47
+ _ref$connectPath = _ref.connectPath,
48
+ connectPath = _ref$connectPath === void 0 ? "" : _ref$connectPath,
49
+ _ref$connectUrl = _ref.connectUrl,
50
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
51
+ _ref$helpDocUrl = _ref.helpDocUrl,
52
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
53
+ _ref$managePath = _ref.managePath,
54
+ managePath = _ref$managePath === void 0 ? "" : _ref$managePath,
55
+ _ref$integrationName = _ref.integrationName,
56
+ integrationName = _ref$integrationName === void 0 ? "" : _ref$integrationName,
57
+ _ref$disconnectMessag = _ref.disconnectMessage,
58
+ disconnectMessage = _ref$disconnectMessag === void 0 ? "" : _ref$disconnectMessag,
59
+ _ref$isConnectDisable = _ref.isConnectDisabled,
60
+ isConnectDisabled = _ref$isConnectDisable === void 0 ? false : _ref$isConnectDisable,
61
+ _ref$connectTooltipPr = _ref.connectTooltipProps,
62
+ connectTooltipProps = _ref$connectTooltipPr === void 0 ? null : _ref$connectTooltipPr;
63
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
64
+ className: "mx-auto w-full max-w-3xl"
65
+ }, /*#__PURE__*/React__default.createElement("div", {
66
+ className: "neeto-ui-border-gray-300 neeto-ui-rounded-xl mt-10 w-full space-y-4 border p-6"
67
+ }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
68
+ className: "neeto-ui-text-gray-600",
69
+ size: 60
70
+ }), /*#__PURE__*/React__default.createElement("div", {
71
+ className: "space-y-2"
72
+ }, /*#__PURE__*/React__default.createElement("div", {
73
+ className: "flex items-center space-x-4"
74
+ }, /*#__PURE__*/React__default.createElement(Typography, {
75
+ className: "neeto-ui-text-gray-800 mb-0.5",
76
+ style: "h2",
77
+ weight: "semibold"
78
+ }, title), isConnected && /*#__PURE__*/React__default.createElement("div", {
79
+ className: "neeto-ui-bg-success-500 neeto-ui-text-white neeto-ui-rounded-full flex items-center justify-center p-1"
80
+ }, /*#__PURE__*/React__default.createElement(Check, {
81
+ size: 24
82
+ }))), /*#__PURE__*/React__default.createElement(Typography, {
83
+ className: "neeto-ui-text-gray-800 break-all",
84
+ style: "body1",
85
+ weight: "normal"
86
+ }, description), helpDocUrl && /*#__PURE__*/React__default.createElement(Typography, {
87
+ className: "neeto-ui-text-gray-800 break-all",
88
+ style: "body2",
89
+ weight: "normal"
90
+ }, /*#__PURE__*/React__default.createElement(Trans, {
91
+ i18nKey: "settings.integrations.common.helpDocUrl",
92
+ components: {
93
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
94
+ href: helpDocUrl,
95
+ style: "link"
96
+ })
97
+ },
98
+ values: {
99
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
100
+ }
101
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
102
+ className: "space-x-2"
103
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
104
+ to: managePath,
105
+ label: t("settings.integrations.common.manageIntegration", {
106
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
107
+ })
108
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
109
+ style: "danger",
110
+ label: t("settings.integrations.common.disconnectIntegration", {
111
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
112
+ }),
113
+ onClick: function onClick() {
114
+ return setIsDisconnectAlertOpen(true);
115
+ }
116
+ })) : /*#__PURE__*/React__default.createElement(Button, {
117
+ disabled: isConnectDisabled,
118
+ href: connectUrl,
119
+ to: connectPath,
120
+ tooltipProps: connectTooltipProps,
121
+ label: t("settings.integrations.common.connectIntegration", {
122
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
123
+ })
124
+ }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
125
+ isDisconnecting: isDisconnecting,
126
+ onClose: onClose,
127
+ onDisconnect: onDisconnect,
128
+ isOpen: isDisconnectAlertOpen,
129
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
130
+ message: disconnectMessage !== null && disconnectMessage !== void 0 ? disconnectMessage : t("settings.integrations.".concat(integration, ".disconnect.message"))
131
+ }));
132
+ });
24
133
 
25
134
  function _typeof(obj) {
26
135
  "@babel/helpers - typeof";
@@ -281,6 +390,7 @@ var Form = function Form(_ref) {
281
390
  i18nKey: "neetoIntegrations.daily.helpDoc",
282
391
  components: {
283
392
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
393
+ "data-cy": "api-key-help-doc-link",
284
394
  href: helpDocUrl,
285
395
  rel: "noreferrer",
286
396
  target: "_blank"
@@ -310,46 +420,9 @@ var Form = function Form(_ref) {
310
420
  };
311
421
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
312
422
 
313
- var Manage$1 = withT(function (_ref) {
314
- var t = _ref.t,
315
- title = _ref.title,
316
- description = _ref.description,
317
- integration = _ref.integration,
318
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
319
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
320
- isDisconnecting = _ref.isDisconnecting,
321
- onDisconnect = _ref.onDisconnect,
322
- onClose = _ref.onClose;
323
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
324
- className: "mx-auto w-full max-w-md"
325
- }, /*#__PURE__*/React__default.createElement("div", {
326
- className: "mt-10 w-full space-y-4"
327
- }, /*#__PURE__*/React__default.createElement(Typography, {
328
- className: "neeto-ui-text-gray-800 mb-0.5",
329
- style: "h3",
330
- weight: "semibold"
331
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
332
- className: "neeto-ui-text-gray-600 break-all",
333
- style: "body1",
334
- weight: "normal"
335
- }, description), /*#__PURE__*/React__default.createElement(Button, {
336
- label: t("neetoIntegrations.common.disconnect"),
337
- style: "danger",
338
- onClick: function onClick() {
339
- return setIsDisconnectAlertOpen(true);
340
- }
341
- }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
342
- isDisconnecting: isDisconnecting,
343
- onClose: onClose,
344
- onDisconnect: onDisconnect,
345
- isOpen: isDisconnectAlertOpen,
346
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
347
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
348
- }));
349
- });
350
-
351
423
  var Manage = function Manage(_ref) {
352
- var onDisconnect = _ref.onDisconnect;
424
+ var description = _ref.description,
425
+ onDisconnect = _ref.onDisconnect;
353
426
  var _useState = useState(false),
354
427
  _useState2 = _slicedToArray(_useState, 2),
355
428
  isDisconnectAlertOpen = _useState2[0],
@@ -359,7 +432,7 @@ var Manage = function Manage(_ref) {
359
432
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
360
433
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
361
434
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
362
- isLoading = _useFetchDaily.isLoading;
435
+ isFetching = _useFetchDaily.isFetching;
363
436
  var _ref2 = metadata || {},
364
437
  _ref2$apiKey = _ref2.apiKey,
365
438
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -373,24 +446,33 @@ var Manage = function Manage(_ref) {
373
446
  }),
374
447
  destroyIntegration = _useDestroyDaily.mutate,
375
448
  isDisconnecting = _useDestroyDaily.isLoading;
449
+ var isConnected = isPresent(apiKey);
376
450
  var handleDisconnect = function handleDisconnect() {
377
451
  return destroyIntegration("daily");
378
452
  };
379
- if (isLoading || isDisconnecting) {
380
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
381
- }
382
- if (isNotPresent(apiKey)) {
383
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
384
- }
453
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
385
454
  return /*#__PURE__*/React__default.createElement(Manage$1, {
455
+ isConnected: isConnected,
386
456
  isDisconnectAlertOpen: isDisconnectAlertOpen,
387
457
  isDisconnecting: isDisconnecting,
388
458
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
389
- description: t("neetoIntegrations.daily.yourApiKey", {
390
- apiKey: apiKey
459
+ Icon: Daily$1,
460
+ connectPath: buildUrl(window.location.pathname, {
461
+ connect: true
391
462
  }),
392
463
  integration: "daily",
393
- title: t("neetoIntegrations.daily.connected"),
464
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
465
+ components: {
466
+ underline: /*#__PURE__*/React__default.createElement("u", {
467
+ className: "font-medium"
468
+ })
469
+ },
470
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
471
+ values: {
472
+ apiKey: apiKey
473
+ }
474
+ }) : description,
475
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
394
476
  onClose: function onClose() {
395
477
  return setIsDisconnectAlertOpen(false);
396
478
  },
@@ -405,10 +487,14 @@ var Daily = function Daily(_ref) {
405
487
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
406
488
  _ref$videoUrl = _ref.videoUrl,
407
489
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
490
+ _ref$description = _ref.description,
491
+ description = _ref$description === void 0 ? "" : _ref$description,
408
492
  _ref$onConnect = _ref.onConnect,
409
493
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
410
494
  _ref$onDisconnect = _ref.onDisconnect,
411
495
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
496
+ var _useQueryParams = useQueryParams(),
497
+ connect = _useQueryParams.connect;
412
498
  var _useFetchDaily = useFetchDaily(),
413
499
  _useFetchDaily$data = _useFetchDaily.data,
414
500
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -417,8 +503,9 @@ var Daily = function Daily(_ref) {
417
503
  var _ref2 = metadata || {},
418
504
  _ref2$apiKey = _ref2.apiKey,
419
505
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
420
- if (isPresent(apiKey) && !isOnboarding) {
506
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
421
507
  return /*#__PURE__*/React__default.createElement(Manage, {
508
+ description: description,
422
509
  onDisconnect: onDisconnect
423
510
  });
424
511
  }
@@ -477,7 +564,7 @@ var GoogleCalendar = function GoogleCalendar(_ref) {
477
564
  setSteps = _useState2[1];
478
565
  var _getQueryParams = getQueryParams(),
479
566
  status = _getQueryParams.status;
480
- var activeTab = isPresent$1(status) ? STEPS.finish : STEPS.connect;
567
+ var activeTab = isPresent(status) ? STEPS.finish : STEPS.connect;
481
568
  useEffect(function () {
482
569
  setSteps(function () {
483
570
  var stepsClone = _toConsumableArray(steps);
@@ -497,15 +584,15 @@ var GoogleCalendar = function GoogleCalendar(_ref) {
497
584
  isOpen: true,
498
585
  onClose: handleClose
499
586
  }, activeTab === STEPS.connect && /*#__PURE__*/React__default.createElement("div", {
500
- className: "mx-auto w-full max-w-2xl"
587
+ className: "w-full max-w-2xl mx-auto"
501
588
  }, /*#__PURE__*/React__default.createElement(GoogleCalendar$1, {
502
589
  size: 42
503
590
  }), /*#__PURE__*/React__default.createElement(Typography, {
504
- className: "neeto-ui-text-gray-800 mb-3 mt-6",
591
+ className: "mt-6 mb-3 neeto-ui-text-gray-800",
505
592
  style: "h2",
506
593
  weight: "semibold"
507
594
  }, t("neetoIntegrations.google.connect.title")), /*#__PURE__*/React__default.createElement("div", {
508
- className: "flex w-full flex-col items-start pt-2"
595
+ className: "flex flex-col items-start w-full pt-2"
509
596
  }, /*#__PURE__*/React__default.createElement(Callout, {
510
597
  className: "block leading-5"
511
598
  }, /*#__PURE__*/React__default.createElement(Trans, {
@@ -517,7 +604,7 @@ var GoogleCalendar = function GoogleCalendar(_ref) {
517
604
  selectCheckbox: t("neetoIntegrations.google.connect.selectCheckbox")
518
605
  }
519
606
  })), permissionImage && /*#__PURE__*/React__default.createElement("div", {
520
- className: "neeto-ui-border-gray-300 my-4 border"
607
+ className: "my-4 border neeto-ui-border-gray-300"
521
608
  }, /*#__PURE__*/React__default.createElement("img", {
522
609
  src: permissionImage
523
610
  }))), /*#__PURE__*/React__default.createElement(Button, {
@@ -822,7 +909,11 @@ var useDestroyZoom = function useDestroyZoom(_ref) {
822
909
  };
823
910
 
824
911
  var Zoom = function Zoom(_ref) {
825
- var _ref$onDisconnect = _ref.onDisconnect,
912
+ var _ref$connectUrl = _ref.connectUrl,
913
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
914
+ _ref$description = _ref.description,
915
+ description = _ref$description === void 0 ? "" : _ref$description,
916
+ _ref$onDisconnect = _ref.onDisconnect,
826
917
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
827
918
  var _useTranslation = useTranslation(),
828
919
  t = _useTranslation.t;
@@ -846,24 +937,31 @@ var Zoom = function Zoom(_ref) {
846
937
  }),
847
938
  destroyIntegration = _useDestroyZoom.mutate,
848
939
  isDisconnecting = _useDestroyZoom.isLoading;
940
+ var isConnected = isPresent(email);
849
941
  var handleDisconnect = function handleDisconnect() {
850
942
  return destroyIntegration("zoom");
851
943
  };
852
- if (isLoading) {
853
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
854
- }
855
- if (isNotPresent(email)) {
856
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
857
- }
944
+ if (isLoading) return /*#__PURE__*/React__default.createElement(PageLoader, null);
858
945
  return /*#__PURE__*/React__default.createElement(Manage$1, {
946
+ connectUrl: connectUrl,
947
+ isConnected: isConnected,
859
948
  isDisconnectAlertOpen: isDisconnectAlertOpen,
860
949
  isDisconnecting: isDisconnecting,
861
950
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
862
- description: t("neetoIntegrations.zoom.account", {
863
- email: email
864
- }),
951
+ Icon: Zoom$1,
865
952
  integration: "zoom",
866
- title: t("neetoIntegrations.zoom.connected"),
953
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
954
+ components: {
955
+ underline: /*#__PURE__*/React__default.createElement("u", {
956
+ className: "font-medium"
957
+ })
958
+ },
959
+ i18nKey: "neetoIntegrations.zoom.account",
960
+ values: {
961
+ email: email
962
+ }
963
+ }) : description,
964
+ title: isConnected ? t("neetoIntegrations.zoom.connected") : t("neetoIntegrations.zoom.connect"),
867
965
  onClose: function onClose() {
868
966
  return setIsDisconnectAlertOpen(false);
869
967
  },
@@ -1253,5 +1351,5 @@ function n(n, r) {
1253
1351
  var css = ".intrinsic-container{height:0;overflow:hidden;position:relative}.intrinsic-container-16x9{padding-bottom:56.25%}.intrinsic-container-4x3{padding-bottom:75%}.intrinsic-container iframe{height:100%;left:0;position:absolute;top:0;width:100%}";
1254
1352
  n(css,{});
1255
1353
 
1256
- export { Connect, index as Daily, Demo, Finish, GoogleCalendar, Modal, Twilio, Zoom };
1354
+ export { Connect, index as Daily, Demo, Finish, GoogleCalendar, Manage$1 as Manage, Modal, Twilio, Zoom };
1257
1355
  //# sourceMappingURL=index.js.map