@bigbinary/neeto-integrations-frontend 2.10.2 → 2.10.4

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,20 +6,131 @@ 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 { getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
15
- import { GoogleCalendar as GoogleCalendar$1, Google } from '@bigbinary/neeto-icons/misc';
16
- import { Button, Typography, Callout, Modal as Modal$1 } from '@bigbinary/neetoui';
17
- 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';
18
18
  import { Form as Form$2, Input, Select, ActionBlock } from '@bigbinary/neetoui/formik';
19
19
  import { prop, equals, isEmpty } from 'ramda';
20
20
  import * as yup from 'yup';
21
21
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
22
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 ? undefined : _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: "neetoIntegrations.common.helpDocUrl",
92
+ components: {
93
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
94
+ href: helpDocUrl,
95
+ style: "link",
96
+ target: "_blank"
97
+ })
98
+ },
99
+ values: {
100
+ integration: integrationName || humanize(integration)
101
+ }
102
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
103
+ className: "space-x-2"
104
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
105
+ to: managePath,
106
+ label: t("neetoIntegrations.common.manageIntegration", {
107
+ integration: integrationName || humanize(integration)
108
+ })
109
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
110
+ style: "secondary",
111
+ label: t("neetoIntegrations.common.disconnectIntegration", {
112
+ integration: integrationName || humanize(integration)
113
+ }),
114
+ onClick: function onClick() {
115
+ return setIsDisconnectAlertOpen(true);
116
+ }
117
+ })) : /*#__PURE__*/React__default.createElement(Button, {
118
+ disabled: isConnectDisabled,
119
+ href: connectUrl,
120
+ to: connectPath,
121
+ tooltipProps: connectTooltipProps,
122
+ label: t("neetoIntegrations.common.connectIntegration", {
123
+ integration: integrationName || humanize(integration)
124
+ })
125
+ }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
126
+ isDisconnecting: isDisconnecting,
127
+ onClose: onClose,
128
+ onDisconnect: onDisconnect,
129
+ isOpen: isDisconnectAlertOpen,
130
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
131
+ message: disconnectMessage || t("settings.integrations.".concat(integration, ".disconnect.message"))
132
+ }));
133
+ });
23
134
 
