@atlaskit/smart-card 26.58.1 → 26.59.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +3534 -1954
  2. package/dist/cjs/extractors/common/icon/extractIcon.js +11 -0
  3. package/dist/cjs/extractors/common/icon/extractIconFromDocument.js +20 -0
  4. package/dist/cjs/extractors/common/icon/extractIconFromTask.js +8 -0
  5. package/dist/cjs/extractors/common/icon/prioritiseIcon.js +40 -0
  6. package/dist/cjs/extractors/common/icon/priority.js +3 -0
  7. package/dist/cjs/extractors/flexible/icon/extract-jsonld-data-icon.js +15 -0
  8. package/dist/cjs/extractors/flexible/icon/extract-provider-icon.js +10 -0
  9. package/dist/cjs/extractors/flexible/icon/extract-url-icon.js +7 -0
  10. package/dist/cjs/utils/analytics/analytics.js +1 -1
  11. package/dist/cjs/view/LinkUrl/index.js +1 -1
  12. package/dist/es2019/extractors/common/icon/extractIcon.js +11 -0
  13. package/dist/es2019/extractors/common/icon/extractIconFromDocument.js +22 -0
  14. package/dist/es2019/extractors/common/icon/extractIconFromTask.js +9 -0
  15. package/dist/es2019/extractors/common/icon/prioritiseIcon.js +29 -0
  16. package/dist/es2019/extractors/common/icon/priority.js +3 -0
  17. package/dist/es2019/extractors/flexible/icon/extract-jsonld-data-icon.js +15 -0
  18. package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +11 -0
  19. package/dist/es2019/extractors/flexible/icon/extract-url-icon.js +8 -0
  20. package/dist/es2019/utils/analytics/analytics.js +1 -1
  21. package/dist/es2019/view/LinkUrl/index.js +1 -1
  22. package/dist/esm/extractors/common/icon/extractIcon.js +11 -0
  23. package/dist/esm/extractors/common/icon/extractIconFromDocument.js +20 -0
  24. package/dist/esm/extractors/common/icon/extractIconFromTask.js +9 -0
  25. package/dist/esm/extractors/common/icon/prioritiseIcon.js +34 -0
  26. package/dist/esm/extractors/common/icon/priority.js +3 -0
  27. package/dist/esm/extractors/flexible/icon/extract-jsonld-data-icon.js +15 -0
  28. package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +11 -0
  29. package/dist/esm/extractors/flexible/icon/extract-url-icon.js +8 -0
  30. package/dist/esm/utils/analytics/analytics.js +1 -1
  31. package/dist/esm/view/LinkUrl/index.js +1 -1
  32. package/dist/types/extractors/common/icon/extractIcon.d.ts +3 -3
  33. package/dist/types/extractors/common/icon/extractIconFromDocument.d.ts +8 -1
  34. package/dist/types/extractors/common/icon/extractIconFromTask.d.ts +8 -0
  35. package/dist/types/extractors/common/icon/prioritiseIcon.d.ts +40 -0
  36. package/dist/types/extractors/common/icon/priority.d.ts +3 -0
  37. package/dist/types/extractors/flexible/icon/extract-document-type-icon.d.ts +1 -1
  38. package/dist/types/extractors/flexible/icon/extract-jsonld-data-icon.d.ts +5 -2
  39. package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +10 -0
  40. package/dist/types/extractors/flexible/icon/extract-url-icon.d.ts +7 -0
  41. package/dist/types/extractors/flexible/icon/types.d.ts +3 -0
  42. package/dist/types-ts4.5/extractors/common/icon/extractIcon.d.ts +3 -3
  43. package/dist/types-ts4.5/extractors/common/icon/extractIconFromDocument.d.ts +8 -1
  44. package/dist/types-ts4.5/extractors/common/icon/extractIconFromTask.d.ts +8 -0
  45. package/dist/types-ts4.5/extractors/common/icon/prioritiseIcon.d.ts +40 -0
  46. package/dist/types-ts4.5/extractors/common/icon/priority.d.ts +3 -0
  47. package/dist/types-ts4.5/extractors/flexible/icon/extract-document-type-icon.d.ts +1 -1
  48. package/dist/types-ts4.5/extractors/flexible/icon/extract-jsonld-data-icon.d.ts +5 -2
  49. package/dist/types-ts4.5/extractors/flexible/icon/extract-provider-icon.d.ts +10 -0
  50. package/dist/types-ts4.5/extractors/flexible/icon/extract-url-icon.d.ts +7 -0
  51. package/dist/types-ts4.5/extractors/flexible/icon/types.d.ts +3 -0
  52. package/package.json +10 -7
