@atlaskit/editor-synced-block-renderer 5.6.0 → 5.6.2
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 +22 -0
- package/dist/cjs/ui/AKRendererWrapper.js +3 -9
- package/dist/cjs/ui/SyncedBlockErrorComponent.js +4 -2
- package/dist/cjs/ui/SyncedBlockErrorStateCard.js +5 -2
- package/dist/cjs/ui/SyncedBlockNodeComponentRenderer.js +11 -1
- package/dist/cjs/ui/SyncedBlockNotFoundError.js +27 -2
- package/dist/cjs/ui/SyncedBlockRenderer.js +14 -2
- package/dist/es2019/ui/AKRendererWrapper.js +2 -5
- package/dist/es2019/ui/SyncedBlockErrorComponent.js +4 -2
- package/dist/es2019/ui/SyncedBlockErrorStateCard.js +5 -2
- package/dist/es2019/ui/SyncedBlockNodeComponentRenderer.js +11 -1
- package/dist/es2019/ui/SyncedBlockNotFoundError.js +28 -2
- package/dist/es2019/ui/SyncedBlockRenderer.js +14 -2
- package/dist/esm/ui/AKRendererWrapper.js +3 -9
- package/dist/esm/ui/SyncedBlockErrorComponent.js +4 -2
- package/dist/esm/ui/SyncedBlockErrorStateCard.js +5 -2
- package/dist/esm/ui/SyncedBlockNodeComponentRenderer.js +11 -1
- package/dist/esm/ui/SyncedBlockNotFoundError.js +27 -2
- package/dist/esm/ui/SyncedBlockRenderer.js +14 -2
- package/dist/types/ui/SyncedBlockErrorComponent.d.ts +2 -2
- package/dist/types/ui/SyncedBlockErrorStateCard.d.ts +7 -4
- package/dist/types/ui/SyncedBlockNotFoundError.d.ts +3 -1
- package/dist/types-ts4.5/ui/SyncedBlockErrorComponent.d.ts +2 -2
- package/dist/types-ts4.5/ui/SyncedBlockErrorStateCard.d.ts +7 -4
- package/dist/types-ts4.5/ui/SyncedBlockNotFoundError.d.ts +3 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-renderer
|
|
2
2
|
|
|
3
|
+
## 5.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`74c826b26352b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/74c826b26352b) -
|
|
8
|
+
[ux] EDITOR-4765 In SSR, if server returned error, we should render loading state instead of error
|
|
9
|
+
state
|
|
10
|
+
- [`a372f642e42a5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a372f642e42a5) -
|
|
11
|
+
[ux] EDITOR-4716 Fix content shifting when tooltip is shown for tasks in Synced Block
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 5.6.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`28434cbe03f1e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/28434cbe03f1e) -
|
|
19
|
+
[ux] [EDITOR-2851]
|
|
20
|
+
- Implement unsync feature for source sync block
|
|
21
|
+
- Update deletion confirmation modal and reference block UI after source deletion
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 5.6.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -40,15 +40,9 @@ var DisabledTaskWithTooltip = function DisabledTaskWithTooltip(_ref2) {
|
|
|
40
40
|
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
41
41
|
content: tooltipContent,
|
|
42
42
|
position: "auto-start"
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
47
|
-
_react.default.createElement("div", tooltipProps, /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, props, {
|
|
48
|
-
disableOnChange: true
|
|
49
|
-
})))
|
|
50
|
-
);
|
|
51
|
-
});
|
|
43
|
+
}, /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, props, {
|
|
44
|
+
disableOnChange: true
|
|
45
|
+
})));
|
|
52
46
|
};
|
|
53
47
|
var defaultOptions = {
|
|
54
48
|
appearance: 'full-width',
|
|
@@ -42,13 +42,15 @@ var SyncedBlockErrorComponent = exports.SyncedBlockErrorComponent = function Syn
|
|
|
42
42
|
resourceId = _ref.resourceId,
|
|
43
43
|
fireAnalyticsEvent = _ref.fireAnalyticsEvent;
|
|
44
44
|
var getErrorContent = (0, _react.useMemo)(function () {
|
|
45
|
-
switch (error) {
|
|
45
|
+
switch (error === null || error === void 0 ? void 0 : error.type) {
|
|
46
46
|
case _editorSyncedBlockProvider.SyncBlockError.Offline:
|
|
47
47
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockOfflineError.SyncedBlockOfflineError, null);
|
|
48
48
|
case _editorSyncedBlockProvider.SyncBlockError.Forbidden:
|
|
49
49
|
return getForbiddenErrorContent(resourceId, fireAnalyticsEvent);
|
|
50
50
|
case _editorSyncedBlockProvider.SyncBlockError.NotFound:
|
|
51
|
-
return /*#__PURE__*/_react.default.createElement(_SyncedBlockNotFoundError.SyncedBlockNotFoundError,
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedBlockNotFoundError.SyncedBlockNotFoundError, {
|
|
52
|
+
reason: error.reason
|
|
53
|
+
});
|
|
52
54
|
case _editorSyncedBlockProvider.SyncBlockError.Errored:
|
|
53
55
|
case _editorSyncedBlockProvider.SyncBlockError.RateLimited:
|
|
54
56
|
case _editorSyncedBlockProvider.SyncBlockError.ServerError:
|
|
@@ -10,16 +10,19 @@ require("./SyncedBlockErrorStateCard.compiled.css");
|
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _warningOutline = _interopRequireDefault(require("@atlaskit/icon-lab/core/warning-outline"));
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
14
15
|
var styles = {
|
|
15
16
|
wrapper: "_zulppxbi _ca0qu2gc _n3tdu2gc _19bvpxbi _u5f3pxbi _1e0c1txw _1bahv2br _4cvr1h6o"
|
|
16
17
|
};
|
|
17
18
|
var SyncedBlockErrorStateCard = exports.SyncedBlockErrorStateCard = function SyncedBlockErrorStateCard(_ref) {
|
|
18
19
|
var children = _ref.children,
|
|
19
|
-
description = _ref.description
|
|
20
|
+
description = _ref.description,
|
|
21
|
+
icon = _ref.icon;
|
|
22
|
+
var Icon = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? icon !== null && icon !== void 0 ? icon : _warningOutline.default : _warningOutline.default;
|
|
20
23
|
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
21
24
|
xcss: styles.wrapper
|
|
22
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(Icon, {
|
|
23
26
|
color: "var(--ds-icon-subtle, #505258)",
|
|
24
27
|
label: ""
|
|
25
28
|
}), /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
@@ -53,10 +53,20 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
|
|
|
53
53
|
if (isLoading && !syncBlockInstance) {
|
|
54
54
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
// In SSR, if server returned error, we should render loading state instead of error state
|
|
58
|
+
// since FE will do another fetch and render the error state or proper data then
|
|
59
|
+
if ((0, _coreUtils.isSSR)() && syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
61
|
+
}
|
|
56
62
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
57
63
|
var _syncBlockInstance$er, _syncBlockInstance$da;
|
|
58
64
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
59
|
-
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ?
|
|
65
|
+
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? {
|
|
66
|
+
type: _editorSyncedBlockProvider.SyncBlockError.NotFound
|
|
67
|
+
} : {
|
|
68
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Errored
|
|
69
|
+
},
|
|
60
70
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
61
71
|
onRetry: reloadData,
|
|
62
72
|
isLoading: isLoading,
|
|
@@ -8,11 +8,36 @@ exports.SyncedBlockNotFoundError = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
+
var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
13
|
var _SyncedBlockErrorStateCard = require("./SyncedBlockErrorStateCard");
|
|
12
|
-
var
|
|
14
|
+
var errorMap = {
|
|
15
|
+
'source-block-unsynced': {
|
|
16
|
+
description: _messages.syncBlockMessages.sourceUnsyncedDescription,
|
|
17
|
+
icon: _linkBroken.default
|
|
18
|
+
},
|
|
19
|
+
'source-block-deleted': {
|
|
20
|
+
description: _messages.syncBlockMessages.sourceDeletedDescription,
|
|
21
|
+
icon: _linkBroken.default
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var SyncedBlockNotFoundError = exports.SyncedBlockNotFoundError = function SyncedBlockNotFoundError(_ref) {
|
|
25
|
+
var _ref$reason = _ref.reason,
|
|
26
|
+
reason = _ref$reason === void 0 ? 'source-block-deleted' : _ref$reason;
|
|
13
27
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
14
28
|
formatMessage = _useIntl.formatMessage;
|
|
29
|
+
var errorInfo = {
|
|
30
|
+
description: _messages.syncBlockMessages.notFoundDescription
|
|
31
|
+
};
|
|
32
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
33
|
+
var _errorMap$reason;
|
|
34
|
+
errorInfo = (_errorMap$reason = errorMap[reason]) !== null && _errorMap$reason !== void 0 ? _errorMap$reason : {};
|
|
35
|
+
}
|
|
36
|
+
var _errorInfo = errorInfo,
|
|
37
|
+
description = _errorInfo.description,
|
|
38
|
+
icon = _errorInfo.icon;
|
|
15
39
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorStateCard.SyncedBlockErrorStateCard, {
|
|
16
|
-
description: formatMessage(
|
|
40
|
+
description: formatMessage(description),
|
|
41
|
+
icon: icon
|
|
17
42
|
});
|
|
18
43
|
};
|
|
@@ -56,16 +56,28 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
56
56
|
// In SSR, we should always attempt to render content
|
|
57
57
|
if (isCollabOffline && !(0, _coreUtils.isSSR)()) {
|
|
58
58
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
59
|
-
error:
|
|
59
|
+
error: {
|
|
60
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Offline
|
|
61
|
+
}
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
if (!syncBlockInstance) {
|
|
63
65
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
64
66
|
}
|
|
67
|
+
|
|
68
|
+
// In SSR, if server returned error, we should render loading state instead of error state
|
|
69
|
+
// since FE will do another fetch and render the error state or proper data then
|
|
70
|
+
if ((0, _coreUtils.isSSR)() && syncBlockInstance.error && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
72
|
+
}
|
|
65
73
|
if (syncBlockInstance.error || !syncBlockInstance.data || syncBlockInstance.data.status === 'deleted' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
66
74
|
var _syncBlockInstance$er, _syncBlockInstance$da, _api$analytics;
|
|
67
75
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
68
|
-
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ?
|
|
76
|
+
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? {
|
|
77
|
+
type: _editorSyncedBlockProvider.SyncBlockError.NotFound
|
|
78
|
+
} : {
|
|
79
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Errored
|
|
80
|
+
},
|
|
69
81
|
resourceId: syncBlockInstance.resourceId,
|
|
70
82
|
onRetry: reloadData,
|
|
71
83
|
isLoading: isLoading,
|
|
@@ -27,12 +27,9 @@ const DisabledTaskWithTooltip = ({
|
|
|
27
27
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
28
28
|
content: tooltipContent,
|
|
29
29
|
position: "auto-start"
|
|
30
|
-
},
|
|
31
|
-
/*#__PURE__*/
|
|
32
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
33
|
-
React.createElement("div", tooltipProps, /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
30
|
+
}, /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
34
31
|
disableOnChange: true
|
|
35
|
-
})))
|
|
32
|
+
})));
|
|
36
33
|
};
|
|
37
34
|
const defaultOptions = {
|
|
38
35
|
appearance: 'full-width',
|
|
@@ -36,13 +36,15 @@ export const SyncedBlockErrorComponent = ({
|
|
|
36
36
|
fireAnalyticsEvent
|
|
37
37
|
}) => {
|
|
38
38
|
const getErrorContent = useMemo(() => {
|
|
39
|
-
switch (error) {
|
|
39
|
+
switch (error === null || error === void 0 ? void 0 : error.type) {
|
|
40
40
|
case SyncBlockError.Offline:
|
|
41
41
|
return /*#__PURE__*/React.createElement(SyncedBlockOfflineError, null);
|
|
42
42
|
case SyncBlockError.Forbidden:
|
|
43
43
|
return getForbiddenErrorContent(resourceId, fireAnalyticsEvent);
|
|
44
44
|
case SyncBlockError.NotFound:
|
|
45
|
-
return /*#__PURE__*/React.createElement(SyncedBlockNotFoundError,
|
|
45
|
+
return /*#__PURE__*/React.createElement(SyncedBlockNotFoundError, {
|
|
46
|
+
reason: error.reason
|
|
47
|
+
});
|
|
46
48
|
case SyncBlockError.Errored:
|
|
47
49
|
case SyncBlockError.RateLimited:
|
|
48
50
|
case SyncBlockError.ServerError:
|
|
@@ -3,17 +3,20 @@ import "./SyncedBlockErrorStateCard.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import WarningOutlineIcon from '@atlaskit/icon-lab/core/warning-outline';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { Box, Text } from '@atlaskit/primitives/compiled';
|
|
7
8
|
const styles = {
|
|
8
9
|
wrapper: "_zulppxbi _ca0qu2gc _n3tdu2gc _19bvpxbi _u5f3pxbi _1e0c1txw _1bahv2br _4cvr1h6o"
|
|
9
10
|
};
|
|
10
11
|
export const SyncedBlockErrorStateCard = ({
|
|
11
12
|
children,
|
|
12
|
-
description
|
|
13
|
+
description,
|
|
14
|
+
icon
|
|
13
15
|
}) => {
|
|
16
|
+
const Icon = fg('platform_synced_block_dogfooding') ? icon !== null && icon !== void 0 ? icon : WarningOutlineIcon : WarningOutlineIcon;
|
|
14
17
|
return /*#__PURE__*/React.createElement(Box, {
|
|
15
18
|
xcss: styles.wrapper
|
|
16
|
-
}, /*#__PURE__*/React.createElement(
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
17
20
|
color: "var(--ds-icon-subtle, #505258)",
|
|
18
21
|
label: ""
|
|
19
22
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
@@ -46,10 +46,20 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
46
46
|
if (isLoading && !syncBlockInstance) {
|
|
47
47
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
// In SSR, if server returned error, we should render loading state instead of error state
|
|
51
|
+
// since FE will do another fetch and render the error state or proper data then
|
|
52
|
+
if (isSSR() && syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error && fg('platform_synced_block_dogfooding')) {
|
|
53
|
+
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
54
|
+
}
|
|
49
55
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted' && fg('platform_synced_block_dogfooding')) {
|
|
50
56
|
var _syncBlockInstance$er, _syncBlockInstance$da;
|
|
51
57
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
52
|
-
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ?
|
|
58
|
+
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ? {
|
|
59
|
+
type: SyncBlockError.NotFound
|
|
60
|
+
} : {
|
|
61
|
+
type: SyncBlockError.Errored
|
|
62
|
+
},
|
|
53
63
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
54
64
|
onRetry: reloadData,
|
|
55
65
|
isLoading: isLoading,
|
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
6
|
import { SyncedBlockErrorStateCard } from './SyncedBlockErrorStateCard';
|
|
5
|
-
|
|
7
|
+
const errorMap = {
|
|
8
|
+
'source-block-unsynced': {
|
|
9
|
+
description: messages.sourceUnsyncedDescription,
|
|
10
|
+
icon: LinkBrokenIcon
|
|
11
|
+
},
|
|
12
|
+
'source-block-deleted': {
|
|
13
|
+
description: messages.sourceDeletedDescription,
|
|
14
|
+
icon: LinkBrokenIcon
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const SyncedBlockNotFoundError = ({
|
|
18
|
+
reason = 'source-block-deleted'
|
|
19
|
+
}) => {
|
|
6
20
|
const {
|
|
7
21
|
formatMessage
|
|
8
22
|
} = useIntl();
|
|
23
|
+
let errorInfo = {
|
|
24
|
+
description: messages.notFoundDescription
|
|
25
|
+
};
|
|
26
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
27
|
+
var _errorMap$reason;
|
|
28
|
+
errorInfo = (_errorMap$reason = errorMap[reason]) !== null && _errorMap$reason !== void 0 ? _errorMap$reason : {};
|
|
29
|
+
}
|
|
30
|
+
const {
|
|
31
|
+
description,
|
|
32
|
+
icon
|
|
33
|
+
} = errorInfo;
|
|
9
34
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorStateCard, {
|
|
10
|
-
description: formatMessage(
|
|
35
|
+
description: formatMessage(description),
|
|
36
|
+
icon: icon
|
|
11
37
|
});
|
|
12
38
|
};
|
|
@@ -49,16 +49,28 @@ const SyncedBlockRendererComponent = ({
|
|
|
49
49
|
// In SSR, we should always attempt to render content
|
|
50
50
|
if (isCollabOffline && !isSSR()) {
|
|
51
51
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
52
|
-
error:
|
|
52
|
+
error: {
|
|
53
|
+
type: SyncBlockError.Offline
|
|
54
|
+
}
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
if (!syncBlockInstance) {
|
|
56
58
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
57
59
|
}
|
|
60
|
+
|
|
61
|
+
// In SSR, if server returned error, we should render loading state instead of error state
|
|
62
|
+
// since FE will do another fetch and render the error state or proper data then
|
|
63
|
+
if (isSSR() && syncBlockInstance.error && fg('platform_synced_block_dogfooding')) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
65
|
+
}
|
|
58
66
|
if (syncBlockInstance.error || !syncBlockInstance.data || syncBlockInstance.data.status === 'deleted' && fg('platform_synced_block_dogfooding')) {
|
|
59
67
|
var _syncBlockInstance$er, _syncBlockInstance$da, _api$analytics;
|
|
60
68
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
61
|
-
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ?
|
|
69
|
+
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ? {
|
|
70
|
+
type: SyncBlockError.NotFound
|
|
71
|
+
} : {
|
|
72
|
+
type: SyncBlockError.Errored
|
|
73
|
+
},
|
|
62
74
|
resourceId: syncBlockInstance.resourceId,
|
|
63
75
|
onRetry: reloadData,
|
|
64
76
|
isLoading: isLoading,
|
|
@@ -31,15 +31,9 @@ var DisabledTaskWithTooltip = function DisabledTaskWithTooltip(_ref2) {
|
|
|
31
31
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
32
32
|
content: tooltipContent,
|
|
33
33
|
position: "auto-start"
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
38
|
-
React.createElement("div", tooltipProps, /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
39
|
-
disableOnChange: true
|
|
40
|
-
})))
|
|
41
|
-
);
|
|
42
|
-
});
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
35
|
+
disableOnChange: true
|
|
36
|
+
})));
|
|
43
37
|
};
|
|
44
38
|
var defaultOptions = {
|
|
45
39
|
appearance: 'full-width',
|
|
@@ -34,13 +34,15 @@ export var SyncedBlockErrorComponent = function SyncedBlockErrorComponent(_ref)
|
|
|
34
34
|
resourceId = _ref.resourceId,
|
|
35
35
|
fireAnalyticsEvent = _ref.fireAnalyticsEvent;
|
|
36
36
|
var getErrorContent = useMemo(function () {
|
|
37
|
-
switch (error) {
|
|
37
|
+
switch (error === null || error === void 0 ? void 0 : error.type) {
|
|
38
38
|
case SyncBlockError.Offline:
|
|
39
39
|
return /*#__PURE__*/React.createElement(SyncedBlockOfflineError, null);
|
|
40
40
|
case SyncBlockError.Forbidden:
|
|
41
41
|
return getForbiddenErrorContent(resourceId, fireAnalyticsEvent);
|
|
42
42
|
case SyncBlockError.NotFound:
|
|
43
|
-
return /*#__PURE__*/React.createElement(SyncedBlockNotFoundError,
|
|
43
|
+
return /*#__PURE__*/React.createElement(SyncedBlockNotFoundError, {
|
|
44
|
+
reason: error.reason
|
|
45
|
+
});
|
|
44
46
|
case SyncBlockError.Errored:
|
|
45
47
|
case SyncBlockError.RateLimited:
|
|
46
48
|
case SyncBlockError.ServerError:
|
|
@@ -3,16 +3,19 @@ import "./SyncedBlockErrorStateCard.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import WarningOutlineIcon from '@atlaskit/icon-lab/core/warning-outline';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { Box, Text } from '@atlaskit/primitives/compiled';
|
|
7
8
|
var styles = {
|
|
8
9
|
wrapper: "_zulppxbi _ca0qu2gc _n3tdu2gc _19bvpxbi _u5f3pxbi _1e0c1txw _1bahv2br _4cvr1h6o"
|
|
9
10
|
};
|
|
10
11
|
export var SyncedBlockErrorStateCard = function SyncedBlockErrorStateCard(_ref) {
|
|
11
12
|
var children = _ref.children,
|
|
12
|
-
description = _ref.description
|
|
13
|
+
description = _ref.description,
|
|
14
|
+
icon = _ref.icon;
|
|
15
|
+
var Icon = fg('platform_synced_block_dogfooding') ? icon !== null && icon !== void 0 ? icon : WarningOutlineIcon : WarningOutlineIcon;
|
|
13
16
|
return /*#__PURE__*/React.createElement(Box, {
|
|
14
17
|
xcss: styles.wrapper
|
|
15
|
-
}, /*#__PURE__*/React.createElement(
|
|
18
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
16
19
|
color: "var(--ds-icon-subtle, #505258)",
|
|
17
20
|
label: ""
|
|
18
21
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
@@ -44,10 +44,20 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
|
|
|
44
44
|
if (isLoading && !syncBlockInstance) {
|
|
45
45
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
// In SSR, if server returned error, we should render loading state instead of error state
|
|
49
|
+
// since FE will do another fetch and render the error state or proper data then
|
|
50
|
+
if (isSSR() && syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error && fg('platform_synced_block_dogfooding')) {
|
|
51
|
+
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
52
|
+
}
|
|
47
53
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted' && fg('platform_synced_block_dogfooding')) {
|
|
48
54
|
var _syncBlockInstance$er, _syncBlockInstance$da;
|
|
49
55
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
50
|
-
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ?
|
|
56
|
+
error: (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ? {
|
|
57
|
+
type: SyncBlockError.NotFound
|
|
58
|
+
} : {
|
|
59
|
+
type: SyncBlockError.Errored
|
|
60
|
+
},
|
|
51
61
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
52
62
|
onRetry: reloadData,
|
|
53
63
|
isLoading: isLoading,
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
6
|
import { SyncedBlockErrorStateCard } from './SyncedBlockErrorStateCard';
|
|
5
|
-
|
|
7
|
+
var errorMap = {
|
|
8
|
+
'source-block-unsynced': {
|
|
9
|
+
description: messages.sourceUnsyncedDescription,
|
|
10
|
+
icon: LinkBrokenIcon
|
|
11
|
+
},
|
|
12
|
+
'source-block-deleted': {
|
|
13
|
+
description: messages.sourceDeletedDescription,
|
|
14
|
+
icon: LinkBrokenIcon
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export var SyncedBlockNotFoundError = function SyncedBlockNotFoundError(_ref) {
|
|
18
|
+
var _ref$reason = _ref.reason,
|
|
19
|
+
reason = _ref$reason === void 0 ? 'source-block-deleted' : _ref$reason;
|
|
6
20
|
var _useIntl = useIntl(),
|
|
7
21
|
formatMessage = _useIntl.formatMessage;
|
|
22
|
+
var errorInfo = {
|
|
23
|
+
description: messages.notFoundDescription
|
|
24
|
+
};
|
|
25
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
26
|
+
var _errorMap$reason;
|
|
27
|
+
errorInfo = (_errorMap$reason = errorMap[reason]) !== null && _errorMap$reason !== void 0 ? _errorMap$reason : {};
|
|
28
|
+
}
|
|
29
|
+
var _errorInfo = errorInfo,
|
|
30
|
+
description = _errorInfo.description,
|
|
31
|
+
icon = _errorInfo.icon;
|
|
8
32
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorStateCard, {
|
|
9
|
-
description: formatMessage(
|
|
33
|
+
description: formatMessage(description),
|
|
34
|
+
icon: icon
|
|
10
35
|
});
|
|
11
36
|
};
|
|
@@ -47,16 +47,28 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
47
47
|
// In SSR, we should always attempt to render content
|
|
48
48
|
if (isCollabOffline && !isSSR()) {
|
|
49
49
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
50
|
-
error:
|
|
50
|
+
error: {
|
|
51
|
+
type: SyncBlockError.Offline
|
|
52
|
+
}
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
if (!syncBlockInstance) {
|
|
54
56
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
55
57
|
}
|
|
58
|
+
|
|
59
|
+
// In SSR, if server returned error, we should render loading state instead of error state
|
|
60
|
+
// since FE will do another fetch and render the error state or proper data then
|
|
61
|
+
if (isSSR() && syncBlockInstance.error && fg('platform_synced_block_dogfooding')) {
|
|
62
|
+
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
63
|
+
}
|
|
56
64
|
if (syncBlockInstance.error || !syncBlockInstance.data || syncBlockInstance.data.status === 'deleted' && fg('platform_synced_block_dogfooding')) {
|
|
57
65
|
var _syncBlockInstance$er, _syncBlockInstance$da, _api$analytics;
|
|
58
66
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
59
|
-
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ?
|
|
67
|
+
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' && fg('platform_synced_block_dogfooding') ? {
|
|
68
|
+
type: SyncBlockError.NotFound
|
|
69
|
+
} : {
|
|
70
|
+
type: SyncBlockError.Errored
|
|
71
|
+
},
|
|
60
72
|
resourceId: syncBlockInstance.resourceId,
|
|
61
73
|
onRetry: reloadData,
|
|
62
74
|
isLoading: isLoading,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { type SyncBlockInstance } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
export declare const SyncedBlockErrorComponent: ({ error, isLoading, onRetry, resourceId, fireAnalyticsEvent, }: {
|
|
5
|
-
error:
|
|
5
|
+
error: SyncBlockInstance["error"];
|
|
6
6
|
fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
onRetry?: () => void;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { NewCoreIconProps } from '@atlaskit/icon/types';
|
|
2
3
|
interface SyncedBlockErrorStateCardProps {
|
|
3
|
-
children?:
|
|
4
|
-
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
closeButton?: ReactNode;
|
|
6
|
+
description: ReactNode;
|
|
7
|
+
icon?: (props: NewCoreIconProps) => JSX.Element;
|
|
5
8
|
}
|
|
6
|
-
export declare const SyncedBlockErrorStateCard: ({ children, description, }: SyncedBlockErrorStateCardProps) => React.JSX.Element;
|
|
9
|
+
export declare const SyncedBlockErrorStateCard: ({ children, description, icon, }: SyncedBlockErrorStateCardProps) => React.JSX.Element;
|
|
7
10
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { type SyncBlockInstance } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
export declare const SyncedBlockErrorComponent: ({ error, isLoading, onRetry, resourceId, fireAnalyticsEvent, }: {
|
|
5
|
-
error:
|
|
5
|
+
error: SyncBlockInstance["error"];
|
|
6
6
|
fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
onRetry?: () => void;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { NewCoreIconProps } from '@atlaskit/icon/types';
|
|
2
3
|
interface SyncedBlockErrorStateCardProps {
|
|
3
|
-
children?:
|
|
4
|
-
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
closeButton?: ReactNode;
|
|
6
|
+
description: ReactNode;
|
|
7
|
+
icon?: (props: NewCoreIconProps) => JSX.Element;
|
|
5
8
|
}
|
|
6
|
-
export declare const SyncedBlockErrorStateCard: ({ children, description, }: SyncedBlockErrorStateCardProps) => React.JSX.Element;
|
|
9
|
+
export declare const SyncedBlockErrorStateCard: ({ children, description, icon, }: SyncedBlockErrorStateCardProps) => React.JSX.Element;
|
|
7
10
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-synced-block-renderer",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
4
4
|
"description": "SyncedBlockRenderer for @atlaskit/editor-plugin-synced-block",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@atlaskit/editor-synced-block-provider": "^3.14.0",
|
|
35
35
|
"@atlaskit/heading": "^5.2.0",
|
|
36
36
|
"@atlaskit/icon": "^30.0.0",
|
|
37
|
-
"@atlaskit/icon-lab": "^5.
|
|
37
|
+
"@atlaskit/icon-lab": "^5.15.0",
|
|
38
38
|
"@atlaskit/image": "^3.0.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@atlaskit/primitives": "^17.1.0",
|
|
41
|
-
"@atlaskit/renderer": "^126.
|
|
41
|
+
"@atlaskit/renderer": "^126.2.0",
|
|
42
42
|
"@atlaskit/spinner": "^19.0.0",
|
|
43
43
|
"@atlaskit/tokens": "^10.1.0",
|
|
44
44
|
"@atlaskit/tooltip": "^20.14.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"relay-runtime": "npm:atl-relay-runtime@0.0.0-main-39e79f66"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^111.
|
|
50
|
+
"@atlaskit/editor-common": "^111.9.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
53
53
|
},
|