@atlaskit/smart-card 17.3.1 → 17.4.2

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 (90) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/constants.js +63 -0
  3. package/dist/cjs/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  4. package/dist/cjs/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  5. package/dist/cjs/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  6. package/dist/cjs/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  7. package/dist/cjs/extractors/flexible/icon/extract-provider-icon.js +20 -3
  8. package/dist/cjs/extractors/flexible/icon/extract-url-icon.js +4 -1
  9. package/dist/cjs/extractors/flexible/icon/index.js +11 -20
  10. package/dist/cjs/extractors/flexible/index.js +5 -0
  11. package/dist/cjs/index.js +6 -0
  12. package/dist/cjs/utils/flexible.js +2 -2
  13. package/dist/cjs/utils/token.js +1 -0
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/cjs/view/CardWithUrl/component.js +1 -1
  16. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +10 -2
  17. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +51 -0
  18. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/types.js +5 -0
  19. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +15 -3
  20. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  21. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +2 -4
  22. package/dist/cjs/view/FlexibleCard/components/elements/index.js +6 -2
  23. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +9 -3
  24. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +20 -0
  25. package/dist/cjs/view/FlexibleCard/components/utils.js +15 -1
  26. package/dist/es2019/constants.js +53 -0
  27. package/dist/es2019/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  28. package/dist/es2019/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  29. package/dist/es2019/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  30. package/dist/es2019/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  31. package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +19 -3
  32. package/dist/es2019/extractors/flexible/icon/extract-url-icon.js +4 -1
  33. package/dist/es2019/extractors/flexible/icon/index.js +6 -9
  34. package/dist/es2019/extractors/flexible/index.js +5 -1
  35. package/dist/es2019/index.js +1 -1
  36. package/dist/es2019/utils/flexible.js +2 -2
  37. package/dist/es2019/utils/token.js +1 -0
  38. package/dist/es2019/version.json +1 -1
  39. package/dist/es2019/view/CardWithUrl/component.js +1 -1
  40. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +3 -2
  41. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +29 -0
  42. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
  43. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +28 -4
  44. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  45. package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +2 -4
  46. package/dist/es2019/view/FlexibleCard/components/elements/index.js +3 -1
  47. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +7 -4
  48. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +21 -0
  49. package/dist/es2019/view/FlexibleCard/components/utils.js +11 -0
  50. package/dist/esm/constants.js +53 -0
  51. package/dist/esm/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  52. package/dist/esm/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  53. package/dist/esm/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  54. package/dist/esm/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  55. package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +19 -3
  56. package/dist/esm/extractors/flexible/icon/extract-url-icon.js +4 -1
  57. package/dist/esm/extractors/flexible/icon/index.js +12 -20
  58. package/dist/esm/extractors/flexible/index.js +5 -1
  59. package/dist/esm/index.js +1 -1
  60. package/dist/esm/utils/flexible.js +2 -2
  61. package/dist/esm/utils/token.js +1 -0
  62. package/dist/esm/version.json +1 -1
  63. package/dist/esm/view/CardWithUrl/component.js +1 -1
  64. package/dist/esm/view/FlexibleCard/components/blocks/index.js +3 -2
  65. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +34 -0
  66. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
  67. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +14 -4
  68. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  69. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +2 -4
  70. package/dist/esm/view/FlexibleCard/components/elements/index.js +3 -1
  71. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +10 -3
  72. package/dist/esm/view/FlexibleCard/components/elements/utils.js +19 -0
  73. package/dist/esm/view/FlexibleCard/components/utils.js +11 -0
  74. package/dist/types/__fixtures__/flexible-ui-data-context.d.ts +3 -0
  75. package/dist/types/constants.d.ts +54 -1
  76. package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +1 -1
  77. package/dist/types/extractors/flexible/icon/index.d.ts +3 -3
  78. package/dist/types/extractors/flexible/icon/types.d.ts +5 -1
  79. package/dist/types/index.d.ts +1 -1
  80. package/dist/types/state/flexible-ui-context/types.d.ts +4 -2
  81. package/dist/types/utils/flexible.d.ts +1 -2
  82. package/dist/types/utils/token.d.ts +1 -0
  83. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +2 -1
  84. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +4 -0
  85. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
  86. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +4 -2
  87. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -0
  88. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +2 -0
  89. package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
  90. package/package.json +1 -1
