@atlaskit/editor-synced-block-provider 3.26.1 → 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,26 @@
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
+
16
+ ## 3.26.2
17
+
18
+ ### Patch Changes
19
+
20
+ - [`ab4e4e442ad49`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ab4e4e442ad49) -
21
+ [ux] [EDITOR-3694] Add loading state to bodiedSyncBlock for when saving new block to BE
22
+ - Updated dependencies
23
+
3
24
  ## 3.26.1
4
25
 
5
26
  ### 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);
@@ -11,6 +11,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
  var _monitoring = require("@atlaskit/editor-common/monitoring");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _types = require("../common/types");
15
16
  var _errorHandling = require("../utils/errorHandling");
16
17
  var _experienceTracking = require("../utils/experienceTracking");
@@ -34,6 +35,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
34
35
  });
35
36
  this.dataProvider = dataProvider;
36
37
  this.syncBlockCache = new Map();
38
+ this.creationCompletionCallbacks = new Map();
37
39
  }
38
40
  return (0, _createClass2.default)(SourceSyncBlockStoreManager, [{
39
41
  key: "setFireAnalyticsEvent",
@@ -100,9 +102,11 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
100
102
  bodiedSyncBlockNodes = [];
101
103
  bodiedSyncBlockData = [];
102
104
  Array.from(this.syncBlockCache.values()).forEach(function (syncBlockData) {
103
- // Don't flush nodes that are waiting to be deleted to avoid nodes being re-created
104
- // Don't flush nodes that haven't been updated since we last flushed
105
- if (!syncBlockData.pendingDeletion && syncBlockData.isDirty) {
105
+ // Don't flush nodes that
106
+ // - are waiting to be deleted to avoid nodes being re-created
107
+ // - haven't been updated since we last flushed
108
+ // - are still pending BE creation
109
+ if (!syncBlockData.pendingDeletion && syncBlockData.isDirty && !(_this2.isPendingCreation(syncBlockData.resourceId) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1'))) {
106
110
  bodiedSyncBlockNodes.push({
107
111
  type: 'bodiedSyncBlock',
108
112
  attrs: {
@@ -110,14 +114,17 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
110
114
  resourceId: syncBlockData.resourceId
111
115
  }
112
116
  });
113
- bodiedSyncBlockData.push(syncBlockData);
114
-
115
117
  // reset isDirty early to prevent race condition
116
118
  // There is a race condition where if a user makes changes to a source sync block
117
119
  // on a live page and the source sync block is being saved while the user
118
120
  // is still making changes, the new changes might not be saved if they all happen
119
121
  // exactly at a time when the writeNodesData is being executed asynchronously.
120
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);
121
128
  }
122
129
  });
123
130
  if (!(bodiedSyncBlockNodes.length === 0)) {
@@ -190,12 +197,18 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
190
197
  return _flush.apply(this, arguments);
191
198
  }
192
199
  return flush;
193
- }())
200
+ }() // Remove this method and pendingResourceId when cleaning up platform_synced_block_patch_1
201
+ )
194
202
  }, {
195
203
  key: "registerPendingCreation",
196
204
  value: function registerPendingCreation(resourceId) {
197
205
  this.pendingResourceId = resourceId;
198
206
  }
207
+ }, {
208
+ key: "isPendingCreation",
209
+ value: function isPendingCreation(resourceId) {
210
+ return this.creationCompletionCallbacks.has(resourceId);
211
+ }
199
212
 
200
213
  /**
201
214
  * Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
@@ -212,27 +225,48 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
212
225
  */
213
226
  }, {
214
227
  key: "commitPendingCreation",
215
- value: function commitPendingCreation(success) {
216
- if (success && this.creationCallback) {
217
- var _this$fireAnalyticsEv3;
218
- this.creationCallback();
219
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.createSuccessPayload)(this.pendingResourceId || ''));
220
- } else if (success && !this.creationCallback) {
221
- var _this$fireAnalyticsEv4;
222
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.createErrorPayload)('creation callback missing', this.pendingResourceId));
228
+ value: function commitPendingCreation(success, resourceId) {
229
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
230
+ var onCompletion = this.creationCompletionCallbacks.get(resourceId);
231
+ if (onCompletion) {
232
+ this.creationCompletionCallbacks.delete(resourceId);
233
+ onCompletion(success);
234
+ } else {
235
+ var _this$fireAnalyticsEv3;
236
+ (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.createErrorPayload)('creation complete callback missing', resourceId));
237
+ }
238
+ if (success) {
239
+ var _this$fireAnalyticsEv4;
240
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.createSuccessPayload)(resourceId || ''));
241
+ } else {
242
+ var _this$fireAnalyticsEv5;
243
+ // Delete the node from cache if fail to create so it's not flushed to BE
244
+ this.syncBlockCache.delete(resourceId || '');
245
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.createErrorPayload)('Fail to create bodied sync block', resourceId));
246
+ }
247
+ } else {
248
+ if (success && this.creationCallback) {
249
+ var _this$fireAnalyticsEv6;
250
+ this.creationCallback();
251
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.createSuccessPayload)(this.pendingResourceId || ''));
252
+ } else if (success && !this.creationCallback) {
253
+ var _this$fireAnalyticsEv7;
254
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.createErrorPayload)('creation callback missing', this.pendingResourceId));
255
+ }
256
+ this.pendingResourceId = undefined;
223
257
  }
224
- this.pendingResourceId = undefined;
225
258
  this.creationCallback = undefined;
226
259
  }
227
260
 
228
261
  /**
229
262
  *
230
263
  * @returns true if waiting for the result of saving new bodiedSyncBlock to backend
264
+ * Remove this method when cleaning up platform_synced_block_patch_1
231
265
  */
