@atlaskit/smart-card 19.1.20 → 19.1.23
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 +21 -0
- package/dist/cjs/state/actions/index.js +11 -4
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +7 -3
- package/dist/cjs/state/helpers.js +26 -4
- package/dist/cjs/utils/analytics/analytics.js +3 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +19 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +19 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -25
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +5 -3
- package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +4 -4
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/utils.js +19 -2
- package/dist/cjs/view/HoverCard/components/hover-card-content.js +2 -1
- package/dist/cjs/view/HoverCard/utils.js +6 -3
- package/dist/es2019/state/actions/index.js +12 -6
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +6 -3
- package/dist/es2019/state/helpers.js +25 -3
- package/dist/es2019/utils/analytics/analytics.js +3 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +5 -3
- package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +48 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +16 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -33
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +6 -1
- package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +7 -2
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/utils.js +17 -1
- package/dist/es2019/view/HoverCard/components/hover-card-content.js +2 -1
- package/dist/es2019/view/HoverCard/utils.js +4 -3
- package/dist/esm/state/actions/index.js +12 -5
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +8 -4
- package/dist/esm/state/helpers.js +19 -3
- package/dist/esm/utils/analytics/analytics.js +3 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +5 -3
- package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +19 -3
- package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +19 -1
- package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -26
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +5 -3
- package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +4 -4
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +1 -1
- package/dist/esm/view/FlexibleCard/components/utils.js +15 -1
- package/dist/esm/view/HoverCard/components/hover-card-content.js +2 -1
- package/dist/esm/view/HoverCard/utils.js +4 -3
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +3 -1
- package/dist/types/state/helpers.d.ts +3 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
- package/dist/types/utils/analytics/analytics.d.ts +1 -1
- package/dist/types/utils/analytics/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
- package/package.json +2 -2
|
@@ -19,9 +19,31 @@ export const getClickUrl = (url, jsonLd) => {
|
|
|
19
19
|
|
|
20
20
|
return url;
|
|
21
21
|
};
|
|
22
|
-
export const getDefinitionId = details =>
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export const getDefinitionId = details => {
|
|
23
|
+
var _details$meta;
|
|
24
|
+
|
|
25
|
+
return details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.definitionId;
|
|
26
|
+
};
|
|
27
|
+
export const getExtensionKey = details => {
|
|
28
|
+
var _details$meta2;
|
|
29
|
+
|
|
30
|
+
return details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.key;
|
|
31
|
+
};
|
|
32
|
+
export const getResourceType = details => {
|
|
33
|
+
var _details$meta3;
|
|
34
|
+
|
|
35
|
+
return details === null || details === void 0 ? void 0 : (_details$meta3 = details.meta) === null || _details$meta3 === void 0 ? void 0 : _details$meta3.resourceType;
|
|
36
|
+
};
|
|
37
|
+
export const getProduct = details => {
|
|
38
|
+
var _details$meta4;
|
|
39
|
+
|
|
40
|
+
return details === null || details === void 0 ? void 0 : (_details$meta4 = details.meta) === null || _details$meta4 === void 0 ? void 0 : _details$meta4.product;
|
|
41
|
+
};
|
|
42
|
+
export const getSubproduct = details => {
|
|
43
|
+
var _details$meta5;
|
|
44
|
+
|
|
45
|
+
return details === null || details === void 0 ? void 0 : (_details$meta5 = details.meta) === null || _details$meta5 === void 0 ? void 0 : _details$meta5.subproduct;
|
|
46
|
+
};
|
|
25
47
|
export const getServices = details => details && details.meta.auth || [];
|
|
26
48
|
export const hasResolved = details => details && isAccessible(details) && isVisible(details);
|
|
27
49
|
export const isAccessible = ({
|
|
@@ -174,7 +174,7 @@ export const uiAuthAlternateAccountEvent = (display, definitionId, extensionKey)
|
|
|
174
174
|
display
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
export const uiCardClickedEvent = (id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct) => ({
|
|
177
|
+
export const uiCardClickedEvent = (id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct) => ({
|
|
178
178
|
action: 'clicked',
|
|
179
179
|
actionSubject: 'smartLink',
|
|
180
180
|
actionSubjectId: 'titleGoToLink',
|
|
@@ -187,7 +187,8 @@ export const uiCardClickedEvent = (id, display, status, definitionId, extensionK
|
|
|
187
187
|
display,
|
|
188
188
|
isModifierKeyPressed,
|
|
189
189
|
location,
|
|
190
|
-
destinationProduct
|
|
190
|
+
destinationProduct,
|
|
191
|
+
destinationSubproduct
|
|
191
192
|
}
|
|
192
193
|
});
|
|
193
194
|
export const uiActionClickedEvent = (id, actionType, extensionKey, display) => ({
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { isSpecialEvent } from '../../utils';
|
|
3
3
|
import * as measure from '../../utils/performance';
|
|
4
|
-
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey } from '../../state/helpers';
|
|
4
|
+
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
|
|
5
5
|
import { useSmartLink } from '../../state';
|
|
6
6
|
import { BlockCard } from '../BlockCard';
|
|
7
7
|
import { InlineCard } from '../InlineCard';
|
|
@@ -42,6 +42,8 @@ export function CardWithUrlContent({
|
|
|
42
42
|
const definitionId = getDefinitionId(state.details);
|
|
43
43
|
const extensionKey = getExtensionKey(state.details);
|
|
44
44
|
const resourceType = getResourceType(state.details);
|
|
45
|
+
const product = getProduct(state.details);
|
|
46
|
+
const subproduct = getSubproduct(state.details);
|
|
45
47
|
const services = getServices(state.details);
|
|
46
48
|
let isFlexibleUi = useMemo(() => isFlexibleUiCard(children), [children]); // Setup UI handlers.
|
|
47
49
|
|
|
@@ -51,14 +53,14 @@ export function CardWithUrlContent({
|
|
|
51
53
|
}, [state.details, url]);
|
|
52
54
|
const handleClickWrapper = useCallback(event => {
|
|
53
55
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
54
|
-
analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed);
|
|
56
|
+
analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed, undefined, product, subproduct);
|
|
55
57
|
|
|
56
58
|
if (onClick) {
|
|
57
59
|
onClick(event);
|
|
58
60
|
} else if (!isFlexibleUi) {
|
|
59
61
|
handleClick(event);
|
|
60
62
|
}
|
|
61
|
-
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
63
|
+
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi, product, subproduct]);
|
|
62
64
|
const handleAuthorize = useCallback(() => actions.authorize(appearance), [actions, appearance]);
|
|
63
65
|
const handleRetry = useCallback(() => {
|
|
64
66
|
actions.reload();
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
4
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
5
|
-
import { getBaseStyles, renderChildren } from '../utils';
|
|
5
|
+
import { getBaseStyles, getGapSize, renderChildren } from '../utils';
|
|
6
|
+
import { getMaxLineHeight, getTruncateStyles } from '../../utils';
|
|
6
7
|
|
|
7
8
|
const getAlignmentStyles = align => {
|
|
8
9
|
switch (align) {
|
|
@@ -21,11 +22,57 @@ const getAlignmentStyles = align => {
|
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
const getGapStyles = (size, align) => {
|
|
26
|
+
const gap = getGapSize(size);
|
|
27
|
+
|
|
28
|
+
if (align === SmartLinkAlignment.Right) {
|
|
29
|
+
return css`
|
|
30
|
+
> span {
|
|
31
|
+
margin-left: ${gap}rem;
|
|
32
|
+
&:first-child {
|
|
33
|
+
margin-left: initial;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return css`
|
|
40
|
+
> span {
|
|
41
|
+
margin-right: ${gap}rem;
|
|
42
|
+
&:last-child {
|
|
43
|
+
margin-right: initial;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getHorizontalDirectionStyles = (size, align) => {
|
|
50
|
+
const lineHeight = getMaxLineHeight(size);
|
|
51
|
+
return css`
|
|
52
|
+
display: block;
|
|
53
|
+
vertical-align: middle;
|
|
54
|
+
${getTruncateStyles(1, lineHeight + 'rem')}
|
|
55
|
+
|
|
56
|
+
> span, > div {
|
|
57
|
+
vertical-align: middle;
|
|
58
|
+
|
|
59
|
+
&[data-smart-element-date-time],
|
|
60
|
+
&[data-smart-element-text] {
|
|
61
|
+
// Show all/wrapped/truncated
|
|
62
|
+
display: inline;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
${getGapStyles(size, align)}
|
|
67
|
+
`;
|
|
68
|
+
};
|
|
69
|
+
|
|
24
70
|
export const getElementGroupStyles = (direction, size, align, width) => css`
|
|
25
71
|
${getBaseStyles(direction, size)}
|
|
26
72
|
${getAlignmentStyles(align)}
|
|
27
73
|
min-width: 10%;
|
|
28
74
|
${width === SmartLinkWidth.Flexible ? `flex: 1 3;` : ''}
|
|
75
|
+
${direction === SmartLinkDirection.Horizontal ? getHorizontalDirectionStyles(size, align) : ''}
|
|
29
76
|
`;
|
|
30
77
|
/**
|
|
31
78
|
* Creates a group of Action components. Accepts an array of Actions, in addition to some styling
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { css } from '@emotion/core';
|
|
4
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
|
|
4
5
|
import Block from '../block';
|
|
5
6
|
import ElementGroup from '../element-group';
|
|
6
7
|
import { Provider } from '../../elements';
|
|
7
8
|
import ActionGroup from '../action-group';
|
|
9
|
+
|
|
10
|
+
const getActionGroupStyles = size => {
|
|
11
|
+
if (size === SmartLinkSize.XLarge) {
|
|
12
|
+
// The biggest height of the action button exceeds the max line-height
|
|
13
|
+
// of the elements causing the action on the block with x-large size to
|
|
14
|
+
// get cut at the bottom.
|
|
15
|
+
return css`
|
|
16
|
+
max-height: 2rem;
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
8
20
|
/**
|
|
9
21
|
* Represents a FooterBlock, designed to contain elements and actions that should appear
|
|
10
22
|
* at the bottom of a link card.
|
|
@@ -13,10 +25,12 @@ import ActionGroup from '../action-group';
|
|
|
13
25
|
* @see Block
|
|
14
26
|
*/
|
|
15
27
|
|
|
28
|
+
|
|
16
29
|
const FooterBlock = props => {
|
|
17
30
|
const {
|
|
18
31
|
status,
|
|
19
32
|
actions,
|
|
33
|
+
size = SmartLinkSize.Medium,
|
|
20
34
|
testId = 'smart-footer-block'
|
|
21
35
|
} = props;
|
|
22
36
|
|
|
@@ -32,6 +46,7 @@ const FooterBlock = props => {
|
|
|
32
46
|
testId: "smart-element-group-actions",
|
|
33
47
|
align: SmartLinkAlignment.Right,
|
|
34
48
|
direction: SmartLinkDirection.Horizontal,
|
|
49
|
+
overrideCss: getActionGroupStyles(size),
|
|
35
50
|
width: SmartLinkWidth.Flexible
|
|
36
51
|
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
37
52
|
items: actions,
|
|
@@ -2,9 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css } from '@emotion/core';
|
|
4
4
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
|
|
5
|
-
import {
|
|
5
|
+
import { renderElementItems } from '../utils';
|
|
6
6
|
import Block from '../block';
|
|
7
7
|
import ElementGroup from '../element-group';
|
|
8
|
+
import { getMaxLineHeight, getTruncateStyles } from '../../utils';
|
|
8
9
|
const DEFAULT_MAX_LINES = 2;
|
|
9
10
|
const MAXIMUM_MAX_LINES = 2;
|
|
10
11
|
const MINIMUM_MAX_LINES = 1;
|
|
@@ -12,43 +13,15 @@ const MINIMUM_MAX_LINES = 1;
|
|
|
12
13
|
const getElementGroupStyles = (size, maxLines) => {
|
|
13
14
|
// MetadataBlock allows metadata elements to be displayed in
|
|
14
15
|
// multiple lines, with maximum of 2 lines.
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
// it's fix max height of the element group so that anything that is
|
|
19
|
-
// overflown will not be visible.
|
|
20
|
-
const lineHeight = getLineHeight(size);
|
|
21
|
-
const gap = getGapSize(size);
|
|
22
|
-
const gapHeight = gap * (maxLines - 1);
|
|
23
|
-
const height = lineHeight * maxLines + gapHeight;
|
|
16
|
+
// We need the height of the line to be equal on both left and right
|
|
17
|
+
// sides so they line up nicely.
|
|
18
|
+
const lineHeight = getMaxLineHeight(size);
|
|
24
19
|
return css`
|
|
25
|
-
flex-wrap: wrap;
|
|
26
20
|
line-height: ${lineHeight}rem;
|
|
27
|
-
|
|
28
|
-
> span,
|
|
29
|
-
> div {
|
|
30
|
-
min-height: ${lineHeight}rem;
|
|
31
|
-
max-height: ${lineHeight}rem;
|
|
32
|
-
line-height: ${lineHeight}rem;
|
|
33
|
-
}
|
|
21
|
+
${getTruncateStyles(maxLines, lineHeight + 'rem')}
|
|
34
22
|
`;
|
|
35
23
|
};
|
|
36
24
|
|
|
37
|
-
const getLineHeight = size => {
|
|
38
|
-
// The maximum height of all elements in specific size.
|
|
39
|
-
// These heights belongs to AvatarGroup.
|
|
40
|
-
switch (size) {
|
|
41
|
-
case SmartLinkSize.XLarge:
|
|
42
|
-
case SmartLinkSize.Large:
|
|
43
|
-
return 1.75;
|
|
44
|
-
|
|
45
|
-
case SmartLinkSize.Medium:
|
|
46
|
-
case SmartLinkSize.Small:
|
|
47
|
-
default:
|
|
48
|
-
return 1.5;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
25
|
const getMaxLines = maxLines => {
|
|
53
26
|
if (maxLines > MAXIMUM_MAX_LINES) {
|
|
54
27
|
return DEFAULT_MAX_LINES;
|
|
@@ -6,16 +6,21 @@ import { SmartLinkSize } from '../../../../../constants';
|
|
|
6
6
|
const MAX_COUNT = 4;
|
|
7
7
|
|
|
8
8
|
const getStyles = size => {
|
|
9
|
+
const styles = css`
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
`;
|
|
12
|
+
|
|
9
13
|
switch (size) {
|
|
10
14
|
case SmartLinkSize.XLarge:
|
|
11
15
|
case SmartLinkSize.Large:
|
|
12
16
|
// Default AK small size
|
|
13
|
-
return;
|
|
17
|
+
return styles;
|
|
14
18
|
|
|
15
19
|
case SmartLinkSize.Medium:
|
|
16
20
|
case SmartLinkSize.Small:
|
|
17
21
|
default:
|
|
18
22
|
return css`
|
|
23
|
+
${styles}
|
|
19
24
|
li {
|
|
20
25
|
span,
|
|
21
26
|
svg {
|
|
@@ -9,15 +9,19 @@ import ImageIcon from '../../common/image-icon';
|
|
|
9
9
|
import AtlaskitIcon from '../../common/atlaskit-icon';
|
|
10
10
|
const badgeStyles = css`
|
|
11
11
|
align-items: center;
|
|
12
|
-
display: flex;
|
|
12
|
+
display: inline-flex;
|
|
13
13
|
min-width: fit-content;
|
|
14
14
|
`;
|
|
15
15
|
const iconStyles = css`
|
|
16
16
|
color: ${tokens.badgeIcon};
|
|
17
|
+
line-height: 0;
|
|
18
|
+
vertical-align: middle;
|
|
17
19
|
${getIconSizeStyles('1rem')}
|
|
20
|
+
img,
|
|
18
21
|
span,
|
|
19
22
|
svg {
|
|
20
23
|
line-height: 0;
|
|
24
|
+
vertical-align: middle;
|
|
21
25
|
}
|
|
22
26
|
`;
|
|
23
27
|
const labelStyles = css`
|
|
@@ -25,6 +29,7 @@ const labelStyles = css`
|
|
|
25
29
|
font-size: 0.75rem;
|
|
26
30
|
line-height: 1rem;
|
|
27
31
|
padding-left: 0.125rem;
|
|
32
|
+
vertical-align: middle;
|
|
28
33
|
`;
|
|
29
34
|
const messageMapper = {
|
|
30
35
|
[IconType.PriorityBlocker]: messages.priority_blocker,
|
|
@@ -99,7 +104,7 @@ const Badge = ({
|
|
|
99
104
|
return null;
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
return jsx("
|
|
107
|
+
return jsx("span", {
|
|
103
108
|
css: [badgeStyles, overrideCss],
|
|
104
109
|
"data-fit-to-content": true,
|
|
105
110
|
"data-smart-element-badge": true,
|
|
@@ -96,6 +96,20 @@ export const getLinkSizeStyles = size => {
|
|
|
96
96
|
`;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
+
export const getMaxLineHeight = size => {
|
|
100
|
+
// The maximum line height based on all elements in specific size.
|
|
101
|
+
// These heights belongs to AvatarGroup.
|
|
102
|
+
switch (size) {
|
|
103
|
+
case SmartLinkSize.XLarge:
|
|
104
|
+
case SmartLinkSize.Large:
|
|
105
|
+
return 1.75;
|
|
106
|
+
|
|
107
|
+
case SmartLinkSize.Medium:
|
|
108
|
+
case SmartLinkSize.Small:
|
|
109
|
+
default:
|
|
110
|
+
return 1.5;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
99
113
|
export const getMaxLines = (value, defaultValue, max, min) => {
|
|
100
114
|
if (value > max) {
|
|
101
115
|
return defaultValue;
|
|
@@ -115,7 +129,9 @@ export const getTruncateStyles = (maxLines, lineHeight = '1rem', wordBreak = 'br
|
|
|
115
129
|
-webkit-line-clamp: ${maxLines};
|
|
116
130
|
-webkit-box-orient: vertical;
|
|
117
131
|
// Fallback options
|
|
118
|
-
|
|
132
|
+
@supports not (-webkit-line-clamp: 1) {
|
|
133
|
+
max-height: calc(${maxLines} * ${lineHeight});
|
|
134
|
+
}
|
|
119
135
|
`;
|
|
120
136
|
export const hasWhiteSpace = str => {
|
|
121
137
|
return str.search(/\s/) >= 0;
|
|
@@ -76,7 +76,8 @@ const HoverCardContent = ({
|
|
|
76
76
|
actions: titleActions
|
|
77
77
|
}), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
78
78
|
primary: primary,
|
|
79
|
-
secondary: secondary
|
|
79
|
+
secondary: secondary,
|
|
80
|
+
size: SmartLinkSize.Small
|
|
80
81
|
}), body, /*#__PURE__*/React.createElement(FooterBlock, {
|
|
81
82
|
actions: footerActions
|
|
82
83
|
}));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ElementName } from '../../constants';
|
|
1
2
|
export const HOVER_CARD_ANALYTICS_DISPLAY = 'flexible';
|
|
2
3
|
export const getSimulatedMetadata = (extensionKey = '') => {
|
|
3
4
|
switch (extensionKey) {
|
|
4
5
|
case 'confluence-object-provider':
|
|
5
6
|
return {
|
|
6
7
|
metadata: {
|
|
7
|
-
primary: [
|
|
8
|
+
primary: [ElementName.AuthorGroup, ElementName.CreatedBy, ElementName.CommentCount, ElementName.ReactCount],
|
|
8
9
|
secondary: []
|
|
9
10
|
}
|
|
10
11
|
};
|
|
@@ -12,7 +13,7 @@ export const getSimulatedMetadata = (extensionKey = '') => {
|
|
|
12
13
|
case 'jira-object-provider':
|
|
13
14
|
return {
|
|
14
15
|
metadata: {
|
|
15
|
-
primary: [
|
|
16
|
+
primary: [ElementName.AuthorGroup, ElementName.State, ElementName.Priority],
|
|
16
17
|
secondary: []
|
|
17
18
|
}
|
|
18
19
|
};
|
|
@@ -20,7 +21,7 @@ export const getSimulatedMetadata = (extensionKey = '') => {
|
|
|
20
21
|
default:
|
|
21
22
|
return {
|
|
22
23
|
metadata: {
|
|
23
|
-
primary: [
|
|
24
|
+
primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
|
|
24
25
|
secondary: []
|
|
25
26
|
}
|
|
26
27
|
};
|
|
@@ -4,7 +4,7 @@ import { useMemo, useCallback } from 'react';
|
|
|
4
4
|
import { auth } from '@atlaskit/outbound-auth-flow-client';
|
|
5
5
|
import { APIError } from '@atlaskit/linking-common';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
|
-
import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, cardAction } from '@atlaskit/linking-common';
|
|
7
|
+
import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, cardAction } from '@atlaskit/linking-common';
|
|
8
8
|
import { getDefinitionId, getByDefinitionId, getServices, getStatus, getExtensionKey } from '../helpers';
|
|
9
9
|
import { ERROR_MESSAGE_OAUTH, ERROR_MESSAGE_FATAL } from './constants';
|
|
10
10
|
import * as measure from '../../utils/performance';
|
|
@@ -67,6 +67,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
67
67
|
}
|
|
68
68
|
}, [hasData, status, dispatch, details]);
|
|
69
69
|
var handleResolvedLinkResponse = useCallback(function (resourceUrl, response) {
|
|
70
|
+
var isReloading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
70
71
|
var hostname = new URL(resourceUrl).hostname;
|
|
71
72
|
var nextStatus = response ? getStatus(response) : 'fatal'; // If we require authorization & do not have an authFlow available,
|
|
72
73
|
// throw an error and render as a normal blue link.
|
|
@@ -83,9 +84,15 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
83
84
|
} // Dispatch Analytics and resolved card action - including unauthorized states.
|
|
84
85
|
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if (isReloading) {
|
|
88
|
+
dispatch(cardAction(ACTION_RELOADING, {
|
|
89
|
+
url: resourceUrl
|
|
90
|
+
}, response));
|
|
91
|
+
} else {
|
|
92
|
+
dispatch(cardAction(ACTION_RESOLVED, {
|
|
93
|
+
url: resourceUrl
|
|
94
|
+
}, response));
|
|
95
|
+
}
|
|
89
96
|
}, [dispatch, handleResolvedLinkError, hasAuthFlowSupported]);
|
|
90
97
|
var resolve = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
91
98
|
var resourceUrl,
|
|
@@ -104,7 +111,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
return _context.abrupt("return", connections.client.fetchData(resourceUrl).then(function (response) {
|
|
107
|
-
return handleResolvedLinkResponse(resourceUrl, response);
|
|
114
|
+
return handleResolvedLinkResponse(resourceUrl, response, isReloading);
|
|
108
115
|
}).catch(function (error) {
|
|
109
116
|
return handleResolvedLinkError(resourceUrl, error);
|
|
110
117
|
}));
|
|
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { getUrl } from '@atlaskit/linking-common';
|
|
3
3
|
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
4
4
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
5
|
-
import { getDefinitionId, getExtensionKey, getResourceType } from '../helpers';
|
|
5
|
+
import { getDefinitionId, getExtensionKey, getResourceType, getSubproduct, getProduct } from '../helpers';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
7
|
/**
|
|
8
8
|
* This hook provides usage of Smart Link analytics outside of the Card component.
|
|
@@ -24,6 +24,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
|
|
|
24
24
|
var extractedDefinitionId = getDefinitionId(state.details);
|
|
25
25
|
var extractedExtensionKey = getExtensionKey(state.details);
|
|
26
26
|
var extractedResourceType = getResourceType(state.details);
|
|
27
|
+
var extractedSubproduct = getSubproduct(state.details);
|
|
28
|
+
var extractedProduct = getProduct(state.details);
|
|
27
29
|
/** Contains all ui analytics events */
|
|
28
30
|
|
|
29
31
|
var ui = useMemo(function () {
|
|
@@ -60,6 +62,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
|
|
|
60
62
|
* This fires an event that represents when a user clicks on a Smart Link.
|
|
61
63
|
* @param id The unique ID for this Smart Link.
|
|
62
64
|
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
65
|
+
* @param status What status the Smart Link is currently in (e.g. resolved, unresolved)
|
|
63
66
|
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
64
67
|
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
65
68
|
* @param isModifierKeyPressed Whether a modifier key was pressed when clicking the Smart Link.
|
|
@@ -75,8 +78,9 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
|
|
|
75
78
|
var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
|
|
76
79
|
var isModifierKeyPressed = arguments.length > 5 ? arguments[5] : undefined;
|
|
77
80
|
var location = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultLocation;
|
|
78
|
-
var destinationProduct = arguments.length > 7 ? arguments[7] :
|
|
79
|
-
|
|
81
|
+
var destinationProduct = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : extractedProduct;
|
|
82
|
+
var destinationSubproduct = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : extractedSubproduct;
|
|
83
|
+
return dispatchAnalytics(uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct));
|
|
80
84
|
},
|
|
81
85
|
|
|
82
86
|
/**
|
|
@@ -186,7 +190,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
|
|
|
186
190
|
return dispatchAnalytics(uiHoverCardDismissedEvent(id, previewDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod));
|
|
187
191
|
}
|
|
188
192
|
};
|
|
189
|
-
}, [defaultId, defaultLocation,
|
|
193
|
+
}, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics, defaultId, defaultLocation, extractedProduct, extractedSubproduct]);
|
|
190
194
|
/** Contains all operational analytics events */
|
|
191
195
|
|
|
192
196
|
var operational = useMemo(function () {
|
|
@@ -18,13 +18,29 @@ export var getClickUrl = function getClickUrl(url, jsonLd) {
|
|
|
18
18
|
return url;
|
|
19
19
|
};
|
|
20
20
|
export var getDefinitionId = function getDefinitionId(details) {
|
|
21
|
-
|
|
21
|
+
var _details$meta;
|
|
22
|
+
|
|
23
|
+
return details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.definitionId;
|
|
22
24
|
};
|
|
23
25
|
export var getExtensionKey = function getExtensionKey(details) {
|
|
24
|
-
|
|
26
|
+
var _details$meta2;
|
|
27
|
+
|
|
28
|
+
return details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.key;
|
|
25
29
|
};
|
|
26
30
|
export var getResourceType = function getResourceType(details) {
|
|
27
|
-
|
|
31
|
+
var _details$meta3;
|
|
32
|
+
|
|
33
|
+
return details === null || details === void 0 ? void 0 : (_details$meta3 = details.meta) === null || _details$meta3 === void 0 ? void 0 : _details$meta3.resourceType;
|
|
34
|
+
};
|
|
35
|
+
export var getProduct = function getProduct(details) {
|
|
36
|
+
var _details$meta4;
|
|
37
|
+
|
|
38
|
+
return details === null || details === void 0 ? void 0 : (_details$meta4 = details.meta) === null || _details$meta4 === void 0 ? void 0 : _details$meta4.product;
|
|
39
|
+
};
|
|
40
|
+
export var getSubproduct = function getSubproduct(details) {
|
|
41
|
+
var _details$meta5;
|
|
42
|
+
|
|
43
|
+
return details === null || details === void 0 ? void 0 : (_details$meta5 = details.meta) === null || _details$meta5 === void 0 ? void 0 : _details$meta5.subproduct;
|
|
28
44
|
};
|
|
29
45
|
export var getServices = function getServices(details) {
|
|
30
46
|
return details && details.meta.auth || [];
|
|
@@ -187,7 +187,7 @@ export var uiAuthAlternateAccountEvent = function uiAuthAlternateAccountEvent(di
|
|
|
187
187
|
})
|
|
188
188
|
};
|
|
189
189
|
};
|
|
190
|
-
export var uiCardClickedEvent = function uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct) {
|
|
190
|
+
export var uiCardClickedEvent = function uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct) {
|
|
191
191
|
return {
|
|
192
192
|
action: 'clicked',
|
|
193
193
|
actionSubject: 'smartLink',
|
|
@@ -201,7 +201,8 @@ export var uiCardClickedEvent = function uiCardClickedEvent(id, display, status,
|
|
|
201
201
|
display: display,
|
|
202
202
|
isModifierKeyPressed: isModifierKeyPressed,
|
|
203
203
|
location: location,
|
|
204
|
-
destinationProduct: destinationProduct
|
|
204
|
+
destinationProduct: destinationProduct,
|
|
205
|
+
destinationSubproduct: destinationSubproduct
|
|
205
206
|
})
|
|
206
207
|
};
|
|
207
208
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { isSpecialEvent } from '../../utils';
|
|
3
3
|
import * as measure from '../../utils/performance';
|
|
4
|
-
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey } from '../../state/helpers';
|
|
4
|
+
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
|
|
5
5
|
import { useSmartLink } from '../../state';
|
|
6
6
|
import { BlockCard } from '../BlockCard';
|
|
7
7
|
import { InlineCard } from '../InlineCard';
|
|
@@ -42,6 +42,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
42
42
|
var definitionId = getDefinitionId(state.details);
|
|
43
43
|
var extensionKey = getExtensionKey(state.details);
|
|
44
44
|
var resourceType = getResourceType(state.details);
|
|
45
|
+
var product = getProduct(state.details);
|
|
46
|
+
var subproduct = getSubproduct(state.details);
|
|
45
47
|
var services = getServices(state.details);
|
|
46
48
|
var isFlexibleUi = useMemo(function () {
|
|
47
49
|
return isFlexibleUiCard(children);
|
|
@@ -53,14 +55,14 @@ export function CardWithUrlContent(_ref) {
|
|
|
53
55
|
}, [state.details, url]);
|
|
54
56
|
var handleClickWrapper = useCallback(function (event) {
|
|
55
57
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
56
|
-
analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed);
|
|
58
|
+
analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed, undefined, product, subproduct);
|
|
57
59
|
|
|
58
60
|
if (onClick) {
|
|
59
61
|
onClick(event);
|
|
60
62
|
} else if (!isFlexibleUi) {
|
|
61
63
|
handleClick(event);
|
|
62
64
|
}
|
|
63
|
-
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
|
|
65
|
+
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi, product, subproduct]);
|
|
64
66
|
var handleAuthorize = useCallback(function () {
|
|
65
67
|
return actions.authorize(appearance);
|
|
66
68
|
}, [actions, appearance]);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/core';
|
|
8
8
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
9
|
-
import { getBaseStyles, renderChildren } from '../utils';
|
|
9
|
+
import { getBaseStyles, getGapSize, renderChildren } from '../utils';
|
|
10
|
+
import { getMaxLineHeight, getTruncateStyles } from '../../utils';
|
|
10
11
|
|
|
11
12
|
var getAlignmentStyles = function getAlignmentStyles(align) {
|
|
12
13
|
switch (align) {
|
|
@@ -19,8 +20,23 @@ var getAlignmentStyles = function getAlignmentStyles(align) {
|
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
|
|
23
|
+
var getGapStyles = function getGapStyles(size, align) {
|
|
24
|
+
var gap = getGapSize(size);
|
|
25
|
+
|
|
26
|
+
if (align === SmartLinkAlignment.Right) {
|
|
27
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n > span {\n margin-left: ", "rem;\n &:first-child {\n margin-left: initial;\n }\n }\n "])), gap);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n > span {\n margin-right: ", "rem;\n &:last-child {\n margin-right: initial;\n }\n }\n "])), gap);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var getHorizontalDirectionStyles = function getHorizontalDirectionStyles(size, align) {
|
|
34
|
+
var lineHeight = getMaxLineHeight(size);
|
|
35
|
+
return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: block;\n vertical-align: middle;\n ", "\n\n > span, > div {\n vertical-align: middle;\n\n &[data-smart-element-date-time],\n &[data-smart-element-text] {\n // Show all/wrapped/truncated\n display: inline;\n }\n }\n\n ", "\n "])), getTruncateStyles(1, lineHeight + 'rem'), getGapStyles(size, align));
|
|
36
|
+
};
|
|
37
|
+
|
|
22
38
|
export var getElementGroupStyles = function getElementGroupStyles(direction, size, align, width) {
|
|
23
|
-
return css(
|
|
39
|
+
return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ", "\n ", "\n min-width: 10%;\n ", "\n ", "\n"])), getBaseStyles(direction, size), getAlignmentStyles(align), width === SmartLinkWidth.Flexible ? "flex: 1 3;" : '', direction === SmartLinkDirection.Horizontal ? getHorizontalDirectionStyles(size, align) : '');
|
|
24
40
|
};
|
|
25
41
|
/**
|
|
26
42
|
* Creates a group of Action components. Accepts an array of Actions, in addition to some styling
|