@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/Daily.js CHANGED
@@ -1,24 +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/pure';
15
- import '@bigbinary/neeto-commons-frontend/utils';
16
- import '@bigbinary/neeto-icons/misc';
15
+ import { Trans, useTranslation } from 'react-i18next';
17
16
  import { Typography, Button } from '@bigbinary/neetoui';
18
17
  import { Form as Form$2, Input } from '@bigbinary/neetoui/formik';
19
18
  import 'ramda';
20
19
  import * as yup from 'yup';
21
20
  import classnames from 'classnames';
21
+ import { Check } from '@bigbinary/neeto-icons';
22
22
 
23
23
  function _typeof(obj) {
24
24
  "@babel/helpers - typeof";
@@ -164,60 +164,131 @@ function _slicedToArray(arr, i) {
164
164
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
165
165
  }
166
166
 
167
- [{
168
- step: "1",
169
- label: t$1("neetoIntegrations.common.connect"),
170
- isActive: true,
171
- isCompleted: false
172
- }, {
173
- step: "2",
174
- label: t$1("neetoIntegrations.common.finish"),
175
- isActive: false,
176
- isCompleted: false
177
- }];
178
- ({
179
- connect: t$1("neetoIntegrations.common.connect"),
180
- finish: t$1("neetoIntegrations.common.finish")
181
- });
182
-
183
167
  var Manage$1 = withT(function (_ref) {
184
168
  var t = _ref.t,
185
- title = _ref.title,
186
- description = _ref.description,
187
- integration = _ref.integration,
188
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
189
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
190
- isDisconnecting = _ref.isDisconnecting,
191
- onDisconnect = _ref.onDisconnect,
192
- 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;
193
205
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
194
- className: "mx-auto w-full max-w-md"
206
+ className: "mx-auto w-full max-w-3xl"
195
207
  }, /*#__PURE__*/React__default.createElement("div", {
196
- 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"
197
216
  }, /*#__PURE__*/React__default.createElement(Typography, {
198
217
  className: "neeto-ui-text-gray-800 mb-0.5",
199
- style: "h3",
218
+ style: "h2",
200
219
  weight: "semibold"
201
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
202
- 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",
203
226
  style: "body1",
204
227
  weight: "normal"
205
- }, description), /*#__PURE__*/React__default.createElement(Button, {
206
- 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, {
207
251
  style: "danger",
252
+ label: t("settings.integrations.common.disconnectIntegration", {
253
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
254
+ }),
208
255
  onClick: function onClick() {
209
256
  return setIsDisconnectAlertOpen(true);
210
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
+ })
211
266
  }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
212
267
  isDisconnecting: isDisconnecting,
213
268
  onClose: onClose,
214
269
  onDisconnect: onDisconnect,
215
270
  isOpen: isDisconnectAlertOpen,
216
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
217
- 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"))
218
273
  }));
219
274
  });
220
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
+
221
292
  function _extends$1() {
222
293
  _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
223
294
  for (var i = 1; i < arguments.length; i++) {
@@ -583,6 +654,7 @@ var Form = function Form(_ref) {
583
654
  i18nKey: "neetoIntegrations.daily.helpDoc",
584
655
  components: {
585
656
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
657
+ "data-cy": "api-key-help-doc-link",
586
658
  href: helpDocUrl,
587
659
  rel: "noreferrer",
588
660
  target: "_blank"
@@ -613,7 +685,8 @@ var Form = function Form(_ref) {
613
685
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
614
686
 
615
687
  var Manage = function Manage(_ref) {
616
- var onDisconnect = _ref.onDisconnect;
688
+ var description = _ref.description,
689
+ onDisconnect = _ref.onDisconnect;
617
690
  var _useState = useState(false),
618
691
  _useState2 = _slicedToArray(_useState, 2),
619
692
  isDisconnectAlertOpen = _useState2[0],
@@ -623,7 +696,7 @@ var Manage = function Manage(_ref) {
623
696
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
624
697
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
625
698
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
626
- isLoading = _useFetchDaily.isLoading;
699
+ isFetching = _useFetchDaily.isFetching;
627
700
  var _ref2 = metadata || {},
628
701
  _ref2$apiKey = _ref2.apiKey,
629
702
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -637,24 +710,33 @@ var Manage = function Manage(_ref) {
637
710
  }),
638
711
  destroyIntegration = _useDestroyDaily.mutate,
639
712
  isDisconnecting = _useDestroyDaily.isLoading;
713
+ var isConnected = isPresent(apiKey);
640
714
  var handleDisconnect = function handleDisconnect() {
641
715
  return destroyIntegration("daily");
642
716
  };
643
- if (isLoading || isDisconnecting) {
644
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
645
- }
646
- if (isNotPresent(apiKey)) {
647
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
648
- }
717
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
649
718
  return /*#__PURE__*/React__default.createElement(Manage$1, {
719
+ isConnected: isConnected,
650
720
  isDisconnectAlertOpen: isDisconnectAlertOpen,
651
721
  isDisconnecting: isDisconnecting,
652
722
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
653
- description: t("neetoIntegrations.daily.yourApiKey", {
654
- apiKey: apiKey
723
+ Icon: Daily$1,
724
+ connectPath: buildUrl(window.location.pathname, {
725
+ connect: true
655
726
  }),
656
727
  integration: "daily",
657
- 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"),
658
740
  onClose: function onClose() {
659
741
  return setIsDisconnectAlertOpen(false);
660
742
  },
@@ -669,10 +751,14 @@ var Daily = function Daily(_ref) {
669
751
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
670
752
  _ref$videoUrl = _ref.videoUrl,
671
753
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
754
+ _ref$description = _ref.description,
755
+ description = _ref$description === void 0 ? "" : _ref$description,
672
756
  _ref$onConnect = _ref.onConnect,
673
757
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
674
758
  _ref$onDisconnect = _ref.onDisconnect,
675
759
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
760
+ var _useQueryParams = useQueryParams(),
761
+ connect = _useQueryParams.connect;
676
762
  var _useFetchDaily = useFetchDaily(),
677
763
  _useFetchDaily$data = _useFetchDaily.data,
678
764
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -681,8 +767,9 @@ var Daily = function Daily(_ref) {
681
767
  var _ref2 = metadata || {},
682
768
  _ref2$apiKey = _ref2.apiKey,
683
769
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
684
- if (isPresent(apiKey) && !isOnboarding) {
770
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
685
771
  return /*#__PURE__*/React__default.createElement(Manage, {
772
+ description: description,
686
773
  onDisconnect: onDisconnect
687
774
  });
688
775
  }