@atlaskit/editor-synced-block-renderer 4.0.3 → 4.0.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-synced-block-renderer
2
2
 
3
+ ## 4.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`50cf7cca6bb76`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/50cf7cca6bb76) -
8
+ [ux] EDITOR-3896 update sync block border styles
9
+ - Updated dependencies
10
+
11
+ ## 4.0.4
12
+
13
+ ### Patch Changes
14
+
15
+ - [`a41bf96788d92`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a41bf96788d92) -
16
+ [ux] Fix sync block permissions denied error to show the correct state
17
+ - Updated dependencies
18
+
3
19
  ## 4.0.3
4
20
 
5
21
  ### Patch Changes
@@ -41,6 +41,9 @@
41
41
  {
42
42
  "path": "../../../design-system/icon/afm-products/tsconfig.json"
43
43
  },
44
+ {
45
+ "path": "../../../design-system/icon-lab/afm-products/tsconfig.json"
46
+ },
44
47
  {
45
48
  "path": "../../../design-system/image/afm-products/tsconfig.json"
46
49
  },
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.SyncedBlockErrorComponent = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _monitoring = require("@atlaskit/editor-common/monitoring");
9
10
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
10
11
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
11
12
  var _SyncedBlockGenericError = require("./SyncedBlockGenericError");
@@ -13,24 +14,38 @@ var _SyncedBlockLoadError = require("./SyncedBlockLoadError");
13
14
  var _SyncedBlockOfflineError = require("./SyncedBlockOfflineError");
14
15
  var _SyncedBlockPermissionDenied = require("./SyncedBlockPermissionDenied");
15
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ var getForbiddenErrorContent = function getForbiddenErrorContent(resourceId, fireAnalyticsEvent) {
18
+ try {
19
+ if (!resourceId) {
20
+ throw new Error('Missing resource id');
21
+ }
22
+ var _getContentIdAndProdu = (0, _editorSyncedBlockProvider.getContentIdAndProductFromResourceId)(resourceId),
23
+ sourceContentId = _getContentIdAndProdu.sourceContentId,
24
+ sourceProduct = _getContentIdAndProdu.sourceProduct;
25
+ return /*#__PURE__*/_react.default.createElement(_SyncedBlockPermissionDenied.SyncedBlockPermissionDenied, {
26
+ sourceContentId: sourceContentId,
27
+ sourceProduct: sourceProduct
28
+ });
29
+ } catch (error) {
30
+ (0, _monitoring.logException)(error, {
31
+ location: 'editor-synced-block-renderer/SyncedBlockErrorComponent'
32
+ });
33
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent((0, _editorSyncedBlockProvider.fetchErrorPayload)(error.message));
34
+ return /*#__PURE__*/_react.default.createElement(_SyncedBlockGenericError.SyncedBlockGenericError, null);
35
+ }
36
+ };
16
37
  var SyncedBlockErrorComponent = exports.SyncedBlockErrorComponent = function SyncedBlockErrorComponent(_ref) {
17
38
  var error = _ref.error,
18
39
  isLoading = _ref.isLoading,
19
40
  onRetry = _ref.onRetry,
20
- sourceAri = _ref.sourceAri,
21
- sourceProduct = _ref.sourceProduct;
41
+ resourceId = _ref.resourceId,
42
+ fireAnalyticsEvent = _ref.fireAnalyticsEvent;
22
43
  var getErrorContent = (0, _react.useMemo)(function () {
23
44
  switch (error) {
24
45
  case _editorSyncedBlockProvider.SyncBlockError.Offline:
25
46
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockOfflineError.SyncedBlockOfflineError, null);
26
47
  case _editorSyncedBlockProvider.SyncBlockError.Forbidden:
27
- if (!sourceAri || !sourceProduct) {
28
- return /*#__PURE__*/_react.default.createElement(_SyncedBlockGenericError.SyncedBlockGenericError, null);
29
- }
30
- return /*#__PURE__*/_react.default.createElement(_SyncedBlockPermissionDenied.SyncedBlockPermissionDenied, {
31
- sourceAri: sourceAri,
32
- sourceProduct: sourceProduct
33
- });
48
+ return getForbiddenErrorContent(resourceId, fireAnalyticsEvent);
34
49
  case _editorSyncedBlockProvider.SyncBlockError.NotFound:
35
50
  case _editorSyncedBlockProvider.SyncBlockError.Errored:
36
51
  case _editorSyncedBlockProvider.SyncBlockError.RateLimited:
@@ -42,7 +57,7 @@ var SyncedBlockErrorComponent = exports.SyncedBlockErrorComponent = function Syn
42
57
  default:
43
58
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockGenericError.SyncedBlockGenericError, null);
44
59
  }
45
- }, [error, isLoading, onRetry, sourceAri, sourceProduct]);
60
+ }, [error, isLoading, onRetry, resourceId, fireAnalyticsEvent]);
46
61
  return (
47
62
  /*#__PURE__*/
48
63
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.SyncedBlockNodeComponentRenderer = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _syncBlock = require("@atlaskit/editor-common/sync-block");
9
10
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
10
11
  var _AKRendererWrapper = require("./AKRendererWrapper");
11
12
  var _SyncedBlockErrorComponent = require("./SyncedBlockErrorComponent");
@@ -27,13 +28,13 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
27
28
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
28
29
  }
