@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.
@@ -4,21 +4,21 @@ import '@bigbinary/neeto-molecules/IntegrationCard';
4
4
  import DisconnectAlert from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
5
5
  import WalkthroughModal from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
6
6
  import i18next, { t as t$1 } from 'i18next';
7
- import { isNotPresent, isPresent, noop, isNotEmpty } from '@bigbinary/neeto-cist';
8
- import { useMutationWithInvalidation, withTitle, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
7
+ import { humanize, noop, isPresent, isNotEmpty } from '@bigbinary/neeto-cist';
8
+ import { withT, useMutationWithInvalidation, withTitle, useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
9
9
  import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
10
10
  import { useQuery } from 'react-query';
11
11
  import axios from 'axios';
12
- import { isPresent as isPresent$1 } from '@bigbinary/neeto-commons-frontend/pure';
13
- import { getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
14
- import { GoogleCalendar as GoogleCalendar$1, Google } from '@bigbinary/neeto-icons/misc';
15
- import { Button, Typography, Modal as Modal$1, Callout } from '@bigbinary/neetoui';
16
- import { useTranslation, Trans } from 'react-i18next';
12
+ import { buildUrl, getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
13
+ import { Daily as Daily$1, GoogleCalendar as GoogleCalendar$1, Google } from '@bigbinary/neeto-icons/misc';
14
+ import { Typography, Button, Modal as Modal$1, Callout } from '@bigbinary/neetoui';
15
+ import { Trans, useTranslation } from 'react-i18next';
17
16
  import { Form as Form$2, Input } from '@bigbinary/neetoui/formik';
18
17
  import 'ramda';
19
18
  import * as yup from 'yup';
20
19
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
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";
@@ -132,6 +132,115 @@ function _slicedToArray(arr, i) {
132
132
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
133
133
  }
134
134
 
135
+ var Manage$1 = withT(function (_ref) {
136
+ var t = _ref.t,
137
+ _ref$title = _ref.title,
138
+ title = _ref$title === void 0 ? "" : _ref$title,
139
+ _ref$description = _ref.description,
140
+ description = _ref$description === void 0 ? "" : _ref$description,
141
+ _ref$integration = _ref.integration,
142
+ integration = _ref$integration === void 0 ? "" : _ref$integration,
143
+ _ref$isDisconnectAler = _ref.isDisconnectAlertOpen,
144
+ isDisconnectAlertOpen = _ref$isDisconnectAler === void 0 ? false : _ref$isDisconnectAler,
145
+ _ref$setIsDisconnectA = _ref.setIsDisconnectAlertOpen,
146
+ setIsDisconnectAlertOpen = _ref$setIsDisconnectA === void 0 ? noop : _ref$setIsDisconnectA,
147
+ _ref$isDisconnecting = _ref.isDisconnecting,
148
+ isDisconnecting = _ref$isDisconnecting === void 0 ? false : _ref$isDisconnecting,
149
+ _ref$onDisconnect = _ref.onDisconnect,
150
+ onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect,
151
+ _ref$onClose = _ref.onClose,
152
+ onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
153
+ _ref$Icon = _ref.Icon,
154
+ Icon = _ref$Icon === void 0 ? null : _ref$Icon,
155
+ _ref$isConnected = _ref.isConnected,
156
+ isConnected = _ref$isConnected === void 0 ? false : _ref$isConnected,
157
+ _ref$connectPath = _ref.connectPath,
158
+ connectPath = _ref$connectPath === void 0 ? "" : _ref$connectPath,
159
+ _ref$connectUrl = _ref.connectUrl,
160
+ connectUrl = _ref$connectUrl === void 0 ? "" : _ref$connectUrl,
161
+ _ref$helpDocUrl = _ref.helpDocUrl,
162
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
163
+ _ref$managePath = _ref.managePath,
164
+ managePath = _ref$managePath === void 0 ? "" : _ref$managePath,
165
+ _ref$integrationName = _ref.integrationName,
166
+ integrationName = _ref$integrationName === void 0 ? "" : _ref$integrationName,
167
+ _ref$disconnectMessag = _ref.disconnectMessage,
168
+ disconnectMessage = _ref$disconnectMessag === void 0 ? "" : _ref$disconnectMessag,
169
+ _ref$isConnectDisable = _ref.isConnectDisabled,
170
+ isConnectDisabled = _ref$isConnectDisable === void 0 ? false : _ref$isConnectDisable,
171
+ _ref$connectTooltipPr = _ref.connectTooltipProps,
172
+ connectTooltipProps = _ref$connectTooltipPr === void 0 ? null : _ref$connectTooltipPr;
173
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
174
+ className: "mx-auto w-full max-w-3xl"
175
+ }, /*#__PURE__*/React__default.createElement("div", {
176
+ className: "neeto-ui-border-gray-300 neeto-ui-rounded-xl mt-10 w-full space-y-4 border p-6"
177
+ }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
178
+ className: "neeto-ui-text-gray-600",
179
+ size: 60
180
+ }), /*#__PURE__*/React__default.createElement("div", {
181
+ className: "space-y-2"
182
+ }, /*#__PURE__*/React__default.createElement("div", {
183
+ className: "flex items-center space-x-4"
184
+ }, /*#__PURE__*/React__default.createElement(Typography, {
185
+ className: "neeto-ui-text-gray-800 mb-0.5",
186
+ style: "h2",
187
+ weight: "semibold"
188
+ }, title), isConnected && /*#__PURE__*/React__default.createElement("div", {
189
+ className: "neeto-ui-bg-success-500 neeto-ui-text-white neeto-ui-rounded-full flex items-center justify-center p-1"
190
+ }, /*#__PURE__*/React__default.createElement(Check, {
191
+ size: 24
192
+ }))), /*#__PURE__*/React__default.createElement(Typography, {
193
+ className: "neeto-ui-text-gray-800 break-all",
194
+ style: "body1",
195
+ weight: "normal"
196
+ }, description), helpDocUrl && /*#__PURE__*/React__default.createElement(Typography, {
197
+ className: "neeto-ui-text-gray-800 break-all",
198
+ style: "body2",
199
+ weight: "normal"
200
+ }, /*#__PURE__*/React__default.createElement(Trans, {
201
+ i18nKey: "settings.integrations.common.helpDocUrl",
202
+ components: {
203
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
204
+ href: helpDocUrl,
205
+ style: "link"
206
+ })
207
+ },
208
+ values: {
209
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
210
+ }
211
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
212
+ className: "space-x-2"
213
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
214
+ to: managePath,
215
+ label: t("settings.integrations.common.manageIntegration", {
216
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
217
+ })
218
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
219
+ style: "danger",
220
+ label: t("settings.integrations.common.disconnectIntegration", {
221
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
222
+ }),
223
+ onClick: function onClick() {
224
+ return setIsDisconnectAlertOpen(true);
225
+ }
226
+ })) : /*#__PURE__*/React__default.createElement(Button, {
227
+ disabled: isConnectDisabled,
228
+ href: connectUrl,
229
+ to: connectPath,
230
+ tooltipProps: connectTooltipProps,
231
+ label: t("settings.integrations.common.connectIntegration", {
232
+ integration: integrationName !== null && integrationName !== void 0 ? integrationName : humanize(integration)
233
+ })
234
+ }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
235
+ isDisconnecting: isDisconnecting,
236
+ onClose: onClose,
237
+ onDisconnect: onDisconnect,
238
+ isOpen: isDisconnectAlertOpen,
239
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
240
+ message: disconnectMessage !== null && disconnectMessage !== void 0 ? disconnectMessage : t("settings.integrations.".concat(integration, ".disconnect.message"))
241
+ }));
242
+ });
243
+
135
244
  var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
