@atlaskit/editor-synced-block-provider 3.25.0 → 3.26.1
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 +21 -0
- package/dist/cjs/clients/block-service/blockService.js +98 -57
- package/dist/cjs/clients/confluence/sourceInfo.js +112 -69
- package/dist/cjs/hooks/useFetchSyncBlockData.js +5 -11
- package/dist/cjs/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/cjs/providers/syncBlockProvider.js +34 -75
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +83 -124
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +59 -93
- package/dist/cjs/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/cjs/utils/errorHandling.js +2 -5
- package/dist/cjs/utils/resolveSyncBlockInstance.js +1 -3
- package/dist/cjs/utils/utils.js +5 -6
- package/dist/es2019/clients/block-service/blockService.js +55 -19
- package/dist/es2019/clients/confluence/sourceInfo.js +51 -4
- package/dist/es2019/hooks/useFetchSyncBlockData.js +6 -12
- package/dist/es2019/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/es2019/providers/syncBlockProvider.js +22 -54
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +73 -114
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +60 -92
- package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/es2019/utils/errorHandling.js +1 -4
- package/dist/es2019/utils/resolveSyncBlockInstance.js +2 -5
- package/dist/es2019/utils/utils.js +5 -6
- package/dist/esm/clients/block-service/blockService.js +98 -57
- package/dist/esm/clients/confluence/sourceInfo.js +111 -68
- package/dist/esm/hooks/useFetchSyncBlockData.js +5 -11
- package/dist/esm/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/esm/providers/syncBlockProvider.js +34 -75
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +83 -124
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +59 -93
- package/dist/esm/store-manager/syncBlockStoreManager.js +2 -4
- package/dist/esm/utils/errorHandling.js +2 -5
- package/dist/esm/utils/resolveSyncBlockInstance.js +1 -3
- package/dist/esm/utils/utils.js +5 -6
- package/dist/types/clients/confluence/sourceInfo.d.ts +1 -2
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types/providers/types.d.ts +3 -3
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/dist/types-ts4.5/clients/confluence/sourceInfo.d.ts +1 -2
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types-ts4.5/providers/types.d.ts +3 -3
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -1
- package/package.json +2 -5
|
@@ -113,69 +113,79 @@ var resolveNoAccessPageInfo = /*#__PURE__*/function () {
|
|
|
113
113
|
return _ref2.apply(this, arguments);
|
|
114
114
|
};
|
|
115
115
|
}();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Fetches unpublished page info from the v2 pages API
|
|
119
|
+
* Used when the GraphQL query returns empty content.nodes for unpublished pages
|
|
120
|
+
* @param pageAri - The page ARI
|
|
121
|
+
* @param localId - Optional local ID to append as block anchor
|
|
122
|
+
* @returns Source info with URL, title, and optional subtype
|
|
123
|
+
*/
|
|
124
|
+
var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
|
|
125
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(pageAri, localId) {
|
|
126
|
+
var _pageData$_links, _pageData$_links2, _getPageIdAndTypeFrom, pageId, response, pageData, base, edituiv2, title, subType, url;
|
|
119
127
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
120
128
|
while (1) switch (_context3.prev = _context3.next) {
|
|
121
129
|
case 0:
|
|
122
130
|
_context3.prev = 0;
|
|
123
131
|
_getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
|
|
124
132
|
ari: pageAri
|
|
125
|
-
}),
|
|
133
|
+
}), pageId = _getPageIdAndTypeFrom.id;
|
|
126
134
|
_context3.next = 4;
|
|
127
|
-
return
|
|
135
|
+
return fetchWithRetry("/wiki/api/v2/pages/".concat(pageId, "?draft=true"), {
|
|
136
|
+
method: 'GET',
|
|
137
|
+
headers: COMMON_HEADERS
|
|
138
|
+
});
|
|
128
139
|
case 4:
|
|
129
140
|
response = _context3.sent;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (base && contentData !== null && contentData !== void 0 && (_contentData$space = contentData.space) !== null && _contentData$space !== void 0 && _contentData$space.key && contentData !== null && contentData !== void 0 && contentData.id) {
|
|
134
|
-
if (isBlogPageType(pageType)) {
|
|
135
|
-
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/blog/edit-v2/").concat(contentData.id);
|
|
136
|
-
} else if (contentData.subType === 'live') {
|
|
137
|
-
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/").concat(contentData.id);
|
|
138
|
-
} else {
|
|
139
|
-
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/edit-v2/").concat(contentData.id);
|
|
140
|
-
}
|
|
141
|
+
if (response.ok) {
|
|
142
|
+
_context3.next = 7;
|
|
143
|
+
break;
|
|
141
144
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
throw new Error("Failed to get unpublished page info: ".concat(response.statusText));
|
|
146
|
+
case 7:
|
|
147
|
+
_context3.next = 9;
|
|
148
|
+
return response.json();
|
|
149
|
+
case 9:
|
|
150
|
+
pageData = _context3.sent;
|
|
151
|
+
base = (_pageData$_links = pageData._links) === null || _pageData$_links === void 0 ? void 0 : _pageData$_links.base;
|
|
152
|
+
edituiv2 = (_pageData$_links2 = pageData._links) === null || _pageData$_links2 === void 0 ? void 0 : _pageData$_links2.edituiv2;
|
|
153
|
+
title = pageData.title;
|
|
154
|
+
subType = pageData.subtype;
|
|
155
|
+
if (base && edituiv2) {
|
|
156
|
+
url = "".concat(base).concat(edituiv2);
|
|
157
|
+
url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
|
|
145
158
|
}
|
|
146
|
-
return _context3.abrupt("return",
|
|
159
|
+
return _context3.abrupt("return", {
|
|
147
160
|
title: title,
|
|
148
161
|
url: url,
|
|
149
|
-
sourceAri: pageAri
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
sourceAri: pageAri,
|
|
163
|
+
subType: subType
|
|
164
|
+
});
|
|
165
|
+
case 18:
|
|
166
|
+
_context3.prev = 18;
|
|
153
167
|
_context3.t0 = _context3["catch"](0);
|
|
154
168
|
logException(_context3.t0, {
|
|
155
|
-
location: 'editor-synced-block-provider/sourceInfo'
|
|
169
|
+
location: 'editor-synced-block-provider/sourceInfo/fetchUnpublishedConfluencePageInfo'
|
|
156
170
|
});
|
|
157
|
-
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(getSourceInfoErrorPayload(_context3.t0.message));
|
|
158
171
|
return _context3.abrupt("return", Promise.resolve(undefined));
|
|
159
|
-
case
|
|
172
|
+
case 22:
|
|
160
173
|
case "end":
|
|
161
174
|
return _context3.stop();
|
|
162
175
|
}
|
|
163
|
-
}, _callee3, null, [[0,
|
|
176
|
+
}, _callee3, null, [[0, 18]]);
|
|
164
177
|
}));
|
|
165
|
-
return function
|
|
178
|
+
return function fetchUnpublishedConfluencePageInfo(_x3, _x4) {
|
|
166
179
|
return _ref3.apply(this, arguments);
|
|
167
180
|
};
|
|
168
181
|
}();
|
|
169
|
-
export var
|
|
170
|
-
var
|
|
171
|
-
var _response$
|
|
182
|
+
export var fetchConfluencePageInfoOld = /*#__PURE__*/function () {
|
|
183
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(pageAri, localId, fireAnalyticsEvent) {
|
|
184
|
+
var _response$data, _contentData$space, _getPageIdAndTypeFrom2, pageType, response, contentData, title, url, _ref5, base;
|
|
172
185
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
173
186
|
while (1) switch (_context4.prev = _context4.next) {
|
|
174
187
|
case 0:
|
|
175
|
-
|
|
176
|
-
_context4.next = 13;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
188
|
+
_context4.prev = 0;
|
|
179
189
|
_getPageIdAndTypeFrom2 = getPageIdAndTypeFromConfluencePageAri({
|
|
180
190
|
ari: pageAri
|
|
181
191
|
}), pageType = _getPageIdAndTypeFrom2.type;
|
|
@@ -183,69 +193,102 @@ export var fetchConfluencePageInfoNew = /*#__PURE__*/function () {
|
|
|
183
193
|
return getConfluenceSourceInfo(pageAri);
|
|
184
194
|
case 4:
|
|
185
195
|
response = _context4.sent;
|
|
186
|
-
contentData = (_response$
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (base && contentData !== null && contentData !== void 0 && (_contentData$
|
|
196
|
+
contentData = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.content) === null || _response$data === void 0 || (_response$data = _response$data.nodes) === null || _response$data === void 0 ? void 0 : _response$data[0];
|
|
197
|
+
title = contentData === null || contentData === void 0 ? void 0 : contentData.title;
|
|
198
|
+
_ref5 = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {}, base = _ref5.base;
|
|
199
|
+
if (base && contentData !== null && contentData !== void 0 && (_contentData$space = contentData.space) !== null && _contentData$space !== void 0 && _contentData$space.key && contentData !== null && contentData !== void 0 && contentData.id) {
|
|
190
200
|
if (isBlogPageType(pageType)) {
|
|
191
|
-
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/blog
|
|
201
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/blog/edit-v2/").concat(contentData.id);
|
|
192
202
|
} else if (contentData.subType === 'live') {
|
|
193
203
|
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/").concat(contentData.id);
|
|
194
204
|
} else {
|
|
195
|
-
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages
|
|
205
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/edit-v2/").concat(contentData.id);
|
|
196
206
|
}
|
|
197
207
|
}
|
|
198
208
|
url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
|
|
209
|
+
if (!title || !url) {
|
|
210
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(getSourceInfoErrorPayload('Failed to get confluence page source info'));
|
|
211
|
+
}
|
|
199
212
|
return _context4.abrupt("return", Promise.resolve({
|
|
200
213
|
title: title,
|
|
201
214
|
url: url,
|
|
202
|
-
sourceAri: pageAri
|
|
203
|
-
subType: subType
|
|
215
|
+
sourceAri: pageAri
|
|
204
216
|
}));
|
|
205
|
-
case
|
|
206
|
-
_context4.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
217
|
+
case 14:
|
|
218
|
+
_context4.prev = 14;
|
|
219
|
+
_context4.t0 = _context4["catch"](0);
|
|
220
|
+
logException(_context4.t0, {
|
|
221
|
+
location: 'editor-synced-block-provider/sourceInfo'
|
|
222
|
+
});
|
|
223
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(getSourceInfoErrorPayload(_context4.t0.message));
|
|
224
|
+
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
225
|
+
case 19:
|
|
211
226
|
case "end":
|
|
212
227
|
return _context4.stop();
|
|
213
228
|
}
|
|
214
|
-
}, _callee4);
|
|
229
|
+
}, _callee4, null, [[0, 14]]);
|
|
215
230
|
}));
|
|
216
|
-
return function
|
|
217
|
-
return
|
|
231
|
+
return function fetchConfluencePageInfoOld(_x5, _x6, _x7) {
|
|
232
|
+
return _ref4.apply(this, arguments);
|
|
218
233
|
};
|
|
219
234
|
}();
|
|
220
235
|
export var fetchConfluencePageInfo = /*#__PURE__*/function () {
|
|
221
|
-
var
|
|
236
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(pageAri, hasAccess, urlType, localId, isUnpublished) {
|
|
237
|
+
var _response$data2, _contentData$space2, _getPageIdAndTypeFrom3, pageType, response, contentData, _ref7, title, subType, url, _ref8, base;
|
|
222
238
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
223
239
|
while (1) switch (_context5.prev = _context5.next) {
|
|
224
240
|
case 0:
|
|
225
|
-
if (!fg('
|
|
226
|
-
_context5.next =
|
|
241
|
+
if (!(isUnpublished && fg('platform_synced_block_patch_1'))) {
|
|
242
|
+
_context5.next = 4;
|
|
227
243
|
break;
|
|
228
244
|
}
|
|
229
245
|
_context5.next = 3;
|
|
230
|
-
return
|
|
246
|
+
return fetchUnpublishedConfluencePageInfo(pageAri, localId);
|
|
231
247
|
case 3:
|
|
232
|
-
_context5.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
248
|
+
return _context5.abrupt("return", _context5.sent);
|
|
249
|
+
case 4:
|
|
250
|
+
if (!hasAccess) {
|
|
251
|
+
_context5.next = 17;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
_getPageIdAndTypeFrom3 = getPageIdAndTypeFromConfluencePageAri({
|
|
255
|
+
ari: pageAri
|
|
256
|
+
}), pageType = _getPageIdAndTypeFrom3.type;
|
|
236
257
|
_context5.next = 8;
|
|
237
|
-
return
|
|
258
|
+
return getConfluenceSourceInfo(pageAri);
|
|
238
259
|
case 8:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
260
|
+
response = _context5.sent;
|
|
261
|
+
contentData = (_response$data2 = response.data) === null || _response$data2 === void 0 || (_response$data2 = _response$data2.content) === null || _response$data2 === void 0 || (_response$data2 = _response$data2.nodes) === null || _response$data2 === void 0 ? void 0 : _response$data2[0];
|
|
262
|
+
_ref7 = contentData || {}, title = _ref7.title, subType = _ref7.subType;
|
|
263
|
+
_ref8 = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {}, base = _ref8.base;
|
|
264
|
+
if (base && contentData !== null && contentData !== void 0 && (_contentData$space2 = contentData.space) !== null && _contentData$space2 !== void 0 && _contentData$space2.key && contentData !== null && contentData !== void 0 && contentData.id) {
|
|
265
|
+
if (isBlogPageType(pageType)) {
|
|
266
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/blog").concat(urlType === 'edit' ? '/edit-v2' : '', "/").concat(contentData.id);
|
|
267
|
+
} else if (contentData.subType === 'live') {
|
|
268
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/").concat(contentData.id);
|
|
269
|
+
} else {
|
|
270
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages").concat(urlType === 'edit' ? '/edit-v2' : '', "/").concat(contentData.id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
|
|
274
|
+
return _context5.abrupt("return", Promise.resolve({
|
|
275
|
+
title: title,
|
|
276
|
+
url: url,
|
|
277
|
+
sourceAri: pageAri,
|
|
278
|
+
subType: subType
|
|
279
|
+
}));
|
|
280
|
+
case 17:
|
|
281
|
+
_context5.next = 19;
|
|
282
|
+
return resolveNoAccessPageInfo(pageAri);
|
|
283
|
+
case 19:
|
|
284
|
+
return _context5.abrupt("return", _context5.sent);
|
|
285
|
+
case 20:
|
|
243
286
|
case "end":
|
|
244
287
|
return _context5.stop();
|
|
245
288
|
}
|
|
246
289
|
}, _callee5);
|
|
247
290
|
}));
|
|
248
|
-
return function fetchConfluencePageInfo(
|
|
249
|
-
return
|
|
291
|
+
return function fetchConfluencePageInfo(_x8, _x9, _x0, _x1, _x10) {
|
|
292
|
+
return _ref6.apply(this, arguments);
|
|
250
293
|
};
|
|
251
294
|
}();
|
|
@@ -7,11 +7,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { SyncBlockError } from '../common/types';
|
|
12
|
-
import { fetchErrorPayload } from '../utils/errorHandling';
|
|
13
11
|
import { createSyncBlockNode } from '../utils/utils';
|
|
14
|
-
export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId,
|
|
12
|
+
export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId, _fireAnalyticsEvent) {
|
|
15
13
|
// Initialize both states from a single cache lookup to avoid race conditions.
|
|
16
14
|
// When a block is moved/remounted, the old component's cleanup may clear the cache
|
|
17
15
|
// before or after the new component mounts. By doing a single lookup, we ensure
|
|
@@ -72,13 +70,9 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
72
70
|
logException(_context.t0, {
|
|
73
71
|
location: 'editor-synced-block-provider/useFetchSyncBlockData'
|
|
74
72
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
} else {
|
|
80
|
-
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(_context.t0.message));
|
|
81
|
-
}
|
|
73
|
+
manager === null || manager === void 0 || (_manager$referenceMan2 = manager.referenceManager) === null || _manager$referenceMan2 === void 0 || (_manager$referenceMan2 = _manager$referenceMan2.fetchExperience) === null || _manager$referenceMan2 === void 0 || _manager$referenceMan2.failure({
|
|
74
|
+
reason: _context.t0.message
|
|
75
|
+
});
|
|
82
76
|
|
|
83
77
|
// Set error state if fetching fails
|
|
84
78
|
setFetchState({
|
|
@@ -102,7 +96,7 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
102
96
|
return _context.stop();
|
|
103
97
|
}
|
|
104
98
|
}, _callee, null, [[2, 11]]);
|
|
105
|
-
})), [isLoading, localId, manager.referenceManager, resourceId
|
|
99
|
+
})), [isLoading, localId, manager.referenceManager, resourceId]);
|
|
106
100
|
useEffect(function () {
|
|
107
101
|
if (isSSR()) {
|
|
108
102
|
// in SSR, we don't need to subscribe to updates,
|
|
@@ -735,7 +735,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
735
735
|
_context6.t0 = undefined;
|
|
736
736
|
case 11:
|
|
737
737
|
stepVersion = _context6.t0;
|
|
738
|
-
status = fg('platform_synced_block_patch_1') ? 'unpublished' :
|
|
738
|
+
status = fg('platform_synced_block_patch_1') ? 'unpublished' : (_this$isParentUnpubli = this.isParentUnpublished) !== null && _this$isParentUnpubli !== void 0 && _this$isParentUnpubli.call(this) ? 'unpublished' : data.status || 'active';
|
|
739
739
|
_context6.prev = 13;
|
|
740
740
|
_context6.next = 16;
|
|
741
741
|
return createSyncedBlock({
|
|
@@ -11,7 +11,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
11
11
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
16
15
|
import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
|
|
17
16
|
import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
|
|
@@ -97,40 +96,14 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
97
96
|
}
|
|
98
97
|
return _context.abrupt("return", []);
|
|
99
98
|
case 3:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
_context.prev = 4;
|
|
105
|
-
_context.next = 7;
|
|
99
|
+
_context.prev = 3;
|
|
100
|
+
_context.next = 6;
|
|
106
101
|
return this.fetchProvider.batchFetchData(blockIdentifiers);
|
|
107
|
-
case
|
|
102
|
+
case 6:
|
|
108
103
|
return _context.abrupt("return", _context.sent);
|
|
109
|
-
case
|
|
110
|
-
_context.prev =
|
|
111
|
-
_context.t0 = _context["catch"](
|
|
112
|
-
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
113
|
-
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
114
|
-
return data;
|
|
115
|
-
}, function () {
|
|
116
|
-
return {
|
|
117
|
-
error: {
|
|
118
|
-
type: SyncBlockError.Errored
|
|
119
|
-
},
|
|
120
|
-
resourceId: blockIdentifier.resourceId
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
})).then(function (results) {
|
|
124
|
-
return results.filter(function (result) {
|
|
125
|
-
return result.status === 'fulfilled';
|
|
126
|
-
}).map(function (result) {
|
|
127
|
-
return result.value;
|
|
128
|
-
});
|
|
129
|
-
}));
|
|
130
|
-
case 13:
|
|
131
|
-
_context.next = 16;
|
|
132
|
-
break;
|
|
133
|
-
case 15:
|
|
104
|
+
case 9:
|
|
105
|
+
_context.prev = 9;
|
|
106
|
+
_context.t0 = _context["catch"](3);
|
|
134
107
|
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
135
108
|
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
136
109
|
return data;
|
|
@@ -149,11 +122,11 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
149
122
|
return result.value;
|
|
150
123
|
});
|
|
151
124
|
}));
|
|
152
|
-
case
|
|
125
|
+
case 12:
|
|
153
126
|
case "end":
|
|
154
127
|
return _context.stop();
|
|
155
128
|
}
|
|
156
|
-
}, _callee, this, [[
|
|
129
|
+
}, _callee, this, [[3, 9]]);
|
|
157
130
|
}));
|
|
158
131
|
function fetchNodesData(_x) {
|
|
159
132
|
return _fetchNodesData.apply(this, arguments);
|
|
@@ -300,80 +273,66 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
300
273
|
key: "fetchSyncBlockSourceInfo",
|
|
301
274
|
value: (function () {
|
|
302
275
|
var _fetchSyncBlockSourceInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(localId, sourceAri, sourceProduct, fireAnalyticsEvent) {
|
|
276
|
+
var _this$writeProvider, _this$writeProvider3;
|
|
303
277
|
var hasAccess,
|
|
304
278
|
urlType,
|
|
279
|
+
isUnpublished,
|
|
305
280
|
ari,
|
|
306
281
|
product,
|
|
307
|
-
_this$writeProvider,
|
|
308
|
-
sourceInfo,
|
|
309
282
|
_this$writeProvider2,
|
|
310
|
-
_this$writeProvider3,
|
|
311
283
|
_sourceInfo,
|
|
284
|
+
sourceInfo,
|
|
312
285
|
_args4 = arguments;
|
|
313
286
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
314
287
|
while (1) switch (_context4.prev = _context4.next) {
|
|
315
288
|
case 0:
|
|
316
289
|
hasAccess = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : true;
|
|
317
290
|
urlType = _args4.length > 5 && _args4[5] !== undefined ? _args4[5] : 'edit';
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
|
|
322
|
-
}
|
|
291
|
+
isUnpublished = _args4.length > 6 ? _args4[6] : undefined;
|
|
292
|
+
ari = sourceAri !== null && sourceAri !== void 0 ? sourceAri : (_this$writeProvider = this.writeProvider) === null || _this$writeProvider === void 0 ? void 0 : _this$writeProvider.parentAri;
|
|
293
|
+
product = sourceProduct !== null && sourceProduct !== void 0 ? sourceProduct : getProductFromSourceAri(ari);
|
|
323
294
|
if (!(!ari || !product)) {
|
|
324
|
-
_context4.next =
|
|
295
|
+
_context4.next = 7;
|
|
325
296
|
break;
|
|
326
297
|
}
|
|
327
298
|
return _context4.abrupt("return", Promise.reject(new Error('Source ari or source product is undefined')));
|
|
328
|
-
case
|
|
299
|
+
case 7:
|
|
329
300
|
_context4.t0 = product;
|
|
330
|
-
_context4.next = _context4.t0 === 'confluence-page' ?
|
|
301
|
+
_context4.next = _context4.t0 === 'confluence-page' ? 10 : _context4.t0 === 'jira-work-item' ? 16 : 22;
|
|
331
302
|
break;
|
|
332
|
-
case
|
|
333
|
-
_context4.next =
|
|
334
|
-
return fetchConfluencePageInfo(ari, hasAccess, urlType, localId,
|
|
335
|
-
case
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
_context4.next = 18;
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
if (sourceInfo) {
|
|
303
|
+
case 10:
|
|
304
|
+
_context4.next = 12;
|
|
305
|
+
return fetchConfluencePageInfo(ari, hasAccess, urlType, localId, isUnpublished);
|
|
306
|
+
case 12:
|
|
307
|
+
_sourceInfo = _context4.sent;
|
|
308
|
+
if (_sourceInfo) {
|
|
342
309
|
_context4.next = 15;
|
|
343
310
|
break;
|
|
344
311
|
}
|
|
345
312
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
346
313
|
case 15:
|
|
347
|
-
return _context4.abrupt("return", _objectSpread(_objectSpread({},
|
|
314
|
+
return _context4.abrupt("return", _objectSpread(_objectSpread({}, _sourceInfo), {}, {
|
|
348
315
|
onSameDocument: ((_this$writeProvider2 = this.writeProvider) === null || _this$writeProvider2 === void 0 ? void 0 : _this$writeProvider2.parentAri) === ari,
|
|
349
316
|
productType: product
|
|
350
317
|
}));
|
|
351
|
-
case
|
|
352
|
-
|
|
353
|
-
case 19:
|
|
354
|
-
if (!fg('platform_synced_block_dogfooding')) {
|
|
355
|
-
_context4.next = 26;
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
_context4.next = 22;
|
|
318
|
+
case 16:
|
|
319
|
+
_context4.next = 18;
|
|
359
320
|
return fetchJiraWorkItemInfo(ari, hasAccess);
|
|
360
|
-
case
|
|
361
|
-
|
|
362
|
-
if (
|
|
363
|
-
_context4.next =
|
|
321
|
+
case 18:
|
|
322
|
+
sourceInfo = _context4.sent;
|
|
323
|
+
if (sourceInfo) {
|
|
324
|
+
_context4.next = 21;
|
|
364
325
|
break;
|
|
365
326
|
}
|
|
366
327
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
367
|
-
case
|
|
368
|
-
return _context4.abrupt("return", _objectSpread(_objectSpread({},
|
|
328
|
+
case 21:
|
|
329
|
+
return _context4.abrupt("return", _objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
369
330
|
onSameDocument: ((_this$writeProvider3 = this.writeProvider) === null || _this$writeProvider3 === void 0 ? void 0 : _this$writeProvider3.parentAri) === ari,
|
|
370
331
|
productType: product
|
|
371
332
|
}));
|
|
372
|
-
case
|
|
373
|
-
return _context4.abrupt("return", Promise.reject(new Error('Jira work item source product not supported')));
|
|
374
|
-
case 27:
|
|
333
|
+
case 22:
|
|
375
334
|
return _context4.abrupt("return", Promise.reject(new Error("".concat(product, " source product not supported"))));
|
|
376
|
-
case
|
|
335
|
+
case 23:
|
|
377
336
|
case "end":
|
|
378
337
|
return _context4.stop();
|
|
379
338
|
}
|