29
30
  if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data)) {
30
- var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
31
+ var _syncBlockInstance$er;
31
32
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
32
33
  error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : _editorSyncedBlockProvider.SyncBlockError.Errored,
33
- sourceAri: syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.sourceAri,
34
- sourceProduct: syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
34
+ resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
35
35
  onRetry: reloadData,
36
- isLoading: isLoading
36
+ isLoading: isLoading,
37
+ fireAnalyticsEvent: fireAnalyticsEvent
37
38
  });
38
39
  }
39
40
  var syncBlockDoc = {
@@ -41,11 +42,16 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
41
42
  version: 1,
42
43
  type: 'doc'
43
44
  };
44
- return /*#__PURE__*/_react.default.createElement("div", {
45
- "data-sync-block-renderer": true
46
- }, /*#__PURE__*/_react.default.createElement(_AKRendererWrapper.AKRendererWrapper, {
47
- doc: syncBlockDoc,
48
- dataProviders: providerFactory,
49
- options: rendererOptions
50
- }));
45
+ return (
46
+ /*#__PURE__*/
47
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
48
+ _react.default.createElement("div", {
49
+ className: _syncBlock.SyncBlockSharedCssClassName.renderer,
50
+ "data-sync-block-renderer": true
51
+ }, /*#__PURE__*/_react.default.createElement(_AKRendererWrapper.AKRendererWrapper, {
52
+ doc: syncBlockDoc,
53
+ dataProviders: providerFactory,
54
+ options: rendererOptions
55
+ }))
56
+ );
51
57
  };
@@ -16,7 +16,6 @@ var _reactIntlNext = require("react-intl-next");
16
16
  var _reactRelay = require("react-relay");
17
17
  var _new = _interopRequireDefault(require("@atlaskit/button/new"));
18
18
  var _messages = require("@atlaskit/editor-common/messages");
19
- var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
20
19
  var _heading = _interopRequireDefault(require("@atlaskit/heading"));
21
20
  var _statusSuccess = _interopRequireDefault(require("@atlaskit/icon/core/status-success"));
22
21
  var _image = _interopRequireDefault(require("@atlaskit/image"));
@@ -35,8 +34,7 @@ var RequestAccessState = /*#__PURE__*/function (RequestAccessState) {
35
34
  return RequestAccessState;
36
35
  }(RequestAccessState || {});
37
36
  var SyncedBlockPermissionDeniedConfluencePage = function SyncedBlockPermissionDeniedConfluencePage(_ref) {
38
- var sourceAri = _ref.sourceAri;
39
- var contentId = (0, _editorSyncedBlockProvider.getPageIdAndTypeFromConfluencePageAri)(sourceAri).id;
37
+ var sourceContentId = _ref.sourceContentId;
40
38
  var _useIntl = (0, _reactIntlNext.useIntl)(),
41
39
  formatMessage = _useIntl.formatMessage;
42
40
  var _useState = (0, _react.useState)(RequestAccessState.default),
@@ -57,7 +55,7 @@ var SyncedBlockPermissionDeniedConfluencePage = function SyncedBlockPermissionDe
57
55
  commitMutation({
58
56
  variables: {
59
57
  requestPageAccessInput: {
60
- pageId: contentId,
58
+ pageId: sourceContentId,
61
59
  accessType: 'VIEW'
62
60
  }
63
61
  },
@@ -106,12 +104,12 @@ var SyncedBlockPermissionDeniedConfluencePage = function SyncedBlockPermissionDe
106
104
  }, formatMessage(_messages.syncBlockMessages.requestAccessError)))));