@@ -10,6 +10,8 @@ import AvatarGroup from './avatar-group';
10
10
  import Text from './text';
11
11
  import { messages } from '../../../../messages';
12
12
  import DateTime from './date-time';
13
+ import { tokens } from '../../../../utils/token';
14
+ const SNIPPET_DEFAULT_MAX_LINES = 3;
13
15
  const elementMappings = {
14
16
  [ElementName.AuthorGroup]: {
15
17
  component: AvatarGroup
@@ -41,6 +43,13 @@ const elementMappings = {
41
43
  icon: IconType.ProgrammingLanguage
42
44
  }
43
45
  },
46
+ [ElementName.Snippet]: {
47
+ component: Text,
48
+ props: {
49
+ color: tokens.snippet,
50
+ maxLines: SNIPPET_DEFAULT_MAX_LINES
51
+ }
52
+ },
44
53
  [ElementName.State]: {
45
54
  component: Lozenge
46
55
  },
@@ -58,6 +67,9 @@ const elementMappings = {
58
67
  },
59
68
  [ElementName.ModifiedOn]: {
60
69
  component: DateTime
70
+ },
71
+ [ElementName.Provider]: {
72
+ component: Badge
61
73
  }
62
74
  };
63
75
 
@@ -96,6 +108,9 @@ const getData = (elementName, contextKey, context) => {
96
108
  case ElementName.ModifiedOn:
97
109
  return toDateTimeProps('modified', context.modifiedOn);
98
110
 
111
+ case ElementName.Snippet:
112
+ return toTextProps(data);
113
+
99
114
  case ElementName.Title:
100
115
  return toLinkProps(context.title, context.url);
101
116
 
@@ -141,6 +156,12 @@ const toLinkProps = (text, url) => {
141
156
  } : undefined;
142
157
  };
143
158
 
