@atlaskit/editor-synced-block-provider 3.26.2 → 3.27.0

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,18 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 3.27.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8433176cb97f5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8433176cb97f5) -
8
+ Edit at source for an archived page should not redirect and show ask for edit flag
9
+
10
+ ### Patch Changes
11
+
12
+ - [`328425ff14e85`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/328425ff14e85) -
13
+ Update synced block to active state on flush
14
+ - Updated dependencies
15
+
3
16
  ## 3.26.2
4
17
 
5
18
  ### Patch Changes
@@ -135,11 +135,14 @@ var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlo
135
135
  var buildGetBlockQuery = function buildGetBlockQuery(blockAri) {
136
136
  return "query ".concat(GET_BLOCK_OPERATION_NAME, " {\n\tblockService_getBlock(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\tblockAri\n\t\tblockInstanceId\n\t\tcontent\n\t\tcontentUpdatedAt\n\t\tcreatedAt\n\t\tcreatedBy\n\t\tdeletionReason\n\t\tproduct\n\t\tsourceAri\n\t\tstatus\n\t\tversion\n\t}\n}");
137
137
  };
138
- var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion) {
138
+ var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion, status) {
139
139
  var inputParts = ["blockAri: ".concat(JSON.stringify(blockAri)), "content: ".concat(JSON.stringify(content))];
140
140
  if (stepVersion !== undefined) {
141
141
  inputParts.push("stepVersion: ".concat(stepVersion));
142
142
  }
143
+ if (status !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
144
+ inputParts.push("status: ".concat(JSON.stringify(status)));
145
+ }
143
146
  var inputArgs = inputParts.join(', ');
144
147
  return "mutation ".concat(UPDATE_BLOCK_OPERATION_NAME, " {\n\tblockService_updateBlock(input: { ").concat(inputArgs, " }) {\n\t\t__typename\n\t}\n}");
145
148
  };
@@ -457,17 +460,17 @@ var deleteSyncedBlock = exports.deleteSyncedBlock = /*#__PURE__*/function () {
457
460
  }();
458
461
  var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
