@atlaskit/smart-card 25.8.0 → 25.9.1
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 +15 -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 +11 -27
- package/dist/cjs/state/hooks/use-resolve/index.js +12 -21
- 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 +3 -12
- 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 +8 -4
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +5 -0
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +4 -11
- 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 +12 -32
- package/dist/es2019/state/hooks/use-resolve/index.js +12 -21
- 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 +2 -8
- 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 +17 -1
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +7 -1
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +3 -10
- 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 +11 -27
- package/dist/esm/state/hooks/use-resolve/index.js +12 -21
- 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 +2 -10
- 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 +9 -5
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +6 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +4 -11
- 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/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 +2 -3
- package/report.api.md +8 -0
- package/tmp/api-report-tmp.d.ts +8 -1
- package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +0 -47
- package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +0 -35
- package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +0 -36
- package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +0 -9
|
@@ -16,21 +16,14 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
16
16
|
getState,
|
|
17
17
|
dispatch
|
|
18
18
|
} = store;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
details,
|
|
30
|
-
status,
|
|
31
|
-
metadataStatus
|
|
32
|
-
};
|
|
33
|
-
}, [getState, url]);
|
|
19
|
+
const {
|
|
20
|
+
details,
|
|
21
|
+
status,
|
|
22
|
+
metadataStatus
|
|
23
|
+
} = getState()[url] || {
|
|
24
|
+
status: SmartLinkStatus.Pending,
|
|
25
|
+
details: undefined
|
|
26
|
+
};
|
|
34
27
|
const setMetadataStatus = useCallback(metadataStatus => {
|
|
35
28
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
36
29
|
url
|
|
@@ -38,9 +31,6 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
38
31
|
}, [dispatch, url]);
|
|
39
32
|
const resolve = useCallback(async (resourceUrl = url, isReloading = false, isMetadataRequest = false) => resolveUrl(resourceUrl, isReloading, isMetadataRequest, id), [id, resolveUrl, url]);
|
|
40
33
|
const register = useCallback(() => {
|
|
41
|
-
const {
|
|
42
|
-
details
|
|
43
|
-
} = getSmartLinkState();
|
|
44
34
|
if (!details) {
|
|
45
35
|
dispatch(cardAction(ACTION_RESOLVING, {
|
|
46
36
|
url
|
|
@@ -48,33 +38,23 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
48
38
|
setMetadataStatus('pending');
|
|
49
39
|
}
|
|
50
40
|
return resolve();
|
|
51
|
-
}, [
|
|
41
|
+
}, [details, resolve, dispatch, url, setMetadataStatus]);
|
|
52
42
|
const reload = useCallback(() => {
|
|
53
|
-
const {
|
|
54
|
-
details
|
|
55
|
-
} = getSmartLinkState();
|
|
56
43
|
const definitionId = getDefinitionId(details);
|
|
57
44
|
if (definitionId) {
|
|
58
45
|
getByDefinitionId(definitionId, getState()).map(url => resolve(url, true));
|
|
59
46
|
} else {
|
|
60
47
|
resolve(url, true);
|
|
61
48
|
}
|
|
62
|
-
}, [
|
|
49
|
+
}, [details, url, getState, resolve]);
|
|
63
50
|
const loadMetadata = useCallback(() => {
|
|
64
|
-
const {
|
|
65
|
-
metadataStatus
|
|
66
|
-
} = getSmartLinkState();
|
|
67
51
|
//metadataStatus will be undefined for SSR links only
|
|
68
52
|
if (metadataStatus === undefined) {
|
|
69
53
|
setMetadataStatus('pending');
|
|
70
54
|
return resolve(url, false, true);
|
|
71
55
|
}
|
|
72
|
-
}, [
|
|
56
|
+
}, [metadataStatus, resolve, setMetadataStatus, url]);
|
|
73
57
|
const authorize = useCallback(appearance => {
|
|
74
|
-
const {
|
|
75
|
-
details,
|
|
76
|
-
status
|
|
77
|
-
} = getSmartLinkState();
|
|
78
58
|
const definitionId = getDefinitionId(details);
|
|
79
59
|
const extensionKey = getExtensionKey(details);
|
|
80
60
|
const services = getServices(details);
|
|
@@ -126,7 +106,7 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
126
106
|
reload();
|
|
127
107
|
});
|
|
128
108
|
}
|
|
129
|
-
}, [
|
|
109
|
+
}, [analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload, details, status]);
|
|
130
110
|
const invoke = useCallback(async (opts, appearance) => {
|
|
131
111
|
const {
|
|
132
112
|
key,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { unstable_batchedUpdates } from 'react-dom';
|
|
3
2
|
import { addMetadataToExperience } from '../../analytics';
|
|
4
3
|
import { getStatus } from '../../helpers';
|
|
5
4
|
import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction } from '@atlaskit/linking-common';
|
|
@@ -99,26 +98,18 @@ const useResolve = () => {
|
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
url: resourceUrl
|
|
115
|
-
}, response));
|
|
116
|
-
} else {
|
|
117
|
-
dispatch(cardAction(ACTION_RESOLVED, {
|
|
118
|
-
url: resourceUrl
|
|
119
|
-
}, response, undefined, undefined, isMetadataRequest));
|
|
120
|
-
}
|
|
121
|
-
});
|
|
101
|
+
//if a link resolves normally, metadata will also always be resolved
|
|
102
|
+
setMetadataStatus(resourceUrl, 'resolved');
|
|
103
|
+
// Dispatch Analytics and resolved card action - including unauthorized states.
|
|
104
|
+
if (isReloading) {
|
|
105
|
+
dispatch(cardAction(ACTION_RELOADING, {
|
|
106
|
+
url: resourceUrl
|
|
107
|
+
}, response));
|
|
108
|
+
} else {
|
|
109
|
+
dispatch(cardAction(ACTION_RESOLVED, {
|
|
110
|
+
url: resourceUrl
|
|
111
|
+
}, response, undefined, undefined, isMetadataRequest));
|
|
112
|
+
}
|
|
122
113
|
}, [dispatch, handleResolvedLinkError, hasAuthFlowSupported, setMetadataStatus]);
|
|
123
114
|
return useCallback(async (url, isReloading = false, isMetadataRequest = false, id = '') => {
|
|
124
115
|
const {
|
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,8 +12,7 @@ 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
|
-
|
|
16
|
-
function Component({
|
|
15
|
+
export function CardWithUrlContent({
|
|
17
16
|
id,
|
|
18
17
|
url,
|
|
19
18
|
isSelected,
|
|
@@ -255,9 +254,4 @@ function Component({
|
|
|
255
254
|
onIframeFocus: onIframeFocus
|
|
256
255
|
});
|
|
257
256
|
}
|
|
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));
|
|
257
|
+
}
|
|
@@ -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,22 @@ const containerStyles = css`
|
|
|
14
14
|
`;
|
|
15
15
|
const getThemeStyles = theme => {
|
|
16
16
|
switch (theme) {
|
|
17
|
+
case SmartLinkInternalTheme.Grey:
|
|
18
|
+
// We are being specifc with the CSS selectors to ensure that Confluence overrides
|
|
19
|
+
// do not affect our internal Smart Card styles
|
|
20
|
+
return css`
|
|
21
|
+
a& {
|
|
22
|
+
color: ${"var(--ds-text-subtlest, #626F86)"};
|
|
23
|
+
&:active,
|
|
24
|
+
&:visited,
|
|
25
|
+
&:focus,
|
|
26
|
+
&:hover {
|
|
27
|
+
color: ${"var(--ds-text-subtlest, #626F86)"};
|
|
28
|
+
text-decoration: underline;
|
|
29
|
+
}
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
17
33
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
18
34
|
case SmartLinkTheme.Black:
|
|
19
35
|
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,11 +9,9 @@ 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';
|
|
13
12
|
export const HoverCardComponent = ({
|
|
14
13
|
children,
|
|
15
14
|
url,
|
|
16
|
-
id,
|
|
17
15
|
analyticsHandler,
|
|
18
16
|
analytics,
|
|
19
17
|
canOpen = true,
|
|
@@ -114,11 +112,7 @@ export const HoverCardComponent = ({
|
|
|
114
112
|
}, [closeOnChildClick, hideCard]);
|
|
115
113
|
const content = useCallback(({
|
|
116
114
|
update
|
|
117
|
-
}) => jsx(
|
|
118
|
-
url: url,
|
|
119
|
-
appearance: CardDisplay.HoverCardPreview,
|
|
120
|
-
id: id
|
|
121
|
-
}, jsx(HoverCardContent, {
|
|
115
|
+
}) => jsx(HoverCardContent, {
|
|
122
116
|
onMouseEnter: initShowCard,
|
|
123
117
|
onMouseLeave: initHideCard,
|
|
124
118
|
analytics: analytics,
|
|
@@ -128,9 +122,8 @@ export const HoverCardComponent = ({
|
|
|
128
122
|
onResolve: update,
|
|
129
123
|
renderers: renderers,
|
|
130
124
|
showServerActions: showServerActions,
|
|
131
|
-
url: url
|
|
132
|
-
|
|
133
|
-
})), [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
|
|
125
|
+
url: url
|
|
126
|
+
}), [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url]);
|
|
134
127
|
const trigger = useCallback(triggerProps => jsx("span", {
|
|
135
128
|
ref: parentSpan
|
|
136
129
|
}, 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,20 +16,13 @@ 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
|
-
|
|
26
|
-
metadataStatus = _ref.metadataStatus;
|
|
27
|
-
return {
|
|
28
|
-
details: details,
|
|
29
|
-
status: status,
|
|
30
|
-
metadataStatus: metadataStatus
|
|
31
|
-
};
|
|
32
|
-
}, [getState, url]);
|
|
19
|
+
var _ref = getState()[url] || {
|
|
20
|
+
status: SmartLinkStatus.Pending,
|
|
21
|
+
details: undefined
|
|
22
|
+
},
|
|
23
|
+
details = _ref.details,
|
|
24
|
+
status = _ref.status,
|
|
25
|
+
metadataStatus = _ref.metadataStatus;
|
|
33
26
|
var setMetadataStatus = useCallback(function (metadataStatus) {
|
|
34
27
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
35
28
|
url: url
|
|
@@ -56,8 +49,6 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
56
49
|
}, _callee);
|
|
57
50
|
})), [id, resolveUrl, url]);
|
|
58
51
|
var register = useCallback(function () {
|
|
59
|
-
var _getSmartLinkState = getSmartLinkState(),
|
|
60
|
-
details = _getSmartLinkState.details;
|
|
61
52
|
if (!details) {
|
|
62
53
|
dispatch(cardAction(ACTION_RESOLVING, {
|
|
63
54
|
url: url
|
|
@@ -65,10 +56,8 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
65
56
|
setMetadataStatus('pending');
|
|
66
57
|
}
|
|
67
58
|
return resolve();
|
|
68
|
-
}, [
|
|
59
|
+
}, [details, resolve, dispatch, url, setMetadataStatus]);
|
|
69
60
|
var reload = useCallback(function () {
|
|
70
|
-
var _getSmartLinkState2 = getSmartLinkState(),
|
|
71
|
-
details = _getSmartLinkState2.details;
|
|
72
61
|
var definitionId = getDefinitionId(details);
|
|
73
62
|
if (definitionId) {
|
|
74
63
|
getByDefinitionId(definitionId, getState()).map(function (url) {
|
|
@@ -77,20 +66,15 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
77
66
|
} else {
|
|
78
67
|
resolve(url, true);
|
|
79
68
|
}
|
|
80
|
-
}, [
|
|
69
|
+
}, [details, url, getState, resolve]);
|
|
81
70
|
var loadMetadata = useCallback(function () {
|
|
82
|
-
var _getSmartLinkState3 = getSmartLinkState(),
|
|
83
|
-
metadataStatus = _getSmartLinkState3.metadataStatus;
|
|
84
71
|
//metadataStatus will be undefined for SSR links only
|
|
85
72
|
if (metadataStatus === undefined) {
|
|
86
73
|
setMetadataStatus('pending');
|
|
87
74
|
return resolve(url, false, true);
|
|
88
75
|
}
|
|
89
|
-
}, [
|
|
76
|
+
}, [metadataStatus, resolve, setMetadataStatus, url]);
|
|
90
77
|
var authorize = useCallback(function (appearance) {
|
|
91
|
-
var _getSmartLinkState4 = getSmartLinkState(),
|
|
92
|
-
details = _getSmartLinkState4.details,
|
|
93
|
-
status = _getSmartLinkState4.status;
|
|
94
78
|
var definitionId = getDefinitionId(details);
|
|
95
79
|
var extensionKey = getExtensionKey(details);
|
|
96
80
|
var services = getServices(details);
|
|
@@ -142,7 +126,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
142
126
|
reload();
|
|
143
127
|
});
|
|
144
128
|
}
|
|
145
|
-
}, [
|
|
129
|
+
}, [analytics.ui, analytics.screen, analytics.track, analytics.operational, id, reload, details, status]);
|
|
146
130
|
var invoke = useCallback( /*#__PURE__*/function () {
|
|
147
131
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(opts, appearance) {
|
|
148
132
|
var key, action, source, markName, response;
|
|
@@ -2,7 +2,6 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
|
-
import { unstable_batchedUpdates } from 'react-dom';
|
|
6
5
|
import { addMetadataToExperience } from '../../analytics';
|
|
7
6
|
import { getStatus } from '../../helpers';
|
|
8
7
|
import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction } from '@atlaskit/linking-common';
|
|
@@ -100,26 +99,18 @@ var useResolve = function useResolve() {
|
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
url: resourceUrl
|
|
116
|
-
}, response));
|
|
117
|
-
} else {
|
|
118
|
-
dispatch(cardAction(ACTION_RESOLVED, {
|
|
119
|
-
url: resourceUrl
|
|
120
|
-
}, response, undefined, undefined, isMetadataRequest));
|
|
121
|
-
}
|
|
122
|
-
});
|
|
102
|
+
//if a link resolves normally, metadata will also always be resolved
|
|
103
|
+
setMetadataStatus(resourceUrl, 'resolved');
|
|
104
|
+
// Dispatch Analytics and resolved card action - including unauthorized states.
|
|
105
|
+
if (isReloading) {
|
|
106
|
+
dispatch(cardAction(ACTION_RELOADING, {
|
|
107
|
+
url: resourceUrl
|
|
108
|
+
}, response));
|
|
109
|
+
} else {
|
|
110
|
+
dispatch(cardAction(ACTION_RESOLVED, {
|
|
111
|
+
url: resourceUrl
|
|
112
|
+
}, response, undefined, undefined, isMetadataRequest));
|
|
113
|
+
}
|
|
123
114
|
}, [dispatch, handleResolvedLinkError, hasAuthFlowSupported, setMetadataStatus]);
|
|
124
115
|
return useCallback( /*#__PURE__*/function () {
|
|
125
116
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
|
package/dist/esm/version.json
CHANGED