107
105
  };
108
106
  var SyncedBlockPermissionDenied = exports.SyncedBlockPermissionDenied = function SyncedBlockPermissionDenied(_ref2) {
109
- var sourceAri = _ref2.sourceAri,
107
+ var sourceContentId = _ref2.sourceContentId,
110
108
  sourceProduct = _ref2.sourceProduct;
111
109
  switch (sourceProduct) {
112
110
  case 'confluence-page':
113
111
  return /*#__PURE__*/_react.default.createElement(SyncedBlockPermissionDeniedConfluencePage, {
114
- sourceAri: sourceAri
112
+ sourceContentId: sourceContentId
115
113
  });
116
114
  default:
117
115
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockGenericError.SyncedBlockGenericError, null);
@@ -37,13 +37,13 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
37
37
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
38
38
  }
39
39
  if (syncBlockInstance.error || !syncBlockInstance.data) {
40
- var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
40
+ var _syncBlockInstance$er, _api$analytics;
41
41
  return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
42
42
  error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : _editorSyncedBlockProvider.SyncBlockError.Errored,
43
- sourceAri: (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.sourceAri,
44
- sourceProduct: (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
43
+ resourceId: syncBlockInstance.resourceId,
45
44
  onRetry: reloadData,
46
- isLoading: isLoading
45
+ isLoading: isLoading,
46
+ fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent
47
47
  });
48
48
  }