159
+ const toTextProps = content => {
160
+ return content ? {
161
+ content
162
+ } : undefined;
163
+ };
164
+
144
165
  export const createElement = name => {
145
166
  const {
146
167
  component: BaseElement,
@@ -80,6 +80,17 @@ export const getLinkSizeStyles = size => {
80
80
  `;
81
81
  }
82
82
  };
83
+ export const getMaxLines = (value, defaultValue, max, min) => {
84
+ if (value > max) {
85
+ return defaultValue;
86
+ }
87
+
88
+ if (value < min) {
89
+ return min;
90
+ }
91
+
92
+ return value;
93
+ };
83
94
  export const getTruncateStyles = (maxLines, lineHeight = '1rem') => css`
84
95
  display: -webkit-box;
85
96
  overflow: hidden;
@@ -1,4 +1,12 @@
1
+ /**
2
+ * The alignment of Flexible UI component.
3
+ */
1
4
  export var SmartLinkAlignment;
5
+ /**
6
+ * The direction of Flexible UI components. It establish the main-axis
7
+ * or how the child components laid out inside the parent component.
8
+ * Similar to flex's flex-direction concept.
9
+ */
2
10
 
3
11
  (function (SmartLinkAlignment) {
4
12
  SmartLinkAlignment["Left"] = "left";
@@ -6,6 +14,10 @@ export var SmartLinkAlignment;
6
14
  })(SmartLinkAlignment || (SmartLinkAlignment = {}));
7
15
 
8
16
  export var SmartLinkDirection;
17
+ /**
18
+ * The positioning of the component within the parent component.
19
+ * Similar to flex's align-items or align-self concept.
20
+ */
9
21
 
10
22
  (function (SmartLinkDirection) {
11
23
  SmartLinkDirection["Horizontal"] = "horizontal";
@@ -13,6 +25,11 @@ export var SmartLinkDirection;
13
25
  })(SmartLinkDirection || (SmartLinkDirection = {}));
14
26
 
15
27
  export var SmartLinkPosition;
28
+ /**
29
+ * The sizing options of the Flexible UI component. Every component
30
+ * has or inherits the sizing props. Implementation varies
31
+ * as per component.
32
+ */
16
33
 
17
34
  (function (SmartLinkPosition) {
18
35
  SmartLinkPosition["Top"] = "top";
@@ -20,6 +37,9 @@ export var SmartLinkPosition;
20
37
  })(SmartLinkPosition || (SmartLinkPosition = {}));
21
38
 
22
39
  export var SmartLinkSize;
40
+ /**
41
+ * Smart Links link request status
42
+ */
23
43
 
24
44
  (function (SmartLinkSize) {
25
45
  SmartLinkSize["XLarge"] = "xlarge";
@@ -29,6 +49,10 @@ export var SmartLinkSize;
29
49
  })(SmartLinkSize || (SmartLinkSize = {}));
30
50
 
31
51
  export var SmartLinkStatus;
52
+ /**
53
+ * Flexible UI theme available on the Card level.
54
+ * This determine the styling of the link.
55
+ */
32
56
 
33
57
  (function (SmartLinkStatus) {
34
58
  SmartLinkStatus["Pending"] = "pending";
@@ -42,6 +66,11 @@ export var SmartLinkStatus;
42
66
  })(SmartLinkStatus || (SmartLinkStatus = {}));
43
67
 
44
68
  export var SmartLinkTheme;
69
+ /**
70
+ * Determines whether the container size will fit to the content
71
+ * or expand to the available width or the parent component.
72
+ * Similar to flex's flex-grow concept.
73
+ */
45
74
 
46
75
  (function (SmartLinkTheme) {
47
76
  SmartLinkTheme["Black"] = "black";
@@ -49,6 +78,22 @@ export var SmartLinkTheme;
49
78
  })(SmartLinkTheme || (SmartLinkTheme = {}));
50
79
 
51
80
  export var SmartLinkWidth;
81
+ /**
82
+ * Flexible UI element name - each reflecting the link data its represented.
83
+ * When adding an element...
84
+ * 1) Create base element if it doesn't already existed.
85
+ * Base element are inside src/view/FlexibleCard/components/elements.
86
+ * E.g. Badge,DateTime, Icon, Lozenge, etc.
87
+ * 2) Update FlexibleUiContext with the new prop for data representing
88
+ * the element, preferably with the same name as the element itself.
89
+ * (src/state/flexible-ui-context/types.ts)
90
+ * 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
91
+ * 4) Set base element and data mapping
92
+ * (src/view/FlexibleCard/components/elements/utils.tsx)
93
+ * 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
94
+ * 6) Update element ElementDisplaySchema for inline/block display
95
+ * (src/view/FlexibleCard/components/blocks/utils.tsx)
96
+ */
52
97
 
53
98
  (function (SmartLinkWidth) {
54
99
  SmartLinkWidth["FitToContent"] = "fit-to-content";
@@ -56,6 +101,9 @@ export var SmartLinkWidth;
56
101
  })(SmartLinkWidth || (SmartLinkWidth = {}));
57
102
 
58
103
  export var ElementName;
104
+ /**
105
+ * Flexible UI action (button)
106
+ */
59
107
 
60
108
  (function (ElementName) {
61
109
  ElementName["AuthorGroup"] = "AuthorGroup";
@@ -68,12 +116,17 @@ export var ElementName;
68
116
  ElementName["ModifiedOn"] = "ModifiedOn";
69
117
  ElementName["Priority"] = "Priority";
70
118
  ElementName["ProgrammingLanguage"] = "ProgrammingLanguage";
119
+ ElementName["Snippet"] = "Snippet";
71
120
  ElementName["State"] = "State";
72
121
  ElementName["SubscriberCount"] = "SubscriberCount";
73
122
  ElementName["Title"] = "Title";
123
+ ElementName["Provider"] = "Provider";
74
124
  })(ElementName || (ElementName = {}));
75
125
 
76
126
  export var ActionName;
127
+ /**
128
+ * Flexible UI icons - each mapped to AK icons.
129
+ */
77
130
 
78
131
  (function (ActionName) {
79
132
  ActionName["DeleteAction"] = "DeleteAction";
@@ -3,25 +3,46 @@ import { IconType } from '../../../constants';
3
3
  var extractDocumentTypeIcon = function extractDocumentTypeIcon(documentType, label) {
4
4
  switch (documentType) {
5
5
  case 'schema:BlogPosting':
6
- return [IconType.Blog, label || 'Blog'];
6
+ return {
7
+ icon: IconType.Blog,
8
+ label: label || 'Blog'
9
+ };
7
10
 
8
11
  case 'schema:DigitalDocument':
9
- return [IconType.File, label || 'File'];
12
+ return {
13
+ icon: IconType.File,
14
+ label: label || 'File'
15
+ };
10
16
 
11
17
  case 'schema:TextDigitalDocument':
12
- return [IconType.Document, label || 'Document'];
18
+ return {
19
+ icon: IconType.Document,
20
+ label: label || 'Document'
21
+ };
13
22
 
14
23
  case 'schema:PresentationDigitalDocument':
15
- return [IconType.Presentation, label || 'Presentation'];
24
+ return {
25
+ icon: IconType.Presentation,
26
+ label: label || 'Presentation'
27
+ };
16
28
 
17
29
  case 'schema:SpreadsheetDigitalDocument':
18
- return [IconType.Spreadsheet, label || 'Spreadsheet'];
30
+ return {
31
+ icon: IconType.Spreadsheet,
32
+ label: label || 'Spreadsheet'
33
+ };
19
34
 
20
35
  case 'atlassian:Template':
21
- return [IconType.Template, label || 'Template'];
36
+ return {
37
+ icon: IconType.Template,
38
+ label: label || 'Template'
39
+ };
22
40
 
23
41
  case 'atlassian:UndefinedLink':
24
- return [IconType.Document, label || 'Undefined link'];
42
+ return {
43
+ icon: IconType.Document,
44
+ label: label || 'Undefined link'
45
+ };
25
46
 
26
47
  default:
27
48
  return undefined;
@@ -4,66 +4,111 @@ var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
4
4
  switch (fileFormat) {
5
5
  // Generic documents
6
6
  case 'folder':
7
- return [IconType.Folder, 'Folder'];
7
+ return {
8
+ icon: IconType.Folder,
9
+ label: 'Folder'
10
+ };
8
11
 
9
12
  case 'text/plain':
10
13
  case 'application/vnd.oasis.opendocument.text':
11
14
  case 'application/vnd.apple.pages':
12
- return [IconType.Document, 'Document'];
15
+ return {
16
+ icon: IconType.Document,
17
+ label: 'Document'
18
+ };
13
19
 
14
20
  case 'application/pdf':
15
- return [IconType.PDF, 'PDF document'];
21
+ return {
22
+ icon: IconType.PDF,
23
+ label: 'PDF document'
24
+ };
16
25
 
17
26
  case 'application/vnd.oasis.opendocument.presentation':
18
27
  case 'application/vnd.apple.keynote':
19
- return [IconType.Presentation, 'Presentation'];
28
+ return {
29
+ icon: IconType.Presentation,
30
+ label: 'Presentation'
31
+ };
20
32
 
21
33
  case 'application/vnd.oasis.opendocument.spreadsheet':
22
34
  case 'application/vnd.apple.numbers':
23
- return [IconType.Spreadsheet, 'Spreadsheet'];
35
+ return {
36
+ icon: IconType.Spreadsheet,
37
+ label: 'Spreadsheet'
38
+ };
24
39
  // Google Drive
25
40
 
26
41
  case 'application/vnd.google-apps.document':
27
- return [IconType.GoogleDocs, 'Google Docs'];
42
+ return {
43
+ icon: IconType.GoogleDocs,
44
+ label: 'Google Docs'
45
+ };
28
46
 
29
47
  case 'application/vnd.google-apps.form':
30
- return [IconType.GoogleForms, 'Google Form'];
48
+ return {
49
+ icon: IconType.GoogleForms,
50
+ label: 'Google Form'
51
+ };
31
52
 
32
53
  case 'application/vnd.google-apps.spreadsheet':
33
- return [IconType.GoogleSheets, 'Google Sheets'];
54
+ return {
55
+ icon: IconType.GoogleSheets,
56
+ label: 'Google Sheets'
57
+ };
34
58
 
35
59
  case 'application/vnd.google-apps.presentation':
36
- return [IconType.GoogleSlides, 'Google Slides'];
60
+ return {
61
+ icon: IconType.GoogleSlides,
62
+ label: 'Google Slides'
63
+ };
37
64
  // Microsoft
38
65
 
39
66
  case 'application/vnd.ms-excel':
40
67
  case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
41
- return [IconType.MSExcel, 'Excel spreadsheet'];
68
+ return {
69
+ icon: IconType.MSExcel,
70
+ label: 'Excel spreadsheet'
71
+ };
42
72
 
43
73
  case 'application/vnd.ms-powerpoint':
44
74
  case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
45
- return [IconType.MSPowerpoint, 'PowerPoint presentation'];
75
+ return {
76
+ icon: IconType.MSPowerpoint,
77
+ label: 'PowerPoint presentation'
78
+ };
46
79
 
47
80
  case 'application/msword':
48
81
  case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
49
- return [IconType.MSWord, 'Word document'];
82
+ return {
83
+ icon: IconType.MSWord,
84
+ label: 'Word document'
85
+ };
50
86
 
51
87
  case 'image/png':
52
88
  case 'image/jpeg':
53
89
  case 'image/bmp':
54
90
  case 'image/webp':
55
91
  case 'image/svg+xml':
56
- return [IconType.Image, 'Image'];
92
+ return {
93
+ icon: IconType.Image,
94
+ label: 'Image'
95
+ };
57
96
 
58
97
  case 'image/gif':
59
- return [IconType.GIF, 'GIF'];
98
+ return {
99
+ icon: IconType.GIF,
100
+ label: 'GIF'
101
+ };
60
102
 
61
103
  case 'audio/midi':
62
104
  case 'audio/mpeg':
63
105
  case 'audio/webm':
64
106
  case 'audio/ogg':
65
107
  case 'audio/wav':
66
- return [IconType.Audio, 'Audio'];
108
+ return {
109
+ icon: IconType.Audio,
110
+ label: 'Audio'
111
+ };
67
112
 
68
113
  case 'video/mp4':
69
114
  case 'video/quicktime':
@@ -72,13 +117,19 @@ var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
72
117
  case 'video/ogg':
73
118
  case 'video/x-ms-wmv':
74
119
  case 'video/x-msvideo':
75
- return [IconType.Video, 'Video'];
120
+ return {
121
+ icon: IconType.Video,
122
+ label: 'Video'
123
+ };
76
124
  // Others
77
125
 
78
126
  case 'text/css':
79
127
  case 'text/html':
80
128
  case 'application/javascript':
81
- return [IconType.Code, 'Source Code'];
129
+ return {
130
+ icon: IconType.Code,
131
+ label: 'Source Code'
132
+ };
82
133
 
83
134
  case 'application/zip':
84
135
  case 'application/x-tar':
@@ -86,19 +137,34 @@ var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
86
137
  case 'application/x-7z-compressed':
87
138
  case 'application/x-apple-diskimage':
88
139
  case 'application/vnd.rar':
89
- return [IconType.Archive, 'Archive'];
140
+ return {
141
+ icon: IconType.Archive,
142
+ label: 'Archive'
143
+ };
90
144
 
91
145
  case 'application/dmg':
92
- return [IconType.Executable, 'Executable'];
146
+ return {
147
+ icon: IconType.Executable,
148
+ label: 'Executable'
149
+ };
93
150
 
94
151
  case 'application/sketch':
95
- return [IconType.Sketch, 'Sketch'];
152
+ return {
153
+ icon: IconType.Sketch,
154
+ label: 'Sketch'
155
+ };
96
156
 
97
157
  case 'application/octet-stream':
98
- return [IconType.Generic, 'Binary file'];
158
+ return {
159
+ icon: IconType.Generic,
160
+ label: 'Binary file'
161
+ };
99
162
 
100
163
  case 'application/invision.prototype':
101
- return [IconType.Generic, 'Prototype'];
164
+ return {
165
+ icon: IconType.Generic,
166
+ label: 'Prototype'
167
+ };
102
168
 
103
169
  default:
104
170
  return undefined;
@@ -5,32 +5,59 @@ var extractJiraTaskIcon = function extractJiraTaskIcon(taskType) {
5
5
 
6
6
  switch (taskType) {
7
7
  case 'JiraBug':
8
- return [IconType.Bug, label];
8
+ return {
9
+ icon: IconType.Bug,
10
+ label: label
11
+ };
9
12
 
10
13
  case 'JiraChange':
11
- return [IconType.Change, label];
14
+ return {
15
+ icon: IconType.Change,
16
+ label: label
17
+ };
12
18
 
13
19
  case 'JiraEpic':
14
- return [IconType.Epic, label];
20
+ return {
21
+ icon: IconType.Epic,
22
+ label: label
23
+ };
15
24
 
16
25
  case 'JiraIncident':
17
- return [IconType.Incident, label];
26
+ return {
27
+ icon: IconType.Incident,
28
+ label: label
29
+ };
18
30
 
19
31
  case 'JiraProblem':
20
- return [IconType.Problem, label];
32
+ return {
33
+ icon: IconType.Problem,
34
+ label: label
35
+ };
21
36
 
22
37
  case 'JiraServiceRequest':
23
- return [IconType.ServiceRequest, label];
38
+ return {
39
+ icon: IconType.ServiceRequest,
40
+ label: label
41
+ };
24
42
 
25
43
  case 'JiraStory':
26
- return [IconType.Story, label];
44
+ return {
45
+ icon: IconType.Story,
46
+ label: label
47
+ };
27
48
 
28
49
  case 'JiraSubTask':
29
- return [IconType.SubTask, label];
50
+ return {
51
+ icon: IconType.SubTask,
52
+ label: label
53
+ };
30
54
 
31
55
  case 'JiraTask':
32
56
  default:
33
- return [IconType.Task, label];
57
+ return {
58
+ icon: IconType.Task,
59
+ label: label
60
+ };
34
61
  }
35
62
  };
36
63
 
@@ -15,7 +15,10 @@ var extractTask = function extractTask(data, label) {
15
15
  url = _ref.icon;
16
16
 
17
17
  var taskType = id === null || id === void 0 ? void 0 : id.split('#').pop();
18
- var taskIcon = url ? [undefined, label, url] : undefined;
18
+ var taskIcon = url ? {
19
+ label: label,
20
+ url: url
21
+ } : undefined;
19
22
  return {
20
23
  taskType: taskType,
21
24
  taskIcon: taskIcon
@@ -47,7 +50,7 @@ var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
47
50
  var type = extractType(data);
48
51
  var urlIcon = extractUrlIcon(data.icon, label);
49
52
  var provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
50
- var providerIcon = extractProviderIcon(provider, generator === null || generator === void 0 ? void 0 : generator.icon, label);
53
+ var providerIcon = extractProviderIcon(data);
51
54
 
52
55
  switch (type) {
53
56
  case 'Document':
@@ -76,25 +79,46 @@ var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
76
79
  taskType = _extractTask.taskType,
77
80
  taskIcon = _extractTask.taskIcon;
78
81
 
79
- return taskType === 'JiraCustomTaskType' ? taskIcon || urlIcon || providerIcon || [IconType.Task, taskLabel] : extractJiraTaskIcon(taskType, taskLabel);
82
+ return taskType === 'JiraCustomTaskType' ? taskIcon || urlIcon || providerIcon || {
83
+ icon: IconType.Task,
84
+ label: taskLabel
85
+ } : extractJiraTaskIcon(taskType, taskLabel);
80
86
  }
81
87
 
82
- return [IconType.Task, taskLabel];
88
+ return {
89
+ icon: IconType.Task,
90
+ label: taskLabel
91
+ };
83
92
 
84
93
  case 'atlassian:Project':
85
- return urlIcon || [IconType.Project, label || 'Project'];
94
+ return urlIcon || {
95
+ icon: IconType.Project,
96
+ label: label || 'Project'
97
+ };
86
98
 
87
99
  case 'atlassian:SourceCodeCommit':
88
- return [IconType.Commit, label || 'Commit'];
100
+ return {
101
+ icon: IconType.Commit,
102
+ label: label || 'Commit'
103
+ };
89
104
 
90
105
  case 'atlassian:SourceCodePullRequest':
91
- return [IconType.PullRequest, label || 'Pull request'];
106
+ return {
107
+ icon: IconType.PullRequest,
108
+ label: label || 'Pull request'
109
+ };
92
110
 
93
111
  case 'atlassian:SourceCodeReference':
94
- return [IconType.Branch, label || 'Reference'];
112
+ return {
113
+ icon: IconType.Branch,
114
+ label: label || 'Reference'
115
+ };
95
116
 
96
117
  case 'atlassian:SourceCodeRepository':
97
- return [IconType.Repo, label || 'Repository'];
118
+ return {
119
+ icon: IconType.Repo,
120
+ label: label || 'Repository'
121
+ };
98
122
 
99
123
  default:
100
124
  return providerIcon;
@@ -1,14 +1,30 @@
1
1
  import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
2
  import { IconType } from '../../../constants';
3
3
  import extractUrlIcon from './extract-url-icon';
4
+ import { extractTitle } from '../../common/primitives';
5
+
6
+ var extractProviderIcon = function extractProviderIcon(data) {
7
+ if (!data) {
8
+ return undefined;
9
+ }
10
+
11
+ var generator = data.generator;
12
+ var provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
13
+ var icon = generator === null || generator === void 0 ? void 0 : generator.icon;
14
+ var label = (generator === null || generator === void 0 ? void 0 : generator.name) || extractTitle(data);
4
15
 
5
- var extractProviderIcon = function extractProviderIcon(provider, icon, label) {
6
16
  if (provider === CONFLUENCE_GENERATOR_ID) {
7
- return [IconType.Confluence, label || 'Confluence'];
17
+ return {
18
+ icon: IconType.Confluence,
19
+ label: label || 'Confluence'
20
+ };
8
21
  }
9
22
 
10
23
  if (provider === JIRA_GENERATOR_ID) {
11
- return [IconType.Jira, label || 'Jira'];
24
+ return {
25
+ icon: IconType.Jira,
26
+ label: label || 'Jira'
27
+ };
12
28
  }
13
29
 
14
30
  return extractUrlIcon(icon, label);
@@ -2,7 +2,10 @@ import { extractUrlFromIconJsonLd } from '../../common/utils';
2
2
 
3
3
  var extractUrlIcon = function extractUrlIcon(icon, label) {
4
4
  var url = icon && extractUrlFromIconJsonLd(icon);
5
- return url ? [undefined, label, url] : undefined;
5
+ return url ? {
6
+ label: label,
7
+ url: url
8
+ } : undefined;
6
9
  };
7
10
 
8
11
  export default extractUrlIcon;
@@ -1,36 +1,28 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
2
7
  import extractJsonldDataIcon from './extract-jsonld-data-icon';
3
8
  import extractProviderIcon from './extract-provider-icon';
4
9
  import { IconType, SmartLinkStatus } from '../../../constants';
5
10
  import extractIconRenderer from './extract-icon-renderer';
6
11
  export var extractLinkIcon = function extractLinkIcon(response, renderers) {
7
12
  var data = response.data;
8
-
9
- var _ref = extractJsonldDataIcon(data) || [],
10
- _ref2 = _slicedToArray(_ref, 3),
11
- icon = _ref2[0],
12
- label = _ref2[1],
13
- url = _ref2[2];
14
-
15
13
  var render = extractIconRenderer(data, renderers);
16
- return {
17
- icon: icon,
18
- label: label,
19
- render: render,
20
- url: url
21
- };
14
+ return _objectSpread(_objectSpread({}, extractJsonldDataIcon(data)), {}, {
15
+ render: render
16
+ });
22
17
  };
23
18
  export var extractErrorIcon = function extractErrorIcon(response, status) {
24
19
  // Try to get provider icon first.
25
20
  if (response) {
26
21
  var data = response.data;
27
- var generator = data.generator;
28
- var provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
29
22
 
30
- var _ref3 = extractProviderIcon(provider, generator === null || generator === void 0 ? void 0 : generator.icon) || [],
31
- _ref4 = _slicedToArray(_ref3, 3),
32
- icon = _ref4[0],
33
- url = _ref4[2];
23
+ var _ref = extractProviderIcon(data) || {},
24
+ icon = _ref.icon,
25
+ url = _ref.url;
34
26
 
35
27
  if (icon || url) {
36
28
  return {