459
462
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref8) {
460
- var blockAri, content, stepVersion, bodyData, _response4, result, requestBody, response;
463
+ var blockAri, content, stepVersion, status, bodyData, _response4, result, requestBody, response;
461
464
  return _regenerator.default.wrap(function _callee5$(_context5) {
462
465
  while (1) switch (_context5.prev = _context5.next) {
463
466
  case 0:
464
- blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion;
467
+ blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion, status = _ref8.status;
465
468
  if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
466
469
  _context5.next = 14;
467
470
  break;
468
471
  }
469
472
  bodyData = {
470
- query: buildUpdateBlockMutation(blockAri, content, stepVersion),
473
+ query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
471
474
  operationName: UPDATE_BLOCK_OPERATION_NAME
472
475
  };
473
476
  _context5.next = 5;
@@ -504,20 +507,23 @@ var updateSyncedBlock = exports.updateSyncedBlock = /*#__PURE__*/function () {
504
507
  if (stepVersion !== undefined) {
505
508
  requestBody.stepVersion = stepVersion;
506
509
  }
507
- _context5.next = 18;
510
+ if (status !== undefined && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
511
+ requestBody.status = status;
512
+ }
513
+ _context5.next = 19;
508
514
  return (0, _retry.fetchWithRetry)("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
509
515
  method: 'PUT',
510
516
  headers: COMMON_HEADERS,
511
517
  body: JSON.stringify(requestBody)
512
518
  });
513
- case 18:
519
+ case 19:
514
520
  response = _context5.sent;
515
521
  if (response.ok) {
516
- _context5.next = 21;
522
+ _context5.next = 22;
517
523
  break;
518
524
  }
519
525
  throw new BlockError(response.status);
520
- case 21:
526
+ case 22:
521
527
  case "end":
522
528
  return _context5.stop();
523
529
  }
@@ -126,9 +126,9 @@ var resolveNoAccessPageInfo = /*#__PURE__*/function () {
126
126
  * @param localId - Optional local ID to append as block anchor
127
127
  * @returns Source info with URL, title, and optional subtype
128
128
  */
129
- var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
129
+ var fetchCompleteConfluencePageInfo = /*#__PURE__*/function () {
130
130
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(pageAri, localId) {
131
- var _pageData$_links, _pageData$_links2, _getPageIdAndTypeFrom, pageId, response, pageData, base, edituiv2, title, subType, url;
131
+ var _pageData$_links, _pageData$_links2, _pageData$_links3, _getPageIdAndTypeFrom, pageId, response, pageData, base, edituiv2, webui, title, subType, status, url;
132
132
  return _regenerator.default.wrap(function _callee3$(_context3) {
133
133
  while (1) switch (_context3.prev = _context3.next) {
134
134
  case 0:
@@ -155,11 +155,15 @@ var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
155
155
  pageData = _context3.sent;
156
156
  base = (_pageData$_links = pageData._links) === null || _pageData$_links === void 0 ? void 0 : _pageData$_links.base;
157
157
  edituiv2 = (_pageData$_links2 = pageData._links) === null || _pageData$_links2 === void 0 ? void 0 : _pageData$_links2.edituiv2;
158
+ webui = (_pageData$_links3 = pageData._links) === null || _pageData$_links3 === void 0 ? void 0 : _pageData$_links3.webui;
158
159
  title = pageData.title;
159
160
  subType = pageData.subtype;
160
- if (base && edituiv2) {
161
+ status = pageData.status;
162
+ if (base && edituiv2 && ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_2') ? status !== 'archived' : true)) {
161
163
  url = "".concat(base).concat(edituiv2);
162
164
  url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
165
+ } else if (base && webui && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
166
+ url = "".concat(base).concat(webui);
163
167
  }
164
168
  return _context3.abrupt("return", {
165
169
  title: title,
@@ -167,20 +171,20 @@ var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
167
171
  sourceAri: pageAri,
168
172
  subType: subType
169
173
  });
170
- case 18:
171
- _context3.prev = 18;
174
+ case 20:
175
+ _context3.prev = 20;
172
176
  _context3.t0 = _context3["catch"](0);
173
177
  (0, _monitoring.logException)(_context3.t0, {
174
- location: 'editor-synced-block-provider/sourceInfo/fetchUnpublishedConfluencePageInfo'
178
+ location: 'editor-synced-block-provider/sourceInfo/fetchCompleteConfluencePageInfo'
175
179
  });
176
180
  return _context3.abrupt("return", Promise.resolve(undefined));
177
- case 22:
181
+ case 24:
178
182
  case "end":
179
183
  return _context3.stop();
180
184
  }
181
- }, _callee3, null, [[0, 18]]);
185
+ }, _callee3, null, [[0, 20]]);
182
186
  }));
183
- return function fetchUnpublishedConfluencePageInfo(_x3, _x4) {
187
+ return function fetchCompleteConfluencePageInfo(_x3, _x4) {
184
188
  return _ref3.apply(this, arguments);
185
189
  };
186
190
  }();
@@ -244,24 +248,37 @@ var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/fun
244
248
  while (1) switch (_context5.prev = _context5.next) {
245
249
  case 0:
246
250
  if (!(isUnpublished && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1'))) {
247
- _context5.next = 4;
251
+ _context5.next = 5;
248
252
  break;
249
253
  }
250
- _context5.next = 3;
251
- return fetchUnpublishedConfluencePageInfo(pageAri, localId);
252
- case 3:
253
- return _context5.abrupt("return", _context5.sent);
254
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_2')) {
255
+ _context5.next = 5;
256
+ break;
257
+ }
258
+ _context5.next = 4;
259
+ return fetchCompleteConfluencePageInfo(pageAri, localId);
254
260
  case 4:
261
+ return _context5.abrupt("return", _context5.sent);
262
+ case 5:
255
263
  if (!hasAccess) {
256
- _context5.next = 17;
264
+ _context5.next = 22;
257
265
  break;
258
266
  }
259
267
  _getPageIdAndTypeFrom3 = (0, _ari.getPageIdAndTypeFromConfluencePageAri)({
260
268
  ari: pageAri
261
269
  }), pageType = _getPageIdAndTypeFrom3.type;
262
- _context5.next = 8;
270
+ if (!(pageType === 'page' && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_2'))) {
271
+ _context5.next = 11;
272
+ break;
273
+ }
274
+ _context5.next = 10;
275
+ return fetchCompleteConfluencePageInfo(pageAri, localId);
276
+ case 10:
277
+ return _context5.abrupt("return", _context5.sent);
278
+ case 11:
279
+ _context5.next = 13;
263
280
  return getConfluenceSourceInfo(pageAri);
264
- case 8:
281
+ case 13:
265
282
  response = _context5.sent;
266
283
  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];
267
284
  _ref7 = contentData || {}, title = _ref7.title, subType = _ref7.subType;
@@ -282,12 +299,12 @@ var fetchConfluencePageInfo = exports.fetchConfluencePageInfo = /*#__PURE__*/fun
282
299
  sourceAri: pageAri,
283
300
  subType: subType
284
301
  }));
