@atlaskit/editor-synced-block-provider 3.29.3 → 3.30.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
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.30.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`94134fec8eb68`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94134fec8eb68) -
|
|
8
|
+
Also fetch current pages for retrieving source info
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 3.30.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`05e18ecc17fb3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05e18ecc17fb3) -
|
|
16
|
+
Use GraphQL to also fetch the URLs for draft + unpublished pages
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 3.29.3
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _errorHandling = require("../../utils/errorHandling");
|
|
13
14
|
var _retry = require("../../utils/retry");
|
|
14
15
|
var _ari = require("./ari");
|
|
@@ -29,45 +30,49 @@ var GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
|
|
|
29
30
|
* @param documentARI
|
|
30
31
|
* @returns subType live if livePage, subType null if classic page
|
|
31
32
|
*/
|
|
32
|
-
var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID
|
|
33
|
+
var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!, $status: [String]) {\n\tcontent (id: $id, status: $status) {\n\t\tnodes {\n\t\t\tid\n\t\t\tlinks {\n\t\t\t\tbase\n\t\t\t\teditui\n\t\t\t\twebui\n\t\t\t}\n\t\t\tspace {\n\t\t\t\tkey\n\t\t\t}\n\t\t\tstatus\n\t\t\tsubType\n\t\t\ttitle\n\t\t}\n\t}\n}");
|
|
33
34
|
var getConfluenceSourceInfo = /*#__PURE__*/function () {
|
|
34
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ari) {
|
|
35
|
-
var bodyData, response;
|
|
35
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ari, status) {
|
|
36
|
+
var variables, bodyData, response;
|
|
36
37
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
37
38
|
while (1) switch (_context.prev = _context.next) {
|
|
38
39
|
case 0:
|
|
40
|
+
variables = {
|
|
41
|
+
id: ari
|
|
42
|
+
};
|
|
43
|
+
if (status) {
|
|
44
|
+
variables.status = status;
|
|
45
|
+
}
|
|
39
46
|
bodyData = {
|
|
40
47
|
query: GET_SOURCE_INFO_QUERY,
|
|
41
48
|
operationName: GET_SOURCE_INFO_OPERATION_NAME,
|
|
42
|
-
variables:
|
|
43
|
-
id: ari
|
|
44
|
-
}
|
|
49
|
+
variables: variables
|
|
45
50
|
};
|
|
46
|
-
_context.next =
|
|
51
|
+
_context.next = 5;
|
|
47
52
|
return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
|
|
48
53
|
method: 'POST',
|
|
49
54
|
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
50
55
|
body: JSON.stringify(bodyData)
|
|
51
56
|
});
|
|
52
|
-
case
|
|
57
|
+
case 5:
|
|
53
58
|
response = _context.sent;
|
|
54
59
|
if (response.ok) {
|
|
55
|
-
_context.next =
|
|
60
|
+
_context.next = 8;
|
|
56
61
|
break;
|
|
57
62
|
}
|
|
58
63
|
throw new Error("Failed to get url: ".concat(response.statusText));
|
|
59
|
-
case 6:
|
|
60
|
-
_context.next = 8;
|
|
61
|
-
return response.json();
|
|
62
64
|
case 8:
|
|
65
|
+
_context.next = 10;
|
|
66
|
+
return response.json();
|
|
67
|
+
case 10:
|
|
63
68
|
return _context.abrupt("return", _context.sent);
|
|
64
|
-
case
|
|
69
|
+
case 11:
|
|
65
70
|
case "end":
|
|
66
71
|
return _context.stop();
|
|
67
72
|
}
|
|
68
73
|
}, _callee);
|
|
69
74
|
}));
|
|
70
|
-
return function getConfluenceSourceInfo(_x) {
|
|
75
|
+
return function getConfluenceSourceInfo(_x, _x2) {
|
|
71
76
|
return _ref.apply(this, arguments);
|
|
72
77
|
};
|
|
73
78
|
}();
|
|
@@ -113,7 +118,7 @@ var resolveNoAccessPageInfo = /*#__PURE__*/function () {
|
|
|
113
118
|
}
|
|
114
119
|
}, _callee2);
|
|
115
120
|
}));
|
|
116
|
-
return function resolveNoAccessPageInfo(
|
|
121
|
+
return function resolveNoAccessPageInfo(_x3) {
|
|
117
122
|
return _ref2.apply(this, arguments);
|
|
118
123
|
};
|
|
119
124
|
}();
|
|
@@ -179,13 +184,13 @@ var fetchCompleteConfluencePageInfo = /*#__PURE__*/function () {
|
|
|
179
184
|
}
|
|
180
185
|
}, _callee3, null, [[0, 18]]);
|
|
181
186
|
}));
|
|
182
|
-
return function fetchCompleteConfluencePageInfo(
|
|
187
|
+
return function fetchCompleteConfluencePageInfo(_x4, _x5) {
|
|
183
188
|
return _ref3.apply(this, arguments);
|
|
184
189
|
};
|
|
185
190
|
}();
|
|
186
191
|
var fetchConfluencePageInfoOld = exports.fetchConfluencePageInfoOld = /*#__PURE__*/function () {
|
|
187
192
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(pageAri, localId, fireAnalyticsEvent) {
|
|
188
|
-
var _response$data, _contentData$space, _getPageIdAndTypeFrom2, pageType, response, contentData, title, url, _ref5, base;
|
|
193
|
+
var _response$data, _contentData$space, _getPageIdAndTypeFrom2, pageType, status, response, contentData, title, url, _ref5, base;
|
|
189
194
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
190
195
|
while (1) switch (_context4.prev = _context4.next) {
|
|
191
196
|
case 0:
|
|
@@ -193,9 +198,10 @@ var fetchConfluencePageInfoOld = exports.fetchConfluencePageInfoOld = /*#__PURE_
|
|
|
193
198
|
_getPageIdAndTypeFrom2 = (0, _ari.getPageIdAndTypeFromConfluencePageAri)({
|
|
194
199
|
ari: pageAri
|
|
195
200
|
}), pageType = _getPageIdAndTypeFrom2.type;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
status = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
|
|
202
|
+
_context4.next = 5;
|
|
203
|
+
return getConfluenceSourceInfo(pageAri, status);
|
|
204
|
+
case 5:
|
|
199
205
|
response = _context4.sent;
|
|
200
206
|
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];
|
|
201
207
|
title = contentData === null || contentData === void 0 ? void 0 : contentData.title;
|
|
@@ -218,31 +224,31 @@ var fetchConfluencePageInfoOld = exports.fetchConfluencePageInfoOld = /*#__PURE_
|
|
|
218
224
|
url: url,
|
|
219
225
|
sourceAri: pageAri
|
|
220
226
|
}));
|
|
221
|
-
case
|
|
222
|
-
_context4.prev =
|
|
227
|
+
case 15:
|
|
228
|
+
_context4.prev = 15;
|
|
223
229
|
_context4.t0 = _context4["catch"](0);
|
|
224
230
|
(0, _monitoring.logException)(_context4.t0, {
|
|
225
231
|
location: 'editor-synced-block-provider/sourceInfo'
|
|
226
232
|
});
|
|
227
233
|
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent((0, _errorHandling.getSourceInfoErrorPayload)(_context4.t0.message));
|
|
228
234
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
229
|
-
case
|
|
235
|
+
case 20:
|
|
230
236
|
case "end":
|
|
231
237
|
return _context4.stop();
|
|
232
238
|
}
|
|
233
|
-
}, _callee4, null, [[0,
|
|
239
|
+
}, _callee4, null, [[0, 15]]);
|
|
234
240
|
}));
|
|
235
|
-
return function fetchConfluencePageInfoOld(
|
|
241
|
+
return function fetchConfluencePageInfoOld(_x6, _x7, _x8) {
|
|
236
242
|
return _ref4.apply(this, arguments);
|
|
237
243
|
};
|
|
238
244
|
}();
|
|
239
245
|
var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/function () {
|
|
240
246
|
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(pageAri, hasAccess, urlType, localId, isUnpublished) {
|
|
241
|
-
var _response$data2,
|
|
247
|
+
var _response$data2, _getPageIdAndTypeFrom3, pageType, status, response, contentData, _ref7, title, subType, url, _ref8, base, editui, webui, pageStatus, _contentData$space2;
|
|
242
248
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
243
249
|
while (1) switch (_context5.prev = _context5.next) {
|
|
244
250
|
case 0:
|
|
245
|
-
if (!isUnpublished) {
|
|
251
|
+
if (!(isUnpublished && !(0, _platformFeatureFlags.fg)('platform_synced_block_patch_3'))) {
|
|
246
252
|
_context5.next = 4;
|
|
247
253
|
break;
|
|
248
254
|
}
|
|
@@ -252,26 +258,36 @@ var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/fun
|
|
|
252
258
|
return _context5.abrupt("return", _context5.sent);
|
|
253
259
|
case 4:
|
|
254
260
|
if (!hasAccess) {
|
|
255
|
-
_context5.next =
|
|
261
|
+
_context5.next = 19;
|
|
256
262
|
break;
|
|
257
263
|
}
|
|
258
264
|
_getPageIdAndTypeFrom3 = (0, _ari.getPageIdAndTypeFromConfluencePageAri)({
|
|
259
265
|
ari: pageAri
|
|
260
266
|
}), pageType = _getPageIdAndTypeFrom3.type;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
status = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
|
|
268
|
+
_context5.next = 9;
|
|
269
|
+
return getConfluenceSourceInfo(pageAri, status);
|
|
270
|
+
case 9:
|
|
264
271
|
response = _context5.sent;
|
|
265
272
|
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];
|
|
266
273
|
_ref7 = contentData || {}, title = _ref7.title, subType = _ref7.subType;
|
|
267
|
-
_ref8 = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {}, base = _ref8.base;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
_ref8 = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {}, base = _ref8.base, editui = _ref8.editui, webui = _ref8.webui;
|
|
275
|
+
pageStatus = contentData === null || contentData === void 0 ? void 0 : contentData.status;
|
|
276
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
|
|
277
|
+
if (base && editui && pageStatus !== 'archived') {
|
|
278
|
+
url = "".concat(base).concat(editui);
|
|
279
|
+
} else if (base && webui && pageStatus === 'archived') {
|
|
280
|
+
url = "".concat(base).concat(webui);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
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) {
|
|
284
|
+
if ((0, _utils.isBlogPageType)(pageType)) {
|
|
285
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/blog").concat(urlType === 'edit' ? '/edit-v2' : '', "/").concat(contentData.id);
|
|
286
|
+
} else if (contentData.subType === 'live') {
|
|
287
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/").concat(contentData.id);
|
|
288
|
+
} else {
|
|
289
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages").concat(urlType === 'edit' ? '/edit-v2' : '', "/").concat(contentData.id);
|
|
290
|
+
}
|
|
275
291
|
}
|
|
276
292
|
}
|
|
277
293
|
url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
|
|
@@ -281,18 +297,18 @@ var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/fun
|
|
|
281
297
|
sourceAri: pageAri,
|
|
282
298
|
subType: subType
|
|
283
299
|
}));
|
|
284
|
-
case 17:
|
|
285
|
-
_context5.next = 19;
|
|
286
|
-
return resolveNoAccessPageInfo(pageAri);
|
|
287
300
|
case 19:
|
|
301
|
+
_context5.next = 21;
|
|
302
|
+
return resolveNoAccessPageInfo(pageAri);
|
|
303
|
+
case 21:
|
|
288
304
|
return _context5.abrupt("return", _context5.sent);
|
|
289
|
-
case
|
|
305
|
+
case 22:
|
|
290
306
|
case "end":
|
|
291
307
|
return _context5.stop();
|
|
292
308
|
}
|
|
293
309
|
}, _callee5);
|
|
294
310
|
}));
|
|
295
|
-
return function fetchConfluencePageInfo(
|
|
311
|
+
return function fetchConfluencePageInfo(_x9, _x0, _x1, _x10, _x11) {
|
|
296
312
|
return _ref6.apply(this, arguments);
|
|
297
313
|
};
|
|
298
314
|
}();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
|
|
3
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { getSourceInfoErrorPayload } from '../../utils/errorHandling';
|
|
5
6
|
import { fetchWithRetry } from '../../utils/retry';
|
|
6
7
|
import { getPageIdAndTypeFromConfluencePageAri } from './ari';
|
|
@@ -19,28 +20,35 @@ const GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
|
|
|
19
20
|
* @param documentARI
|
|
20
21
|
* @returns subType live if livePage, subType null if classic page
|
|
21
22
|
*/
|
|
22
|
-
const GET_SOURCE_INFO_QUERY = `query ${GET_SOURCE_INFO_OPERATION_NAME} ($id: ID
|
|
23
|
-
content (id: $id) {
|
|
23
|
+
const GET_SOURCE_INFO_QUERY = `query ${GET_SOURCE_INFO_OPERATION_NAME} ($id: ID!, $status: [String]) {
|
|
24
|
+
content (id: $id, status: $status) {
|
|
24
25
|
nodes {
|
|
25
26
|
id
|
|
26
27
|
links {
|
|
27
28
|
base
|
|
29
|
+
editui
|
|
30
|
+
webui
|
|
28
31
|
}
|
|
29
32
|
space {
|
|
30
33
|
key
|
|
31
34
|
}
|
|
35
|
+
status
|
|
32
36
|
subType
|
|
33
37
|
title
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
}`;
|
|
37
|
-
const getConfluenceSourceInfo = async ari => {
|
|
41
|
+
const getConfluenceSourceInfo = async (ari, status) => {
|
|
42
|
+
const variables = {
|
|
43
|
+
id: ari
|
|
44
|
+
};
|
|
45
|
+
if (status) {
|
|
46
|
+
variables.status = status;
|
|
47
|
+
}
|
|
38
48
|
const bodyData = {
|
|
39
49
|
query: GET_SOURCE_INFO_QUERY,
|
|
40
50
|
operationName: GET_SOURCE_INFO_OPERATION_NAME,
|
|
41
|
-
variables
|
|
42
|
-
id: ari
|
|
43
|
-
}
|
|
51
|
+
variables
|
|
44
52
|
};
|
|
45
53
|
const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
46
54
|
method: 'POST',
|
|
@@ -134,7 +142,8 @@ export const fetchConfluencePageInfoOld = async (pageAri, localId, fireAnalytics
|
|
|
134
142
|
} = getPageIdAndTypeFromConfluencePageAri({
|
|
135
143
|
ari: pageAri
|
|
136
144
|
});
|
|
137
|
-
const
|
|
145
|
+
const status = fg('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
|
|
146
|
+
const response = await getConfluenceSourceInfo(pageAri, status);
|
|
138
147
|
const contentData = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$conten = _response$data.content) === null || _response$data$conten === void 0 ? void 0 : (_response$data$conten2 = _response$data$conten.nodes) === null || _response$data$conten2 === void 0 ? void 0 : _response$data$conten2[0];
|
|
139
148
|
const title = contentData === null || contentData === void 0 ? void 0 : contentData.title;
|
|
140
149
|
let url;
|
|
@@ -169,17 +178,19 @@ export const fetchConfluencePageInfoOld = async (pageAri, localId, fireAnalytics
|
|
|
169
178
|
};
|
|
170
179
|
export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, localId, isUnpublished) => {
|
|
171
180
|
// For unpublished pages, use the v2 pages API as GraphQL returns empty content.nodes
|
|
172
|
-
if (
|
|
181
|
+
// We don't want to use the Rest API at all because it doesn't work if accessed from a custom base URL (e.g in Jira)
|
|
182
|
+
if (isUnpublished && !fg('platform_synced_block_patch_3')) {
|
|
173
183
|
return await fetchCompleteConfluencePageInfo(pageAri, localId);
|
|
174
184
|
}
|
|
175
185
|
if (hasAccess) {
|
|
176
|
-
var _response$data2, _response$data2$conte, _response$data2$conte2
|
|
186
|
+
var _response$data2, _response$data2$conte, _response$data2$conte2;
|
|
177
187
|
const {
|
|
178
188
|
type: pageType
|
|
179
189
|
} = getPageIdAndTypeFromConfluencePageAri({
|
|
180
190
|
ari: pageAri
|
|
181
191
|
});
|
|
182
|
-
const
|
|
192
|
+
const status = fg('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
|
|
193
|
+
const response = await getConfluenceSourceInfo(pageAri, status);
|
|
183
194
|
const contentData = (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : (_response$data2$conte = _response$data2.content) === null || _response$data2$conte === void 0 ? void 0 : (_response$data2$conte2 = _response$data2$conte.nodes) === null || _response$data2$conte2 === void 0 ? void 0 : _response$data2$conte2[0];
|
|
184
195
|
const {
|
|
185
196
|
title,
|
|
@@ -187,15 +198,27 @@ export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, local
|
|
|
187
198
|
} = contentData || {};
|
|
188
199
|
let url;
|
|
189
200
|
const {
|
|
190
|
-
base
|
|
201
|
+
base,
|
|
202
|
+
editui,
|
|
203
|
+
webui
|
|
191
204
|
} = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
205
|
+
const pageStatus = contentData === null || contentData === void 0 ? void 0 : contentData.status;
|
|
206
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
207
|
+
if (base && editui && pageStatus !== 'archived') {
|
|
208
|
+
url = `${base}${editui}`;
|
|
209
|
+
} else if (base && webui && pageStatus === 'archived') {
|
|
210
|
+
url = `${base}${webui}`;
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
var _contentData$space2;
|
|
214
|
+
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) {
|
|
215
|
+
if (isBlogPageType(pageType)) {
|
|
216
|
+
url = `${base}/spaces/${contentData.space.key}/blog${urlType === 'edit' ? '/edit-v2' : ''}/${contentData.id}`;
|
|
217
|
+
} else if (contentData.subType === 'live') {
|
|
218
|
+
url = `${base}/spaces/${contentData.space.key}/pages/${contentData.id}`;
|
|
219
|
+
} else {
|
|
220
|
+
url = `${base}/spaces/${contentData.space.key}/pages${urlType === 'edit' ? '/edit-v2' : ''}/${contentData.id}`;
|
|
221
|
+
}
|
|
199
222
|
}
|
|
200
223
|
}
|
|
201
224
|
url = url && localId ? `${url}#block-${localId}` : url;
|
|
@@ -6,6 +6,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
6
|
/* eslint-disable require-unicode-regexp */
|
|
7
7
|
|
|
8
8
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { getSourceInfoErrorPayload } from '../../utils/errorHandling';
|
|
10
11
|
import { fetchWithRetry } from '../../utils/retry';
|
|
11
12
|
import { getPageIdAndTypeFromConfluencePageAri } from './ari';
|
|
@@ -24,45 +25,49 @@ var GET_SOURCE_INFO_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET_SOURCE_INFO';
|
|
|
24
25
|
* @param documentARI
|
|
25
26
|
* @returns subType live if livePage, subType null if classic page
|
|
26
27
|
*/
|
|
27
|
-
var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID
|
|
28
|
+
var GET_SOURCE_INFO_QUERY = "query ".concat(GET_SOURCE_INFO_OPERATION_NAME, " ($id: ID!, $status: [String]) {\n\tcontent (id: $id, status: $status) {\n\t\tnodes {\n\t\t\tid\n\t\t\tlinks {\n\t\t\t\tbase\n\t\t\t\teditui\n\t\t\t\twebui\n\t\t\t}\n\t\t\tspace {\n\t\t\t\tkey\n\t\t\t}\n\t\t\tstatus\n\t\t\tsubType\n\t\t\ttitle\n\t\t}\n\t}\n}");
|
|
28
29
|
var getConfluenceSourceInfo = /*#__PURE__*/function () {
|
|
29
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ari) {
|
|
30
|
-
var bodyData, response;
|
|
30
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ari, status) {
|
|
31
|
+
var variables, bodyData, response;
|
|
31
32
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
33
|
while (1) switch (_context.prev = _context.next) {
|
|
33
34
|
case 0:
|
|
35
|
+
variables = {
|
|
36
|
+
id: ari
|
|
37
|
+
};
|
|
38
|
+
if (status) {
|
|
39
|
+
variables.status = status;
|
|
40
|
+
}
|
|
34
41
|
bodyData = {
|
|
35
42
|
query: GET_SOURCE_INFO_QUERY,
|
|
36
43
|
operationName: GET_SOURCE_INFO_OPERATION_NAME,
|
|
37
|
-
variables:
|
|
38
|
-
id: ari
|
|
39
|
-
}
|
|
44
|
+
variables: variables
|
|
40
45
|
};
|
|
41
|
-
_context.next =
|
|
46
|
+
_context.next = 5;
|
|
42
47
|
return fetchWithRetry(GRAPHQL_ENDPOINT, {
|
|
43
48
|
method: 'POST',
|
|
44
49
|
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
45
50
|
body: JSON.stringify(bodyData)
|
|
46
51
|
});
|
|
47
|
-
case
|
|
52
|
+
case 5:
|
|
48
53
|
response = _context.sent;
|
|
49
54
|
if (response.ok) {
|
|
50
|
-
_context.next =
|
|
55
|
+
_context.next = 8;
|
|
51
56
|
break;
|
|
52
57
|
}
|
|
53
58
|
throw new Error("Failed to get url: ".concat(response.statusText));
|
|
54
|
-
case 6:
|
|
55
|
-
_context.next = 8;
|
|
56
|
-
return response.json();
|
|
57
59
|
case 8:
|
|
60
|
+
_context.next = 10;
|
|
61
|
+
return response.json();
|
|
62
|
+
case 10:
|
|
58
63
|
return _context.abrupt("return", _context.sent);
|
|
59
|
-
case
|
|
64
|
+
case 11:
|
|
60
65
|
case "end":
|
|
61
66
|
return _context.stop();
|
|
62
67
|
}
|
|
63
68
|
}, _callee);
|
|
64
69
|
}));
|
|
65
|
-
return function getConfluenceSourceInfo(_x) {
|
|
70
|
+
return function getConfluenceSourceInfo(_x, _x2) {
|
|
66
71
|
return _ref.apply(this, arguments);
|
|
67
72
|
};
|
|
68
73
|
}();
|
|
@@ -108,7 +113,7 @@ var resolveNoAccessPageInfo = /*#__PURE__*/function () {
|
|
|
108
113
|
}
|
|
109
114
|
}, _callee2);
|
|
110
115
|
}));
|
|
111
|
-
return function resolveNoAccessPageInfo(
|
|
116
|
+
return function resolveNoAccessPageInfo(_x3) {
|
|
112
117
|
return _ref2.apply(this, arguments);
|
|
113
118
|
};
|
|
114
119
|
}();
|
|
@@ -174,13 +179,13 @@ var fetchCompleteConfluencePageInfo = /*#__PURE__*/function () {
|
|
|
174
179
|
}
|
|
175
180
|
}, _callee3, null, [[0, 18]]);
|
|
176
181
|
}));
|
|
177
|
-
return function fetchCompleteConfluencePageInfo(
|
|
182
|
+
return function fetchCompleteConfluencePageInfo(_x4, _x5) {
|
|
178
183
|
return _ref3.apply(this, arguments);
|
|
179
184
|
};
|
|
180
185
|
}();
|
|
181
186
|
export var fetchConfluencePageInfoOld = /*#__PURE__*/function () {
|
|
182
187
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(pageAri, localId, fireAnalyticsEvent) {
|
|
183
|
-
var _response$data, _contentData$space, _getPageIdAndTypeFrom2, pageType, response, contentData, title, url, _ref5, base;
|
|
188
|
+
var _response$data, _contentData$space, _getPageIdAndTypeFrom2, pageType, status, response, contentData, title, url, _ref5, base;
|
|
184
189
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
185
190
|
while (1) switch (_context4.prev = _context4.next) {
|
|
186
191
|
case 0:
|
|
@@ -188,9 +193,10 @@ export var fetchConfluencePageInfoOld = /*#__PURE__*/function () {
|
|
|
188
193
|
_getPageIdAndTypeFrom2 = getPageIdAndTypeFromConfluencePageAri({
|
|
189
194
|
ari: pageAri
|
|
190
195
|
}), pageType = _getPageIdAndTypeFrom2.type;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
status = fg('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
|
|
197
|
+
_context4.next = 5;
|
|
198
|
+
return getConfluenceSourceInfo(pageAri, status);
|
|
199
|
+
case 5:
|
|
194
200
|
response = _context4.sent;
|
|
195
201
|
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];
|
|
196
202
|
title = contentData === null || contentData === void 0 ? void 0 : contentData.title;
|
|
@@ -213,31 +219,31 @@ export var fetchConfluencePageInfoOld = /*#__PURE__*/function () {
|
|
|
213
219
|
url: url,
|
|
214
220
|
sourceAri: pageAri
|
|
215
221
|
}));
|
|
216
|
-
case
|
|
217
|
-
_context4.prev =
|
|
222
|
+
case 15:
|
|
223
|
+
_context4.prev = 15;
|
|
218
224
|
_context4.t0 = _context4["catch"](0);
|
|
219
225
|
logException(_context4.t0, {
|
|
220
226
|
location: 'editor-synced-block-provider/sourceInfo'
|
|
221
227
|
});
|
|
222
228
|
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(getSourceInfoErrorPayload(_context4.t0.message));
|
|
223
229
|
return _context4.abrupt("return", Promise.resolve(undefined));
|
|
224
|
-
case
|
|
230
|
+
case 20:
|
|
225
231
|
case "end":
|
|
226
232
|
return _context4.stop();
|
|
227
233
|
}
|
|
228
|
-
}, _callee4, null, [[0,
|
|
234
|
+
}, _callee4, null, [[0, 15]]);
|
|
229
235
|
}));
|
|
230
|
-
return function fetchConfluencePageInfoOld(
|
|
236
|
+
return function fetchConfluencePageInfoOld(_x6, _x7, _x8) {
|
|
231
237
|
return _ref4.apply(this, arguments);
|
|
232
238
|
};
|
|
233
239
|
}();
|
|
234
240
|
export var fetchConfluencePageInfo = /*#__PURE__*/function () {
|
|
235
241
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(pageAri, hasAccess, urlType, localId, isUnpublished) {
|
|
236
|
-
var _response$data2,
|
|
242
|
+
var _response$data2, _getPageIdAndTypeFrom3, pageType, status, response, contentData, _ref7, title, subType, url, _ref8, base, editui, webui, pageStatus, _contentData$space2;
|
|
237
243
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
238
244
|
while (1) switch (_context5.prev = _context5.next) {
|
|
239
245
|
case 0:
|
|
240
|
-
if (!isUnpublished) {
|
|
246
|
+
if (!(isUnpublished && !fg('platform_synced_block_patch_3'))) {
|
|
241
247
|
_context5.next = 4;
|
|
242
248
|
break;
|
|
243
249
|
}
|
|
@@ -247,26 +253,36 @@ export var fetchConfluencePageInfo = /*#__PURE__*/function () {
|
|
|
247
253
|
return _context5.abrupt("return", _context5.sent);
|
|
248
254
|
case 4:
|
|
249
255
|
if (!hasAccess) {
|
|
250
|
-
_context5.next =
|
|
256
|
+
_context5.next = 19;
|
|
251
257
|
break;
|
|
252
258
|
}
|
|
253
259
|
_getPageIdAndTypeFrom3 = getPageIdAndTypeFromConfluencePageAri({
|
|
254
260
|
ari: pageAri
|
|
255
261
|
}), pageType = _getPageIdAndTypeFrom3.type;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
262
|
+
status = fg('platform_synced_block_patch_3') ? ['draft', 'archived', 'current'] : undefined;
|
|
263
|
+
_context5.next = 9;
|
|
264
|
+
return getConfluenceSourceInfo(pageAri, status);
|
|
265
|
+
case 9:
|
|
259
266
|
response = _context5.sent;
|
|
260
267
|
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];
|
|
261
268
|
_ref7 = contentData || {}, title = _ref7.title, subType = _ref7.subType;
|
|
262
|
-
_ref8 = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {}, base = _ref8.base;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
_ref8 = (contentData === null || contentData === void 0 ? void 0 : contentData.links) || {}, base = _ref8.base, editui = _ref8.editui, webui = _ref8.webui;
|
|
270
|
+
pageStatus = contentData === null || contentData === void 0 ? void 0 : contentData.status;
|
|
271
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
272
|
+
if (base && editui && pageStatus !== 'archived') {
|
|
273
|
+
url = "".concat(base).concat(editui);
|
|
274
|
+
} else if (base && webui && pageStatus === 'archived') {
|
|
275
|
+
url = "".concat(base).concat(webui);
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
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) {
|
|
279
|
+
if (isBlogPageType(pageType)) {
|
|
280
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/blog").concat(urlType === 'edit' ? '/edit-v2' : '', "/").concat(contentData.id);
|
|
281
|
+
} else if (contentData.subType === 'live') {
|
|
282
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages/").concat(contentData.id);
|
|
283
|
+
} else {
|
|
284
|
+
url = "".concat(base, "/spaces/").concat(contentData.space.key, "/pages").concat(urlType === 'edit' ? '/edit-v2' : '', "/").concat(contentData.id);
|
|
285
|
+
}
|
|
270
286
|
}
|
|
271
287
|
}
|
|
272
288
|
url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
|
|
@@ -276,18 +292,18 @@ export var fetchConfluencePageInfo = /*#__PURE__*/function () {
|
|
|
276
292
|
sourceAri: pageAri,
|
|
277
293
|
subType: subType
|
|
278
294
|
}));
|
|
279
|
-
case 17:
|
|
280
|
-
_context5.next = 19;
|
|
281
|
-
return resolveNoAccessPageInfo(pageAri);
|
|
282
295
|
case 19:
|
|
296
|
+
_context5.next = 21;
|
|
297
|
+
return resolveNoAccessPageInfo(pageAri);
|
|
298
|
+
case 21:
|
|
283
299
|
return _context5.abrupt("return", _context5.sent);
|
|
284
|
-
case
|
|
300
|
+
case 22:
|
|
285
301
|
case "end":
|
|
286
302
|
return _context5.stop();
|
|
287
303
|
}
|
|
288
304
|
}, _callee5);
|
|
289
305
|
}));
|
|
290
|
-
return function fetchConfluencePageInfo(
|
|
306
|
+
return function fetchConfluencePageInfo(_x9, _x0, _x1, _x10, _x11) {
|
|
291
307
|
return _ref6.apply(this, arguments);
|
|
292
308
|
};
|
|
293
309
|
}();
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"uuid": "^3.1.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^111.
|
|
40
|
+
"@atlaskit/editor-common": "^111.16.0",
|
|
41
41
|
"react": "^18.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
83
|
-
"version": "3.
|
|
83
|
+
"version": "3.30.1",
|
|
84
84
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
85
85
|
"author": "Atlassian Pty Ltd",
|
|
86
86
|
"license": "Apache-2.0",
|