@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/Daily.js CHANGED
@@ -1,23 +1,24 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useState } from 'react';
3
3
  import i18next, { t as t$1 } from 'i18next';
4
- import { noop, isNotEmpty, isNotPresent, isPresent } from '@bigbinary/neeto-cist';
5
- import { useMutationWithInvalidation, withT, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
4
+ import { humanize, noop, isNotEmpty, isPresent } from '@bigbinary/neeto-cist';
5
+ import { useMutationWithInvalidation, withT, withTitle, useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
6
6
  import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
7
7
  import { useQuery } from 'react-query';
8
8
  import axios from 'axios';
9
9
  import '@bigbinary/neeto-molecules/IntegrationCard';
10
10
  import DisconnectAlert from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
11
11
  import WalkthroughModal from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
12
+ import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
13
+ import { Daily as Daily$1 } from '@bigbinary/neeto-icons/misc';
12
14
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
13
- import { useTranslation, Trans } from 'react-i18next';
14
- import '@bigbinary/neeto-commons-frontend/utils';
15
- import '@bigbinary/neeto-icons/misc';
15
+ import { Trans, useTranslation } from 'react-i18next';
16
16
  import { Typography, Button } 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 _typeof(obj) {
23
24
  "@babel/helpers - typeof";
@@ -163,60 +164,131 @@ function _slicedToArray(arr, i) {
163
164
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
164
165
  }
165
166
 
166
- [{
167
- step: "1",
168
- label: t$1("neetoIntegrations.common.connect"),
169
- isActive: true,
170
- isCompleted: false
171
- }, {
172
- step: "2",
173
- label: t$1("neetoIntegrations.common.finish"),
174
- isActive: false,
175
- isCompleted: false
176
- }];
177
- ({
178
- connect: t$1("neetoIntegrations.common.connect"),
179
- finish: t$1("neetoIntegrations.common.finish")
180
- });
181
-
182
167
  var Manage$1 = withT(function (_ref) {
183
168
  var t = _ref.t,
184
- title = _ref.title,
185
- description = _ref.description,
186
- integration = _ref.integration,
187
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
188
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
189
- isDisconnecting = _ref.isDisconnecting,
190
- onDisconnect = _ref.onDisconnect,
191
- onClose = _ref.onClose;
169
+ _ref$title = _ref.title,
170
+ title = _ref$title === void 0 ? "" : _ref$title,
171
+ _ref$description = _ref.description,
172
+ description = _ref$description === void 0 ? "" : _ref$description,
173
+ _ref$integration = _ref.integration,
174
+ integration = _ref$integration === void 0 ? "" : _ref$integration,
175
+ _ref$isDisconnectAler = _ref.isDisconnectAlertOpen,
176
+ isDisconnectAlertOpen = _ref$isDisconnectAler === void 0 ? false : _ref$isDisconnectAler,
177
+ _ref$setIsDisconnectA = _ref.setIsDisconnectAlertOpen,
178
+ setIsDisconnectAlertOpen = _ref$setIsDisconnectA === void 0 ? noop : _ref$setIsDisconnectA,
179
+ _ref$isDisconnecting = _ref.isDisconnecting,
180
+ isDisconnecting = _ref$isDisconnecting === void 0 ? false : _ref$isDisconnecting,
181
+ _ref$onDisconnect = _ref.onDisconnect,
182
+ onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect,
183
+ _ref$onClose = _ref.onClose,
184
+ onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
185
+ _ref$Icon = _ref.Icon,
186
+ Icon = _ref$Icon === void 0 ? null : _ref$Icon,
187
+ _ref$isConnected = _ref.isConnected,
188
+ isConnected = _ref$isConnected === void 0 ? false : _ref$isConnected,
189
+ _ref$connectPath = _ref.connectPath,
190
+ connectPath = _ref$connectPath === void 0 ? "" : _ref$connectPath,
191
+ _ref$connectUrl = _ref.connectUrl,
192
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
193
+ _ref$helpDocUrl = _ref.helpDocUrl,
194
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
195
+ _ref$managePath = _ref.managePath,
196
+ managePath = _ref$managePath === void 0 ? "" : _ref$managePath,
197
+ _ref$integrationName = _ref.integrationName,
198
+ integrationName = _ref$integrationName === void 0 ? "" : _ref$integrationName,
199
+ _ref$disconnectMessag = _ref.disconnectMessage,
200
+ disconnectMessage = _ref$disconnectMessag === void 0 ? "" : _ref$disconnectMessag,
201
+ _ref$isConnectDisable = _ref.isConnectDisabled,
202
+ isConnectDisabled = _ref$isConnectDisable === void 0 ? false : _ref$isConnectDisable,
203
+ _ref$connectTooltipPr = _ref.connectTooltipProps,
204
+ connectTooltipProps = _ref$connectTooltipPr === void 0 ? null : _ref$connectTooltipPr;
192
205
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
193
- className: "mx-auto w-full max-w-md"
206
+ className: "mx-auto w-full max-w-3xl"
194
207
  }, /*#__PURE__*/React__default.createElement("div", {
195
- className: "mt-10 w-full space-y-4"
208
+ className: "neeto-ui-border-gray-300 neeto-ui-rounded-xl mt-10 w-full space-y-4 border p-6"
209
+ }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
210
+ className: "neeto-ui-text-gray-600",
211
+ size: 60
212
+ }), /*#__PURE__*/React__default.createElement("div", {
213
+ className: "space-y-2"
214
+ }, /*#__PURE__*/React__default.createElement("div", {
215
+ className: "flex items-center space-x-4"
196
216
  }, /*#__PURE__*/React__default.createElement(Typography, {
197
217
  className: "neeto-ui-text-gray-800 mb-0.5",
198
- style: "h3",
218
+ style: "h2",
199
219
  weight: "semibold"
200
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
201
- className: "neeto-ui-text-gray-600 break-all",
220
+ }, title), isConnected && /*#__PURE__*/React__default.createElement("div", {
221
+ className: "neeto-ui-bg-success-500 neeto-ui-text-white neeto-ui-rounded-full flex items-center justify-center p-1"
222
+ }, /*#__PURE__*/React__default.createElement(Check, {
223
+ size: 24
224
+ }))), /*#__PURE__*/React__default.createElement(Typography, {
225
+ className: "neeto-ui-text-gray-800 break-all",
202
226
  style: "body1",
203
227
  weight: "normal"
204
- }, description), /*#__PURE__*/React__default.createElement(Button, {
205
- label: t("neetoIntegrations.common.disconnect"),
228
+ }, description), helpDocUrl && /*#__PURE__*/React__default.createElement(Typography, {
229
+ className: "neeto-ui-text-gray-800 break-all",
230
+ style: "body2",
231
+ weight: "normal"
232
+ }, /*#__PURE__*/React__default.createElement(Trans, {
233
+ i18nKey: "settings.integrations.common.helpDocUrl",
234
+ components: {
235
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
236
+ href: helpDocUrl,
237
+ style: "link"
238
+ })
239
+ },
240
+ values: {
241
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
242
+ }
243
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
244
+ className: "space-x-2"
245
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
246
+ to: managePath,
247
+ label: t("settings.integrations.common.manageIntegration", {
248
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
249
+ })
250
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
206
251
  style: "danger",
252
+ label: t("settings.integrations.common.disconnectIntegration", {
253
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
254
+ }),
207
255
  onClick: function onClick() {
208
256
  return setIsDisconnectAlertOpen(true);
209
257
  }
258
+ })) : /*#__PURE__*/React__default.createElement(Button, {
259
+ disabled: isConnectDisabled,
260
+ href: connectUrl,
261
+ to: connectPath,
262
+ tooltipProps: connectTooltipProps,
263
+ label: t("settings.integrations.common.connectIntegration", {
264
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
265
+ })
210
266
  }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
211
267
  isDisconnecting: isDisconnecting,
212
268
  onClose: onClose,
213
269
  onDisconnect: onDisconnect,
214
270
  isOpen: isDisconnectAlertOpen,
215
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
216
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
271
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
272
+ message: disconnectMessage !== null && disconnectMessage !== void 0 ? disconnectMessage : t("settings.integrations.".concat(integration, ".disconnect.message"))
217
273
  }));
