@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/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,132 @@ 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 ? undefined : _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"),
206
- style: "danger",
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: "neetoIntegrations.common.helpDocUrl",
234
+ components: {
235
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
236
+ href: helpDocUrl,
237
+ style: "link",
238
+ target: "_blank"
239
+ })
240
+ },
241
+ values: {
242
+ integration: integrationName || humanize(integration)
243
+ }
244
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
245
+ className: "space-x-2"
246
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
247
+ to: managePath,
248
+ label: t("neetoIntegrations.common.manageIntegration", {
249
+ integration: integrationName || humanize(integration)
250
+ })
251
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
252
+ style: "secondary",
253
+ label: t("neetoIntegrations.common.disconnectIntegration", {
254
+ integration: integrationName || humanize(integration)
255
+ }),
207
256
  onClick: function onClick() {
208
257
  return setIsDisconnectAlertOpen(true);
209
258
  }
259
+ })) : /*#__PURE__*/React__default.createElement(Button, {
260
+ disabled: isConnectDisabled,
261
+ href: connectUrl,
262
+ to: connectPath,
263
+ tooltipProps: connectTooltipProps,
264
+ label: t("neetoIntegrations.common.connectIntegration", {
265
+ integration: integrationName || humanize(integration)
266
+ })
210
267
  }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
211
268
  isDisconnecting: isDisconnecting,
212
269
  onClose: onClose,
213
270
  onDisconnect: onDisconnect,
214
271
  isOpen: isDisconnectAlertOpen,
215
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
216
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
272
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
273
+ message: disconnectMessage || t("settings.integrations.".concat(integration, ".disconnect.message"))
217
274
  }));
218
275
  });
219
276
 
277
+ [{
278
+ step: "1",
279
+ label: t$1("neetoIntegrations.common.connect"),
280
+ isActive: true,
281
+ isCompleted: false
282
+ }, {
283
+ step: "2",
284
+ label: t$1("neetoIntegrations.common.finish"),
285
+ isActive: false,
286
+ isCompleted: false
287
+ }];
288
+ ({
289
+ connect: t$1("neetoIntegrations.common.connect"),
290
+ finish: t$1("neetoIntegrations.common.finish")
291
+ });
292
+
220
293
  function _extends$1() {
221
294
  _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
222
295
  for (var i = 1; i < arguments.length; i++) {
@@ -582,6 +655,7 @@ var Form = function Form(_ref) {
582
655
  i18nKey: "neetoIntegrations.daily.helpDoc",
583
656
  components: {
584
657
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
658
+ "data-cy": "api-key-help-doc-link",
585
659
  href: helpDocUrl,
586
660
  rel: "noreferrer",
587
661
  target: "_blank"
@@ -612,7 +686,8 @@ var Form = function Form(_ref) {
612
686
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
613
687
 
614
688
  var Manage = function Manage(_ref) {
615
- var onDisconnect = _ref.onDisconnect;
689
+ var description = _ref.description,
690
+ onDisconnect = _ref.onDisconnect;
616
691
  var _useState = useState(false),
617
692
  _useState2 = _slicedToArray(_useState, 2),
618
693
  isDisconnectAlertOpen = _useState2[0],
@@ -622,7 +697,7 @@ var Manage = function Manage(_ref) {
622
697
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
623
698
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
624
699
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
625
- isLoading = _useFetchDaily.isLoading;
700
+ isFetching = _useFetchDaily.isFetching;
626
701
  var _ref2 = metadata || {},
627
702
  _ref2$apiKey = _ref2.apiKey,
628
703
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -636,24 +711,33 @@ var Manage = function Manage(_ref) {
636
711
  }),
637
712
  destroyIntegration = _useDestroyDaily.mutate,
638
713
  isDisconnecting = _useDestroyDaily.isLoading;
714
+ var isConnected = isPresent(apiKey);
639
715
  var handleDisconnect = function handleDisconnect() {
640
716
  return destroyIntegration("daily");
641
717
  };
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
- }
718
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
648
719
  return /*#__PURE__*/React__default.createElement(Manage$1, {
720
+ isConnected: isConnected,
649
721
  isDisconnectAlertOpen: isDisconnectAlertOpen,
650
722
  isDisconnecting: isDisconnecting,
651
723
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
652
- description: t("neetoIntegrations.daily.yourApiKey", {
653
- apiKey: apiKey
724
+ Icon: Daily$1,
725
+ connectPath: buildUrl(window.location.pathname, {
726
+ connect: true
654
727
  }),
655
728
  integration: "daily",
656
- title: t("neetoIntegrations.daily.connected"),
729
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
730
+ components: {
731
+ underline: /*#__PURE__*/React__default.createElement("u", {
732
+ className: "font-medium"
733
+ })
734
+ },
735
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
736
+ values: {
737
+ apiKey: apiKey
738
+ }
739
+ }) : description,
740
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
657
741
  onClose: function onClose() {
658
742
  return setIsDisconnectAlertOpen(false);
659
743
  },
@@ -668,10 +752,14 @@ var Daily = function Daily(_ref) {
668
752
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
669
753
  _ref$videoUrl = _ref.videoUrl,
670
754
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
755
+ _ref$description = _ref.description,
756
+ description = _ref$description === void 0 ? "" : _ref$description,
671
757
  _ref$onConnect = _ref.onConnect,
672
758
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
673
759
  _ref$onDisconnect = _ref.onDisconnect,
674
760
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
761
+ var _useQueryParams = useQueryParams(),
762
+ connect = _useQueryParams.connect;
675
763
  var _useFetchDaily = useFetchDaily(),
676
764
  _useFetchDaily$data = _useFetchDaily.data,
677
765
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -680,8 +768,9 @@ var Daily = function Daily(_ref) {
680
768
  var _ref2 = metadata || {},
681
769
  _ref2$apiKey = _ref2.apiKey,
682
770
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
683
- if (isPresent(apiKey) && !isOnboarding) {
771
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
684
772
  return /*#__PURE__*/React__default.createElement(Manage, {
773
+ description: description,
685
774
  onDisconnect: onDisconnect
686
775
  });
687
776
  }