@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.
@@ -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,115 @@ 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 ? 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
+
134
244
  var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
135
245
  var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
136
246
 
@@ -291,6 +401,7 @@ var Form = function Form(_ref) {
291
401
  i18nKey: "neetoIntegrations.daily.helpDoc",
292
402
  components: {
293
403
  externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
404
+ "data-cy": "api-key-help-doc-link",
294
405
  href: helpDocUrl,
295
406
  rel: "noreferrer",
296
407
  target: "_blank"
@@ -320,46 +431,9 @@ var Form = function Form(_ref) {
320
431
  };
321
432
  var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
322
433
 
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
434
  var Manage = function Manage(_ref) {
362
- var onDisconnect = _ref.onDisconnect;
435
+ var description = _ref.description,
436
+ onDisconnect = _ref.onDisconnect;
363
437
  var _useState = useState(false),
364
438
  _useState2 = _slicedToArray(_useState, 2),
365
439
  isDisconnectAlertOpen = _useState2[0],
@@ -369,7 +443,7 @@ var Manage = function Manage(_ref) {
369
443
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
370
444
  _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
371
445
  metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
372
- isLoading = _useFetchDaily.isLoading;
446
+ isFetching = _useFetchDaily.isFetching;
373
447
  var _ref2 = metadata || {},
374
448
  _ref2$apiKey = _ref2.apiKey,
375
449
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
@@ -383,24 +457,33 @@ var Manage = function Manage(_ref) {
383
457
  }),
384
458
  destroyIntegration = _useDestroyDaily.mutate,
385
459
  isDisconnecting = _useDestroyDaily.isLoading;
460
+ var isConnected = isPresent(apiKey);
386
461
  var handleDisconnect = function handleDisconnect() {
387
462
  return destroyIntegration("daily");
388
463
  };
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
- }
464
+ if (isFetching || isDisconnecting) return /*#__PURE__*/React__default.createElement(PageLoader, null);
395
465
  return /*#__PURE__*/React__default.createElement(Manage$1, {
466
+ isConnected: isConnected,
396
467
  isDisconnectAlertOpen: isDisconnectAlertOpen,
397
468
  isDisconnecting: isDisconnecting,
398
469
  setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
399
- description: t("neetoIntegrations.daily.yourApiKey", {
400
- apiKey: apiKey
470
+ Icon: Daily$1,
471
+ connectPath: buildUrl(window.location.pathname, {
472
+ connect: true
401
473
  }),
402
474
  integration: "daily",
403
- 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"),
404
487
  onClose: function onClose() {
405
488
  return setIsDisconnectAlertOpen(false);
406
489
  },
@@ -415,10 +498,14 @@ var Daily = function Daily(_ref) {
415
498
  helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
416
499
  _ref$videoUrl = _ref.videoUrl,
417
500
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
501
+ _ref$description = _ref.description,
502
+ description = _ref$description === void 0 ? "" : _ref$description,
418
503
  _ref$onConnect = _ref.onConnect,
419
504
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
420
505
  _ref$onDisconnect = _ref.onDisconnect,
421
506
  onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
507
+ var _useQueryParams = useQueryParams(),
508
+ connect = _useQueryParams.connect;
422
509
  var _useFetchDaily = useFetchDaily(),
423
510
  _useFetchDaily$data = _useFetchDaily.data,
424
511
  _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
@@ -427,8 +514,9 @@ var Daily = function Daily(_ref) {
427
514
  var _ref2 = metadata || {},
428
515
  _ref2$apiKey = _ref2.apiKey,
429
516
  apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
430
- if (isPresent(apiKey) && !isOnboarding) {
517
+ if (isPresent(apiKey) && !isOnboarding || !connect) {
431
518
  return /*#__PURE__*/React__default.createElement(Manage, {
519
+ description: description,
432
520
  onDisconnect: onDisconnect
433
521
  });
434
522
  }