@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.
@@ -4,20 +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 { getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
13
- import { GoogleCalendar as GoogleCalendar$1, Google } from '@bigbinary/neeto-icons/misc';
14
- import { Button, Typography, Modal as Modal$1, Callout } from '@bigbinary/neetoui';
15
- 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';
16
16
  import { Form as Form$2, Input } from '@bigbinary/neetoui/formik';
17
17
  import 'ramda';
18
18
  import * as yup from 'yup';
19
19
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
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";
@@ -131,6 +132,116 @@ function _slicedToArray(arr, i) {
131
132
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
132
133
  }
133
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 ? undefined : _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: "neetoIntegrations.common.helpDocUrl",
202
+ components: {
203
+ helpLink: /*#__PURE__*/React__default.createElement(Button, {
204
+ href: helpDocUrl,
205
+ style: "link",
206
+ target: "_blank"
207
+ })
208
+ },
209
+ values: {
210
+ integration: integrationName || humanize(integration)
211
+ }
212
+ }))), isConnected ? /*#__PURE__*/React__default.createElement("div", {
213
+ className: "space-x-2"
214
+ }, managePath && /*#__PURE__*/React__default.createElement(Button, {
215
+ to: managePath,
216
+ label: t("neetoIntegrations.common.manageIntegration", {
217
+ integration: integrationName || humanize(integration)
218
+ })
219
+ }), onDisconnect && /*#__PURE__*/React__default.createElement(Button, {
220
+ style: "secondary",
221
+ label: t("neetoIntegrations.common.disconnectIntegration", {
222
+ integration: integrationName || humanize(integration)
223
+ }),
224
+ onClick: function onClick() {
225
+ return setIsDisconnectAlertOpen(true);
226
+ }
227
+ })) : /*#__PURE__*/React__default.createElement(Button, {
228
+ disabled: isConnectDisabled,
229
+ href: connectUrl,
230
+ to: connectPath,
231
+ tooltipProps: connectTooltipProps,
232
+ label: t("neetoIntegrations.common.connectIntegration", {
233
+ integration: integrationName || humanize(integration)
234
+ })
235
+ }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
236
+ isDisconnecting: isDisconnecting,
237
+ onClose: onClose,
238
+ onDisconnect: onDisconnect,
239
+ isOpen: isDisconnectAlertOpen,
240
+ title: t("settings.integrations.".concat(integration, ".disconnect.title")),
241
+ message: disconnectMessage || t("settings.integrations.".concat(integration, ".disconnect.message"))
242
+ }));
243
+ });
244
+
134
245
  var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
135
246
  var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
136
247
 
