@atlaskit/editor-synced-block-renderer 4.0.3 → 4.0.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.
- package/CHANGELOG.md +8 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/ui/SyncedBlockErrorComponent.js +25 -10
- package/dist/cjs/ui/SyncedBlockNodeComponentRenderer.js +4 -4
- package/dist/cjs/ui/SyncedBlockPermissionDenied.js +4 -6
- package/dist/cjs/ui/SyncedBlockRenderer.js +4 -4
- package/dist/es2019/ui/SyncedBlockErrorComponent.js +27 -11
- package/dist/es2019/ui/SyncedBlockNodeComponentRenderer.js +4 -4
- package/dist/es2019/ui/SyncedBlockPermissionDenied.js +4 -6
- package/dist/es2019/ui/SyncedBlockRenderer.js +4 -4
- package/dist/esm/ui/SyncedBlockErrorComponent.js +26 -11
- package/dist/esm/ui/SyncedBlockNodeComponentRenderer.js +4 -4
- package/dist/esm/ui/SyncedBlockPermissionDenied.js +4 -6
- package/dist/esm/ui/SyncedBlockRenderer.js +4 -4
- package/dist/types/ui/SyncedBlockErrorComponent.d.ts +4 -4
- package/dist/types/ui/SyncedBlockPermissionDenied.d.ts +2 -2
- package/dist/types-ts4.5/ui/SyncedBlockErrorComponent.d.ts +4 -4
- package/dist/types-ts4.5/ui/SyncedBlockPermissionDenied.d.ts +2 -2
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-renderer
|
|
2
2
|
|
|
3
|
+
## 4.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a41bf96788d92`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a41bf96788d92) -
|
|
8
|
+
[ux] Fix sync block permissions denied error to show the correct state
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 4.0.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
@@ -27,13 +27,13 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
|
|
|
27
27
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
28
28
|
}
|
|
29
29
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data)) {
|
|
30
|
-
var _syncBlockInstance$er
|
|
30
|
+
var _syncBlockInstance$er;
|
|
31
31
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
32
32
|
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : _editorSyncedBlockProvider.SyncBlockError.Errored,
|
|
33
|
-
|
|
34
|
-
sourceProduct: syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
|
|
33
|
+
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
35
34
|
onRetry: reloadData,
|
|
36
|
-
isLoading: isLoading
|
|
35
|
+
isLoading: isLoading,
|
|
36
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
var syncBlockDoc = {
|
|
@@ -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
|
|
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:
|
|
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
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
@@ -24,13 +24,13 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
24
24
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
25
25
|
}
|
|
26
26
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data)) {
|
|
27
|
-
var _syncBlockInstance$er
|
|
27
|
+
var _syncBlockInstance$er;
|
|
28
28
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
29
29
|
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : SyncBlockError.Errored,
|
|
30
|
-
|
|
31
|
-
sourceProduct: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
|
|
30
|
+
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
32
31
|
onRetry: reloadData,
|
|
33
|
-
isLoading: isLoading
|
|
32
|
+
isLoading: isLoading,
|
|
33
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
const syncBlockDoc = {
|
|
@@ -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
|
-
|
|
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:
|
|
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
|
-
|
|
94
|
+
sourceContentId,
|
|
97
95
|
sourceProduct
|
|
98
96
|
}) => {
|
|
99
97
|
switch (sourceProduct) {
|
|
100
98
|
case 'confluence-page':
|
|
101
99
|
return /*#__PURE__*/React.createElement(SyncedBlockPermissionDeniedConfluencePage, {
|
|
102
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
@@ -20,13 +20,13 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
|
|
|
20
20
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
21
21
|
}
|
|
22
22
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data)) {
|
|
23
|
-
var _syncBlockInstance$er
|
|
23
|
+
var _syncBlockInstance$er;
|
|
24
24
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
25
25
|
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : SyncBlockError.Errored,
|
|
26
|
-
|
|
27
|
-
sourceProduct: syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product,
|
|
26
|
+
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
28
27
|
onRetry: reloadData,
|
|
29
|
-
isLoading: isLoading
|
|
28
|
+
isLoading: isLoading,
|
|
29
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
var syncBlockDoc = {
|
|
@@ -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
|
|
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:
|
|
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
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
+
sourceContentId: string;
|
|
5
5
|
sourceProduct: SyncBlockProduct;
|
|
6
6
|
}
|
|
7
|
-
export declare const SyncedBlockPermissionDenied: ({
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
+
sourceContentId: string;
|
|
5
5
|
sourceProduct: SyncBlockProduct;
|
|
6
6
|
}
|
|
7
|
-
export declare const SyncedBlockPermissionDenied: ({
|
|
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
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "SyncedBlockRenderer for @atlaskit/editor-plugin-synced-block",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,14 +31,13 @@
|
|
|
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.
|
|
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.
|
|
40
|
+
"@atlaskit/renderer": "^124.19.0",
|
|
42
41
|
"@atlaskit/spinner": "^19.0.0",
|
|
43
42
|
"@atlaskit/tokens": "^8.4.0",
|
|
44
43
|
"@babel/runtime": "^7.0.0",
|
|
@@ -46,7 +45,7 @@
|
|
|
46
45
|
"relay-runtime": "npm:atl-relay-runtime@0.0.0-main-39e79f66"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
49
|
-
"@atlaskit/editor-common": "^110.
|
|
48
|
+
"@atlaskit/editor-common": "^110.42.0",
|
|
50
49
|
"react": "^18.2.0",
|
|
51
50
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
52
51
|
},
|