@@ -38,6 +38,17 @@ var extractIcon = exports.extractIcon = function extractIcon(jsonLd) {
38
38
  return extractIconByType(type, opts);
39
39
  }
40
40
  };
41
+
42
+ /**
43
+ * Extracts an icon based on the given type.
44
+ *
45
+ * Some types return hardcoded icons, while others follow a priority list on how to pick the icon.
46
+ * If type is not recognized, it will return the icon from the provider, or `undefined` if no icon is found.
47
+ *
48
+ * @param type - The type of the object.
49
+ * @param opts - Options for the icon extraction.
50
+ * @returns The extracted icon as a React node, or `undefined` if no icon is found.
51
+ */
41
52
  var extractIconByType = function extractIconByType(type, opts) {
42
53
  switch (type) {
43
54
  case 'Document':
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.extractIconFromDocument = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _ = _interopRequireDefault(require("@atlaskit/icon-object/glyph/blog/16"));
10
11
  var _2 = _interopRequireDefault(require("@atlaskit/icon-file-type/glyph/generic/16"));
11
12
  var _3 = _interopRequireDefault(require("@atlaskit/icon-file-type/glyph/presentation/16"));
@@ -13,10 +14,29 @@ var _4 = _interopRequireDefault(require("@atlaskit/icon-file-type/glyph/spreadsh
13
14
  var _5 = _interopRequireDefault(require("@atlaskit/icon-file-type/glyph/document/16"));
14
15
  var _documentFilled = _interopRequireDefault(require("@atlaskit/icon/glyph/document-filled"));
15
16
  var _utils = require("../../../utils");
17
+ var _prioritiseIcon = require("./prioritiseIcon");
18
+ /**
19
+ * Extracts an icon for a document pbject
20
+ *
21
+ * @param type - The type of the document.
22
+ * @param opts - The options for extracting the icon.
23
+ * @returns The React node representing the extracted icon, or `undefined` if no icon is found.
24
+ */
16
25
  var extractIconFromDocument = exports.extractIconFromDocument = function extractIconFromDocument(type, opts) {
26
+ var provider = opts.provider;
17
27
  var iconFromType = documentTypeToIcon(type, opts);
18
28
  var iconFromFileFormat = documentFileFormatToIcon(opts);
19
29
  var iconFromProvider = opts.provider && opts.provider.icon;
30
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.standardise-smart-link-icon-behaviour')) {
31
+ var providerId = provider === null || provider === void 0 ? void 0 : provider.id;
32
+ return (0, _prioritiseIcon.prioritiseIcon)({
33
+ providerId: providerId,
34
+ fileFormatIcon: iconFromFileFormat,
35
+ documentTypeIcon: iconFromType,
36
+ urlIcon: opts.icon,
37
+ providerIcon: iconFromProvider
38
+ });
39
+ }
20
40
  // If we encounter a native provider, we privilege the
21
41
  // icon generated by its type. Otherwise, we privilege the
22
42
  // provider icon, followed by the type & mime type icons.
@@ -16,6 +16,14 @@ var _7 = _interopRequireDefault(require("@atlaskit/icon-object/glyph/issue/16"))
16
16
  var _8 = _interopRequireDefault(require("@atlaskit/icon-object/glyph/changes/16"));
17
17
  var _9 = _interopRequireDefault(require("@atlaskit/icon-object/glyph/problem/16"));
18
18
  var _constants = require("../../constants");
19
+ /**
20
+ * Chooses an icon for a task based on the provided options.
21
+ *
22
+ * Chooses icon based on variety of Jira task types, based on opts.taskType.id
23
+ *
24
+ * @param opts - The options for extracting the icon.
25
+ * @returns The React node representing the extracted icon, or `undefined` if no icon is found.
26
+ */
19
27
  var extractIconFromTask = exports.extractIconFromTask = function extractIconFromTask(opts) {
20
28
  // Render Atlaskit icons for all supported Jira issue types.
21
29
  var taskType = opts.taskType,
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.prioritiseIcon = prioritiseIcon;
7
+ var _constants = require("../../constants");
8
+ var isConfluenceProvider = function isConfluenceProvider(provider) {
9
+ return provider === _constants.CONFLUENCE_GENERATOR_ID;
10
+ };
11
+ var isJiraProvider = function isJiraProvider(provider) {
12
+ return provider === _constants.JIRA_GENERATOR_ID;
13
+ };
14
+ var isNativeProvider = function isNativeProvider(provider) {
15
+ return isConfluenceProvider(provider) || isJiraProvider(provider);
16
+ };
17
+
18
+ /**
19
+ * Represents an icon. Should either contain a label and url, or a an icon type and label.
20
+ */
21
+
22
+ /**
23
+ * Options required to prioritise which icon to show
24
+ */
25
+
26
+ /**
27
+ * Reusable priority function for choosing which icon to show.
28
+ * Generic so it can be used to prioritise strings, or React components depending on the usage.
29
+ */
30
+ function prioritiseIcon(_ref) {
31
+ var providerId = _ref.providerId,
32
+ fileFormatIcon = _ref.fileFormatIcon,
33
+ documentTypeIcon = _ref.documentTypeIcon,
34
+ urlIcon = _ref.urlIcon,
35
+ providerIcon = _ref.providerIcon;
36
+ if (isNativeProvider(providerId)) {
37
+ return fileFormatIcon || documentTypeIcon || urlIcon || providerIcon;
38
+ }
39
+ return urlIcon || fileFormatIcon || documentTypeIcon || providerIcon;
40
+ }
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.extractorPriorityMap = void 0;
7
+ /**
8
+ * Preference more detailed object types over less detailed ones (like 'Document' or 'Object').
9
+ */
7
10
  var extractorPriorityMap = exports.extractorPriorityMap = {
8
11
  Object: 0,
9
12
  Document: 5,
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  var _constants = require("../../constants");
9
10
  var _extractDocumentTypeIcon = _interopRequireDefault(require("./extract-document-type-icon"));
10
11
  var _extractFileFormatIcon = _interopRequireDefault(require("./extract-file-formatIcon"));
@@ -15,6 +16,7 @@ var _lozenge = require("../../common/lozenge");
15
16
  var _linkExtractors = require("@atlaskit/link-extractors");
16
17
  var _priority = require("../../common/icon/priority");
17
18
  var _constants2 = require("../../../constants");
19
+ var _prioritiseIcon = require("../../common/icon/prioritiseIcon");
18
20
  var extractTask = function extractTask(data, label) {
19
21
  var _ref = (0, _lozenge.extractTaskType)(data) || {},
20
22
  id = _ref.id,
@@ -44,6 +46,10 @@ var isJiraProvider = function isJiraProvider(provider) {
44
46
  var isNativeProvider = function isNativeProvider(provider) {
45
47
  return isConfluenceProvider(provider) || isJiraProvider(provider);
46
48
  };
49
+
50
+ /**
51
+ * Return the icon object given a JSON-LD data object.
52
+ */
47
53
  var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
48
54
  var generator = data.generator;
49
55
  var label = (0, _linkExtractors.extractTitle)(data);
@@ -68,6 +74,15 @@ var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
68
74
  var fileFormat = documentData === null || documentData === void 0 ? void 0 : documentData['schema:fileFormat'];
69
75
  var fileFormatIcon = (0, _extractFileFormatIcon.default)(fileFormat);
70
76
  var documentTypeIcon = (0, _extractDocumentTypeIcon.default)(type, label);
77
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.standardise-smart-link-icon-behaviour')) {
78
+ return (0, _prioritiseIcon.prioritiseIcon)({
79
+ providerId: provider,
80
+ fileFormatIcon: fileFormatIcon,
81
+ documentTypeIcon: documentTypeIcon,
82
+ urlIcon: urlIcon,
83
+ providerIcon: providerIcon
84
+ });
85
+ }
71
86
  return isNativeProvider(provider) ? fileFormatIcon || documentTypeIcon || urlIcon || providerIcon : providerIcon || fileFormatIcon || documentTypeIcon;
72
87
  case 'atlassian:Task':
73
88
  var taskLabel = label || 'Task';
@@ -9,6 +9,16 @@ var _constants = require("../../constants");
9
9
  var _constants2 = require("../../../constants");
10
10
  var _extractUrlIcon = _interopRequireDefault(require("./extract-url-icon"));
11
11
  var _linkExtractors = require("@atlaskit/link-extractors");
12
+ /**
13
+ * Extracts the provider icon and label from the given JSON-LD data.
14
+ *
15
+ * If the data is from Confluence, the icon will be the Confluence icon and the label will be 'Confluence'.
16
+ * If the data is from Jira, the icon will be the Jira icon and the label will be 'Jira'.
17
+ * If the data is from another provider, the icon and label will be extracted from the generator object.
18
+ *
19
+ * @param data - The JSON-LD data to extract the provider icon and label from.
20
+ * @returns IconDescriptor with optional icon string name, url and label, or `undefined` if the data is not provided.
21
+ */
12
22
  var extractProviderIcon = function extractProviderIcon(data) {
13
23
  if (!data) {
14
24
  return undefined;
@@ -5,6 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _linkExtractors = require("@atlaskit/link-extractors");
8
+ /**
9
+ * Extracts the URL icon from the given icon or link object.
10
+ *
11
+ * @param icon - The icon or link object from which to extract the URL icon.
12
+ * @param label - The label for the URL icon.
13
+ * @returns IconDescriptor, which will contain label and url, or undefined
14
+ */
8
15
  var extractUrlIcon = function extractUrlIcon(icon, label) {
9
16
  var url = icon && (0, _linkExtractors.extractUrlFromIconJsonLd)(icon);
10
17
  return url ? {
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "26.58.1"
25
+ packageVersion: "26.59.0"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.58.1",
20
+ packageVersion: "26.59.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -28,6 +28,17 @@ export const extractIcon = (jsonLd, priority = 'type') => {
28
28
  return extractIconByType(type, opts);
29
29
  }
30
30
  };
31
+
32
+ /**
33
+ * Extracts an icon based on the given type.
34
+ *
35
+ * Some types return hardcoded icons, while others follow a priority list on how to pick the icon.
36
+ * If type is not recognized, it will return the icon from the provider, or `undefined` if no icon is found.
37
+ *
38
+ * @param type - The type of the object.
39
+ * @param opts - Options for the icon extraction.
40
+ * @returns The extracted icon as a React node, or `undefined` if no icon is found.
41
+ */
31
42
  const extractIconByType = (type, opts) => {
32
43
  switch (type) {
33
44
  case 'Document':
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  import BlogIcon from '@atlaskit/icon-object/glyph/blog/16';
3
4
  import FileIcon from '@atlaskit/icon-file-type/glyph/generic/16';
4
5
  import PresentationIcon from '@atlaskit/icon-file-type/glyph/presentation/16';
@@ -6,10 +7,31 @@ import SpreadsheetIcon from '@atlaskit/icon-file-type/glyph/spreadsheet/16';
6
7
  import DocumentIcon from '@atlaskit/icon-file-type/glyph/document/16';
7
8
  import DocumentFilledIcon from '@atlaskit/icon/glyph/document-filled';
8
9
  import { getIconForFileType } from '../../../utils';
10
+ import { prioritiseIcon } from './prioritiseIcon';
11
+ /**
12
+ * Extracts an icon for a document pbject
13
+ *
14
+ * @param type - The type of the document.
15
+ * @param opts - The options for extracting the icon.
16
+ * @returns The React node representing the extracted icon, or `undefined` if no icon is found.
17
+ */
9
18
  export const extractIconFromDocument = (type, opts) => {
19
+ const {
20
+ provider
21
+ } = opts;
10
22
  const iconFromType = documentTypeToIcon(type, opts);
11
23
  const iconFromFileFormat = documentFileFormatToIcon(opts);
12
24
  const iconFromProvider = opts.provider && opts.provider.icon;
25
+ if (getBooleanFF('platform.linking-platform.smart-card.standardise-smart-link-icon-behaviour')) {
26
+ const providerId = provider === null || provider === void 0 ? void 0 : provider.id;
27
+ return prioritiseIcon({
28
+ providerId,
29
+ fileFormatIcon: iconFromFileFormat,
30
+ documentTypeIcon: iconFromType,
31
+ urlIcon: opts.icon,
32
+ providerIcon: iconFromProvider
33
+ });
34
+ }
13
35
  // If we encounter a native provider, we privilege the
14
36
  // icon generated by its type. Otherwise, we privilege the
15
37
  // provider icon, followed by the type & mime type icons.
@@ -10,6 +10,15 @@ import JiraServiceRequestIcon from '@atlaskit/icon-object/glyph/issue/16';
10
10
  import JiraChangeIcon from '@atlaskit/icon-object/glyph/changes/16';
11
11
  import JiraProblemIcon from '@atlaskit/icon-object/glyph/problem/16';
12
12
  import { JIRA_GENERATOR_ID, JIRA_TASK, JIRA_SUB_TASK, JIRA_STORY, JIRA_BUG, JIRA_EPIC, JIRA_INCIDENT, JIRA_SERVICE_REQUEST, JIRA_CHANGE, JIRA_PROBLEM, JIRA_CUSTOM_TASK_TYPE } from '../../constants';
13
+
14
+ /**
15
+ * Chooses an icon for a task based on the provided options.
16
+ *
17
+ * Chooses icon based on variety of Jira task types, based on opts.taskType.id
18
+ *
19
+ * @param opts - The options for extracting the icon.
20
+ * @returns The React node representing the extracted icon, or `undefined` if no icon is found.
21
+ */
13
22
  export const extractIconFromTask = opts => {
14
23
  // Render Atlaskit icons for all supported Jira issue types.
15
24
  const {
@@ -0,0 +1,29 @@
1
+ import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
+ const isConfluenceProvider = provider => provider === CONFLUENCE_GENERATOR_ID;
3
+ const isJiraProvider = provider => provider === JIRA_GENERATOR_ID;
4
+ const isNativeProvider = provider => isConfluenceProvider(provider) || isJiraProvider(provider);
5
+
6
+ /**
7
+ * Represents an icon. Should either contain a label and url, or a an icon type and label.
8
+ */
9
+
10
+ /**
11
+ * Options required to prioritise which icon to show
12
+ */
13
+
14
+ /**
15
+ * Reusable priority function for choosing which icon to show.
16
+ * Generic so it can be used to prioritise strings, or React components depending on the usage.
17
+ */
18
+ export function prioritiseIcon({
19
+ providerId,
20
+ fileFormatIcon,
21
+ documentTypeIcon,
22
+ urlIcon,
23
+ providerIcon
24
+ }) {
25
+ if (isNativeProvider(providerId)) {
26
+ return fileFormatIcon || documentTypeIcon || urlIcon || providerIcon;
27
+ }
28
+ return urlIcon || fileFormatIcon || documentTypeIcon || providerIcon;
29
+ }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Preference more detailed object types over less detailed ones (like 'Document' or 'Object').
3
+ */
1
4
  export const extractorPriorityMap = {
2
5
  Object: 0,
3
6
  Document: 5,
@@ -1,3 +1,4 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
3
  import extractDocumentTypeIcon from './extract-document-type-icon';
3
4
  import extractFileFormatIcon from './extract-file-formatIcon';
@@ -8,6 +9,7 @@ import { extractTaskType } from '../../common/lozenge';
8
9
  import { extractTitle } from '@atlaskit/link-extractors';
9
10
  import { extractorPriorityMap as priorityMap } from '../../common/icon/priority';
10
11
  import { IconType } from '../../../constants';
12
+ import { prioritiseIcon } from '../../common/icon/prioritiseIcon';
11
13
  const extractTask = (data, label) => {
12
14
  const {
13
15
  id,
@@ -30,6 +32,10 @@ const extractType = jsonLd => {
30
32
  const isConfluenceProvider = provider => provider === CONFLUENCE_GENERATOR_ID;
31
33
  const isJiraProvider = provider => provider === JIRA_GENERATOR_ID;
32
34
  const isNativeProvider = provider => isConfluenceProvider(provider) || isJiraProvider(provider);
35
+
36
+ /**
37
+ * Return the icon object given a JSON-LD data object.
38
+ */
33
39
  const extractJsonldDataIcon = data => {
34
40
  const generator = data.generator;
35
41
  const label = extractTitle(data);
@@ -54,6 +60,15 @@ const extractJsonldDataIcon = data => {
54
60
  const fileFormat = documentData === null || documentData === void 0 ? void 0 : documentData['schema:fileFormat'];
55
61
  const fileFormatIcon = extractFileFormatIcon(fileFormat);
56
62
  const documentTypeIcon = extractDocumentTypeIcon(type, label);
63
+ if (getBooleanFF('platform.linking-platform.smart-card.standardise-smart-link-icon-behaviour')) {
64
+ return prioritiseIcon({
65
+ providerId: provider,
66
+ fileFormatIcon,
67
+ documentTypeIcon,
68
+ urlIcon,
69
+ providerIcon
70
+ });
71
+ }
57
72
  return isNativeProvider(provider) ? fileFormatIcon || documentTypeIcon || urlIcon || providerIcon : providerIcon || fileFormatIcon || documentTypeIcon;
58
73
  case 'atlassian:Task':
59
74
  const taskLabel = label || 'Task';
@@ -2,6 +2,17 @@ import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
2
  import { IconType } from '../../../constants';
3
3
  import extractUrlIcon from './extract-url-icon';
4
4
  import { extractTitle } from '@atlaskit/link-extractors';
5
+
6
+ /**
7
+ * Extracts the provider icon and label from the given JSON-LD data.
8
+ *
9
+ * If the data is from Confluence, the icon will be the Confluence icon and the label will be 'Confluence'.
10
+ * If the data is from Jira, the icon will be the Jira icon and the label will be 'Jira'.
11
+ * If the data is from another provider, the icon and label will be extracted from the generator object.
12
+ *
13
+ * @param data - The JSON-LD data to extract the provider icon and label from.
14
+ * @returns IconDescriptor with optional icon string name, url and label, or `undefined` if the data is not provided.
15
+ */
5
16
  const extractProviderIcon = data => {
6
17
  if (!data) {
7
18
  return undefined;
@@ -1,4 +1,12 @@
1
1
  import { extractUrlFromIconJsonLd } from '@atlaskit/link-extractors';
2
+
3
+ /**
4
+ * Extracts the URL icon from the given icon or link object.
5
+ *
6
+ * @param icon - The icon or link object from which to extract the URL icon.
7
+ * @param label - The label for the URL icon.
8
+ * @returns IconDescriptor, which will contain label and url, or undefined
9
+ */
2
10
  const extractUrlIcon = (icon, label) => {
3
11
  const url = icon && extractUrlFromIconJsonLd(icon);
4
12
  return url ? {
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "26.58.1"
7
+ packageVersion: "26.59.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.58.1",
10
+ packageVersion: "26.59.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -31,6 +31,17 @@ export var extractIcon = function extractIcon(jsonLd) {
31
31
  return extractIconByType(type, opts);
32
32
  }
33
33
  };
34
+
35
+ /**
36
+ * Extracts an icon based on the given type.
37
+ *
38
+ * Some types return hardcoded icons, while others follow a priority list on how to pick the icon.
39
+ * If type is not recognized, it will return the icon from the provider, or `undefined` if no icon is found.
40
+ *
41
+ * @param type - The type of the object.
42
+ * @param opts - Options for the icon extraction.
43
+ * @returns The extracted icon as a React node, or `undefined` if no icon is found.
44
+ */
34
45
  var extractIconByType = function extractIconByType(type, opts) {
35
46
  switch (type) {
36
47
  case 'Document':
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  import BlogIcon from '@atlaskit/icon-object/glyph/blog/16';
3
4
  import FileIcon from '@atlaskit/icon-file-type/glyph/generic/16';
4
5
  import PresentationIcon from '@atlaskit/icon-file-type/glyph/presentation/16';
@@ -6,10 +7,29 @@ import SpreadsheetIcon from '@atlaskit/icon-file-type/glyph/spreadsheet/16';
6
7
  import DocumentIcon from '@atlaskit/icon-file-type/glyph/document/16';
7
8
  import DocumentFilledIcon from '@atlaskit/icon/glyph/document-filled';
8
9
  import { getIconForFileType } from '../../../utils';
10
+ import { prioritiseIcon } from './prioritiseIcon';
11
+ /**
12
+ * Extracts an icon for a document pbject
13
+ *
14
+ * @param type - The type of the document.
15
+ * @param opts - The options for extracting the icon.
16
+ * @returns The React node representing the extracted icon, or `undefined` if no icon is found.
17
+ */
9
18
  export var extractIconFromDocument = function extractIconFromDocument(type, opts) {
19
+ var provider = opts.provider;
10
20
  var iconFromType = documentTypeToIcon(type, opts);
11
21
  var iconFromFileFormat = documentFileFormatToIcon(opts);
12
22
  var iconFromProvider = opts.provider && opts.provider.icon;
23
+ if (getBooleanFF('platform.linking-platform.smart-card.standardise-smart-link-icon-behaviour')) {
24
+ var providerId = provider === null || provider === void 0 ? void 0 : provider.id;
25
+ return prioritiseIcon({
26
+ providerId: providerId,
27
+ fileFormatIcon: iconFromFileFormat,
28
+ documentTypeIcon: iconFromType,
29
+ urlIcon: opts.icon,
30
+ providerIcon: iconFromProvider
31
+ });
32
+ }
13
33
  // If we encounter a native provider, we privilege the
14
34
  // icon generated by its type. Otherwise, we privilege the
15
35
  // provider icon, followed by the type & mime type icons.
@@ -10,6 +10,15 @@ import JiraServiceRequestIcon from '@atlaskit/icon-object/glyph/issue/16';
10
10
  import JiraChangeIcon from '@atlaskit/icon-object/glyph/changes/16';
11
11
  import JiraProblemIcon from '@atlaskit/icon-object/glyph/problem/16';
12
12
  import { JIRA_GENERATOR_ID, JIRA_TASK, JIRA_SUB_TASK, JIRA_STORY, JIRA_BUG, JIRA_EPIC, JIRA_INCIDENT, JIRA_SERVICE_REQUEST, JIRA_CHANGE, JIRA_PROBLEM, JIRA_CUSTOM_TASK_TYPE } from '../../constants';
13
+
14
+ /**
15
+ * Chooses an icon for a task based on the provided options.
16
+ *
17
+ * Chooses icon based on variety of Jira task types, based on opts.taskType.id
18
+ *
19
+ * @param opts - The options for extracting the icon.
20
+ * @returns The React node representing the extracted icon, or `undefined` if no icon is found.
21
+ */
13
22
  export var extractIconFromTask = function extractIconFromTask(opts) {
14
23
  // Render Atlaskit icons for all supported Jira issue types.
15
24
  var taskType = opts.taskType,
@@ -0,0 +1,34 @@
1
+ import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
+ var isConfluenceProvider = function isConfluenceProvider(provider) {
3
+ return provider === CONFLUENCE_GENERATOR_ID;
4
+ };
5
+ var isJiraProvider = function isJiraProvider(provider) {
6
+ return provider === JIRA_GENERATOR_ID;
7
+ };
8
+ var isNativeProvider = function isNativeProvider(provider) {
9
+ return isConfluenceProvider(provider) || isJiraProvider(provider);
10
+ };
11
+
12
+ /**
13
+ * Represents an icon. Should either contain a label and url, or a an icon type and label.
14
+ */
15
+
16
+ /**
17
+ * Options required to prioritise which icon to show
18
+ */
19
+
20
+ /**
21
+ * Reusable priority function for choosing which icon to show.
22
+ * Generic so it can be used to prioritise strings, or React components depending on the usage.
23
+ */
24
+ export function prioritiseIcon(_ref) {
25
+ var providerId = _ref.providerId,
26
+ fileFormatIcon = _ref.fileFormatIcon,
27
+ documentTypeIcon = _ref.documentTypeIcon,
28
+ urlIcon = _ref.urlIcon,
29
+ providerIcon = _ref.providerIcon;
30
+ if (isNativeProvider(providerId)) {
31
+ return fileFormatIcon || documentTypeIcon || urlIcon || providerIcon;
32
+ }
33
+ return urlIcon || fileFormatIcon || documentTypeIcon || providerIcon;
34
+ }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Preference more detailed object types over less detailed ones (like 'Document' or 'Object').
3
+ */
1
4
  export var extractorPriorityMap = {
2
5
  Object: 0,
3
6
  Document: 5,
@@ -1,3 +1,4 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
3
  import extractDocumentTypeIcon from './extract-document-type-icon';
3
4
  import extractFileFormatIcon from './extract-file-formatIcon';
@@ -8,6 +9,7 @@ import { extractTaskType } from '../../common/lozenge';
8
9
  import { extractTitle } from '@atlaskit/link-extractors';
9
10
  import { extractorPriorityMap as priorityMap } from '../../common/icon/priority';
10
11
  import { IconType } from '../../../constants';
12
+ import { prioritiseIcon } from '../../common/icon/prioritiseIcon';
11
13
  var extractTask = function extractTask(data, label) {
12
14
  var _ref = extractTaskType(data) || {},
13
15
  id = _ref.id,
@@ -37,6 +39,10 @@ var isJiraProvider = function isJiraProvider(provider) {
37
39
  var isNativeProvider = function isNativeProvider(provider) {
38
40
  return isConfluenceProvider(provider) || isJiraProvider(provider);
39
41
  };
42
+
43
+ /**
44
+ * Return the icon object given a JSON-LD data object.
45
+ */
40
46
  var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
41
47
  var generator = data.generator;
42
48
  var label = extractTitle(data);
@@ -61,6 +67,15 @@ var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
61
67
  var fileFormat = documentData === null || documentData === void 0 ? void 0 : documentData['schema:fileFormat'];
62
68
  var fileFormatIcon = extractFileFormatIcon(fileFormat);
63
69
  var documentTypeIcon = extractDocumentTypeIcon(type, label);
70
+ if (getBooleanFF('platform.linking-platform.smart-card.standardise-smart-link-icon-behaviour')) {
71
+ return prioritiseIcon({
72
+ providerId: provider,
73
+ fileFormatIcon: fileFormatIcon,
74
+ documentTypeIcon: documentTypeIcon,
75
+ urlIcon: urlIcon,
76
+ providerIcon: providerIcon
77
+ });
78
+ }
64
79
  return isNativeProvider(provider) ? fileFormatIcon || documentTypeIcon || urlIcon || providerIcon : providerIcon || fileFormatIcon || documentTypeIcon;
65
80
  case 'atlassian:Task':
66
81
  var taskLabel = label || 'Task';
@@ -2,6 +2,17 @@ import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
2
  import { IconType } from '../../../constants';
3
3
  import extractUrlIcon from './extract-url-icon';
4
4
  import { extractTitle } from '@atlaskit/link-extractors';
5
+
6
+ /**
7
+ * Extracts the provider icon and label from the given JSON-LD data.
8
+ *
9
+ * If the data is from Confluence, the icon will be the Confluence icon and the label will be 'Confluence'.
10
+ * If the data is from Jira, the icon will be the Jira icon and the label will be 'Jira'.
11
+ * If the data is from another provider, the icon and label will be extracted from the generator object.
12
+ *
13
+ * @param data - The JSON-LD data to extract the provider icon and label from.
14
+ * @returns IconDescriptor with optional icon string name, url and label, or `undefined` if the data is not provided.
15
+ */
5
16
  var extractProviderIcon = function extractProviderIcon(data) {
6
17
  if (!data) {
7
18
  return undefined;
@@ -1,4 +1,12 @@
1
1
  import { extractUrlFromIconJsonLd } from '@atlaskit/link-extractors';
2
+
3
+ /**
4
+ * Extracts the URL icon from the given icon or link object.
5
+ *
6
+ * @param icon - The icon or link object from which to extract the URL icon.
7
+ * @param label - The label for the URL icon.
8
+ * @returns IconDescriptor, which will contain label and url, or undefined
9
+ */
2
10
  var extractUrlIcon = function extractUrlIcon(icon, label) {
3
11
  var url = icon && extractUrlFromIconJsonLd(icon);
4
12
  return url ? {
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.58.1"
18
+ packageVersion: "26.59.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.58.1",
13
+ packageVersion: "26.59.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { JsonLd } from 'json-ld-types';
3
- import { LinkProvider } from '@atlaskit/link-extractors';
4
- import { LinkTaskType } from '../lozenge/extractTaskType';
2
+ import { type JsonLd } from 'json-ld-types';
3
+ import { type LinkProvider } from '@atlaskit/link-extractors';
4
+ import { type LinkTaskType } from '../lozenge/extractTaskType';
5
5
  export type IconPriority = 'type' | 'provider';
6
6
  export interface IconOpts {
7
7
  title?: string;