@atlaskit/editor-card-provider 5.0.3 → 5.1.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 +17 -0
- package/dist/cjs/provider.js +218 -156
- package/dist/es2019/provider.js +43 -15
- package/dist/esm/provider.js +218 -156
- package/dist/types/provider.d.ts +9 -1
- package/dist/types-ts4.5/provider.d.ts +9 -1
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-card-provider
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#174410](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/174410)
|
|
8
|
+
[`80d17e2d01bc0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/80d17e2d01bc0) -
|
|
9
|
+
Issue Editor - Only call onResolve callback for resolved links if local links (not remote links)
|
|
10
|
+
|
|
11
|
+
## 5.0.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#167423](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/167423)
|
|
16
|
+
[`064579ff3e75c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/064579ff3e75c) -
|
|
17
|
+
Move smart_links_noun_support feature gate to link-extractor
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 5.0.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/cjs/provider.js
CHANGED
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.editorCardProvider = exports.EditorCardProvider = void 0;
|
|
8
|
+
exports.isJiraWorkItem = exports.editorCardProvider = exports.EditorCardProvider = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -105,8 +105,11 @@ var isConfluenceTeamCalendars = function isConfluenceTeamCalendars(url) {
|
|
|
105
105
|
var isJiraIssueNavigator = function isJiraIssueNavigator(url) {
|
|
106
106
|
return url.match(/^https:\/\/.*?\/jira\/software|core\/(c\/)?projects\/[^\/]+?\/issues\/?/);
|
|
107
107
|
};
|
|
108
|
+
var isJiraWorkItem = exports.isJiraWorkItem = function isJiraWorkItem(url) {
|
|
109
|
+
return /\/browse\/((?:\w+)-(?:\d+))/i.test(url);
|
|
110
|
+
};
|
|
108
111
|
var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
109
|
-
function EditorCardProvider(envKey, baseUrlOverride, product) {
|
|
112
|
+
function EditorCardProvider(envKey, baseUrlOverride, product, onResolve) {
|
|
110
113
|
var _this = this;
|
|
111
114
|
(0, _classCallCheck2.default)(this, EditorCardProvider);
|
|
112
115
|
(0, _defineProperty2.default)(this, "getExperimentValue", function (experimentName, parameterName, defaultValue) {
|
|
@@ -119,6 +122,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
119
122
|
this.baseUrl = baseUrlOverride || (0, _linkingCommon.getBaseUrl)(envKey);
|
|
120
123
|
this.resolverUrl = (0, _linkingCommon.getResolverUrl)(envKey, baseUrlOverride);
|
|
121
124
|
this.transformer = new _transformer.Transformer();
|
|
125
|
+
this.onResolve = onResolve;
|
|
122
126
|
this.requestHeaders = {
|
|
123
127
|
Origin: this.baseUrl
|
|
124
128
|
};
|
|
@@ -197,19 +201,63 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
197
201
|
return checkLinkResolved;
|
|
198
202
|
}()
|
|
199
203
|
}, {
|
|
200
|
-
key: "
|
|
204
|
+
key: "fetchDataForResource",
|
|
201
205
|
value: function () {
|
|
202
|
-
var
|
|
203
|
-
var
|
|
206
|
+
var _fetchDataForResource = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceUrl) {
|
|
207
|
+
var response;
|
|
204
208
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
205
209
|
while (1) switch (_context3.prev = _context3.next) {
|
|
206
210
|
case 0:
|
|
207
|
-
|
|
211
|
+
_context3.prev = 0;
|
|
208
212
|
_context3.next = 3;
|
|
209
|
-
return
|
|
213
|
+
return this.cardClient.fetchData(resourceUrl);
|
|
210
214
|
case 3:
|
|
211
215
|
response = _context3.sent;
|
|
212
|
-
|
|
216
|
+
if (!((0, _linkingCommon.getStatus)(response) !== 'not_found')) {
|
|
217
|
+
_context3.next = 6;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
return _context3.abrupt("return", response);
|
|
221
|
+
case 6:
|
|
222
|
+
_context3.next = 11;
|
|
223
|
+
break;
|
|
224
|
+
case 8:
|
|
225
|
+
_context3.prev = 8;
|
|
226
|
+
_context3.t0 = _context3["catch"](0);
|
|
227
|
+
return _context3.abrupt("return", undefined);
|
|
228
|
+
case 11:
|
|
229
|
+
case "end":
|
|
230
|
+
return _context3.stop();
|
|
231
|
+
}
|
|
232
|
+
}, _callee3, this, [[0, 8]]);
|
|
233
|
+
}));
|
|
234
|
+
function fetchDataForResource(_x3) {
|
|
235
|
+
return _fetchDataForResource.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
return fetchDataForResource;
|
|
238
|
+
}()
|
|
239
|
+
}, {
|
|
240
|
+
key: "extractAriFromData",
|
|
241
|
+
value: function extractAriFromData(responseData) {
|
|
242
|
+
if (responseData.data && 'atlassian:ari' in responseData.data) {
|
|
243
|
+
return responseData.data['atlassian:ari'];
|
|
244
|
+
}
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
}, {
|
|
248
|
+
key: "fetchProvidersData",
|
|
249
|
+
value: function () {
|
|
250
|
+
var _fetchProvidersData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
251
|
+
var endpoint, response;
|
|
252
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
253
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
endpoint = "".concat(this.resolverUrl, "/providers");
|
|
256
|
+
_context4.next = 3;
|
|
257
|
+
return api.request('post', endpoint, undefined, this.requestHeaders);
|
|
258
|
+
case 3:
|
|
259
|
+
response = _context4.sent;
|
|
260
|
+
return _context4.abrupt("return", {
|
|
213
261
|
patterns: response.providers.reduce(function (allSources, provider) {
|
|
214
262
|
return allSources.concat(provider.patterns);
|
|
215
263
|
}, []),
|
|
@@ -217,9 +265,9 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
217
265
|
});
|
|
218
266
|
case 5:
|
|
219
267
|
case "end":
|
|
220
|
-
return
|
|
268
|
+
return _context4.stop();
|
|
221
269
|
}
|
|
222
|
-
},
|
|
270
|
+
}, _callee4, this);
|
|
223
271
|
}));
|
|
224
272
|
function fetchProvidersData() {
|
|
225
273
|
return _fetchProvidersData.apply(this, arguments);
|
|
@@ -229,29 +277,29 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
229
277
|
}, {
|
|
230
278
|
key: "loadProviderData",
|
|
231
279
|
value: function () {
|
|
232
|
-
var _loadProviderData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
233
|
-
return _regenerator.default.wrap(function
|
|
234
|
-
while (1) switch (
|
|
280
|
+
var _loadProviderData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
281
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
282
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
235
283
|
case 0:
|
|
236
|
-
|
|
237
|
-
|
|
284
|
+
_context5.prev = 0;
|
|
285
|
+
_context5.next = 3;
|
|
238
286
|
return this.providersLoader.load('providersData');
|
|
239
287
|
case 3:
|
|
240
|
-
this.providersData =
|
|
241
|
-
|
|
288
|
+
this.providersData = _context5.sent;
|
|
289
|
+
_context5.next = 11;
|
|
242
290
|
break;
|
|
243
291
|
case 6:
|
|
244
|
-
|
|
245
|
-
|
|
292
|
+
_context5.prev = 6;
|
|
293
|
+
_context5.t0 = _context5["catch"](0);
|
|
246
294
|
// eslint-disable-next-line
|
|
247
|
-
console.error('failed to fetch /providers',
|
|
295
|
+
console.error('failed to fetch /providers', _context5.t0);
|
|
248
296
|
this.providersLoader.clear('providerData');
|
|
249
|
-
return
|
|
297
|
+
return _context5.abrupt("return", undefined);
|
|
250
298
|
case 11:
|
|
251
299
|
case "end":
|
|
252
|
-
return
|
|
300
|
+
return _context5.stop();
|
|
253
301
|
}
|
|
254
|
-
},
|
|
302
|
+
}, _callee5, this, [[0, 6]]);
|
|
255
303
|
}));
|
|
256
304
|
function loadProviderData() {
|
|
257
305
|
return _loadProviderData.apply(this, arguments);
|
|
@@ -261,31 +309,31 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
261
309
|
}, {
|
|
262
310
|
key: "findPattern",
|
|
263
311
|
value: function () {
|
|
264
|
-
var _findPattern = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
265
|
-
return _regenerator.default.wrap(function
|
|
266
|
-
while (1) switch (
|
|
312
|
+
var _findPattern = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(url) {
|
|
313
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
314
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
267
315
|
case 0:
|
|
268
|
-
|
|
316
|
+
_context6.next = 2;
|
|
269
317
|
return this.findPatternData(url);
|
|
270
318
|
case 2:
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
319
|
+
_context6.t0 = !!_context6.sent;
|
|
320
|
+
if (_context6.t0) {
|
|
321
|
+
_context6.next = 7;
|
|
274
322
|
break;
|
|
275
323
|
}
|
|
276
|
-
|
|
324
|
+
_context6.next = 6;
|
|
277
325
|
return this.checkLinkResolved(url);
|
|
278
326
|
case 6:
|
|
279
|
-
|
|
327
|
+
_context6.t0 = !!_context6.sent;
|
|
280
328
|
case 7:
|
|
281
|
-
return
|
|
329
|
+
return _context6.abrupt("return", _context6.t0);
|
|
282
330
|
case 8:
|
|
283
331
|
case "end":
|
|
284
|
-
return
|
|
332
|
+
return _context6.stop();
|
|
285
333
|
}
|
|
286
|
-
},
|
|
334
|
+
}, _callee6, this);
|
|
287
335
|
}));
|
|
288
|
-
function findPattern(
|
|
336
|
+
function findPattern(_x4) {
|
|
289
337
|
return _findPattern.apply(this, arguments);
|
|
290
338
|
}
|
|
291
339
|
return findPattern;
|
|
@@ -303,23 +351,23 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
303
351
|
}, {
|
|
304
352
|
key: "findUserPreference",
|
|
305
353
|
value: function () {
|
|
306
|
-
var _findUserPreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
354
|
+
var _findUserPreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(url) {
|
|
307
355
|
var _this$providersData,
|
|
308
356
|
_this2 = this;
|
|
309
357
|
var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
|
|
310
|
-
return _regenerator.default.wrap(function
|
|
311
|
-
while (1) switch (
|
|
358
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
359
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
312
360
|
case 0:
|
|
313
361
|
if (this.providersData) {
|
|
314
|
-
|
|
362
|
+
_context7.next = 3;
|
|
315
363
|
break;
|
|
316
364
|
}
|
|
317
|
-
|
|
365
|
+
_context7.next = 3;
|
|
318
366
|
return this.loadProviderData();
|
|
319
367
|
case 3:
|
|
320
368
|
userPreferences = (_this$providersData = this.providersData) === null || _this$providersData === void 0 ? void 0 : _this$providersData.userPreferences;
|
|
321
369
|
if (!userPreferences) {
|
|
322
|
-
|
|
370
|
+
_context7.next = 12;
|
|
323
371
|
break;
|
|
324
372
|
}
|
|
325
373
|
defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
|
|
@@ -328,26 +376,26 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
328
376
|
return _this2.doesUrlMatchPath(urlSegment, url);
|
|
329
377
|
});
|
|
330
378
|
if (!(allMatchedLabeledAppearances.length > 0)) {
|
|
331
|
-
|
|
379
|
+
_context7.next = 10;
|
|
332
380
|
break;
|
|
333
381
|
}
|
|
334
382
|
longestMatchedLabeledAppearance = allMatchedLabeledAppearances.reduce(function (previousLabeledAppearance, currentLabeledAppearance) {
|
|
335
383
|
return previousLabeledAppearance.urlSegment.length > currentLabeledAppearance.urlSegment.length ? previousLabeledAppearance : currentLabeledAppearance;
|
|
336
384
|
});
|
|
337
|
-
return
|
|
385
|
+
return _context7.abrupt("return", longestMatchedLabeledAppearance.appearance);
|
|
338
386
|
case 10:
|
|
339
387
|
if (!(defaultAppearance !== 'inline')) {
|
|
340
|
-
|
|
388
|
+
_context7.next = 12;
|
|
341
389
|
break;
|
|
342
390
|
}
|
|
343
|
-
return
|
|
391
|
+
return _context7.abrupt("return", defaultAppearance);
|
|
344
392
|
case 12:
|
|
345
393
|
case "end":
|
|
346
|
-
return
|
|
394
|
+
return _context7.stop();
|
|
347
395
|
}
|
|
348
|
-
},
|
|
396
|
+
}, _callee7, this);
|
|
349
397
|
}));
|
|
350
|
-
function findUserPreference(
|
|
398
|
+
function findUserPreference(_x5) {
|
|
351
399
|
return _findUserPreference.apply(this, arguments);
|
|
352
400
|
}
|
|
353
401
|
return findUserPreference;
|
|
@@ -355,28 +403,28 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
355
403
|
}, {
|
|
356
404
|
key: "findPatternData",
|
|
357
405
|
value: function () {
|
|
358
|
-
var _findPatternData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
406
|
+
var _findPatternData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(url) {
|
|
359
407
|
var _this$providersData2;
|
|
360
|
-
return _regenerator.default.wrap(function
|
|
361
|
-
while (1) switch (
|
|
408
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
409
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
362
410
|
case 0:
|
|
363
411
|
if (this.providersData) {
|
|
364
|
-
|
|
412
|
+
_context8.next = 3;
|
|
365
413
|
break;
|
|
366
414
|
}
|
|
367
|
-
|
|
415
|
+
_context8.next = 3;
|
|
368
416
|
return this.loadProviderData();
|
|
369
417
|
case 3:
|
|
370
|
-
return
|
|
418
|
+
return _context8.abrupt("return", (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(function (pattern) {
|
|
371
419
|
return url.match(pattern.source);
|
|
372
420
|
}));
|
|
373
421
|
case 4:
|
|
374
422
|
case "end":
|
|
375
|
-
return
|
|
423
|
+
return _context8.stop();
|
|
376
424
|
}
|
|
377
|
-
},
|
|
425
|
+
}, _callee8, this);
|
|
378
426
|
}));
|
|
379
|
-
function findPatternData(
|
|
427
|
+
function findPatternData(_x6) {
|
|
380
428
|
return _findPatternData.apply(this, arguments);
|
|
381
429
|
}
|
|
382
430
|
return findPatternData;
|
|
@@ -425,55 +473,41 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
425
473
|
* Make a /resolve call and find out if result has embed capability
|
|
426
474
|
*/
|
|
427
475
|
function () {
|
|
428
|
-
var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
429
|
-
var details, embed
|
|
430
|
-
return _regenerator.default.wrap(function
|
|
431
|
-
while (1) switch (
|
|
476
|
+
var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(url) {
|
|
477
|
+
var details, embed;
|
|
478
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
479
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
432
480
|
case 0:
|
|
433
|
-
|
|
434
|
-
|
|
481
|
+
_context9.prev = 0;
|
|
482
|
+
_context9.next = 3;
|
|
435
483
|
return this.cardClient.fetchData(url);
|
|
436
484
|
case 3:
|
|
437
|
-
details =
|
|
438
|
-
if (!(0, _platformFeatureFlags.fg)('smart_links_noun_support')) {
|
|
439
|
-
_context8.next = 9;
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
485
|
+
details = _context9.sent;
|
|
442
486
|
if (details) {
|
|
443
|
-
|
|
487
|
+
_context9.next = 6;
|
|
444
488
|
break;
|
|
445
489
|
}
|
|
446
|
-
return
|
|
447
|
-
case
|
|
448
|
-
embed = (0, _linkExtractors.extractSmartLinkEmbed)(details);
|
|
449
|
-
return _context8.abrupt("return", !!embed);
|
|
450
|
-
case 9:
|
|
451
|
-
data = details && details.data;
|
|
452
|
-
if (data) {
|
|
453
|
-
_context8.next = 12;
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
return _context8.abrupt("return", false);
|
|
457
|
-
case 12:
|
|
490
|
+
return _context9.abrupt("return", false);
|
|
491
|
+
case 6:
|
|
458
492
|
if (!((0, _linkingCommon.getStatus)(details) !== 'resolved')) {
|
|
459
|
-
|
|
493
|
+
_context9.next = 8;
|
|
460
494
|
break;
|
|
461
495
|
}
|
|
462
|
-
return
|
|
463
|
-
case
|
|
464
|
-
|
|
465
|
-
return
|
|
466
|
-
case
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
return
|
|
470
|
-
case
|
|
496
|
+
return _context9.abrupt("return", false);
|
|
497
|
+
case 8:
|
|
498
|
+
embed = (0, _linkExtractors.extractSmartLinkEmbed)(details);
|
|
499
|
+
return _context9.abrupt("return", !!embed);
|
|
500
|
+
case 12:
|
|
501
|
+
_context9.prev = 12;
|
|
502
|
+
_context9.t0 = _context9["catch"](0);
|
|
503
|
+
return _context9.abrupt("return", false);
|
|
504
|
+
case 15:
|
|
471
505
|
case "end":
|
|
472
|
-
return
|
|
506
|
+
return _context9.stop();
|
|
473
507
|
}
|
|
474
|
-
},
|
|
508
|
+
}, _callee9, this, [[0, 12]]);
|
|
475
509
|
}));
|
|
476
|
-
function canBeResolvedAsEmbed(
|
|
510
|
+
function canBeResolvedAsEmbed(_x7) {
|
|
477
511
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
478
512
|
}
|
|
479
513
|
return canBeResolvedAsEmbed;
|
|
@@ -485,82 +519,110 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
485
519
|
}, {
|
|
486
520
|
key: "getDatasourceFromResolveResponse",
|
|
487
521
|
value: (function () {
|
|
488
|
-
var _getDatasourceFromResolveResponse = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
522
|
+
var _getDatasourceFromResolveResponse = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url) {
|
|
489
523
|
var response, datasources;
|
|
490
|
-
return _regenerator.default.wrap(function
|
|
491
|
-
while (1) switch (
|
|
524
|
+
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
525
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
492
526
|
case 0:
|
|
493
|
-
|
|
494
|
-
|
|
527
|
+
_context0.prev = 0;
|
|
528
|
+
_context0.next = 3;
|
|
495
529
|
return this.cardClient.fetchData(url);
|
|
496
530
|
case 3:
|
|
497
|
-
response =
|
|
531
|
+
response = _context0.sent;
|
|
498
532
|
datasources = response && response.datasources || [];
|
|
499
533
|
if (!(datasources.length > 0)) {
|
|
500
|
-
|
|
534
|
+
_context0.next = 7;
|
|
501
535
|
break;
|
|
502
536
|
}
|
|
503
|
-
return
|
|
537
|
+
return _context0.abrupt("return", datasources[0]);
|
|
504
538
|
case 7:
|
|
505
|
-
|
|
539
|
+
_context0.next = 12;
|
|
506
540
|
break;
|
|
507
541
|
case 9:
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return
|
|
542
|
+
_context0.prev = 9;
|
|
543
|
+
_context0.t0 = _context0["catch"](0);
|
|
544
|
+
return _context0.abrupt("return", undefined);
|
|
511
545
|
case 12:
|
|
512
546
|
case "end":
|
|
513
|
-
return
|
|
547
|
+
return _context0.stop();
|
|
514
548
|
}
|
|
515
|
-
},
|
|
549
|
+
}, _callee0, this, [[0, 9]]);
|
|
516
550
|
}));
|
|
517
|
-
function getDatasourceFromResolveResponse(
|
|
551
|
+
function getDatasourceFromResolveResponse(_x8) {
|
|
518
552
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
519
553
|
}
|
|
520
554
|
return getDatasourceFromResolveResponse;
|
|
521
|
-
}()
|
|
555
|
+
}()
|
|
556
|
+
/**
|
|
557
|
+
* This is used to determine if the url is a local Jira url or a remote one.
|
|
558
|
+
*/
|
|
559
|
+
)
|
|
560
|
+
}, {
|
|
561
|
+
key: "isLocalUrl",
|
|
562
|
+
value: function isLocalUrl(url) {
|
|
563
|
+
return new URL(url).origin === this.baseUrl;
|
|
564
|
+
}
|
|
522
565
|
}, {
|
|
523
566
|
key: "resolve",
|
|
524
567
|
value: function () {
|
|
525
|
-
var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
526
|
-
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
|
|
527
|
-
return _regenerator.default.wrap(function
|
|
528
|
-
while (1) switch (
|
|
568
|
+
var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
569
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
|
|
570
|
+
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
571
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
529
572
|
case 0:
|
|
530
|
-
|
|
573
|
+
_context1.prev = 0;
|
|
531
574
|
if (!(shouldForceAppearance === true)) {
|
|
532
|
-
|
|
575
|
+
_context1.next = 3;
|
|
533
576
|
break;
|
|
534
577
|
}
|
|
535
|
-
return
|
|
578
|
+
return _context1.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
|
|
536
579
|
case 3:
|
|
537
580
|
hardCodedAppearance = this.getHardCodedAppearance(url);
|
|
538
|
-
|
|
581
|
+
_context1.next = 6;
|
|
539
582
|
return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
|
|
540
583
|
case 6:
|
|
541
|
-
_yield$Promise$all =
|
|
584
|
+
_yield$Promise$all = _context1.sent;
|
|
542
585
|
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
|
|
543
586
|
matchedProviderPattern = _yield$Promise$all2[0];
|
|
544
587
|
userPreference = _yield$Promise$all2[1];
|
|
588
|
+
if (!(0, _platformFeatureFlags.fg)('issue-link-suggestions-in-comments')) {
|
|
589
|
+
_context1.next = 16;
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
if (!(isJiraWorkItem(url) && this.isLocalUrl(url))) {
|
|
593
|
+
_context1.next = 16;
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
_context1.next = 14;
|
|
597
|
+
return this.fetchDataForResource(url);
|
|
598
|
+
case 14:
|
|
599
|
+
data = _context1.sent;
|
|
600
|
+
if (data) {
|
|
601
|
+
issueAri = this.extractAriFromData(data);
|
|
602
|
+
if (issueAri) {
|
|
603
|
+
(_this$onResolve = this.onResolve) === null || _this$onResolve === void 0 || _this$onResolve.call(this, url, issueAri);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
case 16:
|
|
545
607
|
if (!(shouldForceAppearance === false && userPreference === 'url')) {
|
|
546
|
-
|
|
608
|
+
_context1.next = 18;
|
|
547
609
|
break;
|
|
548
610
|
}
|
|
549
|
-
return
|
|
550
|
-
case
|
|
551
|
-
|
|
552
|
-
if (
|
|
553
|
-
|
|
611
|
+
return _context1.abrupt("return", Promise.reject(undefined));
|
|
612
|
+
case 18:
|
|
613
|
+
_context1.t0 = !!matchedProviderPattern;
|
|
614
|
+
if (_context1.t0) {
|
|
615
|
+
_context1.next = 23;
|
|
554
616
|
break;
|
|
555
617
|
}
|
|
556
|
-
|
|
618
|
+
_context1.next = 22;
|
|
557
619
|
return this.checkLinkResolved(url);
|
|
558
|
-
case
|
|
559
|
-
|
|
560
|
-
case
|
|
561
|
-
isSupported =
|
|
620
|
+
case 22:
|
|
621
|
+
_context1.t0 = _context1.sent;
|
|
622
|
+
case 23:
|
|
623
|
+
isSupported = _context1.t0;
|
|
562
624
|
if (!isSupported) {
|
|
563
|
-
|
|
625
|
+
_context1.next = 39;
|
|
564
626
|
break;
|
|
565
627
|
}
|
|
566
628
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
@@ -578,27 +640,27 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
578
640
|
// If not, we pick what editor (or any other client) requested
|
|
579
641
|
appearance;
|
|
580
642
|
if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
|
|
581
|
-
|
|
643
|
+
_context1.next = 32;
|
|
582
644
|
break;
|
|
583
645
|
}
|
|
584
|
-
|
|
646
|
+
_context1.next = 30;
|
|
585
647
|
return this.canBeResolvedAsEmbed(url);
|
|
586
|
-
case
|
|
587
|
-
canItBeEmbed =
|
|
648
|
+
case 30:
|
|
649
|
+
canItBeEmbed = _context1.sent;
|
|
588
650
|
if (!canItBeEmbed) {
|
|
589
651
|
preferredAppearance = 'inline';
|
|
590
652
|
}
|
|
591
|
-
case
|
|
592
|
-
|
|
653
|
+
case 32:
|
|
654
|
+
_context1.next = 34;
|
|
593
655
|
return this.getDatasourceFromResolveResponse(url);
|
|
594
|
-
case
|
|
595
|
-
datasource =
|
|
656
|
+
case 34:
|
|
657
|
+
datasource = _context1.sent;
|
|
596
658
|
if (!datasource) {
|
|
597
|
-
|
|
659
|
+
_context1.next = 38;
|
|
598
660
|
break;
|
|
599
661
|
}
|
|
600
662
|
id = datasource.id, parameters = datasource.parameters;
|
|
601
|
-
return
|
|
663
|
+
return _context1.abrupt("return", this.transformer.toDatasourceAdf({
|
|
602
664
|
id: id,
|
|
603
665
|
parameters: parameters,
|
|
604
666
|
// in the future when we support multiple views, we will need to pass this in as a parameter
|
|
@@ -607,25 +669,25 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
607
669
|
type: 'table'
|
|
608
670
|
}]
|
|
609
671
|
}, url));
|
|
610
|
-
case 32:
|
|
611
|
-
return _context0.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
612
|
-
case 33:
|
|
613
|
-
_context0.next = 38;
|
|
614
|
-
break;
|
|
615
|
-
case 35:
|
|
616
|
-
_context0.prev = 35;
|
|
617
|
-
_context0.t1 = _context0["catch"](0);
|
|
618
|
-
// eslint-disable-next-line
|
|
619
|
-
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context0.t1 instanceof Error ? " - ".concat(_context0.t1.name, " ").concat(_context0.t1.message) : ''), _context0.t1);
|
|
620
672
|
case 38:
|
|
621
|
-
return
|
|
673
|
+
return _context1.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
622
674
|
case 39:
|
|
675
|
+
_context1.next = 44;
|
|
676
|
+
break;
|
|
677
|
+
case 41:
|
|
678
|
+
_context1.prev = 41;
|
|
679
|
+
_context1.t1 = _context1["catch"](0);
|
|
680
|
+
// eslint-disable-next-line
|
|
681
|
+
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context1.t1 instanceof Error ? " - ".concat(_context1.t1.name, " ").concat(_context1.t1.message) : ''), _context1.t1);
|
|
682
|
+
case 44:
|
|
683
|
+
return _context1.abrupt("return", Promise.reject(undefined));
|
|
684
|
+
case 45:
|
|
623
685
|
case "end":
|
|
624
|
-
return
|
|
686
|
+
return _context1.stop();
|
|
625
687
|
}
|
|
626
|
-
},
|
|
688
|
+
}, _callee1, this, [[0, 41]]);
|
|
627
689
|
}));
|
|
628
|
-
function resolve(
|
|
690
|
+
function resolve(_x9, _x0, _x1, _x10) {
|
|
629
691
|
return _resolve.apply(this, arguments);
|
|
630
692
|
}
|
|
631
693
|
return resolve;
|