232
266
  }, {
233
267
  key: "hasPendingCreation",
234
268
  value: function hasPendingCreation() {
235
- return !!this.pendingResourceId;
269
+ return (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? this.creationCompletionCallbacks.size > 0 : !!this.pendingResourceId;
236
270
  }
237
271
  }, {
238
272
  key: "registerConfirmationCallback",
@@ -273,35 +307,40 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
273
307
  */
274
308
  }, {
275
309
  key: "createBodiedSyncBlockNode",
276
- value: function createBodiedSyncBlockNode(attrs, nodeData) {
310
+ value: function createBodiedSyncBlockNode(attrs, onCompletion, nodeData) {
277
311
  var _this4 = this;
312
+ var resourceId = attrs.resourceId,
313
+ blockInstanceId = attrs.localId;
278
314
  try {
279
315
  var _this$createExperienc;
280
316
  if (!this.dataProvider) {
281
317
  throw new Error('Data provider not set');
282
318
  }
283
- var resourceId = attrs.resourceId,
284
- blockInstanceId = attrs.localId;
319
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
320
+ this.creationCompletionCallbacks.set(resourceId, onCompletion);
321
+ }
285
322
  (_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
286
323
  this.dataProvider.createNodeData({
287
324
  content: [],
288
325
  blockInstanceId: blockInstanceId,
289
326
  resourceId: resourceId
290
327
  }).then(function (result) {
291
- var resourceId = result.resourceId;
292
- if (resourceId) {
328
+ var resourceId = result.resourceId || '';
329
+ if (resourceId && (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') || !result.error)) {
293
330
  var _this4$createExperien;
294
- _this4.commitPendingCreation(true);
331
+ _this4.commitPendingCreation(true, resourceId);
295
332
  (_this4$createExperien = _this4.createExperience) === null || _this4$createExperien === void 0 || _this4$createExperien.success();
296
333
 
297
334
  // Update the sync block data with the node data if it is provided
298
335
  // to avoid any race conditions where the data could be missed during a render operation
299
- if (nodeData) {
300
- _this4.updateSyncBlockData(nodeData);
336
+ if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
337
+ if (nodeData) {
338
+ _this4.updateSyncBlockData(nodeData);
339
+ }
301
340
  }
302
341
  } else {
303
342
  var _this4$createExperien2, _this4$fireAnalyticsE;
304
- _this4.commitPendingCreation(false);
343
+ _this4.commitPendingCreation(false, resourceId);
305
344
  (_this4$createExperien2 = _this4.createExperience) === null || _this4$createExperien2 === void 0 || _this4$createExperien2.failure({
306
345
  reason: result.error || 'Failed to create bodied sync block'
307
346
  });
@@ -309,7 +348,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
309
348
  }
310
349
  }).catch(function (error) {
311
350
  var _this4$createExperien3, _this4$fireAnalyticsE2;
312
- _this4.commitPendingCreation(false);
351
+ _this4.commitPendingCreation(false, resourceId);
313
352
  (0, _monitoring.logException)(error, {
314
353
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
315
354
  });
@@ -318,16 +357,18 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
318
357
  });
319
358
  (_this4$fireAnalyticsE2 = _this4.fireAnalyticsEvent) === null || _this4$fireAnalyticsE2 === void 0 || _this4$fireAnalyticsE2.call(_this4, (0, _errorHandling.createErrorPayload)(error.message, resourceId));
320
359
  });
321
- this.registerPendingCreation(resourceId);
360
+ if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
361
+ this.registerPendingCreation(resourceId);
362
+ }
322
363
  } catch (error) {
323
- var _this$fireAnalyticsEv5;
324
- if (this.hasPendingCreation()) {
325
- this.commitPendingCreation(false);
364
+ var _this$fireAnalyticsEv8;
365
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? this.isPendingCreation(resourceId) : this.hasPendingCreation()) {
366
+ this.commitPendingCreation(false, resourceId);
326
367
  }
327
368
  (0, _monitoring.logException)(error, {
328
369
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
329
370
  });
330
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.createErrorPayload)(error.message));
371
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.createErrorPayload)(error.message));
331
372
  }
332
373
  }
333
374
  }, {
@@ -538,11 +579,11 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
538
579
  return sourceInfo;
539
580
  });
540
581
  } catch (error) {
541
- var _this$fireAnalyticsEv6;
582
+ var _this$fireAnalyticsEv9;
542
583
  (0, _monitoring.logException)(error, {
543
584
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
544
585
  });
545
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
586
+ (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
546
587
  return Promise.resolve(undefined);
547
588
  }
548
589
  }
@@ -555,11 +596,11 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
555
596
  }
556
597
  return this.dataProvider.fetchReferences(resourceId, true);
557
598
  } catch (error) {
558
- var _this$fireAnalyticsEv7;
599
+ var _this$fireAnalyticsEv0;
559
600
  (0, _monitoring.logException)(error, {
560
601
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
561
602
  });
562
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(error.message));
603
+ (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.fetchReferencesErrorPayload)(error.message));
563
604
  return Promise.resolve({
564
605
  error: _types.SyncBlockError.Errored
565
606
  });
@@ -572,6 +613,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
572
613
  this.syncBlockCache.clear();
573
614
  this.confirmationCallback = undefined;
574
615
  this.pendingResourceId = undefined;
616
+ this.creationCompletionCallbacks.clear();
575
617
  this.creationCallback = undefined;
576
618
  this.dataProvider = undefined;
577
619
  (_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.abort({
@@ -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