218
274
  });
219
275
 
276
+ [{
277
+ step: "1",
278
+ label: t$1("neetoIntegrations.common.connect"),
279
+ isActive: true,
280
+ isCompleted: false
281
+ }, {
282
+ step: "2",
283
+ label: t$1("neetoIntegrations.common.finish"),
284
+ isActive: false,
285
+ isCompleted: false
286
+ }];
287
+ ({
288
+ connect: t$1("neetoIntegrations.common.connect"),
289
+ finish: t$1("neetoIntegrations.common.finish")
290
+ });
291
+
220
292
  function _extends$1() {
221
293
  _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
222
294
  for (var i = 1; i < arguments.length; i++) {
@@ -582,6 +654,7 @@ var Form = function Form(_ref) {
582
654
  i18nKey: "neetoIntegrations.daily.helpDoc",
583
655
  components: {
584
656
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
657
+ "data-cy": "api-key-help-doc-link",
585
658
  href: helpDocUrl,
586
659
  rel: "noreferrer",
587
660
  target: "_blank"
@@ -612,7 +685,8 @@ var Form = function Form(_ref) {
612
685
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
613
686
 
614
687
  var Manage = function Manage(_ref) {
615
- var onDisconnect = _ref.onDisconnect;
688
+ var description = _ref.description,
689
+ onDisconnect = _ref.onDisconnect;
616
690
  var _useState = useState(false),
617
691
  _useState2 = _slicedToArray(_useState, 2),
618
692
  isDisconnectAlertOpen = _useState2[0],
@@ -622,7 +696,7 @@ var Manage = function Manage(_ref) {
622
696
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
623
697
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
624
698
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
625
- isLoading = _useFetchDaily.isLoading;
699
+ isFetching = _useFetchDaily.isFetching;
626
700
  var _ref2 = metadata || {},
627
701
  _ref2$apiKey = _ref2.apiKey,
628
702
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -636,24 +710,33 @@ var Manage = function Manage(_ref) {
636
710
  }),
637
711
  destroyIntegration = _useDestroyDaily.mutate,
638
712
  isDisconnecting = _useDestroyDaily.isLoading;
713
+ var isConnected = isPresent(apiKey);
639
714
  var handleDisconnect = function handleDisconnect() {
640
715
  return destroyIntegration("daily");
641
716
  };
642
- if (isLoading || isDisconnecting) {
643
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
644
- }
645
- if (isNotPresent(apiKey)) {
646
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
647
- }
717
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
648
718
  return /*#__PURE__*/React__default.createElement(Manage$1, {
719
+ isConnected: isConnected,
649
720
  isDisconnectAlertOpen: isDisconnectAlertOpen,
650
721
  isDisconnecting: isDisconnecting,
651
722
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
652
- description: t("neetoIntegrations.daily.yourApiKey", {
653
- apiKey: apiKey
723
+ Icon: Daily$1,
724
+ connectPath: buildUrl(window.location.pathname, {
725
+ connect: true
654
726
  }),
655
727
  integration: "daily",
656
- title: t("neetoIntegrations.daily.connected"),
728
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
729
+ components: {
730
+ underline: /*#__PURE__*/React__default.createElement("u", {
731
+ className: "font-medium"
732
+ })
733
+ },
734
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
735
+ values: {
736
+ apiKey: apiKey
737
+ }
738
+ }) : description,
739
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
657
740
  onClose: function onClose() {
658
741
  return setIsDisconnectAlertOpen(false);
659
742
  },
@@ -668,10 +751,14 @@ var Daily = function Daily(_ref) {
668
751
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
669
752
  _ref$videoUrl = _ref.videoUrl,
670
753
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
754
+ _ref$description = _ref.description,
755
+ description = _ref$description === void 0 ? "" : _ref$description,
671
756
  _ref$onConnect = _ref.onConnect,
672
757
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
673
758
  _ref$onDisconnect = _ref.onDisconnect,
674
759
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
760
+ var _useQueryParams = useQueryParams(),
761
+ connect = _useQueryParams.connect;
675
762
  var _useFetchDaily = useFetchDaily(),
676
763
  _useFetchDaily$data = _useFetchDaily.data,
677
764
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -680,8 +767,9 @@ var Daily = function Daily(_ref) {
680
767
  var _ref2 = metadata || {},
681
768
  _ref2$apiKey = _ref2.apiKey,
682
769
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
683
- if (isPresent(apiKey) && !isOnboarding) {
770
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
684
771
  return /*#__PURE__*/React__default.createElement(Manage, {
772
+ description: description,
685
773
  onDisconnect: onDisconnect
686
774
  });
687
775
  }