49
49
  var syncBlockDoc = {
@@ -1,29 +1,45 @@
1
1
  import React, { useMemo } from 'react';
2
+ import { logException } from '@atlaskit/editor-common/monitoring';
2
3
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
3
- import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
4
+ import { fetchErrorPayload, getContentIdAndProductFromResourceId, SyncBlockError } from '@atlaskit/editor-synced-block-provider';
4
5
  import { SyncedBlockGenericError } from './SyncedBlockGenericError';
5
6
  import { SyncedBlockLoadError } from './SyncedBlockLoadError';
6
7
  import { SyncedBlockOfflineError } from './SyncedBlockOfflineError';
7
8
  import { SyncedBlockPermissionDenied } from './SyncedBlockPermissionDenied';
9
+ const getForbiddenErrorContent = (resourceId, fireAnalyticsEvent) => {
10
+ try {
11
+ if (!resourceId) {
12
+ throw new Error('Missing resource id');
13
+ }
14
+ const {
15
+ sourceContentId,
16
+ sourceProduct
17
+ } = getContentIdAndProductFromResourceId(resourceId);
18
+ return /*#__PURE__*/React.createElement(SyncedBlockPermissionDenied, {
19
+ sourceContentId: sourceContentId,
20
+ sourceProduct: sourceProduct
21
+ });
22
+ } catch (error) {
23
+ logException(error, {
24
+ location: 'editor-synced-block-renderer/SyncedBlockErrorComponent'
25
+ });
26
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(fetchErrorPayload(error.message));
27
+ return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
28
+ }
29
+ };
8
30
  export const SyncedBlockErrorComponent = ({
9
31
  error,
10
32
  isLoading,
11
33
  onRetry,
12
- sourceAri,
13
- sourceProduct
34
+ resourceId,
35
+ fireAnalyticsEvent
14
36
  }) => {
15
37
  const getErrorContent = useMemo(() => {
16
38
  switch (error) {
17
39
  case SyncBlockError.Offline:
18
40
  return /*#__PURE__*/React.createElement(SyncedBlockOfflineError, null);
19
41
  case SyncBlockError.Forbidden:
20
- if (!sourceAri || !sourceProduct) {
21
- return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
22
- }
23
- return /*#__PURE__*/React.createElement(SyncedBlockPermissionDenied, {
24
- sourceAri: sourceAri,
25
- sourceProduct: sourceProduct
26
- });
42
+ return getForbiddenErrorContent(resourceId, fireAnalyticsEvent);
27
43
  case SyncBlockError.NotFound:
28
44
  case SyncBlockError.Errored:
29
45
  case SyncBlockError.RateLimited:
@@ -35,7 +51,7 @@ export const SyncedBlockErrorComponent = ({
35
51
  default:
36
52
  return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
37
53
  }
38
- }, [error, isLoading, onRetry, sourceAri, sourceProduct]);
54
+ }, [error, isLoading, onRetry, resourceId, fireAnalyticsEvent]);
39
55
  return (
40
56
  /*#__PURE__*/
41
57
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
2
3
  import { SyncBlockError, useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
3
4
  import { AKRendererWrapper } from './AKRendererWrapper';
4
5
  import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
@@ -24,13 +25,13 @@ export const SyncedBlockNodeComponentRenderer = ({
24
25
  return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
25
26
  }
26
27
  if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data)) {
27
- var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
28
+ var _syncBlockInstance$er;
28
29
  return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
29
30
  error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : SyncBlockError.Errored,
30
- sourceAri: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.sourceAri,
31
- sourceProduct: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
31
+ resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
32
32
  onRetry: reloadData,
33
- isLoading: isLoading
33
+ isLoading: isLoading,
34
+ fireAnalyticsEvent: fireAnalyticsEvent
34
35
  });
35
36
  }
36
37
  const syncBlockDoc = {
@@ -38,11 +39,16 @@ export const SyncedBlockNodeComponentRenderer = ({
38
39
  version: 1,
39
40
  type: 'doc'
40
41
  };
41
- return /*#__PURE__*/React.createElement("div", {
42
- "data-sync-block-renderer": true
43
- }, /*#__PURE__*/React.createElement(AKRendererWrapper, {
44
- doc: syncBlockDoc,
45
- dataProviders: providerFactory,
46
- options: rendererOptions
47
- }));
42
+ return (
43
+ /*#__PURE__*/
44
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
45
+ React.createElement("div", {
46
+ className: SyncBlockSharedCssClassName.renderer,
47
+ "data-sync-block-renderer": true
48
+ }, /*#__PURE__*/React.createElement(AKRendererWrapper, {
49
+ doc: syncBlockDoc,
50
+ dataProviders: providerFactory,
51
+ options: rendererOptions
52
+ }))
53
+ );
48
54
  };
@@ -7,7 +7,6 @@ import { useIntl } from 'react-intl-next';
7
7
  import { useMutation, graphql } from 'react-relay';
8
8
  import Button from '@atlaskit/button/new';
9
9
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
- import { getPageIdAndTypeFromConfluencePageAri } from '@atlaskit/editor-synced-block-provider';
11
10
  import Heading from '@atlaskit/heading';
12
11
  import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
13
12
  import Image from '@atlaskit/image';
@@ -25,9 +24,8 @@ var RequestAccessState = /*#__PURE__*/function (RequestAccessState) {
25
24
  return RequestAccessState;
26
25
  }(RequestAccessState || {});
27
26
  const SyncedBlockPermissionDeniedConfluencePage = ({
28
- sourceAri
27
+ sourceContentId
29
28
  }) => {
30
- const contentId = getPageIdAndTypeFromConfluencePageAri(sourceAri).id;
31
29
  const {
32
30
  formatMessage
33
31
  } = useIntl();
@@ -44,7 +42,7 @@ const SyncedBlockPermissionDeniedConfluencePage = ({
44
42
  commitMutation({
45
43
  variables: {
46
44
  requestPageAccessInput: {
47
- pageId: contentId,
45
+ pageId: sourceContentId,
48
46
  accessType: 'VIEW'
49
47
  }
50
48
  },
@@ -93,13 +91,13 @@ const SyncedBlockPermissionDeniedConfluencePage = ({
93
91
  }, formatMessage(messages.requestAccessError)))));
94
92
  };
95
93
  export const SyncedBlockPermissionDenied = ({
96
- sourceAri,
94
+ sourceContentId,
97
95
  sourceProduct
98
96
  }) => {
99
97
  switch (sourceProduct) {
100
98
  case 'confluence-page':
101
99
  return /*#__PURE__*/React.createElement(SyncedBlockPermissionDeniedConfluencePage, {
102
- sourceAri: sourceAri
100
+ sourceContentId: sourceContentId
103
101
  });
104
102
  default:
105
103
  return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
@@ -31,13 +31,13 @@ const SyncedBlockRendererComponent = ({
31
31
  return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
32
32
  }
33
33
  if (syncBlockInstance.error || !syncBlockInstance.data) {
34
- var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
34
+ var _syncBlockInstance$er, _api$analytics;
35
35
  return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
36
36
  error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : SyncBlockError.Errored,
37
- sourceAri: (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.sourceAri,
38
- sourceProduct: (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
37
+ resourceId: syncBlockInstance.resourceId,
39
38
  onRetry: reloadData,
40
- isLoading: isLoading
39
+ isLoading: isLoading,
40
+ fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent
41
41
  });
42
42
  }
43
43
  const syncBlockDoc = {
@@ -1,28 +1,43 @@
1
1
  import React, { useMemo } from 'react';
2
+ import { logException } from '@atlaskit/editor-common/monitoring';
2
3
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
3
- import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
4
+ import { fetchErrorPayload, getContentIdAndProductFromResourceId, SyncBlockError } from '@atlaskit/editor-synced-block-provider';
4
5
  import { SyncedBlockGenericError } from './SyncedBlockGenericError';
5
6
  import { SyncedBlockLoadError } from './SyncedBlockLoadError';
6
7
  import { SyncedBlockOfflineError } from './SyncedBlockOfflineError';
7
8
  import { SyncedBlockPermissionDenied } from './SyncedBlockPermissionDenied';
9
+ var getForbiddenErrorContent = function getForbiddenErrorContent(resourceId, fireAnalyticsEvent) {
10
+ try {
11
+ if (!resourceId) {
12
+ throw new Error('Missing resource id');
13
+ }
14
+ var _getContentIdAndProdu = getContentIdAndProductFromResourceId(resourceId),
15
+ sourceContentId = _getContentIdAndProdu.sourceContentId,
16
+ sourceProduct = _getContentIdAndProdu.sourceProduct;
17
+ return /*#__PURE__*/React.createElement(SyncedBlockPermissionDenied, {
18
+ sourceContentId: sourceContentId,
19
+ sourceProduct: sourceProduct
20
+ });
21
+ } catch (error) {
22
+ logException(error, {
23
+ location: 'editor-synced-block-renderer/SyncedBlockErrorComponent'
24
+ });
25
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(error.message));
26
+ return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
27
+ }
28
+ };
8
29
  export var SyncedBlockErrorComponent = function SyncedBlockErrorComponent(_ref) {
9
30
  var error = _ref.error,
10
31
  isLoading = _ref.isLoading,
11
32
  onRetry = _ref.onRetry,
12
- sourceAri = _ref.sourceAri,
13
- sourceProduct = _ref.sourceProduct;
33
+ resourceId = _ref.resourceId,
34
+ fireAnalyticsEvent = _ref.fireAnalyticsEvent;
14
35
  var getErrorContent = useMemo(function () {
15
36
  switch (error) {
16
37
  case SyncBlockError.Offline:
17
38
  return /*#__PURE__*/React.createElement(SyncedBlockOfflineError, null);
18
39
  case SyncBlockError.Forbidden:
19
- if (!sourceAri || !sourceProduct) {
20
- return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
21
- }
22
- return /*#__PURE__*/React.createElement(SyncedBlockPermissionDenied, {
23
- sourceAri: sourceAri,
24
- sourceProduct: sourceProduct
25
- });
40
+ return getForbiddenErrorContent(resourceId, fireAnalyticsEvent);
26
41
  case SyncBlockError.NotFound:
27
42
  case SyncBlockError.Errored:
28
43
  case SyncBlockError.RateLimited:
@@ -34,7 +49,7 @@ export var SyncedBlockErrorComponent = function SyncedBlockErrorComponent(_ref)
34
49
  default:
35
50
  return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
36
51
  }
37
- }, [error, isLoading, onRetry, sourceAri, sourceProduct]);
52
+ }, [error, isLoading, onRetry, resourceId, fireAnalyticsEvent]);
38
53
  return (
39
54
  /*#__PURE__*/
40
55
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
2
3
  import { SyncBlockError, useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
3
4
  import { AKRendererWrapper } from './AKRendererWrapper';
4
5
  import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
@@ -20,13 +21,13 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
20
21
  return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
21
22
  }
22
23
  if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data)) {
23
- var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
24
+ var _syncBlockInstance$er;
24
25
  return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
25
26
  error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : SyncBlockError.Errored,
26
- sourceAri: syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.sourceAri,
27
- sourceProduct: syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
27
+ resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
28
28
  onRetry: reloadData,
29
- isLoading: isLoading
29
+ isLoading: isLoading,
30
+ fireAnalyticsEvent: fireAnalyticsEvent
30
31
  });
31
32
  }
32
33
  var syncBlockDoc = {
@@ -34,11 +35,16 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
34
35
  version: 1,
35
36
  type: 'doc'
36
37
  };
37
- return /*#__PURE__*/React.createElement("div", {
38
- "data-sync-block-renderer": true
39
- }, /*#__PURE__*/React.createElement(AKRendererWrapper, {
40
- doc: syncBlockDoc,
41
- dataProviders: providerFactory,
42
- options: rendererOptions
43
- }));
38
+ return (
39
+ /*#__PURE__*/
40
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
41
+ React.createElement("div", {
42
+ className: SyncBlockSharedCssClassName.renderer,
43
+ "data-sync-block-renderer": true
44
+ }, /*#__PURE__*/React.createElement(AKRendererWrapper, {
45
+ doc: syncBlockDoc,
46
+ dataProviders: providerFactory,
47
+ options: rendererOptions
48
+ }))
49
+ );
44
50
  };
@@ -8,7 +8,6 @@ import { useIntl } from 'react-intl-next';
8
8
  import { useMutation, graphql } from 'react-relay';
9
9
  import Button from '@atlaskit/button/new';
10
10
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
11
- import { getPageIdAndTypeFromConfluencePageAri } from '@atlaskit/editor-synced-block-provider';
12
11
  import Heading from '@atlaskit/heading';
13
12
  import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
14
13
  import Image from '@atlaskit/image';
@@ -26,8 +25,7 @@ var RequestAccessState = /*#__PURE__*/function (RequestAccessState) {
26
25
  return RequestAccessState;
27
26
  }(RequestAccessState || {});
28
27
  var SyncedBlockPermissionDeniedConfluencePage = function SyncedBlockPermissionDeniedConfluencePage(_ref) {
29
- var sourceAri = _ref.sourceAri;
30
- var contentId = getPageIdAndTypeFromConfluencePageAri(sourceAri).id;
28
+ var sourceContentId = _ref.sourceContentId;
31
29
  var _useIntl = useIntl(),
32
30
  formatMessage = _useIntl.formatMessage;
33
31
  var _useState = useState(RequestAccessState.default),
@@ -48,7 +46,7 @@ var SyncedBlockPermissionDeniedConfluencePage = function SyncedBlockPermissionDe
48
46
  commitMutation({
49
47
  variables: {
50
48
  requestPageAccessInput: {
51
- pageId: contentId,
49
+ pageId: sourceContentId,
52
50
  accessType: 'VIEW'
53
51
  }
54
52
  },
@@ -97,12 +95,12 @@ var SyncedBlockPermissionDeniedConfluencePage = function SyncedBlockPermissionDe
97
95
  }, formatMessage(messages.requestAccessError)))));