136
245
  var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
137
246
 
@@ -292,6 +401,7 @@ var Form = function Form(_ref) {
292
401
  i18nKey: "neetoIntegrations.daily.helpDoc",
293
402
  components: {
294
403
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
404
+ "data-cy": "api-key-help-doc-link",
295
405
  href: helpDocUrl,
296
406
  rel: "noreferrer",
297
407
  target: "_blank"
@@ -321,46 +431,9 @@ var Form = function Form(_ref) {
321
431
  };
322
432
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
323
433
 
324
- var Manage$1 = withT(function (_ref) {
325
- var t = _ref.t,
326
- title = _ref.title,
327
- description = _ref.description,
328
- integration = _ref.integration,
329
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
330
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
331
- isDisconnecting = _ref.isDisconnecting,
332
- onDisconnect = _ref.onDisconnect,
333
- onClose = _ref.onClose;
334
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
335
- className: "mx-auto w-full max-w-md"
336
- }, /*#__PURE__*/React__default.createElement("div", {
337
- className: "mt-10 w-full space-y-4"
338
- }, /*#__PURE__*/React__default.createElement(Typography, {
339
- className: "neeto-ui-text-gray-800 mb-0.5",
340
- style: "h3",
341
- weight: "semibold"
342
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
343
- className: "neeto-ui-text-gray-600 break-all",
344
- style: "body1",
345
- weight: "normal"
346
- }, description), /*#__PURE__*/React__default.createElement(Button, {
347
- label: t("neetoIntegrations.common.disconnect"),
348
- style: "danger",
349
- onClick: function onClick() {
350
- return setIsDisconnectAlertOpen(true);
351
- }
352
- }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
353
- isDisconnecting: isDisconnecting,
354
- onClose: onClose,
355
- onDisconnect: onDisconnect,
356
- isOpen: isDisconnectAlertOpen,
357
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
358
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
359
- }));
360
- });
361
-
362
434
  var Manage = function Manage(_ref) {
363
- var onDisconnect = _ref.onDisconnect;
435
+ var description = _ref.description,
436
+ onDisconnect = _ref.onDisconnect;
364
437
  var _useState = useState(false),
365
438
  _useState2 = _slicedToArray(_useState, 2),
366
439
  isDisconnectAlertOpen = _useState2[0],
@@ -370,7 +443,7 @@ var Manage = function Manage(_ref) {
370
443
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
371
444
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
372
445
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
373
- isLoading = _useFetchDaily.isLoading;
446
+ isFetching = _useFetchDaily.isFetching;
374
447
  var _ref2 = metadata || {},
375
448
  _ref2$apiKey = _ref2.apiKey,
376
449
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -384,24 +457,33 @@ var Manage = function Manage(_ref) {
384
457
  }),
385
458
  destroyIntegration = _useDestroyDaily.mutate,
386
459
  isDisconnecting = _useDestroyDaily.isLoading;
460
+ var isConnected = isPresent(apiKey);
387
461
  var handleDisconnect = function handleDisconnect() {
388
462
  return destroyIntegration("daily");
389
463
  };
390
- if (isLoading || isDisconnecting) {
391
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
392
- }
393
- if (isNotPresent(apiKey)) {
394
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
395
- }
464
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
396
465
  return /*#__PURE__*/React__default.createElement(Manage$1, {
466
+ isConnected: isConnected,
397
467
  isDisconnectAlertOpen: isDisconnectAlertOpen,
398
468
  isDisconnecting: isDisconnecting,
399
469
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
400
- description: t("neetoIntegrations.daily.yourApiKey", {
401
- apiKey: apiKey
470
+ Icon: Daily$1,
471
+ connectPath: buildUrl(window.location.pathname, {
472
+ connect: true
402
473
  }),
403
474
  integration: "daily",
404
- title: t("neetoIntegrations.daily.connected"),
475
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
476
+ components: {
477
+ underline: /*#__PURE__*/React__default.createElement("u", {
478
+ className: "font-medium"
479
+ })
480
+ },
481
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
482
+ values: {
483
+ apiKey: apiKey
484
+ }
485
+ }) : description,
486
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
405
487
  onClose: function onClose() {
406
488
  return setIsDisconnectAlertOpen(false);
407
489
  },
@@ -416,10 +498,14 @@ var Daily = function Daily(_ref) {
416
498
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
417
499
  _ref$videoUrl = _ref.videoUrl,
418
500
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
501
+ _ref$description = _ref.description,
502
+ description = _ref$description === void 0 ? "" : _ref$description,
419
503
  _ref$onConnect = _ref.onConnect,
420
504
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
421
505
  _ref$onDisconnect = _ref.onDisconnect,
422
506
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
507
+ var _useQueryParams = useQueryParams(),
508
+ connect = _useQueryParams.connect;
423
509
  var _useFetchDaily = useFetchDaily(),
424
510
  _useFetchDaily$data = _useFetchDaily.data,
425
511
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -428,8 +514,9 @@ var Daily = function Daily(_ref) {
428
514
  var _ref2 = metadata || {},
429
515
  _ref2$apiKey = _ref2.apiKey,
430
516
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
431
- if (isPresent(apiKey) && !isOnboarding) {
517
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
432
518
  return /*#__PURE__*/React__default.createElement(Manage, {
519
+ description: description,
433
520
  onDisconnect: onDisconnect
434
521
  });
435
522
  }
@@ -791,7 +878,7 @@ var GoogleCalendar = function GoogleCalendar(_ref) {
791
878
  setSteps = _useState2[1];
792
879
  var _getQueryParams = getQueryParams(),
793
880
  status = _getQueryParams.status;
794
- var activeTab = isPresent$1(status) ? STEPS.finish : STEPS.connect;
881
+ var activeTab = isPresent(status) ? STEPS.finish : STEPS.connect;
795
882
  useEffect(function () {
796
883
  setSteps(function () {
797
884
  var stepsClone = _toConsumableArray(steps);
@@ -811,15 +898,15 @@ var GoogleCalendar = function GoogleCalendar(_ref) {
811
898
  isOpen: true,
812
899
  onClose: handleClose
813
900
  }, activeTab === STEPS.connect && /*#__PURE__*/React__default.createElement("div", {
814
- className: "mx-auto w-full max-w-2xl"
901
+ className: "w-full max-w-2xl mx-auto"
815
902
  }, /*#__PURE__*/React__default.createElement(GoogleCalendar$1, {
816
903
  size: 42
817
904
  }), /*#__PURE__*/React__default.createElement(Typography, {
818
- className: "neeto-ui-text-gray-800 mb-3 mt-6",
905
+ className: "mt-6 mb-3 neeto-ui-text-gray-800",
819
906
  style: "h2",
820
907
  weight: "semibold"
821
908
  }, t("neetoIntegrations.google.connect.title")), /*#__PURE__*/React__default.createElement("div", {
822
- className: "flex w-full flex-col items-start pt-2"
909
+ className: "flex flex-col items-start w-full pt-2"
823
910
  }, /*#__PURE__*/React__default.createElement(Callout, {
824
911
  className: "block leading-5"
825
912
  }, /*#__PURE__*/React__default.createElement(Trans, {
@@ -831,7 +918,7 @@ var GoogleCalendar = function GoogleCalendar(_ref) {
831
918
  selectCheckbox: t("neetoIntegrations.google.connect.selectCheckbox")
832
919
  }
833
920
  })), permissionImage && /*#__PURE__*/React__default.createElement("div", {
834
- className: "neeto-ui-border-gray-300 my-4 border"
921
+ className: "my-4 border neeto-ui-border-gray-300"
835
922
  }, /*#__PURE__*/React__default.createElement("img", {
836
923
  src: permissionImage
837
924
  }))), /*#__PURE__*/React__default.createElement(Button, {