@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/index.js CHANGED
@@ -6,20 +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 { 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 ? 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
+ });
23
133
 
24
134
  function _typeof(obj) {
25
135
  "@babel/helpers - typeof";
@@ -280,6 +390,7 @@ var Form = function Form(_ref) {
280
390
  i18nKey: "neetoIntegrations.daily.helpDoc",
281
391
  components: {
282
392
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
393
+ "data-cy": "api-key-help-doc-link",
283
394
  href: helpDocUrl,
284
395
  rel: "noreferrer",
285
396
  target: "_blank"
@@ -309,46 +420,9 @@ var Form = function Form(_ref) {
309
420
  };
310
421
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
311
422
 
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
423
  var Manage = function Manage(_ref) {
351
- var onDisconnect = _ref.onDisconnect;
424
+ var description = _ref.description,
425
+ onDisconnect = _ref.onDisconnect;
352
426
  var _useState = useState(false),
353
427
  _useState2 = _slicedToArray(_useState, 2),
354
428
  isDisconnectAlertOpen = _useState2[0],
@@ -358,7 +432,7 @@ var Manage = function Manage(_ref) {
358
432
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
359
433
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
360
434
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
361
- isLoading = _useFetchDaily.isLoading;
435
+ isFetching = _useFetchDaily.isFetching;
362
436
  var _ref2 = metadata || {},
363
437
  _ref2$apiKey = _ref2.apiKey,
364
438
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -372,24 +446,33 @@ var Manage = function Manage(_ref) {
372
446
  }),
373
447
  destroyIntegration = _useDestroyDaily.mutate,
374
448
  isDisconnecting = _useDestroyDaily.isLoading;
449
+ var isConnected = isPresent(apiKey);
375
450
  var handleDisconnect = function handleDisconnect() {
376
451
  return destroyIntegration("daily");
377
452
  };
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
- }
453
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
384
454
  return /*#__PURE__*/React__default.createElement(Manage$1, {
455
+ isConnected: isConnected,
385
456
  isDisconnectAlertOpen: isDisconnectAlertOpen,
386
457
  isDisconnecting: isDisconnecting,
387
458
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
388
- description: t("neetoIntegrations.daily.yourApiKey", {
389
- apiKey: apiKey
459
+ Icon: Daily$1,
460
+ connectPath: buildUrl(window.location.pathname, {
461
+ connect: true
390
462
  }),
391
463
  integration: "daily",
392
- 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"),
393
476
  onClose: function onClose() {
394
477
  return setIsDisconnectAlertOpen(false);
395
478
  },
@@ -404,10 +487,14 @@ var Daily = function Daily(_ref) {
404
487
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
405
488
  _ref$videoUrl = _ref.videoUrl,
406
489
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
490
+ _ref$description = _ref.description,
491
+ description = _ref$description === void 0 ? "" : _ref$description,
407
492
  _ref$onConnect = _ref.onConnect,
408
493
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
409
494
  _ref$onDisconnect = _ref.onDisconnect,
410
495
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
496
+ var _useQueryParams = useQueryParams(),
497
+ connect = _useQueryParams.connect;
411
498
  var _useFetchDaily = useFetchDaily(),
412
499
  _useFetchDaily$data = _useFetchDaily.data,
413
500
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -416,8 +503,9 @@ var Daily = function Daily(_ref) {
416
503
  var _ref2 = metadata || {},
417
504
  _ref2$apiKey = _ref2.apiKey,
418
505
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
419
- if (isPresent(apiKey) && !isOnboarding) {
506
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
420
507
  return /*#__PURE__*/React__default.createElement(Manage, {
508
+ description: description,
421
509
  onDisconnect: onDisconnect
422
510
  });
423
511
  }
@@ -821,7 +909,11 @@ var useDestroyZoom = function useDestroyZoom(_ref) {
821
909
  };
822
910
 
823
911
  var Zoom = function Zoom(_ref) {
824
- 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,
825
917
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
826
918
  var _useTranslation = useTranslation(),
827
919
  t = _useTranslation.t;
@@ -845,24 +937,31 @@ var Zoom = function Zoom(_ref) {
845
937
  }),
846
938
  destroyIntegration = _useDestroyZoom.mutate,
847
939
  isDisconnecting = _useDestroyZoom.isLoading;
940
+ var isConnected = isPresent(email);
848
941
  var handleDisconnect = function handleDisconnect() {
849
942
  return destroyIntegration("zoom");
850
943
  };
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
- }
944
+ if (isLoading) return /*#__PURE__*/React__default.createElement(PageLoader, null);
857
945
  return /*#__PURE__*/React__default.createElement(Manage$1, {
946
+ connectUrl: connectUrl,
947
+ isConnected: isConnected,
858
948
  isDisconnectAlertOpen: isDisconnectAlertOpen,
859
949
  isDisconnecting: isDisconnecting,
860
950
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
861
- description: t("neetoIntegrations.zoom.account", {
862
- email: email
863
- }),
951
+ Icon: Zoom$1,
864
952
  integration: "zoom",
865
- 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"),
866
965
  onClose: function onClose() {
867
966
  return setIsDisconnectAlertOpen(false);
868
967
  },
@@ -1252,5 +1351,5 @@ function n(n, r) {
1252
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%}";
1253
1352
  n(css,{});
1254
1353
 
1255
- 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 };
1256
1355
  //# sourceMappingURL=index.js.map