285
- case 17:
286
- _context5.next = 19;
302
+ case 22:
303
+ _context5.next = 24;
287
304
  return resolveNoAccessPageInfo(pageAri);
288
- case 19:
305
+ case 24:
289
306
  return _context5.abrupt("return", _context5.sent);
290
- case 20:
307
+ case 25:
291
308
  case "end":
292
309
  return _context5.stop();
293
310
  }
@@ -632,7 +632,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
632
632
  key: "writeData",
633
633
  value: function () {
634
634
  var _writeData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(data) {
635
- var resourceId, blockAri, stepVersion;
635
+ var resourceId, blockAri, stepVersion, status;
636
636
  return _regenerator.default.wrap(function _callee5$(_context5) {
637
637
  while (1) switch (_context5.prev = _context5.next) {
638
638
  case 0:
@@ -666,37 +666,39 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
666
666
  case 11:
667
667
  stepVersion = _context5.t0;
668
668
  _context5.prev = 12;
669
- _context5.next = 15;
669
+ status = data.status;
670
+ _context5.next = 16;
670
671
  return (0, _blockService.updateSyncedBlock)({
671
672
  blockAri: blockAri,
672
673
  content: JSON.stringify(data.content),
673
- stepVersion: stepVersion
674
+ stepVersion: stepVersion,
675
+ status: status
674
676
  });
675
- case 15:
677
+ case 16:
676
678
  return _context5.abrupt("return", {
677
679
  resourceId: resourceId
678
680
  });
679
- case 18:
680
- _context5.prev = 18;
681
+ case 19:
682
+ _context5.prev = 19;
681
683
  _context5.t1 = _context5["catch"](12);
682
684
  if (!(_context5.t1 instanceof _blockService.BlockError)) {
683
- _context5.next = 22;
685
+ _context5.next = 23;
684
686
  break;
685
687
  }
686
688
  return _context5.abrupt("return", {
687
689
  error: mapBlockError(_context5.t1),
688
690
  resourceId: resourceId
689
691
  });
690
- case 22:
692
+ case 23:
691
693
  return _context5.abrupt("return", {
692
694
  error: (0, _errorHandling.stringifyError)(_context5.t1),
693
695
  resourceId: resourceId
694
696
  });
695
- case 23:
697
+ case 24:
696
698
  case "end":
697
699
  return _context5.stop();
698
700
  }
699
- }, _callee5, this, [[12, 18]]);
701
+ }, _callee5, this, [[12, 19]]);
700
702
  }));
701
703
  function writeData(_x5) {
702
704
  return _writeData.apply(this, arguments);
@@ -114,14 +114,17 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
114
114
  resourceId: syncBlockData.resourceId
115
115
  }
116
116
  });
117
- bodiedSyncBlockData.push(syncBlockData);
118
-
119
117
  // reset isDirty early to prevent race condition
120
118
  // There is a race condition where if a user makes changes to a source sync block
121
119
  // on a live page and the source sync block is being saved while the user
122
120
  // is still making changes, the new changes might not be saved if they all happen
123
121
  // exactly at a time when the writeNodesData is being executed asynchronously.
124
122
  syncBlockData.isDirty = false;
123
+ // When flushing, set status to 'active' so the block is published (when feature gate is on)
124
+ var dataToFlush = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? _objectSpread(_objectSpread({}, syncBlockData), {}, {
125
+ status: 'active'
126
+ }) : syncBlockData;
127
+ bodiedSyncBlockData.push(dataToFlush);
125
128
  }
126
129
  });
