@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.
- package/CHANGELOG.md +24 -0
- package/dist/cjs/constants.js +63 -0
- package/dist/cjs/extractors/flexible/icon/extract-document-type-icon.js +28 -7
- package/dist/cjs/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
- package/dist/cjs/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
- package/dist/cjs/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
- package/dist/cjs/extractors/flexible/icon/extract-provider-icon.js +20 -3
- package/dist/cjs/extractors/flexible/icon/extract-url-icon.js +4 -1
- package/dist/cjs/extractors/flexible/icon/index.js +11 -20
- package/dist/cjs/extractors/flexible/index.js +5 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/utils/flexible.js +2 -2
- package/dist/cjs/utils/token.js +1 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/index.js +10 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +51 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +15 -3
- package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
- package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +2 -4
- package/dist/cjs/view/FlexibleCard/components/elements/index.js +6 -2
- package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +9 -3
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +20 -0
- package/dist/cjs/view/FlexibleCard/components/utils.js +15 -1
- package/dist/es2019/constants.js +53 -0
- package/dist/es2019/extractors/flexible/icon/extract-document-type-icon.js +28 -7
- package/dist/es2019/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
- package/dist/es2019/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
- package/dist/es2019/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
- package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +19 -3
- package/dist/es2019/extractors/flexible/icon/extract-url-icon.js +4 -1
- package/dist/es2019/extractors/flexible/icon/index.js +6 -9
- package/dist/es2019/extractors/flexible/index.js +5 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/utils/flexible.js +2 -2
- package/dist/es2019/utils/token.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +1 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/index.js +3 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +29 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +28 -4
- package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
- package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +2 -4
- package/dist/es2019/view/FlexibleCard/components/elements/index.js +3 -1
- package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +7 -4
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +21 -0
- package/dist/es2019/view/FlexibleCard/components/utils.js +11 -0
- package/dist/esm/constants.js +53 -0
- package/dist/esm/extractors/flexible/icon/extract-document-type-icon.js +28 -7
- package/dist/esm/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
- package/dist/esm/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
- package/dist/esm/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
- package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +19 -3
- package/dist/esm/extractors/flexible/icon/extract-url-icon.js +4 -1
- package/dist/esm/extractors/flexible/icon/index.js +12 -20
- package/dist/esm/extractors/flexible/index.js +5 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/flexible.js +2 -2
- package/dist/esm/utils/token.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/index.js +3 -2
- package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +34 -0
- package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +14 -4
- package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
- package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +2 -4
- package/dist/esm/view/FlexibleCard/components/elements/index.js +3 -1
- package/dist/esm/view/FlexibleCard/components/elements/text/index.js +10 -3
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +19 -0
- package/dist/esm/view/FlexibleCard/components/utils.js +11 -0
- package/dist/types/__fixtures__/flexible-ui-data-context.d.ts +3 -0
- package/dist/types/constants.d.ts +54 -1
- package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/index.d.ts +3 -3
- package/dist/types/extractors/flexible/icon/types.d.ts +5 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/flexible-ui-context/types.d.ts +4 -2
- package/dist/types/utils/flexible.d.ts +1 -2
- package/dist/types/utils/token.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +2 -1
- package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +4 -2
- package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,66 +4,111 @@ const extractFileFormatIcon = fileFormat => {
|
|
|
4
4
|
switch (fileFormat) {
|
|
5
5
|
// Generic documents
|
|
6
6
|
case 'folder':
|
|
7
|
-
return
|
|
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
|
|
15
|
+
return {
|
|
16
|
+
icon: IconType.Document,
|
|
17
|
+
label: 'Document'
|
|
18
|
+
};
|
|
13
19
|
|
|
14
20
|
case 'application/pdf':
|
|
15
|
-
return
|
|
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
|
|
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
|
|
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
|
|
42
|
+
return {
|
|
43
|
+
icon: IconType.GoogleDocs,
|
|
44
|
+
label: 'Google Docs'
|
|
45
|
+
};
|
|
28
46
|
|
|
29
47
|
case 'application/vnd.google-apps.form':
|
|
30
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
icon: IconType.GoogleForms,
|
|
50
|
+
label: 'Google Form'
|
|
51
|
+
};
|
|
31
52
|
|
|
32
53
|
case 'application/vnd.google-apps.spreadsheet':
|
|
33
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
icon: IconType.GoogleSheets,
|
|
56
|
+
label: 'Google Sheets'
|
|
57
|
+
};
|
|
34
58
|
|
|
35
59
|
case 'application/vnd.google-apps.presentation':
|
|
36
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
92
|
+
return {
|
|
93
|
+
icon: IconType.Image,
|
|
94
|
+
label: 'Image'
|
|
95
|
+
};
|
|
57
96
|
|
|
58
97
|
case 'image/gif':
|
|
59
|
-
return
|
|
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
|
|
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 @@ const extractFileFormatIcon = fileFormat => {
|
|
|
72
117
|
case 'video/ogg':
|
|
73
118
|
case 'video/x-ms-wmv':
|
|
74
119
|
case 'video/x-msvideo':
|
|
75
|
-
return
|
|
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
|
|
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 @@ const extractFileFormatIcon = fileFormat => {
|
|
|
86
137
|
case 'application/x-7z-compressed':
|
|
87
138
|
case 'application/x-apple-diskimage':
|
|
88
139
|
case 'application/vnd.rar':
|
|
89
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
icon: IconType.Archive,
|
|
142
|
+
label: 'Archive'
|
|
143
|
+
};
|
|
90
144
|
|
|
91
145
|
case 'application/dmg':
|
|
92
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
icon: IconType.Executable,
|
|
148
|
+
label: 'Executable'
|
|
149
|
+
};
|
|
93
150
|
|
|
94
151
|
case 'application/sketch':
|
|
95
|
-
return
|
|
152
|
+
return {
|
|
153
|
+
icon: IconType.Sketch,
|
|
154
|
+
label: 'Sketch'
|
|
155
|
+
};
|
|
96
156
|
|
|
97
157
|
case 'application/octet-stream':
|
|
98
|
-
return
|
|
158
|
+
return {
|
|
159
|
+
icon: IconType.Generic,
|
|
160
|
+
label: 'Binary file'
|
|
161
|
+
};
|
|
99
162
|
|
|
100
163
|
case 'application/invision.prototype':
|
|
101
|
-
return
|
|
164
|
+
return {
|
|
165
|
+
icon: IconType.Generic,
|
|
166
|
+
label: 'Prototype'
|
|
167
|
+
};
|
|
102
168
|
|
|
103
169
|
default:
|
|
104
170
|
return undefined;
|
|
@@ -3,32 +3,59 @@ import { IconType } from '../../../constants';
|
|
|
3
3
|
const extractJiraTaskIcon = (taskType, label = 'Task') => {
|
|
4
4
|
switch (taskType) {
|
|
5
5
|
case 'JiraBug':
|
|
6
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
icon: IconType.Bug,
|
|
8
|
+
label
|
|
9
|
+
};
|
|
7
10
|
|
|
8
11
|
case 'JiraChange':
|
|
9
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
icon: IconType.Change,
|
|
14
|
+
label
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
case 'JiraEpic':
|
|
12
|
-
return
|
|
18
|
+
return {
|
|
19
|
+
icon: IconType.Epic,
|
|
20
|
+
label
|
|
21
|
+
};
|
|
13
22
|
|
|
14
23
|
case 'JiraIncident':
|
|
15
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
icon: IconType.Incident,
|
|
26
|
+
label
|
|
27
|
+
};
|
|
16
28
|
|
|
17
29
|
case 'JiraProblem':
|
|
18
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
icon: IconType.Problem,
|
|
32
|
+
label
|
|
33
|
+
};
|
|
19
34
|
|
|
20
35
|
case 'JiraServiceRequest':
|
|
21
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
icon: IconType.ServiceRequest,
|
|
38
|
+
label
|
|
39
|
+
};
|
|
22
40
|
|
|
23
41
|
case 'JiraStory':
|
|
24
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
icon: IconType.Story,
|
|
44
|
+
label
|
|
45
|
+
};
|
|
25
46
|
|
|
26
47
|
case 'JiraSubTask':
|
|
27
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
icon: IconType.SubTask,
|
|
50
|
+
label
|
|
51
|
+
};
|
|
28
52
|
|
|
29
53
|
case 'JiraTask':
|
|
30
54
|
default:
|
|
31
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
icon: IconType.Task,
|
|
57
|
+
label
|
|
58
|
+
};
|
|
32
59
|
}
|
|
33
60
|
};
|
|
34
61
|
|
|
@@ -15,7 +15,10 @@ const extractTask = (data, label) => {
|
|
|
15
15
|
icon: url
|
|
16
16
|
} = extractTaskType(data) || {};
|
|
17
17
|
const taskType = id === null || id === void 0 ? void 0 : id.split('#').pop();
|
|
18
|
-
const taskIcon = url ?
|
|
18
|
+
const taskIcon = url ? {
|
|
19
|
+
label,
|
|
20
|
+
url
|
|
21
|
+
} : undefined;
|
|
19
22
|
return {
|
|
20
23
|
taskType,
|
|
21
24
|
taskIcon
|
|
@@ -39,7 +42,7 @@ const extractJsonldDataIcon = data => {
|
|
|
39
42
|
const type = extractType(data);
|
|
40
43
|
const urlIcon = extractUrlIcon(data.icon, label);
|
|
41
44
|
const provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
|
|
42
|
-
const providerIcon = extractProviderIcon(
|
|
45
|
+
const providerIcon = extractProviderIcon(data);
|
|
43
46
|
|
|
44
47
|
switch (type) {
|
|
45
48
|
case 'Document':
|
|
@@ -68,25 +71,46 @@ const extractJsonldDataIcon = data => {
|
|
|
68
71
|
taskType,
|
|
69
72
|
taskIcon
|
|
70
73
|
} = extractTask(data);
|
|
71
|
-
return taskType === 'JiraCustomTaskType' ? taskIcon || urlIcon || providerIcon ||
|
|
74
|
+
return taskType === 'JiraCustomTaskType' ? taskIcon || urlIcon || providerIcon || {
|
|
75
|
+
icon: IconType.Task,
|
|
76
|
+
label: taskLabel
|
|
77
|
+
} : extractJiraTaskIcon(taskType, taskLabel);
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
return
|
|
80
|
+
return {
|
|
81
|
+
icon: IconType.Task,
|
|
82
|
+
label: taskLabel
|
|
83
|
+
};
|
|
75
84
|
|
|
76
85
|
case 'atlassian:Project':
|
|
77
|
-
return urlIcon ||
|
|
86
|
+
return urlIcon || {
|
|
87
|
+
icon: IconType.Project,
|
|
88
|
+
label: label || 'Project'
|
|
89
|
+
};
|
|
78
90
|
|
|
79
91
|
case 'atlassian:SourceCodeCommit':
|
|
80
|
-
return
|
|
92
|
+
return {
|
|
93
|
+
icon: IconType.Commit,
|
|
94
|
+
label: label || 'Commit'
|
|
95
|
+
};
|
|
81
96
|
|
|
82
97
|
case 'atlassian:SourceCodePullRequest':
|
|
83
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
icon: IconType.PullRequest,
|
|
100
|
+
label: label || 'Pull request'
|
|
101
|
+
};
|
|
84
102
|
|
|
85
103
|
case 'atlassian:SourceCodeReference':
|
|
86
|
-
return
|
|
104
|
+
return {
|
|
105
|
+
icon: IconType.Branch,
|
|
106
|
+
label: label || 'Reference'
|
|
107
|
+
};
|
|
87
108
|
|
|
88
109
|
case 'atlassian:SourceCodeRepository':
|
|
89
|
-
return
|
|
110
|
+
return {
|
|
111
|
+
icon: IconType.Repo,
|
|
112
|
+
label: label || 'Repository'
|
|
113
|
+
};
|
|
90
114
|
|
|
91
115
|
default:
|
|
92
116
|
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
|
+
const extractProviderIcon = data => {
|
|
7
|
+
if (!data) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const generator = data.generator;
|
|
12
|
+
const provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
|
|
13
|
+
const icon = generator === null || generator === void 0 ? void 0 : generator.icon;
|
|
14
|
+
const label = (generator === null || generator === void 0 ? void 0 : generator.name) || extractTitle(data);
|
|
4
15
|
|
|
5
|
-
const extractProviderIcon = (provider, icon, label) => {
|
|
6
16
|
if (provider === CONFLUENCE_GENERATOR_ID) {
|
|
7
|
-
return
|
|
17
|
+
return {
|
|
18
|
+
icon: IconType.Confluence,
|
|
19
|
+
label: label || 'Confluence'
|
|
20
|
+
};
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
if (provider === JIRA_GENERATOR_ID) {
|
|
11
|
-
return
|
|
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
|
const extractUrlIcon = (icon, label) => {
|
|
4
4
|
const url = icon && extractUrlFromIconJsonLd(icon);
|
|
5
|
-
return url ?
|
|
5
|
+
return url ? {
|
|
6
|
+
label,
|
|
7
|
+
url
|
|
8
|
+
} : undefined;
|
|
6
9
|
};
|
|
7
10
|
|
|
8
11
|
export default extractUrlIcon;
|
|
@@ -4,22 +4,19 @@ import { IconType, SmartLinkStatus } from '../../../constants';
|
|
|
4
4
|
import extractIconRenderer from './extract-icon-renderer';
|
|
5
5
|
export const extractLinkIcon = (response, renderers) => {
|
|
6
6
|
const data = response.data;
|
|
7
|
-
const [icon, label, url] = extractJsonldDataIcon(data) || [];
|
|
8
7
|
const render = extractIconRenderer(data, renderers);
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
label,
|
|
12
|
-
render,
|
|
13
|
-
url
|
|
8
|
+
return { ...extractJsonldDataIcon(data),
|
|
9
|
+
render
|
|
14
10
|
};
|
|
15
11
|
};
|
|
16
12
|
export const extractErrorIcon = (response, status) => {
|
|
17
13
|
// Try to get provider icon first.
|
|
18
14
|
if (response) {
|
|
19
15
|
const data = response.data;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const {
|
|
17
|
+
icon,
|
|
18
|
+
url
|
|
19
|
+
} = extractProviderIcon(data) || {};
|
|
23
20
|
|
|
24
21
|
if (icon || url) {
|
|
25
22
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractLink, extractTitle } from '../common/primitives';
|
|
1
|
+
import { extractLink, extractSummary, extractTitle } from '../common/primitives';
|
|
2
2
|
import { extractLozenge } from '../common/lozenge';
|
|
3
3
|
import { extractLinkIcon } from './icon';
|
|
4
4
|
import { extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount } from './utils';
|
|
@@ -7,6 +7,7 @@ import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
|
7
7
|
import { extractDateUpdated } from '../common/date/extractDateUpdated';
|
|
8
8
|
import { extractDateCreated } from '../common/date/extractDateCreated';
|
|
9
9
|
import extractPriority from './extract-priority';
|
|
10
|
+
import extractProviderIcon from './icon/extract-provider-icon';
|
|
10
11
|
|
|
11
12
|
const extractFlexibleUiContext = (response, renderers) => {
|
|
12
13
|
if (!response) {
|
|
@@ -26,9 +27,12 @@ const extractFlexibleUiContext = (response, renderers) => {
|
|
|
26
27
|
modifiedOn: extractDateUpdated(data),
|
|
27
28
|
priority: extractPriority(data),
|
|
28
29
|
programmingLanguage: extractProgrammingLanguage(data),
|
|
30
|
+
snippet: extractSummary(data) || undefined,
|
|
31
|
+
// Explicitly set here to remove an empty string
|
|
29
32
|
state: extractLozenge(data),
|
|
30
33
|
subscriberCount: extractSubscriberCount(data),
|
|
31
34
|
title: extractTitle(data) || url,
|
|
35
|
+
provider: extractProviderIcon(data),
|
|
32
36
|
url
|
|
33
37
|
};
|
|
34
38
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -13,4 +13,4 @@ export { contentFooterClassName, metadataListClassName, blockCardResolvingViewCl
|
|
|
13
13
|
export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback'; // Flexible UI
|
|
14
14
|
|
|
15
15
|
export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme } from './constants';
|
|
16
|
-
export { MetadataBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|
|
16
|
+
export { MetadataBlock, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import * as Blocks from '../view/FlexibleCard/components/blocks';
|
|
3
3
|
import { TitleBlock } from '../view/FlexibleCard/components/blocks';
|
|
4
4
|
import * as Elements from '../view/FlexibleCard/components/elements';
|
|
5
|
-
export const isFlexibleUiCard =
|
|
6
|
-
if (
|
|
5
|
+
export const isFlexibleUiCard = children => {
|
|
6
|
+
if (children && React.Children.toArray(children).some(child => isFlexibleUiBlock(child))) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -19,5 +19,6 @@ export const tokens = {
|
|
|
19
19
|
elevation: safeToken('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
|
|
20
20
|
errorMessage: safeToken('color.text.disabled', '#6B778C'),
|
|
21
21
|
errorMessageHover: safeToken('color.text.subtle', '#8993A4'),
|
|
22
|
+
snippet: safeToken('color.text', '#172B4D'),
|
|
22
23
|
text: safeToken('color.text.subtlest', '#626F86')
|
|
23
24
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -80,7 +80,7 @@ export function CardWithUrlContent({
|
|
|
80
80
|
throw error;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (isFlexibleUiCard(
|
|
83
|
+
if (isFlexibleUiCard(children)) {
|
|
84
84
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
85
85
|
cardState: state,
|
|
86
86
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
1
|
+
export { default as MetadataBlock } from './metadata-block';
|
|
2
|
+
export { default as SnippetBlock } from './snippet-block';
|
|
3
|
+
export { default as TitleBlock } from './title-block';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Block from '../block';
|
|
4
|
+
import { SmartLinkStatus } from '../../../../../constants';
|
|
5
|
+
import { Snippet } from '../../elements';
|
|
6
|
+
import { getMaxLines } from '../../utils';
|
|
7
|
+
const DEFAULT_MAX_LINES = 3;
|
|
8
|
+
const MAXIMUM_MAX_LINES = 3;
|
|
9
|
+
const MINIMUM_MAX_LINES = 1;
|
|
10
|
+
|
|
11
|
+
const SnippetBlock = ({
|
|
12
|
+
maxLines = DEFAULT_MAX_LINES,
|
|
13
|
+
status = SmartLinkStatus.Fallback,
|
|
14
|
+
testId = 'smart-block-snippet',
|
|
15
|
+
...blockProps
|
|
16
|
+
}) => {
|
|
17
|
+
if (status !== SmartLinkStatus.Resolved) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const snippetMaxLines = getMaxLines(maxLines, DEFAULT_MAX_LINES, MAXIMUM_MAX_LINES, MINIMUM_MAX_LINES);
|
|
22
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
|
|
23
|
+
testId: `${testId}-resolved-view`
|
|
24
|
+
}), /*#__PURE__*/React.createElement(Snippet, {
|
|
25
|
+
maxLines: snippetMaxLines
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default SnippetBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css } from '@emotion/core';
|
|
4
|
-
import { SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
4
|
+
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
5
5
|
import * as Elements from '../elements';
|
|
6
6
|
import * as Actions from '../actions';
|
|
7
7
|
import { isFlexibleUiElement } from '../../../../utils/flexible';
|
|
8
8
|
import ActionGroup from './action-group';
|
|
9
|
-
import ElementGroup from './element-group';
|
|
9
|
+
import ElementGroup from './element-group'; // Determine whether the element can be display as inline/block.
|
|
10
|
+
|
|
11
|
+
export const ElementDisplaySchema = {
|
|
12
|
+
[ElementName.AuthorGroup]: ['inline'],
|
|
13
|
+
[ElementName.CollaboratorGroup]: ['inline'],
|
|
14
|
+
[ElementName.CommentCount]: ['inline'],
|
|
15
|
+
[ElementName.CreatedBy]: ['inline'],
|
|
16
|
+
[ElementName.CreatedOn]: ['inline'],
|
|
17
|
+
[ElementName.LinkIcon]: ['inline'],
|
|
18
|
+
[ElementName.ModifiedBy]: ['inline'],
|
|
19
|
+
[ElementName.ModifiedOn]: ['inline'],
|
|
20
|
+
[ElementName.Priority]: ['inline'],
|
|
21
|
+
[ElementName.ProgrammingLanguage]: ['inline'],
|
|
22
|
+
[ElementName.Snippet]: ['block'],
|
|
23
|
+
[ElementName.State]: ['inline'],
|
|
24
|
+
[ElementName.SubscriberCount]: ['inline'],
|
|
25
|
+
[ElementName.Title]: ['inline'],
|
|
26
|
+
[ElementName.Provider]: ['inline']
|
|
27
|
+
};
|
|
10
28
|
|
|
11
29
|
const getDirectionStyles = direction => {
|
|
12
30
|
switch (direction) {
|
|
@@ -62,6 +80,12 @@ export const getBaseStyles = (direction, size) => css`
|
|
|
62
80
|
|
|
63
81
|
const isActionGroup = node => /*#__PURE__*/React.isValidElement(node) && node.type === ActionGroup;
|
|
64
82
|
|
|
83
|
+
const isElementDisplayValid = (name, display) => {
|
|
84
|
+
var _ElementDisplaySchema, _ElementDisplaySchema2;
|
|
85
|
+
|
|
86
|
+
return (_ElementDisplaySchema = (_ElementDisplaySchema2 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema2 === void 0 ? void 0 : _ElementDisplaySchema2.includes(display)) !== null && _ElementDisplaySchema !== void 0 ? _ElementDisplaySchema : false;
|
|
87
|
+
};
|
|
88
|
+
|
|
65
89
|
const isElementNull = children => {
|
|
66
90
|
return Boolean(children.type() === null);
|
|
67
91
|
};
|
|
@@ -81,7 +105,7 @@ export const renderChildren = (children, size) => React.Children.map(children, c
|
|
|
81
105
|
|
|
82
106
|
return child;
|
|
83
107
|
});
|
|
84
|
-
export const renderElementItems = (items = []) => {
|
|
108
|
+
export const renderElementItems = (items = [], display = 'inline') => {
|
|
85
109
|
const elements = items.reduce((acc, curr, idx) => {
|
|
86
110
|
const {
|
|
87
111
|
name,
|
|
@@ -89,7 +113,7 @@ export const renderElementItems = (items = []) => {
|
|
|
89
113
|
} = curr;
|
|
90
114
|
const Element = Elements[name];
|
|
91
115
|
|
|
92
|
-
if (Element) {
|
|
116
|
+
if (Element && isElementDisplayValid(name, display)) {
|
|
93
117
|
const element = /*#__PURE__*/React.createElement(Element, _extends({
|
|
94
118
|
key: idx
|
|
95
119
|
}, props));
|
|
@@ -217,6 +217,8 @@ const AtlaskitIcon = ({
|
|
|
217
217
|
case IconType.Jira:
|
|
218
218
|
// Logo component has a different prop set from other icon components
|
|
219
219
|
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
220
|
+
"data-testId": testId // Confluence and Jira imports don't have native testId prop
|
|
221
|
+
,
|
|
220
222
|
textColor: N700,
|
|
221
223
|
iconColor: B200,
|
|
222
224
|
iconGradientStart: B400,
|
|
@@ -40,7 +40,7 @@ const messageMapper = {
|
|
|
40
40
|
[IconType.PriorityUndefined]: messages.priority_undefined
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const getFormattedMessageFromIcon = icon => {
|
|
44
44
|
if (icon) {
|
|
45
45
|
const descriptor = messageMapper[icon];
|
|
46
46
|
|
|
@@ -50,8 +50,6 @@ const getFormattedMessageOrLabel = (icon, content) => {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
return content;
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
const renderAtlaskitIcon = (icon, testId) => {
|
|
@@ -79,7 +77,7 @@ const Badge = ({
|
|
|
79
77
|
label,
|
|
80
78
|
testId = 'smart-element-badge'
|
|
81
79
|
}) => {
|
|
82
|
-
const formattedMessageOrLabel =
|
|
80
|
+
const formattedMessageOrLabel = getFormattedMessageFromIcon(icon) || label;
|
|
83
81
|
const badgeIcon = renderAtlaskitIcon(icon, testId) || renderImageIcon(url, testId);
|
|
84
82
|
|
|
85
83
|
if (!formattedMessageOrLabel || !badgeIcon) {
|
|
@@ -13,6 +13,8 @@ export const ModifiedBy = createElement(ElementName.ModifiedBy);
|
|
|
13
13
|
export const ModifiedOn = createElement(ElementName.ModifiedOn);
|
|
14
14
|
export const Priority = createElement(ElementName.Priority);
|
|
15
15
|
export const ProgrammingLanguage = createElement(ElementName.ProgrammingLanguage);
|
|
16
|
+
export const Snippet = createElement(ElementName.Snippet);
|
|
16
17
|
export const State = createElement(ElementName.State);
|
|
17
18
|
export const SubscriberCount = createElement(ElementName.SubscriberCount);
|
|
18
|
-
export const Title = createElement(ElementName.Title);
|
|
19
|
+
export const Title = createElement(ElementName.Title);
|
|
20
|
+
export const Provider = createElement(ElementName.Provider);
|
|
@@ -3,15 +3,18 @@ import React from 'react';
|
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
4
|
import { getFormattedMessage, getTruncateStyles } from '../../utils';
|
|
5
5
|
import { tokens } from '../../../../../utils/token';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
const getStyles = (maxLines, color) => css`
|
|
8
|
+
color: ${color};
|
|
8
9
|
font-size: 0.75rem;
|
|
9
10
|
line-height: 1rem;
|
|
10
|
-
${getTruncateStyles(
|
|
11
|
+
${getTruncateStyles(maxLines)}
|
|
11
12
|
`;
|
|
12
13
|
|
|
13
14
|
const Text = ({
|
|
15
|
+
color = tokens.text,
|
|
14
16
|
content,
|
|
17
|
+
maxLines = 1,
|
|
15
18
|
message,
|
|
16
19
|
testId = 'smart-element-text'
|
|
17
20
|
}) => {
|
|
@@ -20,7 +23,7 @@ const Text = ({
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
return jsx("span", {
|
|
23
|
-
css:
|
|
26
|
+
css: getStyles(maxLines, color),
|
|
24
27
|
"data-smart-element-text": true,
|
|
25
28
|
"data-testid": testId
|
|
26
29
|
}, getFormattedMessage(message) || content);
|