@atlaskit/editor-plugin-synced-block 17.0.8 → 17.0.9
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-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 17.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ef5742162c47b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef5742162c47b) -
|
|
8
|
+
EDITOR-9184: Make the synced locations dropdown field-aware for Jira work items, behind the
|
|
9
|
+
`editor_synced_blocks_jira_custom_rich_text` experiment. Each Jira location's title and tooltip
|
|
10
|
+
name the work item field holding the block, a location in the field being viewed reads "This work
|
|
11
|
+
item field" and one in another field of the same work item reads "This work item"; `editor-common`
|
|
12
|
+
gains the three `syncBlockMessages` descriptors this uses. With the experiment off the dropdown
|
|
13
|
+
renders as before.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 17.0.8
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.processReferenceData = exports.SyncedLocationDropdownWithCount = exports.SyncedLocationDropdown = void 0;
|
|
9
|
+
exports.processReferenceData = exports.buildFieldAwareItems = exports.SyncedLocationDropdownWithCount = exports.SyncedLocationDropdown = void 0;
|
|
10
10
|
require("./SyncedLocationDropdown.compiled.css");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var React = _react;
|
|
@@ -14,6 +14,7 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
14
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
18
|
var _react2 = require("@compiled/react");
|
|
18
19
|
var _dropdownMenuItem = _interopRequireDefault(require("@atlaskit/dropdown-menu/dropdown-menu-item"));
|
|
19
20
|
var _dropdownMenuItemGroup = _interopRequireDefault(require("@atlaskit/dropdown-menu/dropdown-menu-item-group"));
|
|
@@ -37,6 +38,7 @@ var _iconTile = _interopRequireDefault(require("@atlaskit/icon/icon-tile"));
|
|
|
37
38
|
var _logo = require("@atlaskit/logo");
|
|
38
39
|
var _atlassianIcon = require("@atlaskit/logo/atlassian-icon");
|
|
39
40
|
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge/lozenge"));
|
|
41
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
40
42
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
41
43
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner/spinner"));
|
|
42
44
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -45,6 +47,8 @@ var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
|
45
47
|
var _types = require("../types");
|
|
46
48
|
var _SyncedLocationsEmptyStateIllustration = require("./assets/SyncedLocationsEmptyStateIllustration");
|
|
47
49
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
50
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
51
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
48
52
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
49
53
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
50
54
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } // eslint-disable-next-line import/order -- CI requires icon-lab imports before core icon imports.
|
|
@@ -63,6 +67,8 @@ var styles = {
|
|
|
63
67
|
activationDropdownContent: "_1rjcze3t _1bsb1kdj",
|
|
64
68
|
activationNoResultsContainer: "_vchhusvi _1bsb1kdj _ca0q1ejb _n3td1ejb",
|
|
65
69
|
activationNoResultsContent: "_195g1wug _1bsb12aa _y3gn1h6o",
|
|
70
|
+
fieldAwareDropdownContent: "_1bsb1kdj",
|
|
71
|
+
fieldSecondLine: "_1reo15vq _18m915vq _o5721q9c _1bto1l2s",
|
|
66
72
|
dropdownContent: "_1rjcv77o _1bsbsmdz _c71lko4j _1e0c1txw _1bah1h6o _4cvr1h6o",
|
|
67
73
|
containerWithMinHeight: "_1tkeqkoa",
|
|
68
74
|
contentContainer: "_y44vfmxe _1bsb1osq _1wpz1fhb _18m91wug",
|
|
@@ -71,6 +77,21 @@ var styles = {
|
|
|
71
77
|
learnMoreLink: "_4bfu1r31 _1hmsglyw _ajmmnqa1",
|
|
72
78
|
requestAccess: "_1bsb19n7 _o5721q9c _ahbq12x7 _syaz1rpy"
|
|
73
79
|
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* One field-aware dropdown row. Every string the row shows is composed here from the untouched
|
|
83
|
+
* provider `reference`. Only built with `editor_synced_blocks_jira_custom_rich_text` on.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/** Decided once per fetch. The control shape is what the dropdown held before the experiment. */
|
|
87
|
+
|
|
88
|
+
var EMPTY_LOCATIONS = {
|
|
89
|
+
kind: 'control',
|
|
90
|
+
references: []
|
|
91
|
+
};
|
|
92
|
+
var countLocations = function countLocations(locations) {
|
|
93
|
+
return locations.kind === 'control' ? locations.references.length : locations.items.length;
|
|
94
|
+
};
|
|
74
95
|
var shouldApplyMinHeight = function shouldApplyMinHeight(fetchStatus, itemCount) {
|
|
75
96
|
// When there are 1/2 items, dropdown height is less than minHeight 144px
|
|
76
97
|
return !(fetchStatus === 'success' && itemCount > 0);
|
|
@@ -306,14 +327,114 @@ var processReferenceData = exports.processReferenceData = function processRefere
|
|
|
306
327
|
});
|
|
307
328
|
return sortedReferences;
|
|
308
329
|
};
|
|
309
|
-
var
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
330
|
+
var isFieldAwareLocationList = function isFieldAwareLocationList(references) {
|
|
331
|
+
var _references$some;
|
|
332
|
+
return ((_references$some = references === null || references === void 0 ? void 0 : references.some(function (reference) {
|
|
333
|
+
return (reference === null || reference === void 0 ? void 0 : reference.productType) === 'jira-work-item';
|
|
334
|
+
})) !== null && _references$some !== void 0 ? _references$some : false) && (0, _isExperimentEnabled.isExperimentEnabled)('editor_synced_blocks_jira_custom_rich_text');
|
|
335
|
+
};
|
|
336
|
+
var groupBySourceAri = function groupBySourceAri(referenceData) {
|
|
337
|
+
var groups = new Map();
|
|
338
|
+
referenceData === null || referenceData === void 0 || referenceData.forEach(function (reference) {
|
|
339
|
+
if (!reference) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
var group = groups.get(reference.sourceAri);
|
|
343
|
+
if (group) {
|
|
344
|
+
group.push(reference);
|
|
345
|
+
} else {
|
|
346
|
+
groups.set(reference.sourceAri, [reference]);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
return groups;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
/** Sources first, then accessible locations. `0` leaves the title order to the caller. */
|
|
353
|
+
var compareLocationOrder = function compareLocationOrder(a, b) {
|
|
354
|
+
if (a.isSource !== b.isSource) {
|
|
355
|
+
return b.isSource ? 1 : -1;
|
|
356
|
+
}
|
|
357
|
+
if (a.hasAccess !== b.hasAccess) {
|
|
358
|
+
return a.hasAccess ? -1 : 1;
|
|
359
|
+
}
|
|
360
|
+
return 0;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/** The title alone. The field name is placed by the row and the tooltip, not baked in here. */
|
|
364
|
+
var getBaseTitle = function getBaseTitle(_ref4) {
|
|
365
|
+
var blockIndex = _ref4.blockIndex,
|
|
366
|
+
formatMessage = _ref4.formatMessage,
|
|
367
|
+
reference = _ref4.reference;
|
|
368
|
+
var title = reference.title === '' && reference.hasAccess ? formatMessage(_messages.syncBlockMessages.syncedLocationDropdownUntitledPage) : reference.title || reference.url || '';
|
|
369
|
+
return blockIndex === undefined ? title : "".concat(title, ": ").concat(formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitleBlockIndex, {
|
|
370
|
+
index: blockIndex
|
|
371
|
+
}));
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/** Jira rows are noted from `locationScope`; other rows keep the pre-experiment `onSameDocument` note. */
|
|
375
|
+
var getFieldAwareNote = function getFieldAwareNote(reference, formatMessage) {
|
|
376
|
+
var _reference$locationSc;
|
|
377
|
+
if (reference.productType !== 'jira-work-item') {
|
|
378
|
+
if (!reference.onSameDocument) {
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
return formatMessage(reference.productType === 'confluence-page' ? _messages.syncBlockMessages.syncedLocationDropdownTitleNoteForConfluencePage : _messages.syncBlockMessages.syncedLocationDropdownTitleNoteForJiraWorkItem);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// A provider that computes no scope still reports `onSameDocument`. It is the same host
|
|
385
|
+
// comparison `getLocationScope` starts with, and in Jira the host document is one field.
|
|
386
|
+
var locationScope = (_reference$locationSc = reference.locationScope) !== null && _reference$locationSc !== void 0 ? _reference$locationSc : reference.onSameDocument ? 'same-document' : undefined;
|
|
387
|
+
switch (locationScope) {
|
|
388
|
+
case 'same-document':
|
|
389
|
+
return formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitleNoteForJiraWorkItemField);
|
|
390
|
+
case 'same-parent-document':
|
|
391
|
+
return formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitleNoteForJiraWorkItem);
|
|
392
|
+
default:
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var buildFieldAwareItems = exports.buildFieldAwareItems = function buildFieldAwareItems(referenceData, formatMessage) {
|
|
397
|
+
return Array.from(groupBySourceAri(referenceData).values()).flatMap(function (group) {
|
|
398
|
+
return group.map(function (reference, index) {
|
|
399
|
+
var fieldName = reference.productType === 'jira-work-item' ? reference.fieldName : undefined;
|
|
400
|
+
var note = getFieldAwareNote(reference, formatMessage);
|
|
401
|
+
return _objectSpread(_objectSpread(_objectSpread({
|
|
402
|
+
baseTitle: getBaseTitle({
|
|
403
|
+
blockIndex: group.length > 1 ? index + 1 : undefined,
|
|
404
|
+
formatMessage: formatMessage,
|
|
405
|
+
reference: reference
|
|
406
|
+
})
|
|
407
|
+
}, fieldName !== undefined && {
|
|
408
|
+
fieldName: fieldName
|
|
409
|
+
}), {}, {
|
|
410
|
+
key: "".concat(reference.sourceAri, "#").concat(index)
|
|
411
|
+
}, note !== undefined && {
|
|
412
|
+
note: note
|
|
413
|
+
}), {}, {
|
|
414
|
+
reference: reference
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
}).sort(function (a, b) {
|
|
418
|
+
return compareLocationOrder(a.reference, b.reference) || a.baseTitle.localeCompare(b.baseTitle);
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
var toSyncedLocations = function toSyncedLocations(references, intl) {
|
|
422
|
+
return isFieldAwareLocationList(references) ? {
|
|
423
|
+
kind: 'field-aware',
|
|
424
|
+
items: buildFieldAwareItems(references, intl.formatMessage)
|
|
425
|
+
} : {
|
|
426
|
+
kind: 'control',
|
|
427
|
+
references: processReferenceData(references, intl)
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLocationDropdown(_ref5) {
|
|
431
|
+
var syncBlockStore = _ref5.syncBlockStore,
|
|
432
|
+
resourceId = _ref5.resourceId,
|
|
433
|
+
intl = _ref5.intl,
|
|
434
|
+
isSource = _ref5.isSource,
|
|
435
|
+
localId = _ref5.localId,
|
|
436
|
+
api = _ref5.api,
|
|
437
|
+
floatingToolbarRenderContext = _ref5.floatingToolbarRenderContext;
|
|
317
438
|
return /*#__PURE__*/React.createElement(EditorPositionedSyncedLocationDropdown, {
|
|
318
439
|
syncBlockStore: syncBlockStore,
|
|
319
440
|
resourceId: resourceId,
|
|
@@ -324,14 +445,14 @@ var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLoc
|
|
|
324
445
|
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
325
446
|
});
|
|
326
447
|
};
|
|
327
|
-
var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLocationDropdown(
|
|
328
|
-
var syncBlockStore =
|
|
329
|
-
resourceId =
|
|
330
|
-
intl =
|
|
331
|
-
isSource =
|
|
332
|
-
localId =
|
|
333
|
-
api =
|
|
334
|
-
floatingToolbarRenderContext =
|
|
448
|
+
var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLocationDropdown(_ref6) {
|
|
449
|
+
var syncBlockStore = _ref6.syncBlockStore,
|
|
450
|
+
resourceId = _ref6.resourceId,
|
|
451
|
+
intl = _ref6.intl,
|
|
452
|
+
isSource = _ref6.isSource,
|
|
453
|
+
localId = _ref6.localId,
|
|
454
|
+
api = _ref6.api,
|
|
455
|
+
floatingToolbarRenderContext = _ref6.floatingToolbarRenderContext;
|
|
335
456
|
var triggerTitle = intl.formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
336
457
|
var _useState = (0, _react.useState)(false),
|
|
337
458
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -394,14 +515,14 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
394
515
|
}
|
|
395
516
|
}, content);
|
|
396
517
|
};
|
|
397
|
-
var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(
|
|
398
|
-
var syncBlockStore =
|
|
399
|
-
resourceId =
|
|
400
|
-
intl =
|
|
401
|
-
isSource =
|
|
402
|
-
localId =
|
|
403
|
-
api =
|
|
404
|
-
floatingToolbarRenderContext =
|
|
518
|
+
var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref7) {
|
|
519
|
+
var syncBlockStore = _ref7.syncBlockStore,
|
|
520
|
+
resourceId = _ref7.resourceId,
|
|
521
|
+
intl = _ref7.intl,
|
|
522
|
+
isSource = _ref7.isSource,
|
|
523
|
+
localId = _ref7.localId,
|
|
524
|
+
api = _ref7.api,
|
|
525
|
+
floatingToolbarRenderContext = _ref7.floatingToolbarRenderContext;
|
|
405
526
|
var _useState3 = (0, _react.useState)(false),
|
|
406
527
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
407
528
|
isOpen = _useState4[0],
|
|
@@ -414,20 +535,28 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
414
535
|
syncBlockStore: syncBlockStore
|
|
415
536
|
}),
|
|
416
537
|
fetchStatus = _useReferenceData.fetchStatus,
|
|
417
|
-
|
|
538
|
+
locations = _useReferenceData.locations;
|
|
418
539
|
var referenceCount = (0, _react.useMemo)(function () {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
540
|
+
switch (locations.kind) {
|
|
541
|
+
case 'control':
|
|
542
|
+
return locations.references.filter(function (_ref8) {
|
|
543
|
+
var isSourceItem = _ref8.isSource;
|
|
544
|
+
return !isSourceItem;
|
|
545
|
+
}).length;
|
|
546
|
+
case 'field-aware':
|
|
547
|
+
return locations.items.filter(function (_ref9) {
|
|
548
|
+
var reference = _ref9.reference;
|
|
549
|
+
return !reference.isSource;
|
|
550
|
+
}).length;
|
|
551
|
+
}
|
|
552
|
+
}, [locations]);
|
|
424
553
|
var tooltipContent = !isOpen && fetchStatus === 'success' && referenceCount === 0 ? intl.formatMessage(_messages.syncBlockMessages.syncedLocationDropdownNoReferencesTooltip) : null;
|
|
425
554
|
var content = isOpen ? /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
426
555
|
resourceId: resourceId,
|
|
427
556
|
intl: intl,
|
|
428
557
|
api: api,
|
|
429
558
|
fetchStatus: fetchStatus,
|
|
430
|
-
|
|
559
|
+
locations: locations
|
|
431
560
|
}) : null;
|
|
432
561
|
var toggleOpen = (0, _react.useCallback)(function () {
|
|
433
562
|
setIsOpen(function (currentIsOpen) {
|
|
@@ -485,25 +614,25 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
485
614
|
}
|
|
486
615
|
}, content);
|
|
487
616
|
};
|
|
488
|
-
var DropdownContent = function DropdownContent(
|
|
489
|
-
var syncBlockStore =
|
|
490
|
-
resourceId =
|
|
491
|
-
intl =
|
|
492
|
-
isSource =
|
|
493
|
-
localId =
|
|
494
|
-
api =
|
|
617
|
+
var DropdownContent = function DropdownContent(_ref0) {
|
|
618
|
+
var syncBlockStore = _ref0.syncBlockStore,
|
|
619
|
+
resourceId = _ref0.resourceId,
|
|
620
|
+
intl = _ref0.intl,
|
|
621
|
+
isSource = _ref0.isSource,
|
|
622
|
+
localId = _ref0.localId,
|
|
623
|
+
api = _ref0.api;
|
|
495
624
|
var _useState5 = (0, _react.useState)('none'),
|
|
496
625
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
497
626
|
fetchStatus = _useState6[0],
|
|
498
627
|
setFetchStatus = _useState6[1];
|
|
499
|
-
var _useState7 = (0, _react.useState)(
|
|
628
|
+
var _useState7 = (0, _react.useState)(EMPTY_LOCATIONS),
|
|
500
629
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
501
|
-
|
|
502
|
-
|
|
630
|
+
locations = _useState8[0],
|
|
631
|
+
setLocations = _useState8[1];
|
|
503
632
|
(0, _react.useEffect)(function () {
|
|
504
633
|
setFetchStatus('loading');
|
|
505
634
|
var getReferenceData = /*#__PURE__*/function () {
|
|
506
|
-
var
|
|
635
|
+
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
507
636
|
var response;
|
|
508
637
|
return _regenerator.default.wrap(function (_context) {
|
|
509
638
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -519,7 +648,7 @@ var DropdownContent = function DropdownContent(_ref8) {
|
|
|
519
648
|
setFetchStatus('error');
|
|
520
649
|
return _context.abrupt("return");
|
|
521
650
|
case 2:
|
|
522
|
-
|
|
651
|
+
setLocations(toSyncedLocations(response.references, intl));
|
|
523
652
|
setFetchStatus('success');
|
|
524
653
|
case 3:
|
|
525
654
|
case "end":
|
|
@@ -528,7 +657,7 @@ var DropdownContent = function DropdownContent(_ref8) {
|
|
|
528
657
|
}, _callee);
|
|
529
658
|
}));
|
|
530
659
|
return function getReferenceData() {
|
|
531
|
-
return
|
|
660
|
+
return _ref1.apply(this, arguments);
|
|
532
661
|
};
|
|
533
662
|
}();
|
|
534
663
|
void getReferenceData();
|
|
@@ -538,15 +667,15 @@ var DropdownContent = function DropdownContent(_ref8) {
|
|
|
538
667
|
intl: intl,
|
|
539
668
|
api: api,
|
|
540
669
|
fetchStatus: fetchStatus,
|
|
541
|
-
|
|
670
|
+
locations: locations
|
|
542
671
|
});
|
|
543
672
|
};
|
|
544
|
-
var useReferenceData = function useReferenceData(
|
|
545
|
-
var syncBlockStore =
|
|
546
|
-
resourceId =
|
|
547
|
-
intl =
|
|
548
|
-
isSource =
|
|
549
|
-
localId =
|
|
673
|
+
var useReferenceData = function useReferenceData(_ref10) {
|
|
674
|
+
var syncBlockStore = _ref10.syncBlockStore,
|
|
675
|
+
resourceId = _ref10.resourceId,
|
|
676
|
+
intl = _ref10.intl,
|
|
677
|
+
isSource = _ref10.isSource,
|
|
678
|
+
localId = _ref10.localId;
|
|
550
679
|
var _useState9 = (0, _react.useState)(function () {
|
|
551
680
|
return isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId);
|
|
552
681
|
}),
|
|
@@ -555,7 +684,7 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
555
684
|
var _useState1 = (0, _react.useState)(function () {
|
|
556
685
|
return {
|
|
557
686
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
558
|
-
|
|
687
|
+
locations: EMPTY_LOCATIONS
|
|
559
688
|
};
|
|
560
689
|
}),
|
|
561
690
|
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
@@ -565,10 +694,10 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
565
694
|
var isCurrentRequest = true;
|
|
566
695
|
setState({
|
|
567
696
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
568
|
-
|
|
697
|
+
locations: EMPTY_LOCATIONS
|
|
569
698
|
});
|
|
570
699
|
var getReferenceData = /*#__PURE__*/function () {
|
|
571
|
-
var
|
|
700
|
+
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
572
701
|
var response;
|
|
573
702
|
return _regenerator.default.wrap(function (_context2) {
|
|
574
703
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -592,13 +721,13 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
592
721
|
}
|
|
593
722
|
setState({
|
|
594
723
|
fetchStatus: 'error',
|
|
595
|
-
|
|
724
|
+
locations: EMPTY_LOCATIONS
|
|
596
725
|
});
|
|
597
726
|
return _context2.abrupt("return");
|
|
598
727
|
case 3:
|
|
599
728
|
setState({
|
|
600
729
|
fetchStatus: 'success',
|
|
601
|
-
|
|
730
|
+
locations: toSyncedLocations(response.references, intl)
|
|
602
731
|
});
|
|
603
732
|
case 4:
|
|
604
733
|
case "end":
|
|
@@ -607,7 +736,7 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
607
736
|
}, _callee2);
|
|
608
737
|
}));
|
|
609
738
|
return function getReferenceData() {
|
|
610
|
-
return
|
|
739
|
+
return _ref11.apply(this, arguments);
|
|
611
740
|
};
|
|
612
741
|
}();
|
|
613
742
|
void getReferenceData();
|
|
@@ -617,13 +746,13 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
617
746
|
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock]);
|
|
618
747
|
return {
|
|
619
748
|
fetchStatus: state.fetchStatus,
|
|
620
|
-
|
|
749
|
+
locations: state.locations
|
|
621
750
|
};
|
|
622
751
|
};
|
|
623
|
-
var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(
|
|
624
|
-
var intl =
|
|
625
|
-
fetchStatus =
|
|
626
|
-
referenceCount =
|
|
752
|
+
var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(_ref12) {
|
|
753
|
+
var intl = _ref12.intl,
|
|
754
|
+
fetchStatus = _ref12.fetchStatus,
|
|
755
|
+
referenceCount = _ref12.referenceCount;
|
|
627
756
|
var formatMessage = intl.formatMessage;
|
|
628
757
|
var triggerTitle = formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
629
758
|
var syncedLocationCount = referenceCount === 0 ? 0 : referenceCount + 1;
|
|
@@ -648,13 +777,14 @@ var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(_ref10)
|
|
|
648
777
|
return triggerTitle;
|
|
649
778
|
}
|
|
650
779
|
};
|
|
651
|
-
var DropdownContentWithReferenceData = function DropdownContentWithReferenceData(
|
|
652
|
-
var resourceId =
|
|
653
|
-
intl =
|
|
654
|
-
api =
|
|
655
|
-
fetchStatus =
|
|
656
|
-
|
|
780
|
+
var DropdownContentWithReferenceData = function DropdownContentWithReferenceData(_ref13) {
|
|
781
|
+
var resourceId = _ref13.resourceId,
|
|
782
|
+
intl = _ref13.intl,
|
|
783
|
+
api = _ref13.api,
|
|
784
|
+
fetchStatus = _ref13.fetchStatus,
|
|
785
|
+
locations = _ref13.locations;
|
|
657
786
|
var formatMessage = intl.formatMessage;
|
|
787
|
+
var locationCount = countLocations(locations);
|
|
658
788
|
var handleLocationClick = function handleLocationClick() {
|
|
659
789
|
var _api$analytics;
|
|
660
790
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
|
|
@@ -678,43 +808,22 @@ var DropdownContentWithReferenceData = function DropdownContentWithReferenceData
|
|
|
678
808
|
formatMessage: formatMessage
|
|
679
809
|
});
|
|
680
810
|
case 'success':
|
|
681
|
-
if (
|
|
811
|
+
if (locationCount > 0) {
|
|
682
812
|
return /*#__PURE__*/React.createElement("div", {
|
|
683
813
|
"data-testid": "synced-locations-dropdown-content",
|
|
684
814
|
className: (0, _runtime.ax)([styles.contentContainer, "_ku9g126e _18bk1rpy"])
|
|
685
815
|
}, /*#__PURE__*/React.createElement(_dropdownMenuItemGroup.default, {
|
|
686
816
|
title: formatMessage(_messages.syncBlockMessages.syncedLocationDropdownHeading, {
|
|
687
|
-
count: "".concat(
|
|
817
|
+
count: "".concat(locationCount > 99 ? '99+' : locationCount)
|
|
688
818
|
})
|
|
689
|
-
},
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
698
|
-
reference: reference,
|
|
699
|
-
intl: intl
|
|
700
|
-
}),
|
|
701
|
-
href: reference.url,
|
|
702
|
-
target: "_blank",
|
|
703
|
-
key: reference.title,
|
|
704
|
-
rel: "noopener noreferrer"
|
|
705
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
706
|
-
,
|
|
707
|
-
onClick: function onClick() {
|
|
708
|
-
return handleLocationClick();
|
|
709
|
-
}
|
|
710
|
-
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
711
|
-
title: title,
|
|
712
|
-
formatMessage: formatMessage,
|
|
713
|
-
onSameDocument: reference.onSameDocument,
|
|
714
|
-
isSource: reference.isSource,
|
|
715
|
-
hasAccess: reference.hasAccess,
|
|
716
|
-
productType: reference.productType
|
|
717
|
-
}))));
|
|
819
|
+
}, locations.kind === 'field-aware' ? /*#__PURE__*/React.createElement(FieldAwareLocationRows, {
|
|
820
|
+
items: locations.items,
|
|
821
|
+
intl: intl,
|
|
822
|
+
handleLocationClick: handleLocationClick
|
|
823
|
+
}) : /*#__PURE__*/React.createElement(ControlLocationRows, {
|
|
824
|
+
referenceData: locations.references,
|
|
825
|
+
intl: intl,
|
|
826
|
+
handleLocationClick: handleLocationClick
|
|
718
827
|
})));
|
|
719
828
|
} else {
|
|
720
829
|
return /*#__PURE__*/React.createElement(NoResultScreen, {
|
|
@@ -724,17 +833,127 @@ var DropdownContentWithReferenceData = function DropdownContentWithReferenceData
|
|
|
724
833
|
}
|
|
725
834
|
};
|
|
726
835
|
return /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
727
|
-
xcss: (0, _react2.cx)(styles.dropdownContent,
|
|
836
|
+
xcss: (0, _react2.cx)(styles.dropdownContent,
|
|
837
|
+
// Read off the discriminant rather than the experiment, so the control cohort
|
|
838
|
+
// cannot reach this width and no second exposure is fired for a style.
|
|
839
|
+
locations.kind === 'field-aware' && styles.fieldAwareDropdownContent, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_sync_block_activation', 'isEnabled', true) && fetchStatus === 'success' && locationCount === 0 && styles.activationDropdownContent, shouldApplyMinHeight(fetchStatus, locationCount) && styles.containerWithMinHeight)
|
|
728
840
|
}, content());
|
|
729
841
|
};
|
|
730
|
-
|
|
731
|
-
|
|
842
|
+
// The pre-experiment rows. This block is master's, moved into a component; remove with the experiment.
|
|
843
|
+
var ControlLocationRows = function ControlLocationRows(_ref14) {
|
|
844
|
+
var referenceData = _ref14.referenceData,
|
|
845
|
+
intl = _ref14.intl,
|
|
846
|
+
handleLocationClick = _ref14.handleLocationClick;
|
|
847
|
+
var formatMessage = intl.formatMessage;
|
|
848
|
+
return /*#__PURE__*/React.createElement(_react.Fragment, null, referenceData.map(function (reference) {
|
|
849
|
+
var title = reference.title === '' && reference.hasAccess ? formatMessage(_messages.syncBlockMessages.syncedLocationDropdownUntitledPage) : reference.title || reference.url || '';
|
|
850
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
851
|
+
key: reference.title,
|
|
852
|
+
className: (0, _runtime.ax)(["_2ll012x7"])
|
|
853
|
+
}, /*#__PURE__*/React.createElement(_Tooltip.default, {
|
|
854
|
+
content: title
|
|
855
|
+
}, /*#__PURE__*/React.createElement(_dropdownMenuItem.default, {
|
|
856
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
857
|
+
reference: reference,
|
|
858
|
+
intl: intl
|
|
859
|
+
}),
|
|
860
|
+
href: reference.url,
|
|
861
|
+
target: "_blank",
|
|
862
|
+
key: reference.title,
|
|
863
|
+
rel: "noopener noreferrer"
|
|
864
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
865
|
+
,
|
|
866
|
+
onClick: function onClick() {
|
|
867
|
+
return handleLocationClick();
|
|
868
|
+
}
|
|
869
|
+
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
870
|
+
title: title,
|
|
871
|
+
formatMessage: formatMessage,
|
|
872
|
+
onSameDocument: reference.onSameDocument,
|
|
873
|
+
isSource: reference.isSource,
|
|
874
|
+
hasAccess: reference.hasAccess,
|
|
875
|
+
productType: reference.productType
|
|
876
|
+
}))));
|
|
877
|
+
}));
|
|
878
|
+
};
|
|
879
|
+
var FieldAwareItemTitle = function FieldAwareItemTitle(_ref15) {
|
|
880
|
+
var _ref15$item = _ref15.item,
|
|
881
|
+
baseTitle = _ref15$item.baseTitle,
|
|
882
|
+
fieldName = _ref15$item.fieldName,
|
|
883
|
+
note = _ref15$item.note,
|
|
884
|
+
reference = _ref15$item.reference,
|
|
885
|
+
formatMessage = _ref15.formatMessage;
|
|
886
|
+
var titleLine = /*#__PURE__*/React.createElement(_compiled.Inline, null, /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
887
|
+
as: "span",
|
|
888
|
+
xcss: styles.title
|
|
889
|
+
}, baseTitle), note && /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
890
|
+
as: "span",
|
|
891
|
+
xcss: styles.note
|
|
892
|
+
}, "\xA0- ", note), reference.isSource && /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
893
|
+
as: "span",
|
|
894
|
+
xcss: styles.lozenge
|
|
895
|
+
}, /*#__PURE__*/React.createElement(_lozenge.default, null, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownSourceLozenge))), !reference.hasAccess && /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
896
|
+
as: "span",
|
|
897
|
+
xcss: styles.requestAccess
|
|
898
|
+
}, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownRequestAccess)));
|
|
899
|
+
if (fieldName === undefined) {
|
|
900
|
+
return titleLine;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// AGG localises the field name, so it is shown as given rather than wrapped in a message.
|
|
904
|
+
return /*#__PURE__*/React.createElement(_compiled.Stack, null, titleLine, /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
905
|
+
as: "span",
|
|
906
|
+
xcss: styles.fieldSecondLine
|
|
907
|
+
}, /*#__PURE__*/React.createElement(_compiled.Text, {
|
|
908
|
+
size: "small",
|
|
909
|
+
color: "color.text.subtlest"
|
|
910
|
+
}, fieldName)));
|
|
911
|
+
};
|
|
912
|
+
var FieldAwareLocationRows = function FieldAwareLocationRows(_ref16) {
|
|
913
|
+
var items = _ref16.items,
|
|
914
|
+
intl = _ref16.intl,
|
|
915
|
+
handleLocationClick = _ref16.handleLocationClick;
|
|
916
|
+
var formatMessage = intl.formatMessage;
|
|
917
|
+
return /*#__PURE__*/React.createElement(_react.Fragment, null, items.map(function (item) {
|
|
918
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
919
|
+
key: item.key,
|
|
920
|
+
className: (0, _runtime.ax)(["_2ll012x7"])
|
|
921
|
+
}, /*#__PURE__*/React.createElement(_Tooltip.default, {
|
|
922
|
+
content: item.fieldName ?
|
|
923
|
+
/*#__PURE__*/
|
|
924
|
+
// Two lines in the tooltip's own text flow. Wrapping them in `Text` would
|
|
925
|
+
// default to `font.body` and override the container's `font.body.small`,
|
|
926
|
+
// so the field-aware tooltip would not match every other one.
|
|
927
|
+
React.createElement(_react.Fragment, null, item.baseTitle, /*#__PURE__*/React.createElement("br", null), formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTooltipFieldName, {
|
|
928
|
+
fieldName: item.fieldName
|
|
929
|
+
})) : item.baseTitle
|
|
930
|
+
}, /*#__PURE__*/React.createElement(_dropdownMenuItem.default, {
|
|
931
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
932
|
+
reference: item.reference,
|
|
933
|
+
intl: intl
|
|
934
|
+
}),
|
|
935
|
+
href: item.reference.url,
|
|
936
|
+
target: "_blank",
|
|
937
|
+
rel: "noopener noreferrer"
|
|
938
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
939
|
+
,
|
|
940
|
+
onClick: function onClick() {
|
|
941
|
+
return handleLocationClick();
|
|
942
|
+
}
|
|
943
|
+
}, /*#__PURE__*/React.createElement(FieldAwareItemTitle, {
|
|
944
|
+
item: item,
|
|
945
|
+
formatMessage: formatMessage
|
|
946
|
+
}))));
|
|
947
|
+
}));
|
|
948
|
+
};
|
|
949
|
+
var LoadingScreen = function LoadingScreen(_ref17) {
|
|
950
|
+
var formatMessage = _ref17.formatMessage;
|
|
732
951
|
return /*#__PURE__*/React.createElement(_compiled.Box, null, /*#__PURE__*/React.createElement(_spinner.default, {
|
|
733
952
|
label: formatMessage(_messages.syncBlockMessages.syncedLocationDropdownLoading)
|
|
734
953
|
}));
|
|
735
954
|
};
|
|
736
|
-
var ErrorScreen = function ErrorScreen(
|
|
737
|
-
var formatMessage =
|
|
955
|
+
var ErrorScreen = function ErrorScreen(_ref18) {
|
|
956
|
+
var formatMessage = _ref18.formatMessage;
|
|
738
957
|
return /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
739
958
|
xcss: styles.errorContainer,
|
|
740
959
|
testId: "synced-locations-dropdown-content-error"
|
|
@@ -750,8 +969,8 @@ var ErrorScreen = function ErrorScreen(_ref13) {
|
|
|
750
969
|
size: "medium"
|
|
751
970
|
}, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownError)));
|
|
752
971
|
};
|
|
753
|
-
var NoResultScreen = function NoResultScreen(
|
|
754
|
-
var formatMessage =
|
|
972
|
+
var NoResultScreen = function NoResultScreen(_ref19) {
|
|
973
|
+
var formatMessage = _ref19.formatMessage;
|
|
755
974
|
return (0, _expValEquals.expValEquals)('platform_editor_sync_block_activation', 'isEnabled', true) ? /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
756
975
|
xcss: styles.activationNoResultsContainer,
|
|
757
976
|
testId: "synced-locations-dropdown-content-no-results"
|