127
130
  if (!(bodiedSyncBlockNodes.length === 0)) {
@@ -117,11 +117,14 @@ const buildGetBlockQuery = blockAri => `query ${GET_BLOCK_OPERATION_NAME} {
117
117
  version
118
118
  }
119
119
  }`;
120
- const buildUpdateBlockMutation = (blockAri, content, stepVersion) => {
120
+ const buildUpdateBlockMutation = (blockAri, content, stepVersion, status) => {
121
121
  const inputParts = [`blockAri: ${JSON.stringify(blockAri)}`, `content: ${JSON.stringify(content)}`];
122
122
  if (stepVersion !== undefined) {
123
123
  inputParts.push(`stepVersion: ${stepVersion}`);
124
124
  }
125
+ if (status !== undefined && fg('platform_synced_block_patch_1')) {
126
+ inputParts.push(`status: ${JSON.stringify(status)}`);
127
+ }
125
128
  const inputArgs = inputParts.join(', ');
126
129
  return `mutation ${UPDATE_BLOCK_OPERATION_NAME} {
127
130
  blockService_updateBlock(input: { ${inputArgs} }) {
@@ -389,11 +392,12 @@ export const deleteSyncedBlock = async ({
389
392
  export const updateSyncedBlock = async ({
390
393
  blockAri,
391
394
  content,
392
- stepVersion
395
+ stepVersion,
396
+ status
393
397
  }) => {
394
398
  if (fg('platform_synced_block_patch_1')) {
395
399
  const bodyData = {
396
- query: buildUpdateBlockMutation(blockAri, content, stepVersion),
400
+ query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
397
401
  operationName: UPDATE_BLOCK_OPERATION_NAME
398
402
  };
399
403
  const response = await fetchWithRetry(GRAPHQL_ENDPOINT, {
@@ -416,6 +420,9 @@ export const updateSyncedBlock = async ({
416
420
  if (stepVersion !== undefined) {
417
421
  requestBody.stepVersion = stepVersion;
418
422
  }
423
+ if (status !== undefined && fg('platform_synced_block_patch_1')) {
424
+ requestBody.status = status;
425
+ }
419
426
  const response = await fetchWithRetry(`${BLOCK_SERVICE_API_URL}/block/${encodeURIComponent(blockAri)}`, {
420
427
  method: 'PUT',
421
428
  headers: COMMON_HEADERS,
@@ -89,9 +89,9 @@ const resolveNoAccessPageInfo = async ari => {
89
89
  * @param localId - Optional local ID to append as block anchor
90
90
  * @returns Source info with URL, title, and optional subtype
91
91
  */
92
- const fetchUnpublishedConfluencePageInfo = async (pageAri, localId) => {
92
+ const fetchCompleteConfluencePageInfo = async (pageAri, localId) => {
93
93
  try {
94
- var _pageData$_links, _pageData$_links2;
94
+ var _pageData$_links, _pageData$_links2, _pageData$_links3;
95
95
  const {
96
96
  id: pageId
97
97
  } = getPageIdAndTypeFromConfluencePageAri({
@@ -107,12 +107,16 @@ const fetchUnpublishedConfluencePageInfo = async (pageAri, localId) => {
107
107
  const pageData = await response.json();
108
108
  const base = (_pageData$_links = pageData._links) === null || _pageData$_links === void 0 ? void 0 : _pageData$_links.base;
109
109
  const edituiv2 = (_pageData$_links2 = pageData._links) === null || _pageData$_links2 === void 0 ? void 0 : _pageData$_links2.edituiv2;
110
+ const webui = (_pageData$_links3 = pageData._links) === null || _pageData$_links3 === void 0 ? void 0 : _pageData$_links3.webui;
110
111
  const title = pageData.title;
111
112
  const subType = pageData.subtype;
113
+ const status = pageData.status;
112
114
  let url;
113
- if (base && edituiv2) {
115
+ if (base && edituiv2 && (fg('platform_synced_block_patch_2') ? status !== 'archived' : true)) {
114
116
  url = `${base}${edituiv2}`;
115
117
  url = url && localId ? `${url}#block-${localId}` : url;
118
+ } else if (base && webui && fg('platform_synced_block_patch_2')) {
119
+ url = `${base}${webui}`;
116
120
  }
117
121
  return {
118
122
  title,
@@ -122,7 +126,7 @@ const fetchUnpublishedConfluencePageInfo = async (pageAri, localId) => {
122
126
  };
123
127
  } catch (error) {
124
128
  logException(error, {
125
- location: 'editor-synced-block-provider/sourceInfo/fetchUnpublishedConfluencePageInfo'
129
+ location: 'editor-synced-block-provider/sourceInfo/fetchCompleteConfluencePageInfo'
126
130
  });
127
131
  return Promise.resolve(undefined);
128
132
  }
@@ -171,7 +175,9 @@ export const fetchConfluencePageInfoOld = async (pageAri, localId, fireAnalytics
171
175
  export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, localId, isUnpublished) => {
172
176
  // For unpublished pages, use the v2 pages API as GraphQL returns empty content.nodes
173
177
  if (isUnpublished && fg('platform_synced_block_patch_1')) {
174
- return await fetchUnpublishedConfluencePageInfo(pageAri, localId);
178
+ if (!fg('platform_synced_block_patch_2')) {
179
+ return await fetchCompleteConfluencePageInfo(pageAri, localId);
180
+ }
175
181
  }
176
182
  if (hasAccess) {
177
183
  var _response$data2, _response$data2$conte, _response$data2$conte2, _contentData$space2;
@@ -180,6 +186,9 @@ export const fetchConfluencePageInfo = async (pageAri, hasAccess, urlType, local
180
186
  } = getPageIdAndTypeFromConfluencePageAri({
181
187
  ari: pageAri
182
188
  });
189
+ if (pageType === 'page' && fg('platform_synced_block_patch_2')) {
190
+ return await fetchCompleteConfluencePageInfo(pageAri, localId);
191
+ }
183
192
  const response = await getConfluenceSourceInfo(pageAri);
184
193
  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];
185
194
  const {
@@ -481,11 +481,12 @@ class BlockServiceADFWriteProvider {
481
481
  });
482
482
  const stepVersion = this.getVersion ? await this.getVersion() : undefined;
483
483
  try {
484
- // Try update existing block's content
484
+ const status = data.status;
485
485
  await updateSyncedBlock({
486
486
  blockAri,
487
487
  content: JSON.stringify(data.content),
488
- stepVersion
488
+ stepVersion,
489
+ status
489
490
  });
490
491
  return {
491
492
  resourceId
@@ -88,14 +88,18 @@ export class SourceSyncBlockStoreManager {
88
88
  resourceId: syncBlockData.resourceId
89
89
  }
90
90
  });
91
- bodiedSyncBlockData.push(syncBlockData);
92
-
93
91
  // reset isDirty early to prevent race condition
94
92
  // There is a race condition where if a user makes changes to a source sync block
95
93
  // on a live page and the source sync block is being saved while the user
96
94
  // is still making changes, the new changes might not be saved if they all happen
97
95
  // exactly at a time when the writeNodesData is being executed asynchronously.
98
96
  syncBlockData.isDirty = false;
97
+ // When flushing, set status to 'active' so the block is published (when feature gate is on)
98
+ const dataToFlush = fg('platform_synced_block_patch_1') ? {
99
+ ...syncBlockData,
100
+ status: 'active'
101
+ } : syncBlockData;
102
+ bodiedSyncBlockData.push(dataToFlush);
99
103
  }
100
104
  });