24
135
  function _typeof(obj) {
25
136
  "@babel/helpers - typeof";
@@ -280,6 +391,7 @@ var Form = function Form(_ref) {
280
391
  i18nKey: "neetoIntegrations.daily.helpDoc",
281
392
  components: {
282
393
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
394
+ "data-cy": "api-key-help-doc-link",
283
395
  href: helpDocUrl,
284
396
  rel: "noreferrer",
285
397
  target: "_blank"
@@ -309,46 +421,9 @@ var Form = function Form(_ref) {
309
421
  };
310
422
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
311
423
 
312
- var Manage$1 = withT(function (_ref) {
313
- var t = _ref.t,
314
- title = _ref.title,
315
- description = _ref.description,
316
- integration = _ref.integration,
317
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
318
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
319
- isDisconnecting = _ref.isDisconnecting,
320
- onDisconnect = _ref.onDisconnect,
321
- onClose = _ref.onClose;
322
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
323
- className: "mx-auto w-full max-w-md"
324
- }, /*#__PURE__*/React__default.createElement("div", {
325
- className: "mt-10 w-full space-y-4"
326
- }, /*#__PURE__*/React__default.createElement(Typography, {
327
- className: "neeto-ui-text-gray-800 mb-0.5",
328
- style: "h3",
329
- weight: "semibold"
330
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
331
- className: "neeto-ui-text-gray-600 break-all",
332
- style: "body1",
333
- weight: "normal"
334
- }, description), /*#__PURE__*/React__default.createElement(Button, {
335
- label: t("neetoIntegrations.common.disconnect"),
336
- style: "danger",
337
- onClick: function onClick() {
338
- return setIsDisconnectAlertOpen(true);
339
- }
340
- }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
341
- isDisconnecting: isDisconnecting,
342
- onClose: onClose,
343
- onDisconnect: onDisconnect,
344
- isOpen: isDisconnectAlertOpen,
345
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
346
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
347
- }));
348
- });
349
-
350
424
  var Manage = function Manage(_ref) {
351
- var onDisconnect = _ref.onDisconnect;
425
+ var description = _ref.description,
426
+ onDisconnect = _ref.onDisconnect;
352
427
  var _useState = useState(false),
353
428
  _useState2 = _slicedToArray(_useState, 2),
354
429
  isDisconnectAlertOpen = _useState2[0],
@@ -358,7 +433,7 @@ var Manage = function Manage(_ref) {
358
433
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
359
434
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
360
435
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
361
- isLoading = _useFetchDaily.isLoading;
436
+ isFetching = _useFetchDaily.isFetching;
362
437
  var _ref2 = metadata || {},
363
438
  _ref2$apiKey = _ref2.apiKey,
364
439
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -372,24 +447,33 @@ var Manage = function Manage(_ref) {
372
447
  }),
373
448
  destroyIntegration = _useDestroyDaily.mutate,
374
449
  isDisconnecting = _useDestroyDaily.isLoading;
450
+ var isConnected = isPresent(apiKey);
375
451
  var handleDisconnect = function handleDisconnect() {
376
452
  return destroyIntegration("daily");
377
453
  };
378
- if (isLoading || isDisconnecting) {
379
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
380
- }
381
- if (isNotPresent(apiKey)) {
382
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
383
- }
454
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
384
455
  return /*#__PURE__*/React__default.createElement(Manage$1, {
456
+ isConnected: isConnected,
385
457
  isDisconnectAlertOpen: isDisconnectAlertOpen,
386
458
  isDisconnecting: isDisconnecting,
387
459
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
388
- description: t("neetoIntegrations.daily.yourApiKey", {
389
- apiKey: apiKey
460
+ Icon: Daily$1,
461
+ connectPath: buildUrl(window.location.pathname, {
462
+ connect: true
390
463
  }),
391
464
  integration: "daily",
392
- title: t("neetoIntegrations.daily.connected"),
465
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
466
+ components: {
467
+ underline: /*#__PURE__*/React__default.createElement("u", {
468
+ className: "font-medium"
469
+ })
470
+ },
471
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
472
+ values: {
473
+ apiKey: apiKey
474
+ }
475
+ }) : description,
476
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
393
477
  onClose: function onClose() {
394
478
  return setIsDisconnectAlertOpen(false);
395
479
  },
@@ -404,10 +488,14 @@ var Daily = function Daily(_ref) {
404
488
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
405
489
  _ref$videoUrl = _ref.videoUrl,
406
490
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
491
+ _ref$description = _ref.description,
492
+ description = _ref$description === void 0 ? "" : _ref$description,
407
493
  _ref$onConnect = _ref.onConnect,
408
494
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
409
495
  _ref$onDisconnect = _ref.onDisconnect,
410
496
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
497
+ var _useQueryParams = useQueryParams(),
498
+ connect = _useQueryParams.connect;
411
499
  var _useFetchDaily = useFetchDaily(),
412
500
  _useFetchDaily$data = _useFetchDaily.data,
413
501
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -416,8 +504,9 @@ var Daily = function Daily(_ref) {
416
504
  var _ref2 = metadata || {},
417
505
  _ref2$apiKey = _ref2.apiKey,
418
506
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
419
- if (isPresent(apiKey) && !isOnboarding) {
507
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
420
508
  return /*#__PURE__*/React__default.createElement(Manage, {
509
+ description: description,
421
510
  onDisconnect: onDisconnect
422
511
  });
423
512
  }
@@ -821,7 +910,11 @@ var useDestroyZoom = function useDestroyZoom(_ref) {
821
910
  };
822
911
 
823
912
  var Zoom = function Zoom(_ref) {
824
- var _ref$onDisconnect = _ref.onDisconnect,
913
+ var _ref$connectUrl = _ref.connectUrl,
914
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
915
+ _ref$description = _ref.description,
916
+ description = _ref$description === void 0 ? "" : _ref$description,
917
+ _ref$onDisconnect = _ref.onDisconnect,
825
918
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
826
919
  var _useTranslation = useTranslation(),
827
920
  t = _useTranslation.t;
@@ -845,24 +938,31 @@ var Zoom = function Zoom(_ref) {
845
938
  }),
846
939
  destroyIntegration = _useDestroyZoom.mutate,
847
940
  isDisconnecting = _useDestroyZoom.isLoading;
941
+ var isConnected = isPresent(email);
848
942
  var handleDisconnect = function handleDisconnect() {
849
943
  return destroyIntegration("zoom");
850
944
  };
851
- if (isLoading) {
852
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
853
- }
854
- if (isNotPresent(email)) {
855
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
856
- }
945
+ if (isLoading) return /*#__PURE__*/React__default.createElement(PageLoader, null);
857
946
  return /*#__PURE__*/React__default.createElement(Manage$1, {
947
+ connectUrl: connectUrl,
948
+ isConnected: isConnected,
858
949
  isDisconnectAlertOpen: isDisconnectAlertOpen,
859
950
  isDisconnecting: isDisconnecting,
860
951
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
861
- description: t("neetoIntegrations.zoom.account", {
862
- email: email
863
- }),
952
+ Icon: Zoom$1,
864
953
  integration: "zoom",
865
- title: t("neetoIntegrations.zoom.connected"),
954
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
955
+ components: {
956
+ underline: /*#__PURE__*/React__default.createElement("u", {
957
+ className: "font-medium"
958
+ })
959
+ },
960
+ i18nKey: "neetoIntegrations.zoom.account",
961
+ values: {
962
+ email: email
963
+ }
964
+ }) : description,
965
+ title: isConnected ? t("neetoIntegrations.zoom.connected") : t("neetoIntegrations.zoom.connect"),
866
966
  onClose: function onClose() {
867
967
  return setIsDisconnectAlertOpen(false);
868
968
  },
@@ -1252,5 +1352,5 @@ function n(n, r) {
1252
1352
  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%}";
1253
1353
  n(css,{});
1254
1354
 
1255
- export { Connect, index as Daily, Demo, Finish, GoogleCalendar, Modal, Twilio, Zoom };
1355
+ export { Connect, index as Daily, Demo, Finish, GoogleCalendar, Manage$1 as Manage, Modal, Twilio, Zoom };
1256
1356
  //# sourceMappingURL=index.js.map