@atlaskit/smart-card 25.7.3 → 25.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/constants.js +13 -7
- package/dist/cjs/extractors/flexible/index.js +1 -0
- package/dist/cjs/extractors/flexible/utils.js +14 -2
- package/dist/cjs/state/actions/index.js +27 -11
- package/dist/cjs/state/hooks/use-resolve/index.js +21 -12
- package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +47 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -1
- package/dist/cjs/view/CardWithUrl/component.js +12 -3
- package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +6 -4
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +7 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/index.js +9 -2
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +6 -4
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +5 -0
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +11 -4
- package/dist/cjs/view/HoverCard/styled.js +1 -1
- package/dist/cjs/view/HoverCard/utils.js +1 -1
- package/dist/es2019/constants.js +10 -5
- package/dist/es2019/extractors/flexible/index.js +2 -1
- package/dist/es2019/extractors/flexible/utils.js +12 -0
- package/dist/es2019/state/actions/index.js +32 -12
- package/dist/es2019/state/hooks/use-resolve/index.js +21 -12
- package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +35 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -1
- package/dist/es2019/view/CardWithUrl/component.js +8 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +6 -4
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +8 -3
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +5 -4
- package/dist/es2019/view/FlexibleCard/components/elements/index.js +6 -0
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +10 -1
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +7 -1
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +10 -3
- package/dist/es2019/view/HoverCard/styled.js +1 -1
- package/dist/es2019/view/HoverCard/utils.js +1 -1
- package/dist/esm/constants.js +10 -5
- package/dist/esm/extractors/flexible/index.js +2 -1
- package/dist/esm/extractors/flexible/utils.js +11 -0
- package/dist/esm/state/actions/index.js +27 -11
- package/dist/esm/state/hooks/use-resolve/index.js +21 -12
- package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +36 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -1
- package/dist/esm/view/CardWithUrl/component.js +10 -2
- package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +7 -5
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +8 -3
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/index.js +6 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +7 -5
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +6 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +11 -4
- package/dist/esm/view/HoverCard/styled.js +1 -1
- package/dist/esm/view/HoverCard/utils.js +1 -1
- package/dist/types/constants.d.ts +6 -2
- package/dist/types/extractors/flexible/utils.d.ts +2 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +10 -0
- package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +9 -0
- package/dist/types/view/CardWithUrl/component.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/blocks/element-group/index.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/blocks/element-group/types.d.ts +2 -1
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +7 -1
- package/dist/types/view/FlexibleCard/components/elements/index.d.ts +6 -0
- package/package.json +3 -2
- package/report.api.md +8 -0
- package/tmp/api-report-tmp.d.ts +8 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extractSummary } from '../common/primitives';
|
|
2
2
|
import { extractLinkIcon } from './icon';
|
|
3
|
-
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractOwnedBy } from './utils';
|
|
3
|
+
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy } from './utils';
|
|
4
4
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
5
5
|
import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink } from '@atlaskit/linking-common/extractors';
|
|
6
6
|
import extractPriority from './extract-priority';
|
|
@@ -42,6 +42,7 @@ const extractFlexibleUiContext = ({
|
|
|
42
42
|
downloadAction: extractDownloadAction(data),
|
|
43
43
|
latestCommit: extractLatestCommit(data),
|
|
44
44
|
linkIcon: extractLinkIcon(response, renderers),
|
|
45
|
+
location: extractLocation(data),
|
|
45
46
|
modifiedBy: extractModifiedBy(data),
|
|
46
47
|
modifiedOn: extractDateUpdated(data),
|
|
47
48
|
preview: extractPreview(data),
|
|
@@ -38,4 +38,16 @@ export const extractTargetBranch = data => extractLinkName(data['atlassian:merge
|
|
|
38
38
|
export const extractChecklistProgress = data => {
|
|
39
39
|
const checkItemsObj = extractValue(data, 'atlassian:checkItems');
|
|
40
40
|
return checkItemsObj ? `${checkItemsObj.checkedItems}/${checkItemsObj.totalItems}` : undefined;
|
|
41
|
+
};
|
|
42
|
+
export const extractLocation = data => {
|
|
43
|
+
const {
|
|
44
|
+
url,
|
|
45
|
+
name
|
|
46
|
+
} = extractValue(data, 'location') || {};
|
|
47
|
+
if (url && name && typeof url === 'string') {
|
|
48
|
+
return {
|
|
49
|
+
text: name,
|
|
50
|
+
url
|
|
51
|
+
};
|
|
52
|
+
}
|
|
41
53
|
};
|
|
@@ -16,14 +16,21 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
16
16
|
getState,
|
|
17
17
|
dispatch
|
|
18
18
|
} = store;
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const getSmartLinkState = useCallback(() => {
|
|
20
|
+
var _getState$url;
|
|
21
|
+
const {
|
|
22
|
+
details,
|
|
23
|
+
status,
|
|
24
|
+
metadataStatus
|
|
25
|
+
} = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : {
|
|
26
|
+
status: SmartLinkStatus.Pending
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
details,
|
|
30
|
+
status,
|
|
31
|
+
metadataStatus
|
|
32
|
+
};
|
|
33
|
+
}, [getState, url]);
|
|
27
34
|
const setMetadataStatus = useCallback(metadataStatus => {
|
|
28
35
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
29
36
|
url
|
|
@@ -31,6 +38,9 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
31
38
|
}, [dispatch, url]);
|
|
32
39
|
const resolve = useCallback(async (resourceUrl = url, isReloading = false, isMetadataRequest = false) => resolveUrl(resourceUrl, isReloading, isMetadataRequest, id), [id, resolveUrl, url]);
|
|
33
40
|
const register = useCallback(() => {
|
|
41
|
+
const {
|
|
42
|
+
details
|
|
43
|
+
} = getSmartLinkState();
|
|
34
44
|
if (!details) {
|
|
35
45
|
dispatch(cardAction(ACTION_RESOLVING, {
|
|
36
46
|
url
|
|
@@ -38,23 +48,33 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
38
48
|
setMetadataStatus('pending');
|
|
39
49
|
}
|
|
40
50
|
return resolve();
|
|
41
|
-
}, [
|
|
51
|
+
}, [getSmartLinkState, resolve, dispatch, url, setMetadataStatus]);
|
|
42
52
|
const reload = useCallback(() => {
|
|
53
|
+
const {
|
|
54
|
+
details
|
|
55
|
+
} = getSmartLinkState();
|
|
43
56
|
const definitionId = getDefinitionId(details);
|
|
44
57
|
if (definitionId) {
|
|
45
58
|
getByDefinitionId(definitionId, getState()).map(url => resolve(url, true));
|
|
46
59
|
} else {
|
|
47
60
|
resolve(url, true);
|
|
48
61
|
}
|
|
49
|
-
}, [
|
|
62
|
+
}, [getSmartLinkState, url, getState, resolve]);
|
|
50
63
|
const loadMetadata = useCallback(() => {
|
|
64
|
+
const {
|
|
65
|
+
metadataStatus
|
|
66
|
+
} = getSmartLinkState();
|
|
51
67
|
//metadataStatus will be undefined for SSR links only
|
|
52
68
|
if (metadataStatus === undefined) {
|
|
53
69
|
setMetadataStatus('pending');
|
|
54
70
|
return resolve(url, false, true);
|
|
55
71
|
}
|
|
56
|
-
}, [
|
|
72
|
+
}, [getSmartLinkState, resolve, setMetadataStatus, url]);
|
|
57
73
|
const authorize = useCallback(appearance => {
|
|
74
|
+
const {
|
|
75
|
+
details,
|
|
76
|
+
status
|
|
77
|
+
} = getSmartLinkState();
|
|
58
78
|
const definitionId = getDefinitionId(details);
|
|
59
79
|
const extensionKey = getExtensionKey(details);
|
|
60
80
|
const services = getServices(details);
|
|
@@ -106,7 +126,7 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
106
126
|
reload();
|
|
107
127
|
});
|
|
108
128
|
}
|
|
109
|
-
}, [analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload
|
|
129
|
+
}, [getSmartLinkState, analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload]);
|
|
110
130
|
const invoke = useCallback(async (opts, appearance) => {
|
|
111
131
|
const {
|
|
112
132
|
key,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
+
import { unstable_batchedUpdates } from 'react-dom';
|
|
2
3
|
import { addMetadataToExperience } from '../../analytics';
|
|
3
4
|
import { getStatus } from '../../helpers';
|
|
4
5
|
import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction } from '@atlaskit/linking-common';
|
|
@@ -98,18 +99,26 @@ const useResolve = () => {
|
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Using unstable_batchedUpdates because this store update happens async and trigers a rerender
|
|
104
|
+
* more info:
|
|
105
|
+
* https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
|
|
106
|
+
* https://react-redux.js.org/api/batch
|
|
107
|
+
*/
|
|
108
|
+
unstable_batchedUpdates(() => {
|
|
109
|
+
//if a link resolves normally, metadata will also always be resolved
|
|
110
|
+
setMetadataStatus(resourceUrl, 'resolved');
|
|
111
|
+
// Dispatch Analytics and resolved card action - including unauthorized states.
|
|
112
|
+
if (isReloading) {
|
|
113
|
+
dispatch(cardAction(ACTION_RELOADING, {
|
|
114
|
+
url: resourceUrl
|
|
115
|
+
}, response));
|
|
116
|
+
} else {
|
|
117
|
+
dispatch(cardAction(ACTION_RESOLVED, {
|
|
118
|
+
url: resourceUrl
|
|
119
|
+
}, response, undefined, undefined, isMetadataRequest));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
113
122
|
}, [dispatch, handleResolvedLinkError, hasAuthFlowSupported, setMetadataStatus]);
|
|
114
123
|
return useCallback(async (url, isReloading = false, isMetadataRequest = false, id = '') => {
|
|
115
124
|
const {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
3
|
+
import { getResolvedAttributes, getUrlAttributes } from '@atlaskit/link-analytics/resolved-attributes';
|
|
4
|
+
import { isFlexibleUiCard } from '../flexible';
|
|
5
|
+
import { CardDisplay } from '../../constants';
|
|
6
|
+
import { useSmartCardState as useSmartLinkState } from '../../state/store';
|
|
7
|
+
export const SmartLinkAnalyticsContext = ({
|
|
8
|
+
children,
|
|
9
|
+
url,
|
|
10
|
+
appearance,
|
|
11
|
+
id
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
details,
|
|
15
|
+
status
|
|
16
|
+
} = useSmartLinkState(url);
|
|
17
|
+
const resolvedAttributes = getResolvedAttributes({
|
|
18
|
+
url
|
|
19
|
+
}, details, status);
|
|
20
|
+
const {
|
|
21
|
+
urlHash
|
|
22
|
+
} = getUrlAttributes(url);
|
|
23
|
+
const isFlexibleUi = useMemo(() => isFlexibleUiCard(children), [children]);
|
|
24
|
+
const display = isFlexibleUi ? CardDisplay.Flexible : appearance;
|
|
25
|
+
return /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
26
|
+
data: {
|
|
27
|
+
attributes: {
|
|
28
|
+
...resolvedAttributes,
|
|
29
|
+
urlHash,
|
|
30
|
+
display,
|
|
31
|
+
id
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, children);
|
|
35
|
+
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -71,7 +71,10 @@ const FlexibleResolvedView = ({
|
|
|
71
71
|
}, {
|
|
72
72
|
name: ElementName.State
|
|
73
73
|
}],
|
|
74
|
-
hideRetry: true
|
|
74
|
+
hideRetry: true,
|
|
75
|
+
subtitle: [{
|
|
76
|
+
name: ElementName.Location
|
|
77
|
+
}]
|
|
75
78
|
}), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
76
79
|
primary: metadata,
|
|
77
80
|
maxLines: 1
|
|
@@ -12,7 +12,8 @@ import { isFlexibleUiCard } from '../../utils/flexible';
|
|
|
12
12
|
import FlexibleCard from '../FlexibleCard';
|
|
13
13
|
import { CardDisplay } from '../../constants';
|
|
14
14
|
import { fireLinkClickedEvent } from '../../utils/analytics/click';
|
|
15
|
-
|
|
15
|
+
import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
16
|
+
function Component({
|
|
16
17
|
id,
|
|
17
18
|
url,
|
|
18
19
|
isSelected,
|
|
@@ -254,4 +255,9 @@ export function CardWithUrlContent({
|
|
|
254
255
|
onIframeFocus: onIframeFocus
|
|
255
256
|
});
|
|
256
257
|
}
|
|
257
|
-
}
|
|
258
|
+
}
|
|
259
|
+
export const CardWithUrlContent = props => /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
260
|
+
url: props.url,
|
|
261
|
+
appearance: props.appearance,
|
|
262
|
+
id: props.id
|
|
263
|
+
}, /*#__PURE__*/React.createElement(Component, props));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
4
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
5
5
|
import { getBaseStyles, getGapSize, renderChildren } from '../utils';
|
|
6
6
|
import { getMaxLineHeight, getTruncateStyles } from '../../utils';
|
|
7
7
|
const getAlignmentStyles = align => {
|
|
@@ -65,12 +65,13 @@ const getHorizontalDirectionStyles = (size, align) => {
|
|
|
65
65
|
${getGapStyles(size, align)}
|
|
66
66
|
`;
|
|
67
67
|
};
|
|
68
|
-
export const getElementGroupStyles = (direction, size, align, width) => css`
|
|
68
|
+
export const getElementGroupStyles = (direction, size, align, width, position) => css`
|
|
69
69
|
${getBaseStyles(direction, size)}
|
|
70
70
|
${getAlignmentStyles(align)}
|
|
71
71
|
min-width: 10%;
|
|
72
72
|
${width === SmartLinkWidth.Flexible ? `flex: 1 3;` : ''}
|
|
73
73
|
${direction === SmartLinkDirection.Horizontal ? getHorizontalDirectionStyles(size, align) : ''}
|
|
74
|
+
${position === SmartLinkPosition.Top ? 'align-self: flex-start;' : ''}
|
|
74
75
|
`;
|
|
75
76
|
|
|
76
77
|
/**
|
|
@@ -87,9 +88,10 @@ const ElementGroup = ({
|
|
|
87
88
|
direction = SmartLinkDirection.Horizontal,
|
|
88
89
|
size = SmartLinkSize.Medium,
|
|
89
90
|
testId = 'smart-element-group',
|
|
90
|
-
width = SmartLinkWidth.FitToContent
|
|
91
|
+
width = SmartLinkWidth.FitToContent,
|
|
92
|
+
position = SmartLinkPosition.Center
|
|
91
93
|
}) => jsx("div", {
|
|
92
|
-
css: [getElementGroupStyles(direction, size, align, width), overrideCss],
|
|
94
|
+
css: [getElementGroupStyles(direction, size, align, width, position), overrideCss],
|
|
93
95
|
"data-smart-element-group": true,
|
|
94
96
|
"data-testid": testId
|
|
95
97
|
}, renderChildren(children, size));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { css } from '@emotion/react';
|
|
3
4
|
import { LinkIcon } from '../../../elements';
|
|
4
5
|
import Block from '../../block';
|
|
5
6
|
import ElementGroup from '../../element-group';
|
|
6
|
-
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkWidth } from '../../../../../../constants';
|
|
7
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkPosition, SmartLinkWidth } from '../../../../../../constants';
|
|
7
8
|
import { renderElementItems } from '../../utils';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -29,12 +30,16 @@ const TitleBlockResolvedView = ({
|
|
|
29
30
|
position: position
|
|
30
31
|
}), /*#__PURE__*/React.createElement(ElementGroup, {
|
|
31
32
|
direction: SmartLinkDirection.Vertical,
|
|
32
|
-
width: SmartLinkWidth.Flexible
|
|
33
|
+
width: SmartLinkWidth.Flexible,
|
|
34
|
+
overrideCss: css`
|
|
35
|
+
gap: 0.25rem;
|
|
36
|
+
`
|
|
33
37
|
}, title, subtitleElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
34
38
|
direction: SmartLinkDirection.Horizontal
|
|
35
39
|
}, subtitleElements)), metadataElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
36
40
|
direction: SmartLinkDirection.Horizontal,
|
|
37
|
-
align: SmartLinkAlignment.Right
|
|
41
|
+
align: SmartLinkAlignment.Right,
|
|
42
|
+
position: SmartLinkPosition.Top
|
|
38
43
|
}, metadataElements), actionGroup);
|
|
39
44
|
};
|
|
40
45
|
export default TitleBlockResolvedView;
|
|
@@ -15,14 +15,12 @@ export const ElementDisplaySchema = {
|
|
|
15
15
|
[ElementName.ChecklistProgress]: ['inline'],
|
|
16
16
|
[ElementName.CollaboratorGroup]: ['inline'],
|
|
17
17
|
[ElementName.CommentCount]: ['inline'],
|
|
18
|
-
[ElementName.ViewCount]: ['inline'],
|
|
19
|
-
[ElementName.ReactCount]: ['inline'],
|
|
20
|
-
[ElementName.VoteCount]: ['inline'],
|
|
21
18
|
[ElementName.CreatedBy]: ['inline'],
|
|
22
19
|
[ElementName.CreatedOn]: ['inline'],
|
|
23
20
|
[ElementName.DueOn]: ['inline'],
|
|
24
21
|
[ElementName.LatestCommit]: ['inline'],
|
|
25
22
|
[ElementName.LinkIcon]: ['inline'],
|
|
23
|
+
[ElementName.Location]: ['inline'],
|
|
26
24
|
[ElementName.ModifiedBy]: ['inline'],
|
|
27
25
|
[ElementName.ModifiedOn]: ['inline'],
|
|
28
26
|
[ElementName.OwnedBy]: ['inline'],
|
|
@@ -30,12 +28,15 @@ export const ElementDisplaySchema = {
|
|
|
30
28
|
[ElementName.Priority]: ['inline'],
|
|
31
29
|
[ElementName.ProgrammingLanguage]: ['inline'],
|
|
32
30
|
[ElementName.Provider]: ['inline'],
|
|
31
|
+
[ElementName.ReactCount]: ['inline'],
|
|
33
32
|
[ElementName.Snippet]: ['block'],
|
|
34
33
|
[ElementName.SourceBranch]: ['inline'],
|
|
35
34
|
[ElementName.State]: ['inline'],
|
|
36
35
|
[ElementName.SubscriberCount]: ['inline'],
|
|
37
36
|
[ElementName.TargetBranch]: ['inline'],
|
|
38
|
-
[ElementName.Title]: ['inline']
|
|
37
|
+
[ElementName.Title]: ['inline'],
|
|
38
|
+
[ElementName.ViewCount]: ['inline'],
|
|
39
|
+
[ElementName.VoteCount]: ['inline']
|
|
39
40
|
};
|
|
40
41
|
const getDirectionStyles = direction => {
|
|
41
42
|
switch (direction) {
|
|
@@ -52,6 +52,12 @@ export const LatestCommit = createElement(ElementName.LatestCommit);
|
|
|
52
52
|
* @see Icon
|
|
53
53
|
*/
|
|
54
54
|
export const LinkIcon = createElement(ElementName.LinkIcon);
|
|
55
|
+
/**
|
|
56
|
+
* Creates a Location Link element.
|
|
57
|
+
* This represents the location or container of the resource.
|
|
58
|
+
* @see Link
|
|
59
|
+
*/
|
|
60
|
+
export const Location = createElement(ElementName.Location);
|
|
55
61
|
/**
|
|
56
62
|
* Creates a ModifiedBy Text element using the data from ModifiedBy in the Flexible UI Context.
|
|
57
63
|
* @see Text
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
|
-
import { SmartLinkSize, SmartLinkTheme } from '../../../../../constants';
|
|
5
|
+
import { SmartLinkInternalTheme, SmartLinkSize, SmartLinkTheme } from '../../../../../constants';
|
|
6
6
|
import { getLinkLineHeight, getLinkSizeStyles, getTruncateStyles, hasWhiteSpace } from '../../utils';
|
|
7
7
|
import { tokens } from '../../../../../utils/token';
|
|
8
8
|
import useMouseDownEvent from '../../../../../state/analytics/useMouseDownEvent';
|
|
@@ -14,6 +14,15 @@ const containerStyles = css`
|
|
|
14
14
|
`;
|
|
15
15
|
const getThemeStyles = theme => {
|
|
16
16
|
switch (theme) {
|
|
17
|
+
case SmartLinkInternalTheme.Grey:
|
|
18
|
+
return css`
|
|
19
|
+
color: ${"var(--ds-text-subtlest, #626F86)"};
|
|
20
|
+
:hover {
|
|
21
|
+
color: ${"var(--ds-text-subtlest, #626F86)"};
|
|
22
|
+
text-decoration: underline;
|
|
23
|
+
}
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
`;
|
|
17
26
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
18
27
|
case SmartLinkTheme.Black:
|
|
19
28
|
return css`
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { FormattedDate } from 'react-intl-next';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
|
-
import { ElementName, IconType } from '../../../../constants';
|
|
5
|
+
import { ElementName, IconType, SmartLinkInternalTheme } from '../../../../constants';
|
|
6
6
|
import Icon from './icon';
|
|
7
7
|
import Link from './link';
|
|
8
8
|
import Lozenge from './lozenge';
|
|
@@ -126,6 +126,12 @@ const elementMappings = {
|
|
|
126
126
|
},
|
|
127
127
|
[ElementName.Title]: {
|
|
128
128
|
component: Link
|
|
129
|
+
},
|
|
130
|
+
[ElementName.Location]: {
|
|
131
|
+
component: Link,
|
|
132
|
+
props: {
|
|
133
|
+
theme: SmartLinkInternalTheme.Grey
|
|
134
|
+
}
|
|
129
135
|
}
|
|
130
136
|
};
|
|
131
137
|
const getContextKey = name => {
|
|
@@ -9,9 +9,11 @@ import { useSmartCardState as useLinkState } from '../../../state/store';
|
|
|
9
9
|
import HoverCardContent from '../components/HoverCardContent';
|
|
10
10
|
import { CARD_GAP_PX, HOVER_CARD_Z_INDEX } from '../styled';
|
|
11
11
|
import { CardDisplay } from '../../../constants';
|
|
12
|
+
import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
|
|
12
13
|
export const HoverCardComponent = ({
|
|
13
14
|
children,
|
|
14
15
|
url,
|
|
16
|
+
id,
|
|
15
17
|
analyticsHandler,
|
|
16
18
|
analytics,
|
|
17
19
|
canOpen = true,
|
|
@@ -112,7 +114,11 @@ export const HoverCardComponent = ({
|
|
|
112
114
|
}, [closeOnChildClick, hideCard]);
|
|
113
115
|
const content = useCallback(({
|
|
114
116
|
update
|
|
115
|
-
}) => jsx(
|
|
117
|
+
}) => jsx(SmartLinkAnalyticsContext, {
|
|
118
|
+
url: url,
|
|
119
|
+
appearance: CardDisplay.HoverCardPreview,
|
|
120
|
+
id: id
|
|
121
|
+
}, jsx(HoverCardContent, {
|
|
116
122
|
onMouseEnter: initShowCard,
|
|
117
123
|
onMouseLeave: initHideCard,
|
|
118
124
|
analytics: analytics,
|
|
@@ -122,8 +128,9 @@ export const HoverCardComponent = ({
|
|
|
122
128
|
onResolve: update,
|
|
123
129
|
renderers: renderers,
|
|
124
130
|
showServerActions: showServerActions,
|
|
125
|
-
url: url
|
|
126
|
-
|
|
131
|
+
url: url,
|
|
132
|
+
id: id
|
|
133
|
+
})), [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
|
|
127
134
|
const trigger = useCallback(triggerProps => jsx("span", {
|
|
128
135
|
ref: parentSpan
|
|
129
136
|
}, jsx("span", _extends({}, triggerProps, {
|
|
@@ -44,7 +44,7 @@ export const getSimulatedMetadata = (extensionKey = '', data) => {
|
|
|
44
44
|
metadata: {
|
|
45
45
|
primary: [ElementName.AuthorGroup, ElementName.State, ElementName.DueOn],
|
|
46
46
|
secondary: [ElementName.ReactCount, ElementName.CommentCount, ElementName.AttachmentCount, ElementName.ChecklistProgress],
|
|
47
|
-
subtitle: []
|
|
47
|
+
subtitle: [ElementName.Location]
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
case 'watermelon-object-provider':
|
package/dist/esm/constants.js
CHANGED
|
@@ -63,16 +63,20 @@ export var SmartLinkStatus;
|
|
|
63
63
|
SmartLinkStatus["Fallback"] = "fallback";
|
|
64
64
|
})(SmartLinkStatus || (SmartLinkStatus = {}));
|
|
65
65
|
export var SmartLinkTheme;
|
|
66
|
+
(function (SmartLinkTheme) {
|
|
67
|
+
SmartLinkTheme["Black"] = "black";
|
|
68
|
+
SmartLinkTheme["Link"] = "link";
|
|
69
|
+
})(SmartLinkTheme || (SmartLinkTheme = {}));
|
|
70
|
+
export var SmartLinkInternalTheme;
|
|
66
71
|
|
|
67
72
|
/**
|
|
68
73
|
* Determines whether the container size will fit to the content
|
|
69
74
|
* or expand to the available width or the parent component.
|
|
70
75
|
* Similar to flex's flex-grow concept.
|
|
71
76
|
*/
|
|
72
|
-
(function (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})(SmartLinkTheme || (SmartLinkTheme = {}));
|
|
77
|
+
(function (SmartLinkInternalTheme) {
|
|
78
|
+
SmartLinkInternalTheme["Grey"] = "grey";
|
|
79
|
+
})(SmartLinkInternalTheme || (SmartLinkInternalTheme = {}));
|
|
76
80
|
export var SmartLinkWidth;
|
|
77
81
|
|
|
78
82
|
/**
|
|
@@ -109,7 +113,9 @@ export var ElementName;
|
|
|
109
113
|
ElementName["CreatedBy"] = "CreatedBy";
|
|
110
114
|
ElementName["CreatedOn"] = "CreatedOn";
|
|
111
115
|
ElementName["DueOn"] = "DueOn";
|
|
116
|
+
ElementName["LatestCommit"] = "LatestCommit";
|
|
112
117
|
ElementName["LinkIcon"] = "LinkIcon";
|
|
118
|
+
ElementName["Location"] = "Location";
|
|
113
119
|
ElementName["ModifiedBy"] = "ModifiedBy";
|
|
114
120
|
ElementName["ModifiedOn"] = "ModifiedOn";
|
|
115
121
|
ElementName["OwnedBy"] = "OwnedBy";
|
|
@@ -126,7 +132,6 @@ export var ElementName;
|
|
|
126
132
|
ElementName["Title"] = "Title";
|
|
127
133
|
ElementName["ViewCount"] = "ViewCount";
|
|
128
134
|
ElementName["VoteCount"] = "VoteCount";
|
|
129
|
-
ElementName["LatestCommit"] = "LatestCommit";
|
|
130
135
|
})(ElementName || (ElementName = {}));
|
|
131
136
|
export var ActionName;
|
|
132
137
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extractSummary } from '../common/primitives';
|
|
2
2
|
import { extractLinkIcon } from './icon';
|
|
3
|
-
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractOwnedBy } from './utils';
|
|
3
|
+
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy } from './utils';
|
|
4
4
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
5
5
|
import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink } from '@atlaskit/linking-common/extractors';
|
|
6
6
|
import extractPriority from './extract-priority';
|
|
@@ -42,6 +42,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
|
42
42
|
downloadAction: extractDownloadAction(data),
|
|
43
43
|
latestCommit: extractLatestCommit(data),
|
|
44
44
|
linkIcon: extractLinkIcon(response, renderers),
|
|
45
|
+
location: extractLocation(data),
|
|
45
46
|
modifiedBy: extractModifiedBy(data),
|
|
46
47
|
modifiedOn: extractDateUpdated(data),
|
|
47
48
|
preview: extractPreview(data),
|
|
@@ -59,4 +59,15 @@ export var extractTargetBranch = function extractTargetBranch(data) {
|
|
|
59
59
|
export var extractChecklistProgress = function extractChecklistProgress(data) {
|
|
60
60
|
var checkItemsObj = extractValue(data, 'atlassian:checkItems');
|
|
61
61
|
return checkItemsObj ? "".concat(checkItemsObj.checkedItems, "/").concat(checkItemsObj.totalItems) : undefined;
|
|
62
|
+
};
|
|
63
|
+
export var extractLocation = function extractLocation(data) {
|
|
64
|
+
var _ref = extractValue(data, 'location') || {},
|
|
65
|
+
url = _ref.url,
|
|
66
|
+
name = _ref.name;
|
|
67
|
+
if (url && name && typeof url === 'string') {
|
|
68
|
+
return {
|
|
69
|
+
text: name,
|
|
70
|
+
url: url
|
|
71
|
+
};
|
|
72
|
+
}
|
|
62
73
|
};
|
|
@@ -16,13 +16,20 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
16
16
|
connections = _useSmartLinkContext.connections;
|
|
17
17
|
var getState = store.getState,
|
|
18
18
|
dispatch = store.dispatch;
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
var getSmartLinkState = useCallback(function () {
|
|
20
|
+
var _getState$url;
|
|
21
|
+
var _ref = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : {
|
|
22
|
+
status: SmartLinkStatus.Pending
|
|
23
|
+
},
|
|
24
|
+
details = _ref.details,
|
|
25
|
+
status = _ref.status,
|
|
26
|
+
metadataStatus = _ref.metadataStatus;
|
|
27
|
+
return {
|
|
28
|
+
details: details,
|
|
29
|
+
status: status,
|
|
30
|
+
metadataStatus: metadataStatus
|
|
31
|
+
};
|
|
32
|
+
}, [getState, url]);
|
|
26
33
|
var setMetadataStatus = useCallback(function (metadataStatus) {
|
|
27
34
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
28
35
|
url: url
|
|
@@ -49,6 +56,8 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
49
56
|
}, _callee);
|
|
50
57
|
})), [id, resolveUrl, url]);
|
|
51
58
|
var register = useCallback(function () {
|
|
59
|
+
var _getSmartLinkState = getSmartLinkState(),
|
|
60
|
+
details = _getSmartLinkState.details;
|
|
52
61
|
if (!details) {
|
|
53
62
|
dispatch(cardAction(ACTION_RESOLVING, {
|
|
54
63
|
url: url
|
|
@@ -56,8 +65,10 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
56
65
|
setMetadataStatus('pending');
|
|
57
66
|
}
|
|
58
67
|
return resolve();
|
|
59
|
-
}, [
|
|
68
|
+
}, [getSmartLinkState, resolve, dispatch, url, setMetadataStatus]);
|
|
60
69
|
var reload = useCallback(function () {
|
|
70
|
+
var _getSmartLinkState2 = getSmartLinkState(),
|
|
71
|
+
details = _getSmartLinkState2.details;
|
|
61
72
|
var definitionId = getDefinitionId(details);
|
|
62
73
|
if (definitionId) {
|
|
63
74
|
getByDefinitionId(definitionId, getState()).map(function (url) {
|
|
@@ -66,15 +77,20 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
66
77
|
} else {
|
|
67
78
|
resolve(url, true);
|
|
68
79
|
}
|
|
69
|
-
}, [
|
|
80
|
+
}, [getSmartLinkState, url, getState, resolve]);
|
|
70
81
|
var loadMetadata = useCallback(function () {
|
|
82
|
+
var _getSmartLinkState3 = getSmartLinkState(),
|
|
83
|
+
metadataStatus = _getSmartLinkState3.metadataStatus;
|
|
71
84
|
//metadataStatus will be undefined for SSR links only
|
|
72
85
|
if (metadataStatus === undefined) {
|
|
73
86
|
setMetadataStatus('pending');
|
|
74
87
|
return resolve(url, false, true);
|
|
75
88
|
}
|
|
76
|
-
}, [
|
|
89
|
+
}, [getSmartLinkState, resolve, setMetadataStatus, url]);
|
|
77
90
|
var authorize = useCallback(function (appearance) {
|
|
91
|
+
var _getSmartLinkState4 = getSmartLinkState(),
|
|
92
|
+
details = _getSmartLinkState4.details,
|
|
93
|
+
status = _getSmartLinkState4.status;
|
|
78
94
|
var definitionId = getDefinitionId(details);
|
|
79
95
|
var extensionKey = getExtensionKey(details);
|
|
80
96
|
var services = getServices(details);
|
|
@@ -126,7 +142,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
126
142
|
reload();
|
|
127
143
|
});
|
|
128
144
|
}
|
|
129
|
-
}, [analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload
|
|
145
|
+
}, [getSmartLinkState, analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload]);
|
|
130
146
|
var invoke = useCallback( /*#__PURE__*/function () {
|
|
131
147
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(opts, appearance) {
|
|
132
148
|
var key, action, source, markName, response;
|