101
105
  if (bodiedSyncBlockNodes.length === 0) {
@@ -128,11 +128,14 @@ var buildGetDocumentReferenceBlocksQuery = function buildGetDocumentReferenceBlo
128
128
  var buildGetBlockQuery = function buildGetBlockQuery(blockAri) {
129
129
  return "query ".concat(GET_BLOCK_OPERATION_NAME, " {\n\tblockService_getBlock(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\tblockAri\n\t\tblockInstanceId\n\t\tcontent\n\t\tcontentUpdatedAt\n\t\tcreatedAt\n\t\tcreatedBy\n\t\tdeletionReason\n\t\tproduct\n\t\tsourceAri\n\t\tstatus\n\t\tversion\n\t}\n}");
130
130
  };
131
- var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion) {
131
+ var buildUpdateBlockMutation = function buildUpdateBlockMutation(blockAri, content, stepVersion, status) {
132
132
  var inputParts = ["blockAri: ".concat(JSON.stringify(blockAri)), "content: ".concat(JSON.stringify(content))];
133
133
  if (stepVersion !== undefined) {
134
134
  inputParts.push("stepVersion: ".concat(stepVersion));
135
135
  }
136
+ if (status !== undefined && fg('platform_synced_block_patch_1')) {
137
+ inputParts.push("status: ".concat(JSON.stringify(status)));
138
+ }
136
139
  var inputArgs = inputParts.join(', ');
137
140
  return "mutation ".concat(UPDATE_BLOCK_OPERATION_NAME, " {\n\tblockService_updateBlock(input: { ").concat(inputArgs, " }) {\n\t\t__typename\n\t}\n}");
138
141
  };
@@ -450,17 +453,17 @@ export var deleteSyncedBlock = /*#__PURE__*/function () {
450
453
  }();
451
454
  export var updateSyncedBlock = /*#__PURE__*/function () {
452
455
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
453
- var blockAri, content, stepVersion, bodyData, _response4, result, requestBody, response;
456
+ var blockAri, content, stepVersion, status, bodyData, _response4, result, requestBody, response;
454
457
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
455
458
  while (1) switch (_context5.prev = _context5.next) {
456
459
  case 0:
457
- blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion;
460
+ blockAri = _ref8.blockAri, content = _ref8.content, stepVersion = _ref8.stepVersion, status = _ref8.status;
458
461
  if (!fg('platform_synced_block_patch_1')) {
459
462
  _context5.next = 14;
460
463
  break;
461
464
  }
462
465
  bodyData = {
463
- query: buildUpdateBlockMutation(blockAri, content, stepVersion),
466
+ query: buildUpdateBlockMutation(blockAri, content, stepVersion, status),
464
467
  operationName: UPDATE_BLOCK_OPERATION_NAME
465
468
  };
466
469
  _context5.next = 5;
@@ -497,20 +500,23 @@ export var updateSyncedBlock = /*#__PURE__*/function () {
497
500
  if (stepVersion !== undefined) {
498
501
  requestBody.stepVersion = stepVersion;
499
502
  }
500
- _context5.next = 18;
503
+ if (status !== undefined && fg('platform_synced_block_patch_1')) {
504
+ requestBody.status = status;
505
+ }
506
+ _context5.next = 19;
501
507
  return fetchWithRetry("".concat(BLOCK_SERVICE_API_URL, "/block/").concat(encodeURIComponent(blockAri)), {
502
508
  method: 'PUT',
503
509
  headers: COMMON_HEADERS,
504
510
  body: JSON.stringify(requestBody)
505
511
  });
506
- case 18:
512
+ case 19:
507
513
  response = _context5.sent;
508
514
  if (response.ok) {
509
- _context5.next = 21;
515
+ _context5.next = 22;
510
516
  break;
511
517
  }
512
518
  throw new BlockError(response.status);
513
- case 21:
519
+ case 22:
514
520
  case "end":
515
521
  return _context5.stop();
516
522
  }
@@ -121,9 +121,9 @@ var resolveNoAccessPageInfo = /*#__PURE__*/function () {
121
121
  * @param localId - Optional local ID to append as block anchor
122
122
  * @returns Source info with URL, title, and optional subtype
123
123
  */
124
- var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
124
+ var fetchCompleteConfluencePageInfo = /*#__PURE__*/function () {
125
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;
126
+ var _pageData$_links, _pageData$_links2, _pageData$_links3, _getPageIdAndTypeFrom, pageId, response, pageData, base, edituiv2, webui, title, subType, status, url;
127
127
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
128
128
  while (1) switch (_context3.prev = _context3.next) {
129
129
  case 0:
@@ -150,11 +150,15 @@ var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
150
150
  pageData = _context3.sent;
151
151
  base = (_pageData$_links = pageData._links) === null || _pageData$_links === void 0 ? void 0 : _pageData$_links.base;
152
152
  edituiv2 = (_pageData$_links2 = pageData._links) === null || _pageData$_links2 === void 0 ? void 0 : _pageData$_links2.edituiv2;
153
+ webui = (_pageData$_links3 = pageData._links) === null || _pageData$_links3 === void 0 ? void 0 : _pageData$_links3.webui;
153
154
  title = pageData.title;
154
155
  subType = pageData.subtype;
155
- if (base && edituiv2) {
156
+ status = pageData.status;
157
+ if (base && edituiv2 && (fg('platform_synced_block_patch_2') ? status !== 'archived' : true)) {
156
158
  url = "".concat(base).concat(edituiv2);
157
159
  url = url && localId ? "".concat(url, "#block-").concat(localId) : url;
160
+ } else if (base && webui && fg('platform_synced_block_patch_2')) {
161
+ url = "".concat(base).concat(webui);
158
162
  }
159
163
  return _context3.abrupt("return", {
160
164
  title: title,
@@ -162,20 +166,20 @@ var fetchUnpublishedConfluencePageInfo = /*#__PURE__*/function () {
162
166
  sourceAri: pageAri,
163
167
  subType: subType
164
168
  });
165
- case 18:
166
- _context3.prev = 18;
169
+ case 20:
170
+ _context3.prev = 20;
167
171
  _context3.t0 = _context3["catch"](0);
168
172
  logException(_context3.t0, {
169
- location: 'editor-synced-block-provider/sourceInfo/fetchUnpublishedConfluencePageInfo'
173
+ location: 'editor-synced-block-provider/sourceInfo/fetchCompleteConfluencePageInfo'
170
174
  });
171
175
  return _context3.abrupt("return", Promise.resolve(undefined));
172
- case 22:
176
+ case 24:
173
177
  case "end":
174
178
  return _context3.stop();
175
179
  }
176
- }, _callee3, null, [[0, 18]]);
180
+ }, _callee3, null, [[0, 20]]);
177
181
  }));
