@atlaskit/smart-card 19.1.16 → 19.1.19
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 +26 -0
- package/dist/cjs/constants.js +2 -1
- package/dist/cjs/extractors/block/index.js +2 -1
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +2 -1
- package/dist/cjs/extractors/flexible/index.js +3 -0
- package/dist/cjs/extractors/flexible/latest-commit/index.js +21 -0
- package/dist/cjs/i18n/cs.js +29 -115
- package/dist/cjs/i18n/da.js +31 -116
- package/dist/cjs/i18n/de.js +30 -116
- package/dist/cjs/i18n/en.js +29 -115
- package/dist/cjs/i18n/en_GB.js +29 -115
- package/dist/cjs/i18n/en_ZZ.js +10 -129
- package/dist/cjs/i18n/es.js +29 -115
- package/dist/cjs/i18n/fi.js +29 -115
- package/dist/cjs/i18n/fr.js +30 -116
- package/dist/cjs/i18n/hu.js +30 -116
- package/dist/cjs/i18n/it.js +29 -115
- package/dist/cjs/i18n/ja.js +29 -115
- package/dist/cjs/i18n/ko.js +29 -115
- package/dist/cjs/i18n/nb.js +30 -116
- package/dist/cjs/i18n/nl.js +29 -115
- package/dist/cjs/i18n/pl.js +30 -116
- package/dist/cjs/i18n/pt_BR.js +29 -115
- package/dist/cjs/i18n/ru.js +30 -116
- package/dist/cjs/i18n/sv.js +29 -115
- package/dist/cjs/i18n/th.js +29 -115
- package/dist/cjs/i18n/tr.js +30 -116
- package/dist/cjs/i18n/uk.js +29 -115
- package/dist/cjs/i18n/vi.js +29 -115
- package/dist/cjs/i18n/zh.js +30 -116
- package/dist/cjs/i18n/zh_TW.js +29 -115
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +12 -12
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +2 -1
- package/dist/cjs/utils/analytics/analytics.js +8 -4
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component-lazy/LazyFallback.js +4 -2
- package/dist/cjs/view/CardWithUrl/loader.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/index.js +8 -2
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +6 -0
- package/dist/cjs/view/HoverCard/components/hover-card-content.js +125 -0
- package/dist/cjs/view/HoverCard/index.js +22 -89
- package/dist/cjs/view/HoverCard/utils.js +3 -1
- package/dist/cjs/view/LinkView/index.js +1 -1
- package/dist/es2019/constants.js +2 -1
- package/dist/es2019/extractors/block/index.js +2 -1
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/es2019/extractors/flexible/index.js +2 -0
- package/dist/es2019/extractors/flexible/latest-commit/index.js +12 -0
- package/dist/es2019/i18n/cs.js +29 -115
- package/dist/es2019/i18n/da.js +31 -116
- package/dist/es2019/i18n/de.js +30 -116
- package/dist/es2019/i18n/en.js +29 -115
- package/dist/es2019/i18n/en_GB.js +29 -115
- package/dist/es2019/i18n/en_ZZ.js +10 -129
- package/dist/es2019/i18n/es.js +29 -115
- package/dist/es2019/i18n/fi.js +29 -115
- package/dist/es2019/i18n/fr.js +30 -116
- package/dist/es2019/i18n/hu.js +30 -116
- package/dist/es2019/i18n/it.js +29 -115
- package/dist/es2019/i18n/ja.js +29 -115
- package/dist/es2019/i18n/ko.js +29 -115
- package/dist/es2019/i18n/nb.js +30 -116
- package/dist/es2019/i18n/nl.js +29 -115
- package/dist/es2019/i18n/pl.js +30 -116
- package/dist/es2019/i18n/pt_BR.js +29 -115
- package/dist/es2019/i18n/ru.js +30 -116
- package/dist/es2019/i18n/sv.js +29 -115
- package/dist/es2019/i18n/th.js +29 -115
- package/dist/es2019/i18n/tr.js +30 -116
- package/dist/es2019/i18n/uk.js +29 -115
- package/dist/es2019/i18n/vi.js +29 -115
- package/dist/es2019/i18n/zh.js +30 -116
- package/dist/es2019/i18n/zh_TW.js +29 -115
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +4 -4
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +2 -1
- package/dist/es2019/utils/analytics/analytics.js +8 -4
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component-lazy/LazyFallback.js +13 -9
- package/dist/es2019/view/CardWithUrl/loader.js +4 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/elements/index.js +5 -0
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +7 -0
- package/dist/es2019/view/HoverCard/components/hover-card-content.js +85 -0
- package/dist/es2019/view/HoverCard/index.js +23 -78
- package/dist/es2019/view/HoverCard/utils.js +1 -0
- package/dist/es2019/view/LinkView/index.js +1 -1
- package/dist/esm/constants.js +2 -1
- package/dist/esm/extractors/block/index.js +2 -1
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +2 -1
- package/dist/esm/extractors/flexible/index.js +2 -0
- package/dist/esm/extractors/flexible/latest-commit/index.js +12 -0
- package/dist/esm/i18n/cs.js +29 -115
- package/dist/esm/i18n/da.js +31 -116
- package/dist/esm/i18n/de.js +30 -116
- package/dist/esm/i18n/en.js +29 -115
- package/dist/esm/i18n/en_GB.js +29 -115
- package/dist/esm/i18n/en_ZZ.js +10 -129
- package/dist/esm/i18n/es.js +29 -115
- package/dist/esm/i18n/fi.js +29 -115
- package/dist/esm/i18n/fr.js +30 -116
- package/dist/esm/i18n/hu.js +30 -116
- package/dist/esm/i18n/it.js +29 -115
- package/dist/esm/i18n/ja.js +29 -115
- package/dist/esm/i18n/ko.js +29 -115
- package/dist/esm/i18n/nb.js +30 -116
- package/dist/esm/i18n/nl.js +29 -115
- package/dist/esm/i18n/pl.js +30 -116
- package/dist/esm/i18n/pt_BR.js +29 -115
- package/dist/esm/i18n/ru.js +30 -116
- package/dist/esm/i18n/sv.js +29 -115
- package/dist/esm/i18n/th.js +29 -115
- package/dist/esm/i18n/tr.js +30 -116
- package/dist/esm/i18n/uk.js +29 -115
- package/dist/esm/i18n/vi.js +29 -115
- package/dist/esm/i18n/zh.js +30 -116
- package/dist/esm/i18n/zh_TW.js +29 -115
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +12 -12
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +2 -1
- package/dist/esm/utils/analytics/analytics.js +8 -4
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component-lazy/LazyFallback.js +4 -2
- package/dist/esm/view/CardWithUrl/loader.js +4 -2
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/index.js +5 -0
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +6 -0
- package/dist/esm/view/HoverCard/components/hover-card-content.js +99 -0
- package/dist/esm/view/HoverCard/index.js +25 -87
- package/dist/esm/view/HoverCard/utils.js +1 -0
- package/dist/esm/view/LinkView/index.js +1 -1
- package/dist/types/constants.d.ts +3 -2
- package/dist/types/extractors/block/types.d.ts +2 -0
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +91 -0
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +2 -1
- package/dist/types/extractors/flexible/latest-commit/index.d.ts +2 -0
- package/dist/types/i18n/cs.d.ts +28 -114
- package/dist/types/i18n/da.d.ts +28 -113
- package/dist/types/i18n/de.d.ts +28 -114
- package/dist/types/i18n/en.d.ts +28 -114
- package/dist/types/i18n/en_GB.d.ts +28 -114
- package/dist/types/i18n/en_ZZ.d.ts +9 -128
- package/dist/types/i18n/es.d.ts +28 -114
- package/dist/types/i18n/fi.d.ts +28 -114
- package/dist/types/i18n/fr.d.ts +28 -114
- package/dist/types/i18n/hu.d.ts +28 -114
- package/dist/types/i18n/it.d.ts +28 -114
- package/dist/types/i18n/ja.d.ts +28 -114
- package/dist/types/i18n/ko.d.ts +28 -114
- package/dist/types/i18n/nb.d.ts +28 -114
- package/dist/types/i18n/nl.d.ts +28 -114
- package/dist/types/i18n/pl.d.ts +28 -114
- package/dist/types/i18n/pt_BR.d.ts +28 -114
- package/dist/types/i18n/ru.d.ts +28 -114
- package/dist/types/i18n/sv.d.ts +28 -114
- package/dist/types/i18n/th.d.ts +28 -114
- package/dist/types/i18n/tr.d.ts +28 -114
- package/dist/types/i18n/uk.d.ts +28 -114
- package/dist/types/i18n/vi.d.ts +28 -114
- package/dist/types/i18n/zh.d.ts +28 -114
- package/dist/types/i18n/zh_TW.d.ts +28 -114
- package/dist/types/state/actions/index.d.ts +2 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -2
- package/dist/types/state/flexible-ui-context/types.d.ts +4 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +3 -3
- package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +2 -2
- package/dist/types/utils/analytics/analytics.d.ts +4 -4
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/Card/types.d.ts +1 -0
- package/dist/types/view/CardWithUrl/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/elements/index.d.ts +4 -0
- package/dist/types/view/HoverCard/components/hover-card-content.d.ts +4 -0
- package/dist/types/view/HoverCard/types.d.ts +12 -0
- package/dist/types/view/HoverCard/utils.d.ts +1 -0
- package/dist/types/view/LinkView/index.d.ts +4 -1
- package/package.json +3 -3
|
@@ -190,12 +190,13 @@ export const uiCardClickedEvent = (id, display, status, definitionId, extensionK
|
|
|
190
190
|
destinationProduct
|
|
191
191
|
}
|
|
192
192
|
});
|
|
193
|
-
export const uiActionClickedEvent = (actionType, extensionKey, display) => ({
|
|
193
|
+
export const uiActionClickedEvent = (id, actionType, extensionKey, display) => ({
|
|
194
194
|
action: 'clicked',
|
|
195
195
|
actionSubject: 'button',
|
|
196
196
|
actionSubjectId: uiActionSubjectIds[actionType],
|
|
197
197
|
eventType: 'ui',
|
|
198
198
|
attributes: { ...context,
|
|
199
|
+
id,
|
|
199
200
|
display,
|
|
200
201
|
extensionKey: extensionKey || '',
|
|
201
202
|
actionType: actionType
|
|
@@ -240,22 +241,24 @@ export const uiRenderFailedEvent = (display, error, errorInfo) => ({
|
|
|
240
241
|
display
|
|
241
242
|
}
|
|
242
243
|
});
|
|
243
|
-
export const uiHoverCardViewedEvent = (previewDisplay, definitionId, extensionKey, previewInvokeMethod) => ({
|
|
244
|
+
export const uiHoverCardViewedEvent = (id, previewDisplay, definitionId, extensionKey, previewInvokeMethod) => ({
|
|
244
245
|
action: 'viewed',
|
|
245
246
|
actionSubject: 'hoverCard',
|
|
246
247
|
eventType: 'ui',
|
|
247
248
|
attributes: { ...context,
|
|
249
|
+
id,
|
|
248
250
|
definitionId: definitionId || '',
|
|
249
251
|
extensionKey: extensionKey || '',
|
|
250
252
|
previewDisplay,
|
|
251
253
|
previewInvokeMethod
|
|
252
254
|
}
|
|
253
255
|
});
|
|
254
|
-
export const uiHoverCardDismissedEvent = (previewDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod) => ({
|
|
256
|
+
export const uiHoverCardDismissedEvent = (id, previewDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod) => ({
|
|
255
257
|
action: 'dismissed',
|
|
256
258
|
actionSubject: 'hoverCard',
|
|
257
259
|
eventType: 'ui',
|
|
258
260
|
attributes: { ...context,
|
|
261
|
+
id,
|
|
259
262
|
definitionId: definitionId || '',
|
|
260
263
|
extensionKey: extensionKey || '',
|
|
261
264
|
hoverTime,
|
|
@@ -263,12 +266,13 @@ export const uiHoverCardDismissedEvent = (previewDisplay, hoverTime, definitionI
|
|
|
263
266
|
previewInvokeMethod
|
|
264
267
|
}
|
|
265
268
|
});
|
|
266
|
-
export const uiHoverCardOpenLinkClickedEvent = (previewDisplay, definitionId, extensionKey, previewInvokeMethod) => ({
|
|
269
|
+
export const uiHoverCardOpenLinkClickedEvent = (id, previewDisplay, definitionId, extensionKey, previewInvokeMethod) => ({
|
|
267
270
|
action: 'clicked',
|
|
268
271
|
actionSubject: 'button',
|
|
269
272
|
actionSubjectId: 'shortcutGoToLink',
|
|
270
273
|
eventType: 'ui',
|
|
271
274
|
attributes: { ...context,
|
|
275
|
+
id,
|
|
272
276
|
definitionId: definitionId || '',
|
|
273
277
|
extensionKey: extensionKey || '',
|
|
274
278
|
previewDisplay,
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,12 +3,16 @@ import { CardLinkView } from '../../../view/LinkView';
|
|
|
3
3
|
export const loadingPlaceholderClassName = 'smart-link-loading-placeholder';
|
|
4
4
|
export const LoadingCardLink = ({
|
|
5
5
|
isSelected,
|
|
6
|
-
url
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
url,
|
|
7
|
+
placeholder
|
|
8
|
+
}) => {
|
|
9
|
+
return /*#__PURE__*/React.createElement(CardLinkView, {
|
|
10
|
+
key: 'lazy-render-key',
|
|
11
|
+
testId: 'lazy-render-placeholder',
|
|
12
|
+
"data-trello-do-not-use-override": "lazy-render-placeholder-trello",
|
|
13
|
+
isSelected: isSelected,
|
|
14
|
+
link: url,
|
|
15
|
+
className: loadingPlaceholderClassName,
|
|
16
|
+
placeholder: placeholder
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -35,7 +35,8 @@ export function CardWithURLRenderer(props) {
|
|
|
35
35
|
children,
|
|
36
36
|
ui,
|
|
37
37
|
showHoverPreview,
|
|
38
|
-
analyticsEvents
|
|
38
|
+
analyticsEvents,
|
|
39
|
+
placeholder
|
|
39
40
|
} = props; // Wrapper around analytics.
|
|
40
41
|
|
|
41
42
|
const dispatchAnalytics = useCallback(analyticsPayload => {
|
|
@@ -96,7 +97,8 @@ export function CardWithURLRenderer(props) {
|
|
|
96
97
|
inlinePreloaderStyle,
|
|
97
98
|
ui,
|
|
98
99
|
showHoverPreview,
|
|
99
|
-
analyticsEvents
|
|
100
|
+
analyticsEvents,
|
|
101
|
+
placeholder
|
|
100
102
|
};
|
|
101
103
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
102
104
|
FallbackComponent: ErrorFallback,
|
|
@@ -26,7 +26,8 @@ export const ElementDisplaySchema = {
|
|
|
26
26
|
[ElementName.State]: ['inline'],
|
|
27
27
|
[ElementName.SubscriberCount]: ['inline'],
|
|
28
28
|
[ElementName.Title]: ['inline'],
|
|
29
|
-
[ElementName.Provider]: ['inline']
|
|
29
|
+
[ElementName.Provider]: ['inline'],
|
|
30
|
+
[ElementName.LatestCommit]: ['inline']
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
const getDirectionStyles = direction => {
|
|
@@ -51,6 +51,11 @@ export const CreatedBy = createElement(ElementName.CreatedBy);
|
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
export const CreatedOn = createElement(ElementName.CreatedOn);
|
|
54
|
+
/**
|
|
55
|
+
* Creates an element that contains Last Commit hash
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
export const LatestCommit = createElement(ElementName.LatestCommit);
|
|
54
59
|
/**
|
|
55
60
|
* Creates a LinkIcon Icon element using the data from LinkIcon in the Flexible UI Context.
|
|
56
61
|
* @see Icon
|
|
@@ -95,6 +95,12 @@ const elementMappings = {
|
|
|
95
95
|
},
|
|
96
96
|
[ElementName.Provider]: {
|
|
97
97
|
component: Badge
|
|
98
|
+
},
|
|
99
|
+
[ElementName.LatestCommit]: {
|
|
100
|
+
component: Badge,
|
|
101
|
+
props: {
|
|
102
|
+
icon: IconType.Commit
|
|
103
|
+
}
|
|
98
104
|
}
|
|
99
105
|
};
|
|
100
106
|
|
|
@@ -122,6 +128,7 @@ const getData = (elementName, contextKey, context) => {
|
|
|
122
128
|
case ElementName.VoteCount:
|
|
123
129
|
case ElementName.ProgrammingLanguage:
|
|
124
130
|
case ElementName.SubscriberCount:
|
|
131
|
+
case ElementName.LatestCommit:
|
|
125
132
|
return toBadgeProps(data);
|
|
126
133
|
|
|
127
134
|
case ElementName.CreatedBy:
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
3
|
+
import { getSimulatedMetadata, HOVER_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
4
|
+
import extractPreview from '../../../extractors/flexible/extract-preview';
|
|
5
|
+
import { ActionName, SmartLinkSize, SmartLinkTheme } from '../../../constants';
|
|
6
|
+
import FlexibleCard from '../../FlexibleCard';
|
|
7
|
+
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
8
|
+
import { isSpecialEvent } from '../../../utils';
|
|
9
|
+
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
10
|
+
import { getExtensionKey } from '../../../state/helpers';
|
|
11
|
+
const flexibleUiOptions = {
|
|
12
|
+
hideElevation: true,
|
|
13
|
+
size: SmartLinkSize.Large,
|
|
14
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
15
|
+
theme: SmartLinkTheme.Black
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getOpenAction = (url, analytics) => ({
|
|
19
|
+
name: ActionName.CustomAction,
|
|
20
|
+
icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
21
|
+
label: "open in new tab",
|
|
22
|
+
size: "medium"
|
|
23
|
+
}),
|
|
24
|
+
iconPosition: 'before',
|
|
25
|
+
onClick: () => {
|
|
26
|
+
window.open(url, '_blank');
|
|
27
|
+
analytics.ui.hoverCardOpenLinkClickedEvent('card');
|
|
28
|
+
},
|
|
29
|
+
testId: 'hover-card-open-button'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const toFooterActions = cardActions => cardActions.map(action => ({
|
|
33
|
+
content: action.text,
|
|
34
|
+
name: ActionName.CustomAction,
|
|
35
|
+
onClick: () => action.invoke(),
|
|
36
|
+
testId: action.id
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const HoverCardContent = ({
|
|
40
|
+
analytics,
|
|
41
|
+
cardActions = [],
|
|
42
|
+
cardState,
|
|
43
|
+
onResolve,
|
|
44
|
+
renderers,
|
|
45
|
+
url
|
|
46
|
+
}) => {
|
|
47
|
+
var _cardState$details;
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
// Since hover preview only render on resolved status,
|
|
51
|
+
// there is no need to check for statuses.
|
|
52
|
+
analytics.ui.renderSuccessEvent(HOVER_CARD_ANALYTICS_DISPLAY, cardState.status);
|
|
53
|
+
}, [analytics.ui, cardState.status]);
|
|
54
|
+
const extensionKey = useMemo(() => getExtensionKey(cardState.details), [cardState.details]);
|
|
55
|
+
const onClick = useCallback(event => {
|
|
56
|
+
const isModifierKeyPressed = isSpecialEvent(event);
|
|
57
|
+
analytics.ui.cardClickedEvent(undefined, HOVER_CARD_ANALYTICS_DISPLAY, cardState.status, undefined, undefined, isModifierKeyPressed);
|
|
58
|
+
}, [cardState.status, analytics.ui]);
|
|
59
|
+
const titleActions = useMemo(() => [getOpenAction(url, analytics)], [url, analytics]);
|
|
60
|
+
const footerActions = useMemo(() => toFooterActions(cardActions), [cardActions]); //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
primary,
|
|
64
|
+
secondary
|
|
65
|
+
} = extractMetadata(getSimulatedMetadata(extensionKey));
|
|
66
|
+
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
67
|
+
const body = data && extractPreview(data) ? /*#__PURE__*/React.createElement(PreviewBlock, null) : /*#__PURE__*/React.createElement(SnippetBlock, null);
|
|
68
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
69
|
+
cardState: cardState,
|
|
70
|
+
onClick: onClick,
|
|
71
|
+
onResolve: onResolve,
|
|
72
|
+
renderers: renderers,
|
|
73
|
+
ui: flexibleUiOptions,
|
|
74
|
+
url: url
|
|
75
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
76
|
+
actions: titleActions
|
|
77
|
+
}), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
78
|
+
primary: primary,
|
|
79
|
+
secondary: secondary
|
|
80
|
+
}), body, /*#__PURE__*/React.createElement(FooterBlock, {
|
|
81
|
+
actions: footerActions
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default HoverCardContent;
|
|
@@ -2,22 +2,17 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { jsx } from '@emotion/core';
|
|
5
|
-
import React, { useCallback, useRef
|
|
6
|
-
import { TitleBlock, SnippetBlock, FooterBlock, MetadataBlock, PreviewBlock } from '../FlexibleCard/components/blocks';
|
|
7
|
-
import { Card } from '../Card';
|
|
5
|
+
import React, { useCallback, useRef } from 'react';
|
|
8
6
|
import Popup from '@atlaskit/popup';
|
|
9
|
-
import { SmartLinkSize, ActionName, SmartLinkTheme } from '../../constants';
|
|
10
7
|
import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
|
|
11
8
|
import { HoverCardContainer } from './styled';
|
|
12
|
-
import
|
|
13
|
-
import { withAnalyticsEvents, withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
9
|
+
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
10
|
import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
15
11
|
import { useSmartCardState as useLinkState } from '../../state/store';
|
|
16
12
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import extractPreview from '../../extractors/flexible/extract-preview';
|
|
13
|
+
import { useSmartLinkRenderers } from '../../state/renderers';
|
|
14
|
+
import HoverCardContent from './components/hover-card-content';
|
|
15
|
+
import { HOVER_CARD_ANALYTICS_DISPLAY } from './utils';
|
|
21
16
|
export const HoverCardComponent = ({
|
|
22
17
|
children,
|
|
23
18
|
id,
|
|
@@ -32,10 +27,9 @@ export const HoverCardComponent = ({
|
|
|
32
27
|
const fadeOutTimeoutId = useRef();
|
|
33
28
|
const fadeInTimeoutId = useRef();
|
|
34
29
|
const cardOpenTime = useRef();
|
|
30
|
+
const renderers = useSmartLinkRenderers();
|
|
35
31
|
const linkState = useLinkState(url);
|
|
36
32
|
const analytics = useSmartLinkAnalytics(url, analyticsHandler, id);
|
|
37
|
-
const extensionKey = useMemo(() => getExtensionKey(linkState.details), [linkState]);
|
|
38
|
-
const definitionId = useMemo(() => getDefinitionId(linkState.details), [linkState]);
|
|
39
33
|
const initHideCard = useCallback(() => {
|
|
40
34
|
if (fadeInTimeoutId.current) {
|
|
41
35
|
clearTimeout(fadeInTimeoutId.current);
|
|
@@ -45,12 +39,12 @@ export const HoverCardComponent = ({
|
|
|
45
39
|
//Check its previously open to avoid firing events when moving between the child and hover card components
|
|
46
40
|
if (isOpen === true && cardOpenTime.current) {
|
|
47
41
|
const hoverTime = Date.now() - cardOpenTime.current;
|
|
48
|
-
analytics.ui.hoverCardDismissedEvent('card', hoverTime,
|
|
42
|
+
analytics.ui.hoverCardDismissedEvent('card', hoverTime, 'mouse_hover');
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
setIsOpen(false);
|
|
52
46
|
}, delay);
|
|
53
|
-
}, [delay, isOpen,
|
|
47
|
+
}, [delay, isOpen, analytics.ui]);
|
|
54
48
|
const initShowCard = useCallback(() => {
|
|
55
49
|
if (fadeOutTimeoutId.current) {
|
|
56
50
|
clearTimeout(fadeOutTimeoutId.current);
|
|
@@ -60,73 +54,17 @@ export const HoverCardComponent = ({
|
|
|
60
54
|
//Check if its previously closed to avoid firing events when moving between the child and hover card components
|
|
61
55
|
if (isOpen === false) {
|
|
62
56
|
cardOpenTime.current = Date.now();
|
|
63
|
-
analytics.ui.hoverCardViewedEvent('card',
|
|
57
|
+
analytics.ui.hoverCardViewedEvent('card', 'mouse_hover');
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
setIsOpen(true);
|
|
67
61
|
}, delay);
|
|
68
|
-
}, [delay, isOpen,
|
|
62
|
+
}, [delay, isOpen, analytics.ui]);
|
|
69
63
|
const linkActions = useSmartLinkActions({
|
|
70
64
|
url,
|
|
71
|
-
appearance:
|
|
65
|
+
appearance: HOVER_CARD_ANALYTICS_DISPLAY,
|
|
72
66
|
analyticsHandler
|
|
73
67
|
});
|
|
74
|
-
const smartlinkActions = useMemo(() => linkActions.map(action => ({
|
|
75
|
-
content: action.text,
|
|
76
|
-
name: ActionName.CustomAction,
|
|
77
|
-
onClick: () => action.invoke(),
|
|
78
|
-
testId: action.id
|
|
79
|
-
})), [linkActions]);
|
|
80
|
-
const openAction = useMemo(() => {
|
|
81
|
-
return {
|
|
82
|
-
name: ActionName.CustomAction,
|
|
83
|
-
icon: jsx(ShortcutIcon, {
|
|
84
|
-
label: "open in new tab",
|
|
85
|
-
size: "medium"
|
|
86
|
-
}),
|
|
87
|
-
iconPosition: 'before',
|
|
88
|
-
onClick: () => {
|
|
89
|
-
window.open(url, '_blank');
|
|
90
|
-
analytics.ui.hoverCardOpenLinkClickedEvent('card', definitionId, extensionKey);
|
|
91
|
-
},
|
|
92
|
-
testId: 'hover-card-open-button'
|
|
93
|
-
};
|
|
94
|
-
}, [url, definitionId, extensionKey, analytics]);
|
|
95
|
-
|
|
96
|
-
const CardComponent = ({
|
|
97
|
-
update
|
|
98
|
-
}) => {
|
|
99
|
-
var _linkState$details;
|
|
100
|
-
|
|
101
|
-
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
102
|
-
const metadataElements = extractMetadata(getSimulatedMetadata(extensionKey));
|
|
103
|
-
const linkData = (_linkState$details = linkState.details) === null || _linkState$details === void 0 ? void 0 : _linkState$details.data;
|
|
104
|
-
const content = extractPreview(linkData) ? jsx(PreviewBlock, null) : jsx(SnippetBlock, null);
|
|
105
|
-
return jsx("div", {
|
|
106
|
-
onMouseEnter: initShowCard,
|
|
107
|
-
onMouseLeave: initHideCard,
|
|
108
|
-
css: HoverCardContainer
|
|
109
|
-
}, jsx(Card, {
|
|
110
|
-
id: id,
|
|
111
|
-
appearance: "block",
|
|
112
|
-
url: url,
|
|
113
|
-
ui: {
|
|
114
|
-
hideElevation: true,
|
|
115
|
-
size: SmartLinkSize.Large,
|
|
116
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
117
|
-
theme: SmartLinkTheme.Black
|
|
118
|
-
},
|
|
119
|
-
onResolve: update
|
|
120
|
-
}, jsx(TitleBlock, {
|
|
121
|
-
actions: [openAction]
|
|
122
|
-
}), jsx(MetadataBlock, {
|
|
123
|
-
primary: metadataElements.primary,
|
|
124
|
-
secondary: metadataElements.secondary
|
|
125
|
-
}), content, jsx(FooterBlock, {
|
|
126
|
-
actions: smartlinkActions
|
|
127
|
-
})));
|
|
128
|
-
};
|
|
129
|
-
|
|
130
68
|
const onClose = useCallback(() => setIsOpen(false), []);
|
|
131
69
|
return jsx(Popup, {
|
|
132
70
|
testId: "hover-card",
|
|
@@ -135,11 +73,18 @@ export const HoverCardComponent = ({
|
|
|
135
73
|
placement: "bottom-start",
|
|
136
74
|
content: ({
|
|
137
75
|
update
|
|
138
|
-
}) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
},
|
|
76
|
+
}) => jsx("div", {
|
|
77
|
+
onMouseEnter: initShowCard,
|
|
78
|
+
onMouseLeave: initHideCard,
|
|
79
|
+
css: HoverCardContainer
|
|
80
|
+
}, jsx(HoverCardContent, {
|
|
81
|
+
analytics: analytics,
|
|
82
|
+
cardActions: linkActions,
|
|
83
|
+
cardState: linkState,
|
|
84
|
+
onResolve: update,
|
|
85
|
+
renderers: renderers,
|
|
86
|
+
url: url
|
|
87
|
+
})),
|
|
143
88
|
trigger: triggerProps => jsx("span", _extends({}, triggerProps, {
|
|
144
89
|
onMouseEnter: initShowCard,
|
|
145
90
|
onMouseLeave: initHideCard
|
package/dist/esm/constants.js
CHANGED
|
@@ -81,7 +81,7 @@ export var SmartLinkWidth;
|
|
|
81
81
|
/**
|
|
82
82
|
* Flexible UI element name - each reflecting the link data its represented.
|
|
83
83
|
* When adding an element...
|
|
84
|
-
* 1) Create base element if it doesn't already
|
|
84
|
+
* 1) Create base element if it doesn't already exist.
|
|
85
85
|
* Base element are inside src/view/FlexibleCard/components/elements.
|
|
86
86
|
* E.g. Badge,DateTime, Icon, Lozenge, etc.
|
|
87
87
|
* 2) Update FlexibleUiContext with the new prop for data representing
|
|
@@ -125,6 +125,7 @@ export var ElementName;
|
|
|
125
125
|
ElementName["Title"] = "Title";
|
|
126
126
|
ElementName["ViewCount"] = "ViewCount";
|
|
127
127
|
ElementName["VoteCount"] = "VoteCount";
|
|
128
|
+
ElementName["LatestCommit"] = "LatestCommit";
|
|
128
129
|
})(ElementName || (ElementName = {}));
|
|
129
130
|
|
|
130
131
|
export var ActionName;
|
|
@@ -45,9 +45,10 @@ export var extractBlockActions = function extractBlockActions(props, jsonLd, opt
|
|
|
45
45
|
var handleInvoke = opts.handleInvoke,
|
|
46
46
|
handleAnalytics = opts.handleAnalytics,
|
|
47
47
|
extensionKey = opts.extensionKey,
|
|
48
|
+
source = opts.source,
|
|
48
49
|
testId = opts.testId;
|
|
49
50
|
var actions = extractActions(jsonLd, handleInvoke);
|
|
50
|
-
var previewAction = extractPreviewAction(extensionKey, props, jsonLd, handleInvoke, handleAnalytics, testId, platform); // The previewAction should always be the last action
|
|
51
|
+
var previewAction = extractPreviewAction(extensionKey, props, jsonLd, handleInvoke, handleAnalytics, testId, platform, source); // The previewAction should always be the last action
|
|
51
52
|
|
|
52
53
|
if (previewAction) {
|
|
53
54
|
actions.push(previewAction);
|
|
@@ -60,6 +60,7 @@ export var extractPreviewAction = function extractPreviewAction() {
|
|
|
60
60
|
var handleAnalytics = arguments.length > 4 ? arguments[4] : undefined;
|
|
61
61
|
var testId = arguments.length > 5 ? arguments[5] : undefined;
|
|
62
62
|
var platform = arguments.length > 6 ? arguments[6] : undefined;
|
|
63
|
+
var source = arguments.length > 7 ? arguments[7] : undefined;
|
|
63
64
|
// Extract metadata from view props & raw JSON-LD.
|
|
64
65
|
var metadataFromJsonLd = getMetadataFromJsonLd(jsonLd, platform);
|
|
65
66
|
var metadataFromViewProps = getMetadataFromResolvedProps(viewProps);
|
|
@@ -87,7 +88,7 @@ export var extractPreviewAction = function extractPreviewAction() {
|
|
|
87
88
|
})); // Setup props to go through proper Redux 'invocation' flow
|
|
88
89
|
// for analytics, further state management if required in future.
|
|
89
90
|
|
|
90
|
-
var previewActionProps = getInvokeOpts(key, 'PreviewAction', 'block'); // - Promise invoked by the action invocation handler; open preview.
|
|
91
|
+
var previewActionProps = getInvokeOpts(key, 'PreviewAction', source !== null && source !== void 0 ? source : 'block'); // - Promise invoked by the action invocation handler; open preview.
|
|
91
92
|
|
|
92
93
|
previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
|
|
93
94
|
|
|
@@ -9,6 +9,7 @@ import { extractDateCreated } from '../common/date/extractDateCreated';
|
|
|
9
9
|
import extractPriority from './extract-priority';
|
|
10
10
|
import extractProviderIcon from './icon/extract-provider-icon';
|
|
11
11
|
import extractPreview from './extract-preview';
|
|
12
|
+
import { extractLatestCommit } from './latest-commit';
|
|
12
13
|
|
|
13
14
|
var extractFlexibleUiContext = function extractFlexibleUiContext(response, renderers) {
|
|
14
15
|
if (!response) {
|
|
@@ -38,6 +39,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
|
|
|
38
39
|
subscriberCount: extractSubscriberCount(data),
|
|
39
40
|
title: extractTitle(data) || url,
|
|
40
41
|
provider: extractProviderIcon(data),
|
|
42
|
+
latestCommit: extractLatestCommit(data),
|
|
41
43
|
url: url
|
|
42
44
|
};
|
|
43
45
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var extractLatestCommit = function extractLatestCommit(jsonLd) {
|
|
2
|
+
var latestCommit = jsonLd['atlassian:latestCommit'];
|
|
3
|
+
|
|
4
|
+
if (typeof latestCommit === 'string') {
|
|
5
|
+
return latestCommit;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (latestCommit) {
|
|
9
|
+
//todo: change the properties to latestCommit.hash when BE is ready
|
|
10
|
+
return latestCommit ? latestCommit.name : undefined;
|
|
11
|
+
}
|
|
12
|
+
};
|