98
96
  };
99
97
  export var SyncedBlockPermissionDenied = function SyncedBlockPermissionDenied(_ref2) {
100
- var sourceAri = _ref2.sourceAri,
98
+ var sourceContentId = _ref2.sourceContentId,
101
99
  sourceProduct = _ref2.sourceProduct;
102
100
  switch (sourceProduct) {
103
101
  case 'confluence-page':
104
102
  return /*#__PURE__*/React.createElement(SyncedBlockPermissionDeniedConfluencePage, {
105
- sourceAri: sourceAri
103
+ sourceContentId: sourceContentId
106
104
  });
107
105
  default:
108
106
  return /*#__PURE__*/React.createElement(SyncedBlockGenericError, null);
@@ -29,13 +29,13 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
29
29
  return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
30
30
  }
31
31
  if (syncBlockInstance.error || !syncBlockInstance.data) {
32
- var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
32
+ var _syncBlockInstance$er, _api$analytics;
33
33
  return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
34
34
  error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : SyncBlockError.Errored,
35
- sourceAri: (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.sourceAri,
36
- sourceProduct: (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
35
+ resourceId: syncBlockInstance.resourceId,
37
36
  onRetry: reloadData,
38
- isLoading: isLoading
37
+ isLoading: isLoading,
38
+ fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent
39
39
  });
40
40
  }
41
41
  var syncBlockDoc = {
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
+ import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
3
  import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
3
- import type { SyncBlockProduct } from '@atlaskit/editor-synced-block-provider';
4
- export declare const SyncedBlockErrorComponent: ({ error, isLoading, onRetry, sourceAri, sourceProduct, }: {
4
+ export declare const SyncedBlockErrorComponent: ({ error, isLoading, onRetry, resourceId, fireAnalyticsEvent, }: {
5
5
  error: SyncBlockError;
6
+ fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
6
7
  isLoading?: boolean;
7
8
  onRetry?: () => void;
8
- sourceAri?: string;
9
- sourceProduct?: SyncBlockProduct;
9
+ resourceId?: string;
10
10
  }) => React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type SyncBlockProduct } from '@atlaskit/editor-synced-block-provider';
3
3
  export interface SyncedBlockPermissionDeniedProps {
4
- sourceAri: string;
4
+ sourceContentId: string;
5
5
  sourceProduct: SyncBlockProduct;
6
6
  }
7
- export declare const SyncedBlockPermissionDenied: ({ sourceAri, sourceProduct, }: SyncedBlockPermissionDeniedProps) => React.JSX.Element;
7
+ export declare const SyncedBlockPermissionDenied: ({ sourceContentId, sourceProduct, }: SyncedBlockPermissionDeniedProps) => React.JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
+ import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
3
  import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
3
- import type { SyncBlockProduct } from '@atlaskit/editor-synced-block-provider';
4
- export declare const SyncedBlockErrorComponent: ({ error, isLoading, onRetry, sourceAri, sourceProduct, }: {
4
+ export declare const SyncedBlockErrorComponent: ({ error, isLoading, onRetry, resourceId, fireAnalyticsEvent, }: {
5
5
  error: SyncBlockError;
6
+ fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
6
7
  isLoading?: boolean;
7
8
  onRetry?: () => void;
8
- sourceAri?: string;
9
- sourceProduct?: SyncBlockProduct;
9
+ resourceId?: string;
10
10
  }) => React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type SyncBlockProduct } from '@atlaskit/editor-synced-block-provider';
3
3
  export interface SyncedBlockPermissionDeniedProps {
4
- sourceAri: string;
4
+ sourceContentId: string;
5
5
  sourceProduct: SyncBlockProduct;
6
6
  }
7
- export declare const SyncedBlockPermissionDenied: ({ sourceAri, sourceProduct, }: SyncedBlockPermissionDeniedProps) => React.JSX.Element;
7
+ export declare const SyncedBlockPermissionDenied: ({ sourceContentId, sourceProduct, }: SyncedBlockPermissionDeniedProps) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-synced-block-renderer",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "SyncedBlockRenderer for @atlaskit/editor-plugin-synced-block",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,22 +31,21 @@
31
31
  "@atlaskit/button": "^23.7.0",
32
32
  "@atlaskit/css": "^0.17.0",
33
33
  "@atlaskit/editor-plugin-synced-block": "^4.5.0",
34
- "@atlaskit/editor-prosemirror": "7.0.0",
35
34
  "@atlaskit/editor-synced-block-provider": "^2.15.0",
36
35
  "@atlaskit/heading": "^5.2.0",
37
- "@atlaskit/icon": "^29.0.0",
36
+ "@atlaskit/icon": "^29.1.0",
38
37
  "@atlaskit/icon-lab": "^5.12.0",
39
38
  "@atlaskit/image": "^3.0.0",
40
39
  "@atlaskit/primitives": "^16.4.0",
41
- "@atlaskit/renderer": "^124.17.0",
40
+ "@atlaskit/renderer": "^124.21.0",
42
41
  "@atlaskit/spinner": "^19.0.0",
43
- "@atlaskit/tokens": "^8.4.0",
42
+ "@atlaskit/tokens": "^8.5.0",
44
43
  "@babel/runtime": "^7.0.0",
45
44
  "react-relay": "npm:atl-react-relay@0.0.0-main-39e79f66",
46
45
  "relay-runtime": "npm:atl-relay-runtime@0.0.0-main-39e79f66"
47
46
  },
48
47
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^110.41.0",
48
+ "@atlaskit/editor-common": "^110.44.0",
50
49
  "react": "^18.2.0",
51
50
  "react-intl-next": "npm:react-intl@^5.18.1"
52
51
  },