178
- return function fetchUnpublishedConfluencePageInfo(_x3, _x4) {
182
+ return function fetchCompleteConfluencePageInfo(_x3, _x4) {
179
183
  return _ref3.apply(this, arguments);
180
184
  };
181
185
  }();
@@ -239,24 +243,37 @@ export var fetchConfluencePageInfo = /*#__PURE__*/function () {
239
243
  while (1) switch (_context5.prev = _context5.next) {
240
244
  case 0:
241
245
  if (!(isUnpublished && fg('platform_synced_block_patch_1'))) {
242
- _context5.next = 4;
246
+ _context5.next = 5;
243
247
  break;
244
248
  }
245
- _context5.next = 3;
246
- return fetchUnpublishedConfluencePageInfo(pageAri, localId);
247
- case 3:
248
- return _context5.abrupt("return", _context5.sent);
249
+ if (fg('platform_synced_block_patch_2')) {
250
+ _context5.next = 5;
251
+ break;
252
+ }
253
+ _context5.next = 4;
254
+ return fetchCompleteConfluencePageInfo(pageAri, localId);
249
255
  case 4:
256
+ return _context5.abrupt("return", _context5.sent);
257
+ case 5:
250
258
  if (!hasAccess) {
251
- _context5.next = 17;
259
+ _context5.next = 22;
252
260
  break;
253
261
  }
254
262
  _getPageIdAndTypeFrom3 = getPageIdAndTypeFromConfluencePageAri({
255
263
  ari: pageAri
256
264
  }), pageType = _getPageIdAndTypeFrom3.type;
257
- _context5.next = 8;
265
+ if (!(pageType === 'page' && fg('platform_synced_block_patch_2'))) {
266
+ _context5.next = 11;
267
+ break;
268
+ }
269
+ _context5.next = 10;
270
+ return fetchCompleteConfluencePageInfo(pageAri, localId);
271
+ case 10:
272
+ return _context5.abrupt("return", _context5.sent);
273
+ case 11:
274
+ _context5.next = 13;
258
275
  return getConfluenceSourceInfo(pageAri);
259
- case 8:
276
+ case 13:
260
277
  response = _context5.sent;
261
278
  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
279
  _ref7 = contentData || {}, title = _ref7.title, subType = _ref7.subType;
@@ -277,12 +294,12 @@ export var fetchConfluencePageInfo = /*#__PURE__*/function () {
277
294
  sourceAri: pageAri,
278
295
  subType: subType
279
296
  }));