@@ -291,6 +402,7 @@ var Form = function Form(_ref) {
291
402
  i18nKey: "neetoIntegrations.daily.helpDoc",
292
403
  components: {
293
404
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
405
+ "data-cy": "api-key-help-doc-link",
294
406
  href: helpDocUrl,
295
407
  rel: "noreferrer",
296
408
  target: "_blank"
@@ -320,46 +432,9 @@ var Form = function Form(_ref) {
320
432
  };
321
433
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
322
434
 
323
- var Manage$1 = withT(function (_ref) {
324
- var t = _ref.t,
325
- title = _ref.title,
326
- description = _ref.description,
327
- integration = _ref.integration,
328
- isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
329
- setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
330
- isDisconnecting = _ref.isDisconnecting,
331
- onDisconnect = _ref.onDisconnect,
332
- onClose = _ref.onClose;
333
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
334
- className: "mx-auto w-full max-w-md"
335
- }, /*#__PURE__*/React__default.createElement("div", {
336
- className: "mt-10 w-full space-y-4"
337
- }, /*#__PURE__*/React__default.createElement(Typography, {
338
- className: "neeto-ui-text-gray-800 mb-0.5",
339
- style: "h3",
340
- weight: "semibold"
341
- }, title), /*#__PURE__*/React__default.createElement(Typography, {
342
- className: "neeto-ui-text-gray-600 break-all",
343
- style: "body1",
344
- weight: "normal"
345
- }, description), /*#__PURE__*/React__default.createElement(Button, {
346
- label: t("neetoIntegrations.common.disconnect"),
347
- style: "danger",
348
- onClick: function onClick() {
349
- return setIsDisconnectAlertOpen(true);
350
- }
351
- }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
352
- isDisconnecting: isDisconnecting,
353
- onClose: onClose,
354
- onDisconnect: onDisconnect,
355
- isOpen: isDisconnectAlertOpen,
356
- message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
357
- title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
358
- }));
359
- });
360
-
361
435
  var Manage = function Manage(_ref) {
362
- var onDisconnect = _ref.onDisconnect;
436
+ var description = _ref.description,
437
+ onDisconnect = _ref.onDisconnect;
363
438
  var _useState = useState(false),
364
439
  _useState2 = _slicedToArray(_useState, 2),
365
440
  isDisconnectAlertOpen = _useState2[0],
@@ -369,7 +444,7 @@ var Manage = function Manage(_ref) {
369
444
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
370
445
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
371
446
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
372
- isLoading = _useFetchDaily.isLoading;
447
+ isFetching = _useFetchDaily.isFetching;
373
448
  var _ref2 = metadata || {},
374
449
  _ref2$apiKey = _ref2.apiKey,
375
450
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -383,24 +458,33 @@ var Manage = function Manage(_ref) {
383
458
  }),
384
459
  destroyIntegration = _useDestroyDaily.mutate,
385
460
  isDisconnecting = _useDestroyDaily.isLoading;
461
+ var isConnected = isPresent(apiKey);
386
462
  var handleDisconnect = function handleDisconnect() {
387
463
  return destroyIntegration("daily");
388
464
  };
389
- if (isLoading || isDisconnecting) {
390
- return /*#__PURE__*/React__default.createElement(PageLoader, null);
391
- }
392
- if (isNotPresent(apiKey)) {
393
- onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
394
- }
465
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
395
466
  return /*#__PURE__*/React__default.createElement(Manage$1, {
467
+ isConnected: isConnected,
396
468
  isDisconnectAlertOpen: isDisconnectAlertOpen,
397
469
  isDisconnecting: isDisconnecting,
398
470
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
399
- description: t("neetoIntegrations.daily.yourApiKey", {
400
- apiKey: apiKey
471
+ Icon: Daily$1,
472
+ connectPath: buildUrl(window.location.pathname, {
473
+ connect: true
401
474
  }),
402
475
  integration: "daily",
403
- title: t("neetoIntegrations.daily.connected"),
476
+ description: isConnected ? /*#__PURE__*/React__default.createElement(Trans, {
477
+ components: {
478
+ underline: /*#__PURE__*/React__default.createElement("u", {
479
+ className: "font-medium"
480
+ })
481
+ },
482
+ i18nKey: "neetoIntegrations.daily.yourApiKey",
483
+ values: {
484
+ apiKey: apiKey
485
+ }
486
+ }) : description,
487
+ title: isConnected ? t("neetoIntegrations.daily.connected") : t("neetoIntegrations.daily.connect"),
404
488
  onClose: function onClose() {
405
489
  return setIsDisconnectAlertOpen(false);
406
490
  },
@@ -415,10 +499,14 @@ var Daily = function Daily(_ref) {
415
499
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
416
500
  _ref$videoUrl = _ref.videoUrl,
417
501
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
502
+ _ref$description = _ref.description,
503
+ description = _ref$description === void 0 ? "" : _ref$description,
418
504
  _ref$onConnect = _ref.onConnect,
419
505
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
420
506
  _ref$onDisconnect = _ref.onDisconnect,
421
507
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
508
+ var _useQueryParams = useQueryParams(),
509
+ connect = _useQueryParams.connect;
422
510
  var _useFetchDaily = useFetchDaily(),
423
511
  _useFetchDaily$data = _useFetchDaily.data,
424
512
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -427,8 +515,9 @@ var Daily = function Daily(_ref) {
427
515
  var _ref2 = metadata || {},
428
516
  _ref2$apiKey = _ref2.apiKey,
429
517
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
430
- if (isPresent(apiKey) && !isOnboarding) {
518
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
431
519
  return /*#__PURE__*/React__default.createElement(Manage, {
520
+ description: description,
432
521
  onDisconnect: onDisconnect
433
522
  });
434
523
  }