@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.
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
5
|
import "./SyncedLocationDropdown.compiled.css";
|
|
5
6
|
import * as React from 'react';
|
|
6
7
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
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; }
|
|
10
|
+
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) { _defineProperty(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; }
|
|
8
11
|
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; } } }; }
|
|
9
12
|
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; } }
|
|
10
13
|
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; }
|
|
11
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
|
+
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
12
15
|
import { cx } from '@compiled/react';
|
|
13
16
|
import DropdownItem from '@atlaskit/dropdown-menu/dropdown-menu-item';
|
|
14
17
|
import DropdownItemGroup from '@atlaskit/dropdown-menu/dropdown-menu-item-group';
|
|
@@ -33,6 +36,7 @@ import IconTile from '@atlaskit/icon/icon-tile';
|
|
|
33
36
|
import { ConfluenceIcon, JiraIcon } from '@atlaskit/logo';
|
|
34
37
|
import { AtlassianIcon } from '@atlaskit/logo/atlassian-icon';
|
|
35
38
|
import Lozenge from '@atlaskit/lozenge/lozenge';
|
|
39
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
36
40
|
import { Box, Text, Inline, Anchor, Stack } from '@atlaskit/primitives/compiled';
|
|
37
41
|
import Spinner from '@atlaskit/spinner/spinner';
|
|
38
42
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -55,6 +59,8 @@ var styles = {
|
|
|
55
59
|
activationDropdownContent: "_1rjcze3t _1bsb1kdj",
|
|
56
60
|
activationNoResultsContainer: "_vchhusvi _1bsb1kdj _ca0q1ejb _n3td1ejb",
|
|
57
61
|
activationNoResultsContent: "_195g1wug _1bsb12aa _y3gn1h6o",
|
|
62
|
+
fieldAwareDropdownContent: "_1bsb1kdj",
|
|
63
|
+
fieldSecondLine: "_1reo15vq _18m915vq _o5721q9c _1bto1l2s",
|
|
58
64
|
dropdownContent: "_1rjcv77o _1bsbsmdz _c71lko4j _1e0c1txw _1bah1h6o _4cvr1h6o",
|
|
59
65
|
containerWithMinHeight: "_1tkeqkoa",
|
|
60
66
|
contentContainer: "_y44vfmxe _1bsb1osq _1wpz1fhb _18m91wug",
|
|
@@ -63,6 +69,21 @@ var styles = {
|
|
|
63
69
|
learnMoreLink: "_4bfu1r31 _1hmsglyw _ajmmnqa1",
|
|
64
70
|
requestAccess: "_1bsb19n7 _o5721q9c _ahbq12x7 _syaz1rpy"
|
|
65
71
|
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* One field-aware dropdown row. Every string the row shows is composed here from the untouched
|
|
75
|
+
* provider `reference`. Only built with `editor_synced_blocks_jira_custom_rich_text` on.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/** Decided once per fetch. The control shape is what the dropdown held before the experiment. */
|
|
79
|
+
|
|
80
|
+
var EMPTY_LOCATIONS = {
|
|
81
|
+
kind: 'control',
|
|
82
|
+
references: []
|
|
83
|
+
};
|
|
84
|
+
var countLocations = function countLocations(locations) {
|
|
85
|
+
return locations.kind === 'control' ? locations.references.length : locations.items.length;
|
|
86
|
+
};
|
|
66
87
|
var shouldApplyMinHeight = function shouldApplyMinHeight(fetchStatus, itemCount) {
|
|
67
88
|
// When there are 1/2 items, dropdown height is less than minHeight 144px
|
|
68
89
|
return !(fetchStatus === 'success' && itemCount > 0);
|
|
@@ -298,14 +319,114 @@ export var processReferenceData = function processReferenceData(referenceData, i
|
|
|
298
319
|
});
|
|
299
320
|
return sortedReferences;
|
|
300
321
|
};
|
|
301
|
-
|
|
302
|
-
var
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
322
|
+
var isFieldAwareLocationList = function isFieldAwareLocationList(references) {
|
|
323
|
+
var _references$some;
|
|
324
|
+
return ((_references$some = references === null || references === void 0 ? void 0 : references.some(function (reference) {
|
|
325
|
+
return (reference === null || reference === void 0 ? void 0 : reference.productType) === 'jira-work-item';
|
|
326
|
+
})) !== null && _references$some !== void 0 ? _references$some : false) && isExperimentEnabled('editor_synced_blocks_jira_custom_rich_text');
|
|
327
|
+
};
|
|
328
|
+
var groupBySourceAri = function groupBySourceAri(referenceData) {
|
|
329
|
+
var groups = new Map();
|
|
330
|
+
referenceData === null || referenceData === void 0 || referenceData.forEach(function (reference) {
|
|
331
|
+
if (!reference) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
var group = groups.get(reference.sourceAri);
|
|
335
|
+
if (group) {
|
|
336
|
+
group.push(reference);
|
|
337
|
+
} else {
|
|
338
|
+
groups.set(reference.sourceAri, [reference]);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
return groups;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/** Sources first, then accessible locations. `0` leaves the title order to the caller. */
|
|
345
|
+
var compareLocationOrder = function compareLocationOrder(a, b) {
|
|
346
|
+
if (a.isSource !== b.isSource) {
|
|
347
|
+
return b.isSource ? 1 : -1;
|
|
348
|
+
}
|
|
349
|
+
if (a.hasAccess !== b.hasAccess) {
|
|
350
|
+
return a.hasAccess ? -1 : 1;
|
|
351
|
+
}
|
|
352
|
+
return 0;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/** The title alone. The field name is placed by the row and the tooltip, not baked in here. */
|
|
356
|
+
var getBaseTitle = function getBaseTitle(_ref4) {
|
|
357
|
+
var blockIndex = _ref4.blockIndex,
|
|
358
|
+
formatMessage = _ref4.formatMessage,
|
|
359
|
+
reference = _ref4.reference;
|
|
360
|
+
var title = reference.title === '' && reference.hasAccess ? formatMessage(messages.syncedLocationDropdownUntitledPage) : reference.title || reference.url || '';
|
|
361
|
+
return blockIndex === undefined ? title : "".concat(title, ": ").concat(formatMessage(messages.syncedLocationDropdownTitleBlockIndex, {
|
|
362
|
+
index: blockIndex
|
|
363
|
+
}));
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/** Jira rows are noted from `locationScope`; other rows keep the pre-experiment `onSameDocument` note. */
|
|
367
|
+
var getFieldAwareNote = function getFieldAwareNote(reference, formatMessage) {
|
|
368
|
+
var _reference$locationSc;
|
|
369
|
+
if (reference.productType !== 'jira-work-item') {
|
|
370
|
+
if (!reference.onSameDocument) {
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
return formatMessage(reference.productType === 'confluence-page' ? messages.syncedLocationDropdownTitleNoteForConfluencePage : messages.syncedLocationDropdownTitleNoteForJiraWorkItem);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// A provider that computes no scope still reports `onSameDocument`. It is the same host
|
|
377
|
+
// comparison `getLocationScope` starts with, and in Jira the host document is one field.
|
|
378
|
+
var locationScope = (_reference$locationSc = reference.locationScope) !== null && _reference$locationSc !== void 0 ? _reference$locationSc : reference.onSameDocument ? 'same-document' : undefined;
|
|
379
|
+
switch (locationScope) {
|
|
380
|
+
case 'same-document':
|
|
381
|
+
return formatMessage(messages.syncedLocationDropdownTitleNoteForJiraWorkItemField);
|
|
382
|
+
case 'same-parent-document':
|
|
383
|
+
return formatMessage(messages.syncedLocationDropdownTitleNoteForJiraWorkItem);
|
|
384
|
+
default:
|
|
385
|
+
return undefined;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
export var buildFieldAwareItems = function buildFieldAwareItems(referenceData, formatMessage) {
|
|
389
|
+
return Array.from(groupBySourceAri(referenceData).values()).flatMap(function (group) {
|
|
390
|
+
return group.map(function (reference, index) {
|
|
391
|
+
var fieldName = reference.productType === 'jira-work-item' ? reference.fieldName : undefined;
|
|
392
|
+
var note = getFieldAwareNote(reference, formatMessage);
|
|
393
|
+
return _objectSpread(_objectSpread(_objectSpread({
|
|
394
|
+
baseTitle: getBaseTitle({
|
|
395
|
+
blockIndex: group.length > 1 ? index + 1 : undefined,
|
|
396
|
+
formatMessage: formatMessage,
|
|
397
|
+
reference: reference
|
|
398
|
+
})
|
|
399
|
+
}, fieldName !== undefined && {
|
|
400
|
+
fieldName: fieldName
|
|
401
|
+
}), {}, {
|
|
402
|
+
key: "".concat(reference.sourceAri, "#").concat(index)
|
|
403
|
+
}, note !== undefined && {
|
|
404
|
+
note: note
|
|
405
|
+
}), {}, {
|
|
406
|
+
reference: reference
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
}).sort(function (a, b) {
|
|
410
|
+
return compareLocationOrder(a.reference, b.reference) || a.baseTitle.localeCompare(b.baseTitle);
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
var toSyncedLocations = function toSyncedLocations(references, intl) {
|
|
414
|
+
return isFieldAwareLocationList(references) ? {
|
|
415
|
+
kind: 'field-aware',
|
|
416
|
+
items: buildFieldAwareItems(references, intl.formatMessage)
|
|
417
|
+
} : {
|
|
418
|
+
kind: 'control',
|
|
419
|
+
references: processReferenceData(references, intl)
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
export var SyncedLocationDropdown = function SyncedLocationDropdown(_ref5) {
|
|
423
|
+
var syncBlockStore = _ref5.syncBlockStore,
|
|
424
|
+
resourceId = _ref5.resourceId,
|
|
425
|
+
intl = _ref5.intl,
|
|
426
|
+
isSource = _ref5.isSource,
|
|
427
|
+
localId = _ref5.localId,
|
|
428
|
+
api = _ref5.api,
|
|
429
|
+
floatingToolbarRenderContext = _ref5.floatingToolbarRenderContext;
|
|
309
430
|
return /*#__PURE__*/React.createElement(EditorPositionedSyncedLocationDropdown, {
|
|
310
431
|
syncBlockStore: syncBlockStore,
|
|
311
432
|
resourceId: resourceId,
|
|
@@ -316,14 +437,14 @@ export var SyncedLocationDropdown = function SyncedLocationDropdown(_ref4) {
|
|
|
316
437
|
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
317
438
|
});
|
|
318
439
|
};
|
|
319
|
-
var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLocationDropdown(
|
|
320
|
-
var syncBlockStore =
|
|
321
|
-
resourceId =
|
|
322
|
-
intl =
|
|
323
|
-
isSource =
|
|
324
|
-
localId =
|
|
325
|
-
api =
|
|
326
|
-
floatingToolbarRenderContext =
|
|
440
|
+
var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLocationDropdown(_ref6) {
|
|
441
|
+
var syncBlockStore = _ref6.syncBlockStore,
|
|
442
|
+
resourceId = _ref6.resourceId,
|
|
443
|
+
intl = _ref6.intl,
|
|
444
|
+
isSource = _ref6.isSource,
|
|
445
|
+
localId = _ref6.localId,
|
|
446
|
+
api = _ref6.api,
|
|
447
|
+
floatingToolbarRenderContext = _ref6.floatingToolbarRenderContext;
|
|
327
448
|
var triggerTitle = intl.formatMessage(messages.syncedLocationDropdownTitle);
|
|
328
449
|
var _useState = useState(false),
|
|
329
450
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -386,14 +507,14 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
386
507
|
}
|
|
387
508
|
}, content);
|
|
388
509
|
};
|
|
389
|
-
export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(
|
|
390
|
-
var syncBlockStore =
|
|
391
|
-
resourceId =
|
|
392
|
-
intl =
|
|
393
|
-
isSource =
|
|
394
|
-
localId =
|
|
395
|
-
api =
|
|
396
|
-
floatingToolbarRenderContext =
|
|
510
|
+
export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref7) {
|
|
511
|
+
var syncBlockStore = _ref7.syncBlockStore,
|
|
512
|
+
resourceId = _ref7.resourceId,
|
|
513
|
+
intl = _ref7.intl,
|
|
514
|
+
isSource = _ref7.isSource,
|
|
515
|
+
localId = _ref7.localId,
|
|
516
|
+
api = _ref7.api,
|
|
517
|
+
floatingToolbarRenderContext = _ref7.floatingToolbarRenderContext;
|
|
397
518
|
var _useState3 = useState(false),
|
|
398
519
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
399
520
|
isOpen = _useState4[0],
|
|
@@ -406,20 +527,28 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
406
527
|
syncBlockStore: syncBlockStore
|
|
407
528
|
}),
|
|
408
529
|
fetchStatus = _useReferenceData.fetchStatus,
|
|
409
|
-
|
|
530
|
+
locations = _useReferenceData.locations;
|
|
410
531
|
var referenceCount = useMemo(function () {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
532
|
+
switch (locations.kind) {
|
|
533
|
+
case 'control':
|
|
534
|
+
return locations.references.filter(function (_ref8) {
|
|
535
|
+
var isSourceItem = _ref8.isSource;
|
|
536
|
+
return !isSourceItem;
|
|
537
|
+
}).length;
|
|
538
|
+
case 'field-aware':
|
|
539
|
+
return locations.items.filter(function (_ref9) {
|
|
540
|
+
var reference = _ref9.reference;
|
|
541
|
+
return !reference.isSource;
|
|
542
|
+
}).length;
|
|
543
|
+
}
|
|
544
|
+
}, [locations]);
|
|
416
545
|
var tooltipContent = !isOpen && fetchStatus === 'success' && referenceCount === 0 ? intl.formatMessage(messages.syncedLocationDropdownNoReferencesTooltip) : null;
|
|
417
546
|
var content = isOpen ? /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
418
547
|
resourceId: resourceId,
|
|
419
548
|
intl: intl,
|
|
420
549
|
api: api,
|
|
421
550
|
fetchStatus: fetchStatus,
|
|
422
|
-
|
|
551
|
+
locations: locations
|
|
423
552
|
}) : null;
|
|
424
553
|
var toggleOpen = useCallback(function () {
|
|
425
554
|
setIsOpen(function (currentIsOpen) {
|
|
@@ -477,25 +606,25 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
477
606
|
}
|
|
478
607
|
}, content);
|
|
479
608
|
};
|
|
480
|
-
var DropdownContent = function DropdownContent(
|
|
481
|
-
var syncBlockStore =
|
|
482
|
-
resourceId =
|
|
483
|
-
intl =
|
|
484
|
-
isSource =
|
|
485
|
-
localId =
|
|
486
|
-
api =
|
|
609
|
+
var DropdownContent = function DropdownContent(_ref0) {
|
|
610
|
+
var syncBlockStore = _ref0.syncBlockStore,
|
|
611
|
+
resourceId = _ref0.resourceId,
|
|
612
|
+
intl = _ref0.intl,
|
|
613
|
+
isSource = _ref0.isSource,
|
|
614
|
+
localId = _ref0.localId,
|
|
615
|
+
api = _ref0.api;
|
|
487
616
|
var _useState5 = useState('none'),
|
|
488
617
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
489
618
|
fetchStatus = _useState6[0],
|
|
490
619
|
setFetchStatus = _useState6[1];
|
|
491
|
-
var _useState7 = useState(
|
|
620
|
+
var _useState7 = useState(EMPTY_LOCATIONS),
|
|
492
621
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
493
|
-
|
|
494
|
-
|
|
622
|
+
locations = _useState8[0],
|
|
623
|
+
setLocations = _useState8[1];
|
|
495
624
|
useEffect(function () {
|
|
496
625
|
setFetchStatus('loading');
|
|
497
626
|
var getReferenceData = /*#__PURE__*/function () {
|
|
498
|
-
var
|
|
627
|
+
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
499
628
|
var response;
|
|
500
629
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
501
630
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -511,7 +640,7 @@ var DropdownContent = function DropdownContent(_ref8) {
|
|
|
511
640
|
setFetchStatus('error');
|
|
512
641
|
return _context.abrupt("return");
|
|
513
642
|
case 2:
|
|
514
|
-
|
|
643
|
+
setLocations(toSyncedLocations(response.references, intl));
|
|
515
644
|
setFetchStatus('success');
|
|
516
645
|
case 3:
|
|
517
646
|
case "end":
|
|
@@ -520,7 +649,7 @@ var DropdownContent = function DropdownContent(_ref8) {
|
|
|
520
649
|
}, _callee);
|
|
521
650
|
}));
|
|
522
651
|
return function getReferenceData() {
|
|
523
|
-
return
|
|
652
|
+
return _ref1.apply(this, arguments);
|
|
524
653
|
};
|
|
525
654
|
}();
|
|
526
655
|
void getReferenceData();
|
|
@@ -530,15 +659,15 @@ var DropdownContent = function DropdownContent(_ref8) {
|
|
|
530
659
|
intl: intl,
|
|
531
660
|
api: api,
|
|
532
661
|
fetchStatus: fetchStatus,
|
|
533
|
-
|
|
662
|
+
locations: locations
|
|
534
663
|
});
|
|
535
664
|
};
|
|
536
|
-
var useReferenceData = function useReferenceData(
|
|
537
|
-
var syncBlockStore =
|
|
538
|
-
resourceId =
|
|
539
|
-
intl =
|
|
540
|
-
isSource =
|
|
541
|
-
localId =
|
|
665
|
+
var useReferenceData = function useReferenceData(_ref10) {
|
|
666
|
+
var syncBlockStore = _ref10.syncBlockStore,
|
|
667
|
+
resourceId = _ref10.resourceId,
|
|
668
|
+
intl = _ref10.intl,
|
|
669
|
+
isSource = _ref10.isSource,
|
|
670
|
+
localId = _ref10.localId;
|
|
542
671
|
var _useState9 = useState(function () {
|
|
543
672
|
return isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId);
|
|
544
673
|
}),
|
|
@@ -547,7 +676,7 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
547
676
|
var _useState1 = useState(function () {
|
|
548
677
|
return {
|
|
549
678
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
550
|
-
|
|
679
|
+
locations: EMPTY_LOCATIONS
|
|
551
680
|
};
|
|
552
681
|
}),
|
|
553
682
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
@@ -557,10 +686,10 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
557
686
|
var isCurrentRequest = true;
|
|
558
687
|
setState({
|
|
559
688
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
560
|
-
|
|
689
|
+
locations: EMPTY_LOCATIONS
|
|
561
690
|
});
|
|
562
691
|
var getReferenceData = /*#__PURE__*/function () {
|
|
563
|
-
var
|
|
692
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
564
693
|
var response;
|
|
565
694
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
566
695
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -584,13 +713,13 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
584
713
|
}
|
|
585
714
|
setState({
|
|
586
715
|
fetchStatus: 'error',
|
|
587
|
-
|
|
716
|
+
locations: EMPTY_LOCATIONS
|
|
588
717
|
});
|
|
589
718
|
return _context2.abrupt("return");
|
|
590
719
|
case 3:
|
|
591
720
|
setState({
|
|
592
721
|
fetchStatus: 'success',
|
|
593
|
-
|
|
722
|
+
locations: toSyncedLocations(response.references, intl)
|
|
594
723
|
});
|
|
595
724
|
case 4:
|
|
596
725
|
case "end":
|
|
@@ -599,7 +728,7 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
599
728
|
}, _callee2);
|
|
600
729
|
}));
|
|
601
730
|
return function getReferenceData() {
|
|
602
|
-
return
|
|
731
|
+
return _ref11.apply(this, arguments);
|
|
603
732
|
};
|
|
604
733
|
}();
|
|
605
734
|
void getReferenceData();
|
|
@@ -609,13 +738,13 @@ var useReferenceData = function useReferenceData(_ref0) {
|
|
|
609
738
|
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock]);
|
|
610
739
|
return {
|
|
611
740
|
fetchStatus: state.fetchStatus,
|
|
612
|
-
|
|
741
|
+
locations: state.locations
|
|
613
742
|
};
|
|
614
743
|
};
|
|
615
|
-
var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(
|
|
616
|
-
var intl =
|
|
617
|
-
fetchStatus =
|
|
618
|
-
referenceCount =
|
|
744
|
+
var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(_ref12) {
|
|
745
|
+
var intl = _ref12.intl,
|
|
746
|
+
fetchStatus = _ref12.fetchStatus,
|
|
747
|
+
referenceCount = _ref12.referenceCount;
|
|
619
748
|
var formatMessage = intl.formatMessage;
|
|
620
749
|
var triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
621
750
|
var syncedLocationCount = referenceCount === 0 ? 0 : referenceCount + 1;
|
|
@@ -640,13 +769,14 @@ var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(_ref10)
|
|
|
640
769
|
return triggerTitle;
|
|
641
770
|
}
|
|
642
771
|
};
|
|
643
|
-
var DropdownContentWithReferenceData = function DropdownContentWithReferenceData(
|
|
644
|
-
var resourceId =
|
|
645
|
-
intl =
|
|
646
|
-
api =
|
|
647
|
-
fetchStatus =
|
|
648
|
-
|
|
772
|
+
var DropdownContentWithReferenceData = function DropdownContentWithReferenceData(_ref13) {
|
|
773
|
+
var resourceId = _ref13.resourceId,
|
|
774
|
+
intl = _ref13.intl,
|
|
775
|
+
api = _ref13.api,
|
|
776
|
+
fetchStatus = _ref13.fetchStatus,
|
|
777
|
+
locations = _ref13.locations;
|
|
649
778
|
var formatMessage = intl.formatMessage;
|
|
779
|
+
var locationCount = countLocations(locations);
|
|
650
780
|
var handleLocationClick = function handleLocationClick() {
|
|
651
781
|
var _api$analytics;
|
|
652
782
|
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({
|
|
@@ -670,43 +800,22 @@ var DropdownContentWithReferenceData = function DropdownContentWithReferenceData
|
|
|
670
800
|
formatMessage: formatMessage
|
|
671
801
|
});
|
|
672
802
|
case 'success':
|
|
673
|
-
if (
|
|
803
|
+
if (locationCount > 0) {
|
|
674
804
|
return /*#__PURE__*/React.createElement("div", {
|
|
675
805
|
"data-testid": "synced-locations-dropdown-content",
|
|
676
806
|
className: ax([styles.contentContainer, "_ku9g126e _18bk1rpy"])
|
|
677
807
|
}, /*#__PURE__*/React.createElement(DropdownItemGroup, {
|
|
678
808
|
title: formatMessage(messages.syncedLocationDropdownHeading, {
|
|
679
|
-
count: "".concat(
|
|
809
|
+
count: "".concat(locationCount > 99 ? '99+' : locationCount)
|
|
680
810
|
})
|
|
681
|
-
},
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
690
|
-
reference: reference,
|
|
691
|
-
intl: intl
|
|
692
|
-
}),
|
|
693
|
-
href: reference.url,
|
|
694
|
-
target: "_blank",
|
|
695
|
-
key: reference.title,
|
|
696
|
-
rel: "noopener noreferrer"
|
|
697
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
698
|
-
,
|
|
699
|
-
onClick: function onClick() {
|
|
700
|
-
return handleLocationClick();
|
|
701
|
-
}
|
|
702
|
-
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
703
|
-
title: title,
|
|
704
|
-
formatMessage: formatMessage,
|
|
705
|
-
onSameDocument: reference.onSameDocument,
|
|
706
|
-
isSource: reference.isSource,
|
|
707
|
-
hasAccess: reference.hasAccess,
|
|
708
|
-
productType: reference.productType
|
|
709
|
-
}))));
|
|
811
|
+
}, locations.kind === 'field-aware' ? /*#__PURE__*/React.createElement(FieldAwareLocationRows, {
|
|
812
|
+
items: locations.items,
|
|
813
|
+
intl: intl,
|
|
814
|
+
handleLocationClick: handleLocationClick
|
|
815
|
+
}) : /*#__PURE__*/React.createElement(ControlLocationRows, {
|
|
816
|
+
referenceData: locations.references,
|
|
817
|
+
intl: intl,
|
|
818
|
+
handleLocationClick: handleLocationClick
|
|
710
819
|
})));
|
|
711
820
|
} else {
|
|
712
821
|
return /*#__PURE__*/React.createElement(NoResultScreen, {
|
|
@@ -716,17 +825,127 @@ var DropdownContentWithReferenceData = function DropdownContentWithReferenceData
|
|
|
716
825
|
}
|
|
717
826
|
};
|
|
718
827
|
return /*#__PURE__*/React.createElement(Box, {
|
|
719
|
-
xcss: cx(styles.dropdownContent,
|
|
828
|
+
xcss: cx(styles.dropdownContent,
|
|
829
|
+
// Read off the discriminant rather than the experiment, so the control cohort
|
|
830
|
+
// cannot reach this width and no second exposure is fired for a style.
|
|
831
|
+
locations.kind === 'field-aware' && styles.fieldAwareDropdownContent, expValEqualsNoExposure('platform_editor_sync_block_activation', 'isEnabled', true) && fetchStatus === 'success' && locationCount === 0 && styles.activationDropdownContent, shouldApplyMinHeight(fetchStatus, locationCount) && styles.containerWithMinHeight)
|
|
720
832
|
}, content());
|
|
721
833
|
};
|
|
722
|
-
|
|
723
|
-
|
|
834
|
+
// The pre-experiment rows. This block is master's, moved into a component; remove with the experiment.
|
|
835
|
+
var ControlLocationRows = function ControlLocationRows(_ref14) {
|
|
836
|
+
var referenceData = _ref14.referenceData,
|
|
837
|
+
intl = _ref14.intl,
|
|
838
|
+
handleLocationClick = _ref14.handleLocationClick;
|
|
839
|
+
var formatMessage = intl.formatMessage;
|
|
840
|
+
return /*#__PURE__*/React.createElement(Fragment, null, referenceData.map(function (reference) {
|
|
841
|
+
var title = reference.title === '' && reference.hasAccess ? formatMessage(messages.syncedLocationDropdownUntitledPage) : reference.title || reference.url || '';
|
|
842
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
843
|
+
key: reference.title,
|
|
844
|
+
className: ax(["_2ll012x7"])
|
|
845
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
846
|
+
content: title
|
|
847
|
+
}, /*#__PURE__*/React.createElement(DropdownItem, {
|
|
848
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
849
|
+
reference: reference,
|
|
850
|
+
intl: intl
|
|
851
|
+
}),
|
|
852
|
+
href: reference.url,
|
|
853
|
+
target: "_blank",
|
|
854
|
+
key: reference.title,
|
|
855
|
+
rel: "noopener noreferrer"
|
|
856
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
857
|
+
,
|
|
858
|
+
onClick: function onClick() {
|
|
859
|
+
return handleLocationClick();
|
|
860
|
+
}
|
|
861
|
+
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
862
|
+
title: title,
|
|
863
|
+
formatMessage: formatMessage,
|
|
864
|
+
onSameDocument: reference.onSameDocument,
|
|
865
|
+
isSource: reference.isSource,
|
|
866
|
+
hasAccess: reference.hasAccess,
|
|
867
|
+
productType: reference.productType
|
|
868
|
+
}))));
|
|
869
|
+
}));
|
|
870
|
+
};
|
|
871
|
+
var FieldAwareItemTitle = function FieldAwareItemTitle(_ref15) {
|
|
872
|
+
var _ref15$item = _ref15.item,
|
|
873
|
+
baseTitle = _ref15$item.baseTitle,
|
|
874
|
+
fieldName = _ref15$item.fieldName,
|
|
875
|
+
note = _ref15$item.note,
|
|
876
|
+
reference = _ref15$item.reference,
|
|
877
|
+
formatMessage = _ref15.formatMessage;
|
|
878
|
+
var titleLine = /*#__PURE__*/React.createElement(Inline, null, /*#__PURE__*/React.createElement(Box, {
|
|
879
|
+
as: "span",
|
|
880
|
+
xcss: styles.title
|
|
881
|
+
}, baseTitle), note && /*#__PURE__*/React.createElement(Box, {
|
|
882
|
+
as: "span",
|
|
883
|
+
xcss: styles.note
|
|
884
|
+
}, "\xA0- ", note), reference.isSource && /*#__PURE__*/React.createElement(Box, {
|
|
885
|
+
as: "span",
|
|
886
|
+
xcss: styles.lozenge
|
|
887
|
+
}, /*#__PURE__*/React.createElement(Lozenge, null, formatMessage(messages.syncedLocationDropdownSourceLozenge))), !reference.hasAccess && /*#__PURE__*/React.createElement(Box, {
|
|
888
|
+
as: "span",
|
|
889
|
+
xcss: styles.requestAccess
|
|
890
|
+
}, formatMessage(messages.syncedLocationDropdownRequestAccess)));
|
|
891
|
+
if (fieldName === undefined) {
|
|
892
|
+
return titleLine;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// AGG localises the field name, so it is shown as given rather than wrapped in a message.
|
|
896
|
+
return /*#__PURE__*/React.createElement(Stack, null, titleLine, /*#__PURE__*/React.createElement(Box, {
|
|
897
|
+
as: "span",
|
|
898
|
+
xcss: styles.fieldSecondLine
|
|
899
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
900
|
+
size: "small",
|
|
901
|
+
color: "color.text.subtlest"
|
|
902
|
+
}, fieldName)));
|
|
903
|
+
};
|
|
904
|
+
var FieldAwareLocationRows = function FieldAwareLocationRows(_ref16) {
|
|
905
|
+
var items = _ref16.items,
|
|
906
|
+
intl = _ref16.intl,
|
|
907
|
+
handleLocationClick = _ref16.handleLocationClick;
|
|
908
|
+
var formatMessage = intl.formatMessage;
|
|
909
|
+
return /*#__PURE__*/React.createElement(Fragment, null, items.map(function (item) {
|
|
910
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
911
|
+
key: item.key,
|
|
912
|
+
className: ax(["_2ll012x7"])
|
|
913
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
914
|
+
content: item.fieldName ?
|
|
915
|
+
/*#__PURE__*/
|
|
916
|
+
// Two lines in the tooltip's own text flow. Wrapping them in `Text` would
|
|
917
|
+
// default to `font.body` and override the container's `font.body.small`,
|
|
918
|
+
// so the field-aware tooltip would not match every other one.
|
|
919
|
+
React.createElement(Fragment, null, item.baseTitle, /*#__PURE__*/React.createElement("br", null), formatMessage(messages.syncedLocationDropdownTooltipFieldName, {
|
|
920
|
+
fieldName: item.fieldName
|
|
921
|
+
})) : item.baseTitle
|
|
922
|
+
}, /*#__PURE__*/React.createElement(DropdownItem, {
|
|
923
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
924
|
+
reference: item.reference,
|
|
925
|
+
intl: intl
|
|
926
|
+
}),
|
|
927
|
+
href: item.reference.url,
|
|
928
|
+
target: "_blank",
|
|
929
|
+
rel: "noopener noreferrer"
|
|
930
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
931
|
+
,
|
|
932
|
+
onClick: function onClick() {
|
|
933
|
+
return handleLocationClick();
|
|
934
|
+
}
|
|
935
|
+
}, /*#__PURE__*/React.createElement(FieldAwareItemTitle, {
|
|
936
|
+
item: item,
|
|
937
|
+
formatMessage: formatMessage
|
|
938
|
+
}))));
|
|
939
|
+
}));
|
|
940
|
+
};
|
|
941
|
+
var LoadingScreen = function LoadingScreen(_ref17) {
|
|
942
|
+
var formatMessage = _ref17.formatMessage;
|
|
724
943
|
return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Spinner, {
|
|
725
944
|
label: formatMessage(messages.syncedLocationDropdownLoading)
|
|
726
945
|
}));
|
|
727
946
|
};
|
|
728
|
-
var ErrorScreen = function ErrorScreen(
|
|
729
|
-
var formatMessage =
|
|
947
|
+
var ErrorScreen = function ErrorScreen(_ref18) {
|
|
948
|
+
var formatMessage = _ref18.formatMessage;
|
|
730
949
|
return /*#__PURE__*/React.createElement(Box, {
|
|
731
950
|
xcss: styles.errorContainer,
|
|
732
951
|
testId: "synced-locations-dropdown-content-error"
|
|
@@ -742,8 +961,8 @@ var ErrorScreen = function ErrorScreen(_ref13) {
|
|
|
742
961
|
size: "medium"
|
|
743
962
|
}, formatMessage(messages.syncedLocationDropdownError)));
|
|
744
963
|
};
|
|
745
|
-
var NoResultScreen = function NoResultScreen(
|
|
746
|
-
var formatMessage =
|
|
964
|
+
var NoResultScreen = function NoResultScreen(_ref19) {
|
|
965
|
+
var formatMessage = _ref19.formatMessage;
|
|
747
966
|
return expValEquals('platform_editor_sync_block_activation', 'isEnabled', true) ? /*#__PURE__*/React.createElement(Box, {
|
|
748
967
|
xcss: styles.activationNoResultsContainer,
|
|
749
968
|
testId: "synced-locations-dropdown-content-no-results"
|
|
@@ -11,7 +11,26 @@ interface Props {
|
|
|
11
11
|
resourceId: string;
|
|
12
12
|
syncBlockStore: SyncBlockStoreManager;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* One field-aware dropdown row. Every string the row shows is composed here from the untouched
|
|
16
|
+
* provider `reference`. Only built with `editor_synced_blocks_jira_custom_rich_text` on.
|
|
17
|
+
*/
|
|
18
|
+
export type SyncedLocationItem = {
|
|
19
|
+
/**
|
|
20
|
+
* Work item or page title, with the untitled fallback and the block index applied.
|
|
21
|
+
* Never carries the field name, so the row and the tooltip can place it differently.
|
|
22
|
+
*/
|
|
23
|
+
baseTitle: string;
|
|
24
|
+
/** Jira field holding the block, when the provider resolved one. */
|
|
25
|
+
fieldName?: string;
|
|
26
|
+
/** `sourceAri` plus the block's position within that source. */
|
|
27
|
+
key: string;
|
|
28
|
+
/** Same-location note shown after the title. */
|
|
29
|
+
note?: string;
|
|
30
|
+
reference: SyncBlockSourceInfo;
|
|
31
|
+
};
|
|
14
32
|
export declare const processReferenceData: (referenceData: ReferencesSourceInfo['references'], intl: IntlShape) => SyncBlockSourceInfo[];
|
|
33
|
+
export declare const buildFieldAwareItems: (referenceData: ReferencesSourceInfo['references'], formatMessage: IntlShape['formatMessage']) => SyncedLocationItem[];
|
|
15
34
|
export declare const SyncedLocationDropdown: ({ syncBlockStore, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
16
35
|
export declare const SyncedLocationDropdownWithCount: ({ syncBlockStore, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
17
36
|
export {};
|