280
- case 17:
281
- _context5.next = 19;
297
+ case 22:
298
+ _context5.next = 24;
282
299
  return resolveNoAccessPageInfo(pageAri);
283
- case 19:
300
+ case 24:
284
301
  return _context5.abrupt("return", _context5.sent);
285
- case 20:
302
+ case 25:
286
303
  case "end":
287
304
  return _context5.stop();
288
305
  }
@@ -626,7 +626,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
626
626
  key: "writeData",
627
627
  value: function () {
628
628
  var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data) {
629
- var resourceId, blockAri, stepVersion;
629
+ var resourceId, blockAri, stepVersion, status;
630
630
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
631
631
  while (1) switch (_context5.prev = _context5.next) {
632
632
  case 0:
@@ -660,37 +660,39 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
660
660
  case 11:
661
661
  stepVersion = _context5.t0;
662
662
  _context5.prev = 12;
663
- _context5.next = 15;
663
+ status = data.status;
664
+ _context5.next = 16;
664
665
  return updateSyncedBlock({
665
666
  blockAri: blockAri,
666
667
  content: JSON.stringify(data.content),
667
- stepVersion: stepVersion
668
+ stepVersion: stepVersion,
669
+ status: status
668
670
  });
669
- case 15:
671
+ case 16:
670
672
  return _context5.abrupt("return", {
671
673
  resourceId: resourceId
672
674
  });
673
- case 18:
674
- _context5.prev = 18;
675
+ case 19:
676
+ _context5.prev = 19;
675
677
  _context5.t1 = _context5["catch"](12);
676
678
  if (!(_context5.t1 instanceof BlockError)) {
677
- _context5.next = 22;
679
+ _context5.next = 23;
678
680
  break;
679
681
  }
680
682
  return _context5.abrupt("return", {
681
683
  error: mapBlockError(_context5.t1),
682
684
  resourceId: resourceId
683
685
  });
684
- case 22:
686
+ case 23:
685
687
  return _context5.abrupt("return", {
686
688
  error: stringifyError(_context5.t1),
687
689
  resourceId: resourceId
688
690
  });
689
- case 23:
691
+ case 24:
690
692
  case "end":
691
693
  return _context5.stop();
692
694
  }
693
- }, _callee5, this, [[12, 18]]);
695
+ }, _callee5, this, [[12, 19]]);
694
696
  }));
695
697
  function writeData(_x5) {
696
698
  return _writeData.apply(this, arguments);
@@ -107,14 +107,17 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
107
107
  resourceId: syncBlockData.resourceId
108
108
  }
109
109
  });
110
- bodiedSyncBlockData.push(syncBlockData);
111
-
112
110
  // reset isDirty early to prevent race condition
113
111
  // There is a race condition where if a user makes changes to a source sync block
114
112
  // on a live page and the source sync block is being saved while the user
115
113
  // is still making changes, the new changes might not be saved if they all happen
116
114
  // exactly at a time when the writeNodesData is being executed asynchronously.
117
115
  syncBlockData.isDirty = false;
116
+ // When flushing, set status to 'active' so the block is published (when feature gate is on)
117
+ var dataToFlush = fg('platform_synced_block_patch_1') ? _objectSpread(_objectSpread({}, syncBlockData), {}, {
118
+ status: 'active'
119
+ }) : syncBlockData;
120
+ bodiedSyncBlockData.push(dataToFlush);
118
121
  }
119
122
  });
120
123
  if (!(bodiedSyncBlockNodes.length === 0)) {
@@ -76,6 +76,7 @@ export type DeleteSyncedBlockRequest = {
76
76
  export type UpdateSyncedBlockRequest = {
77
77
  blockAri: string;
78
78
  content: string;
79
+ status?: SyncBlockStatus;
79
80
  stepVersion?: number;
80
81
  };
81
82
  export type CreateSyncedBlockRequest = {
@@ -132,7 +133,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
132
133
  */
133
134
  export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, documentAri, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
134
135
  export declare const deleteSyncedBlock: ({ blockAri, deleteReason, }: DeleteSyncedBlockRequest) => Promise<void>;
135
- export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, }: UpdateSyncedBlockRequest) => Promise<void>;
136
+ export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, status, }: UpdateSyncedBlockRequest) => Promise<void>;
136
137
  export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
137
138
  export declare const updateReferenceSyncedBlockOnDocument: ({ documentAri, blocks, noContent, }: UpdateReferenceSyncedBlockOnDocumentRequest) => Promise<ReferenceSyncedBlockResponse | void>;
138
139
  export declare const getReferenceSyncedBlocksByBlockAri: ({ blockAri, }: GetReferenceSyncedBlocksByBlockAriRequest) => Promise<GetReferenceSyncedBlocksByBlockAriResponse>;
@@ -76,6 +76,7 @@ export type DeleteSyncedBlockRequest = {
76
76
  export type UpdateSyncedBlockRequest = {
77
77
  blockAri: string;
78
78
  content: string;
79
+ status?: SyncBlockStatus;
79
80
  stepVersion?: number;
80
81
  };
81
82
  export type CreateSyncedBlockRequest = {
@@ -132,7 +133,7 @@ export declare const getSyncedBlockContent: ({ blockAri, }: GetSyncedBlockConten
132
133
  */
133
134
  export declare const batchRetrieveSyncedBlocks: ({ blockIdentifiers, documentAri, }: BatchRetrieveSyncedBlocksRequest) => Promise<BatchRetrieveSyncedBlocksResponse>;
134
135
  export declare const deleteSyncedBlock: ({ blockAri, deleteReason, }: DeleteSyncedBlockRequest) => Promise<void>;
135
- export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, }: UpdateSyncedBlockRequest) => Promise<void>;
136
+ export declare const updateSyncedBlock: ({ blockAri, content, stepVersion, status, }: UpdateSyncedBlockRequest) => Promise<void>;
136
137
  export declare const createSyncedBlock: ({ blockAri, blockInstanceId, sourceAri, product, content, stepVersion, status, }: CreateSyncedBlockRequest) => Promise<BlockContentResponse>;
137
138
  export declare const updateReferenceSyncedBlockOnDocument: ({ documentAri, blocks, noContent, }: UpdateReferenceSyncedBlockOnDocumentRequest) => Promise<ReferenceSyncedBlockResponse | void>;
138
139
  export declare const getReferenceSyncedBlocksByBlockAri: ({ blockAri, }: GetReferenceSyncedBlocksByBlockAriRequest) => Promise<GetReferenceSyncedBlocksByBlockAriResponse>;
package/package.json CHANGED
@@ -79,7 +79,7 @@
79
79
  }
80
80
  },
81
81
  "name": "@atlaskit/editor-synced-block-provider",
82
- "version": "3.26.2",
82
+ "version": "3.27.0",
83
83
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
84
84
  "author": "Atlassian Pty Ltd",
85
85
  "license": "Apache-2.0",
@@ -89,6 +89,9 @@
89
89
  "platform-feature-flags": {
90
90
  "platform_synced_block_patch_1": {
91
91
  "type": "boolean"
92
+ },
93
+ "platform_synced_block_patch_2": {
94
+ "type": "boolean"
92
95
  }
93
96
  }
94
97
  }