@atlaskit/smart-card 26.23.2 → 26.25.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 +20 -0
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/extractors/block/index.js +1 -1
- package/dist/cjs/extractors/common/actions/extractActions.js +3 -31
- package/dist/cjs/extractors/flexible/actions/extract-follow-action.js +53 -0
- package/dist/cjs/extractors/flexible/index.js +3 -0
- package/dist/cjs/messages.js +10 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +7 -15
- package/dist/cjs/state/hooks/use-invoke-client-action/index.js +20 -14
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -45
- package/dist/cjs/view/BlockCard/views/flexible/styled.js +2 -2
- package/dist/cjs/view/EmbedCard/components/styled.js +2 -2
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +33 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +41 -15
- package/dist/cjs/view/FlexibleCard/components/actions/action/server-action/index.js +4 -4
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +33 -1
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +43 -0
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/unfollow-icon/index.js +40 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +10 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +2 -19
- package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +8 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +22 -1
- package/dist/cjs/view/FlexibleCard/components/utils.js +9 -20
- package/dist/cjs/view/FlexibleCard/index.js +14 -1
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -0
- package/dist/cjs/view/HoverCard/styled.js +2 -2
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/RedesignedInlineCard/Frame/styled.js +1 -1
- package/dist/cjs/view/RedesignedInlineCard/styled.js +1 -1
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/extractors/block/index.js +2 -2
- package/dist/es2019/extractors/common/actions/extractActions.js +2 -23
- package/dist/es2019/extractors/flexible/actions/extract-follow-action.js +45 -0
- package/dist/es2019/extractors/flexible/index.js +3 -0
- package/dist/es2019/messages.js +10 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +7 -15
- package/dist/es2019/state/hooks/use-invoke-client-action/index.js +14 -8
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -42
- package/dist/es2019/view/BlockCard/views/flexible/styled.js +10 -1
- package/dist/es2019/view/EmbedCard/components/styled.js +2 -2
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +15 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +18 -7
- package/dist/es2019/view/FlexibleCard/components/actions/action/server-action/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +15 -1
- package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +31 -0
- package/dist/es2019/view/FlexibleCard/components/actions/follow-action/unfollow-icon/index.js +28 -0
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +3 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +2 -17
- package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +9 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +19 -1
- package/dist/es2019/view/FlexibleCard/components/utils.js +3 -17
- package/dist/es2019/view/FlexibleCard/index.js +11 -1
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -0
- package/dist/es2019/view/HoverCard/styled.js +3 -3
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/RedesignedInlineCard/Frame/styled.js +1 -1
- package/dist/es2019/view/RedesignedInlineCard/styled.js +1 -1
- package/dist/esm/constants.js +1 -0
- package/dist/esm/extractors/block/index.js +2 -2
- package/dist/esm/extractors/common/actions/extractActions.js +2 -30
- package/dist/esm/extractors/flexible/actions/extract-follow-action.js +45 -0
- package/dist/esm/extractors/flexible/index.js +3 -0
- package/dist/esm/messages.js +10 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +7 -15
- package/dist/esm/state/hooks/use-invoke-client-action/index.js +20 -14
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +1 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -46
- package/dist/esm/view/BlockCard/views/flexible/styled.js +2 -2
- package/dist/esm/view/EmbedCard/components/styled.js +2 -2
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +33 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +41 -15
- package/dist/esm/view/FlexibleCard/components/actions/action/server-action/index.js +4 -4
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +33 -1
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +32 -0
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/unfollow-icon/index.js +32 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +3 -0
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +2 -19
- package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +9 -2
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +21 -1
- package/dist/esm/view/FlexibleCard/components/utils.js +9 -20
- package/dist/esm/view/FlexibleCard/index.js +14 -1
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -0
- package/dist/esm/view/HoverCard/styled.js +2 -2
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/RedesignedInlineCard/Frame/styled.js +1 -1
- package/dist/esm/view/RedesignedInlineCard/styled.js +1 -1
- package/dist/types/__fixtures__/atlas-project.d.ts +68 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +3 -1
- package/dist/types/extractors/common/actions/extractActions.d.ts +1 -1
- package/dist/types/extractors/flexible/actions/extract-follow-action.d.ts +5 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +4 -4
- package/dist/types/state/flexible-ui-context/index.d.ts +3 -119
- package/dist/types/state/flexible-ui-context/types.d.ts +17 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +3 -3
- package/dist/types/utils/analytics/types.d.ts +3 -3
- package/dist/types/utils/mocks.d.ts +3 -3
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/follow-action/unfollow-icon/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +3 -1
- package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -63
- package/dist/types/view/FlexibleCard/types.d.ts +2 -3
- package/dist/types-ts4.5/__fixtures__/atlas-project.d.ts +68 -0
- package/dist/types-ts4.5/constants.d.ts +1 -0
- package/dist/types-ts4.5/extractors/common/__mocks__/jsonld.d.ts +3 -1
- package/dist/types-ts4.5/extractors/common/actions/extractActions.d.ts +1 -1
- package/dist/types-ts4.5/extractors/flexible/actions/extract-follow-action.d.ts +5 -0
- package/dist/types-ts4.5/messages.d.ts +1 -1
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +4 -4
- package/dist/types-ts4.5/state/flexible-ui-context/index.d.ts +3 -119
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +17 -0
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +3 -3
- package/dist/types-ts4.5/utils/analytics/types.d.ts +3 -3
- package/dist/types-ts4.5/utils/mocks.d.ts +3 -3
- package/dist/types-ts4.5/view/Card/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +4 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/unfollow-icon/index.d.ts +4 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/utils.d.ts +3 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +2 -63
- package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -3
- package/package.json +2 -2
- package/report.api.md +9 -6
- package/tmp/api-report-tmp.d.ts +9 -7
|
@@ -235,11 +235,11 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
235
235
|
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
236
236
|
* @param actionType The type of the action that was clicked, e.g. PreviewAction
|
|
237
237
|
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
238
|
-
* @param invokeType
|
|
238
|
+
* @param invokeType @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
|
|
239
239
|
* @returns
|
|
240
240
|
*/
|
|
241
241
|
actionClickedEvent: ({
|
|
242
|
-
id
|
|
242
|
+
id,
|
|
243
243
|
actionType,
|
|
244
244
|
display,
|
|
245
245
|
invokeType,
|
|
@@ -251,14 +251,8 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
251
251
|
location
|
|
252
252
|
}) => {
|
|
253
253
|
const extensionKey = overrideExtensionKey !== null && overrideExtensionKey !== void 0 ? overrideExtensionKey : extractedExtensionKey;
|
|
254
|
-
startUfoExperience('smart-link-action-invocation', experienceId, {
|
|
255
|
-
actionType,
|
|
256
|
-
display,
|
|
257
|
-
extensionKey,
|
|
258
|
-
invokeType
|
|
259
|
-
});
|
|
260
254
|
dispatchAnalytics(applyCommonAttributes(uiActionClickedEvent({
|
|
261
|
-
id: defaultId,
|
|
255
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
262
256
|
actionType,
|
|
263
257
|
display,
|
|
264
258
|
extensionKey,
|
|
@@ -507,7 +501,7 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
507
501
|
* @param display Whether the card was an Inline, Block, Embed or Flexible UI.
|
|
508
502
|
*/
|
|
509
503
|
invokeSucceededEvent: ({
|
|
510
|
-
id
|
|
504
|
+
id,
|
|
511
505
|
actionType,
|
|
512
506
|
display,
|
|
513
507
|
extensionKey,
|
|
@@ -517,9 +511,8 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
517
511
|
destinationSubproduct,
|
|
518
512
|
location
|
|
519
513
|
}) => {
|
|
520
|
-
succeedUfoExperience('smart-link-action-invocation', experienceId);
|
|
521
514
|
dispatchAnalytics(applyCommonAttributes(invokeSucceededEvent({
|
|
522
|
-
id: defaultId,
|
|
515
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
523
516
|
actionType,
|
|
524
517
|
display,
|
|
525
518
|
extensionKey,
|
|
@@ -539,7 +532,7 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
539
532
|
* @param reason The reason the invocation failed.
|
|
540
533
|
*/
|
|
541
534
|
invokeFailedEvent: ({
|
|
542
|
-
id
|
|
535
|
+
id,
|
|
543
536
|
actionType,
|
|
544
537
|
display,
|
|
545
538
|
reason,
|
|
@@ -550,9 +543,8 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
|
|
|
550
543
|
destinationSubproduct,
|
|
551
544
|
location
|
|
552
545
|
}) => {
|
|
553
|
-
failUfoExperience('smart-link-action-invocation', experienceId);
|
|
554
546
|
dispatchAnalytics(applyCommonAttributes(invokeFailedEvent({
|
|
555
|
-
id: defaultId,
|
|
547
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
556
548
|
actionType,
|
|
557
549
|
display,
|
|
558
550
|
reason,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
3
|
import * as measure from '../../../utils/performance';
|
|
4
|
+
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../analytics';
|
|
5
|
+
const ACTION_EXPERIENCE_NAME = 'smart-link-action-invocation';
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Invoke client action such as preview, download and open link
|
|
6
9
|
*/
|
|
@@ -18,31 +21,34 @@ const useInvokeClientAction = ({
|
|
|
18
21
|
const markName = `${experienceId}-${actionType}`;
|
|
19
22
|
measure.mark(markName, 'pending');
|
|
20
23
|
try {
|
|
21
|
-
// Begin
|
|
22
|
-
|
|
23
|
-
id: experienceId,
|
|
24
|
-
extensionKey,
|
|
24
|
+
// Begin UFO experience
|
|
25
|
+
startUfoExperience(ACTION_EXPERIENCE_NAME, experienceId, {
|
|
25
26
|
actionType,
|
|
26
27
|
display,
|
|
28
|
+
extensionKey,
|
|
27
29
|
invokeType: 'client'
|
|
28
30
|
});
|
|
29
31
|
|
|
32
|
+
// Begin analytics instrumentation.
|
|
33
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.actionClickedEvent({
|
|
34
|
+
actionType,
|
|
35
|
+
display
|
|
36
|
+
});
|
|
37
|
+
|
|
30
38
|
// Invoke action
|
|
31
39
|
const result = await actionFn();
|
|
32
40
|
measure.mark(markName, 'resolved');
|
|
41
|
+
succeedUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
|
|
33
42
|
analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeSucceededEvent({
|
|
34
|
-
id: experienceId,
|
|
35
|
-
extensionKey,
|
|
36
43
|
actionType,
|
|
37
44
|
display
|
|
38
45
|
});
|
|
39
46
|
return result;
|
|
40
47
|
} catch (err) {
|
|
41
48
|
measure.mark(markName, 'errored');
|
|
49
|
+
failUfoExperience(ACTION_EXPERIENCE_NAME, experienceId);
|
|
42
50
|
const reason = typeof err === 'string' ? err : err === null || err === void 0 ? void 0 : err.message;
|
|
43
51
|
analytics === null || analytics === void 0 ? void 0 : analytics.operational.invokeFailedEvent({
|
|
44
|
-
id: experienceId,
|
|
45
|
-
extensionKey,
|
|
46
52
|
actionType,
|
|
47
53
|
display,
|
|
48
54
|
reason
|
|
@@ -3,7 +3,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
3
3
|
export const context = {
|
|
4
4
|
componentName: 'smart-cards',
|
|
5
5
|
packageName: "@atlaskit/smart-card",
|
|
6
|
-
packageVersion: "26.
|
|
6
|
+
packageVersion: "26.25.0"
|
|
7
7
|
};
|
|
8
8
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
9
9
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -30,6 +30,7 @@ const FlexibleErroredView = ({
|
|
|
30
30
|
const status = cardState.status;
|
|
31
31
|
const actions = useMemo(() => onAuthorize ? [RetryAction(onAuthorize)] : [], [onAuthorize]);
|
|
32
32
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
33
|
+
appearance: "block",
|
|
33
34
|
cardState: cardState,
|
|
34
35
|
onAuthorize: onAuthorize,
|
|
35
36
|
onClick: onClick,
|
|
@@ -4,8 +4,7 @@ import FlexibleCard from '../../../FlexibleCard';
|
|
|
4
4
|
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
5
5
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
|
|
6
6
|
import { metadataBlockCss, footerBlockCss } from './styled';
|
|
7
|
-
import { ActionName,
|
|
8
|
-
import uuid from 'uuid';
|
|
7
|
+
import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
|
|
9
8
|
import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
|
|
10
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
|
|
@@ -32,7 +31,6 @@ const FlexibleResolvedView = ({
|
|
|
32
31
|
useEffect(() => {
|
|
33
32
|
setIsPreviewBlockErrored(false);
|
|
34
33
|
}, [url, cardState]);
|
|
35
|
-
const [analyticsId] = useState(() => id ? id : uuid());
|
|
36
34
|
const {
|
|
37
35
|
titleMetadata,
|
|
38
36
|
topMetadata,
|
|
@@ -80,49 +78,13 @@ const FlexibleResolvedView = ({
|
|
|
80
78
|
}, {
|
|
81
79
|
actions: [{
|
|
82
80
|
name: ActionName.PreviewAction,
|
|
83
|
-
hideIcon: true
|
|
84
|
-
onClick: () => {
|
|
85
|
-
analytics.ui.actionClickedEvent({
|
|
86
|
-
id: analyticsId,
|
|
87
|
-
actionType: 'PreviewAction',
|
|
88
|
-
display: CardDisplay.Block
|
|
89
|
-
});
|
|
90
|
-
analytics.operational.invokeSucceededEvent({
|
|
91
|
-
id: analyticsId,
|
|
92
|
-
actionType: 'PreviewAction',
|
|
93
|
-
display: CardDisplay.Block
|
|
94
|
-
});
|
|
95
|
-
}
|
|
81
|
+
hideIcon: true
|
|
96
82
|
}, {
|
|
97
83
|
name: ActionName.ViewAction,
|
|
98
|
-
hideIcon: true
|
|
99
|
-
onClick: () => {
|
|
100
|
-
analytics.ui.actionClickedEvent({
|
|
101
|
-
id: analyticsId,
|
|
102
|
-
actionType: 'ViewAction',
|
|
103
|
-
display: CardDisplay.Block
|
|
104
|
-
});
|
|
105
|
-
analytics.operational.invokeSucceededEvent({
|
|
106
|
-
id: analyticsId,
|
|
107
|
-
actionType: 'ViewAction',
|
|
108
|
-
display: CardDisplay.Block
|
|
109
|
-
});
|
|
110
|
-
}
|
|
84
|
+
hideIcon: true
|
|
111
85
|
}, {
|
|
112
86
|
name: ActionName.DownloadAction,
|
|
113
|
-
hideIcon: true
|
|
114
|
-
onClick: () => {
|
|
115
|
-
analytics.ui.actionClickedEvent({
|
|
116
|
-
id: analyticsId,
|
|
117
|
-
actionType: 'DownloadAction',
|
|
118
|
-
display: CardDisplay.Block
|
|
119
|
-
});
|
|
120
|
-
analytics.operational.invokeSucceededEvent({
|
|
121
|
-
id: analyticsId,
|
|
122
|
-
actionType: 'DownloadAction',
|
|
123
|
-
display: CardDisplay.Block
|
|
124
|
-
});
|
|
125
|
-
}
|
|
87
|
+
hideIcon: true
|
|
126
88
|
}]
|
|
127
89
|
})));
|
|
128
90
|
};
|
|
@@ -23,6 +23,15 @@ export const titleBlockCss = css`
|
|
|
23
23
|
`;
|
|
24
24
|
export const footerBlockCss = css`
|
|
25
25
|
height: 1.5rem;
|
|
26
|
+
|
|
27
|
+
.actions-button-group {
|
|
28
|
+
button,
|
|
29
|
+
button:hover,
|
|
30
|
+
button:focus,
|
|
31
|
+
button:active {
|
|
32
|
+
font-size: 0.875rem;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
26
35
|
`;
|
|
27
36
|
const flexibleBlockCardElevationStyle = css`
|
|
28
37
|
border-radius: 1.5px;
|
|
@@ -31,7 +40,7 @@ const flexibleBlockCardElevationStyle = css`
|
|
|
31
40
|
`;
|
|
32
41
|
const refreshedFlexibleBlockCardStyle = css`
|
|
33
42
|
& > div {
|
|
34
|
-
border-radius: ${"var(--ds-border-radius-
|
|
43
|
+
border-radius: ${"var(--ds-border-radius-200, 8px)"};
|
|
35
44
|
border: 1px solid ${`var(--ds-border-input, ${N40})`};
|
|
36
45
|
}
|
|
37
46
|
`;
|
|
@@ -11,10 +11,10 @@ export const borderRadius = `
|
|
|
11
11
|
`;
|
|
12
12
|
const BACKGROUND_COLOR_DARK = '#262B31';
|
|
13
13
|
const wrapperBorderRadius = `
|
|
14
|
-
border-radius: ${"var(--ds-border-radius-
|
|
14
|
+
border-radius: ${"var(--ds-border-radius-200, 8px)"};
|
|
15
15
|
`;
|
|
16
16
|
const contentBorderRadius = `
|
|
17
|
-
border-radius: ${"var(--ds-border-radius-
|
|
17
|
+
border-radius: ${"var(--ds-border-radius-100, 4px)"};
|
|
18
18
|
`;
|
|
19
19
|
export const ellipsis = (maxWidth = '100%') => {
|
|
20
20
|
const unit = typeof maxWidth === 'number' ? 'px' : '';
|
|
@@ -2,6 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { downloadUrl as download } from '../../../../../../utils';
|
|
5
|
+
import { ActionName } from '../../../../../../constants';
|
|
6
|
+
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
7
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
5
8
|
const DownloadAction = props => {
|
|
6
9
|
const {
|
|
7
10
|
appearance,
|
|
@@ -11,11 +14,22 @@ const DownloadAction = props => {
|
|
|
11
14
|
testId,
|
|
12
15
|
url
|
|
13
16
|
} = props;
|
|
17
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
18
|
+
const invoke = useInvokeClientAction({
|
|
19
|
+
analytics
|
|
20
|
+
});
|
|
14
21
|
if (downloadUrl && url) {
|
|
15
22
|
const action = {
|
|
16
23
|
...props,
|
|
17
24
|
onClick: () => {
|
|
18
|
-
|
|
25
|
+
invoke({
|
|
26
|
+
actionType: ActionName.DownloadAction,
|
|
27
|
+
actionFn: async () => download(downloadUrl),
|
|
28
|
+
// These values have already been set in analytics context.
|
|
29
|
+
// We only pass these here for ufo experience.
|
|
30
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
31
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
32
|
+
});
|
|
19
33
|
if (onClick) {
|
|
20
34
|
onClick();
|
|
21
35
|
}
|
|
@@ -2,10 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
5
|
-
import { useSmartLinkAnalytics } from '../../../../../../state';
|
|
6
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
6
|
import { messages } from '../../../../../../messages';
|
|
8
7
|
import { openEmbedModalWithFlexibleUiIcon } from '../../../utils';
|
|
8
|
+
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
9
|
+
import { ActionName } from '../../../../../../constants';
|
|
9
10
|
const PreviewAction = props => {
|
|
10
11
|
const {
|
|
11
12
|
appearance,
|
|
@@ -20,22 +21,32 @@ const PreviewAction = props => {
|
|
|
20
21
|
downloadUrl,
|
|
21
22
|
isSupportTheming
|
|
22
23
|
} = props;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
24
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
25
|
+
const invoke = useInvokeClientAction({
|
|
26
|
+
analytics
|
|
27
|
+
});
|
|
25
28
|
if (src && url) {
|
|
26
|
-
const
|
|
29
|
+
const actionFn = async () => openEmbedModalWithFlexibleUiIcon({
|
|
30
|
+
download: downloadUrl,
|
|
27
31
|
title,
|
|
28
32
|
providerName,
|
|
29
|
-
downloadUrl,
|
|
30
33
|
isSupportTheming,
|
|
31
34
|
analytics,
|
|
32
35
|
linkIcon,
|
|
33
|
-
src
|
|
36
|
+
src,
|
|
37
|
+
url
|
|
34
38
|
});
|
|
35
39
|
const action = {
|
|
36
40
|
...props,
|
|
37
41
|
onClick: () => {
|
|
38
|
-
|
|
42
|
+
invoke({
|
|
43
|
+
actionType: ActionName.PreviewAction,
|
|
44
|
+
actionFn,
|
|
45
|
+
// These values have already been set in analytics context.
|
|
46
|
+
// We only pass these here for ufo experience.
|
|
47
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
48
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
49
|
+
});
|
|
39
50
|
if (onClick) {
|
|
40
51
|
onClick();
|
|
41
52
|
}
|
|
@@ -18,10 +18,10 @@ const ServerAction = ({
|
|
|
18
18
|
setIsLoading(true);
|
|
19
19
|
const request = createInvokeRequest(action);
|
|
20
20
|
await invoke(request);
|
|
21
|
-
setIsLoading(false);
|
|
22
21
|
if (action.reload && action.reload.url) {
|
|
23
22
|
await reload(action.reload.url, true, undefined, action.reload.id);
|
|
24
23
|
}
|
|
24
|
+
setIsLoading(false);
|
|
25
25
|
if (onClick) {
|
|
26
26
|
onClick();
|
|
27
27
|
}
|
|
@@ -2,6 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { openUrl } from '../../../../../../utils';
|
|
5
|
+
import { ActionName } from '../../../../../../constants';
|
|
6
|
+
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
7
|
+
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
5
8
|
const ViewAction = props => {
|
|
6
9
|
const {
|
|
7
10
|
appearance,
|
|
@@ -11,11 +14,22 @@ const ViewAction = props => {
|
|
|
11
14
|
viewUrl,
|
|
12
15
|
url
|
|
13
16
|
} = props;
|
|
17
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
18
|
+
const invoke = useInvokeClientAction({
|
|
19
|
+
analytics
|
|
20
|
+
});
|
|
14
21
|
if (viewUrl && url) {
|
|
15
22
|
const action = {
|
|
16
23
|
...props,
|
|
17
24
|
onClick: () => {
|
|
18
|
-
|
|
25
|
+
invoke({
|
|
26
|
+
actionType: ActionName.ViewAction,
|
|
27
|
+
actionFn: async () => openUrl(viewUrl),
|
|
28
|
+
// These values have already been set in analytics context.
|
|
29
|
+
// We only pass these here for ufo experience.
|
|
30
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
31
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
32
|
+
});
|
|
19
33
|
if (onClick) {
|
|
20
34
|
onClick();
|
|
21
35
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { messages } from '../../../../../messages';
|
|
6
|
+
import { FlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
7
|
+
import ServerAction from '../action/server-action';
|
|
8
|
+
import UnfollowIcon from './unfollow-icon';
|
|
9
|
+
const FollowAction = props => {
|
|
10
|
+
const context = useContext(FlexibleUiContext);
|
|
11
|
+
if (!context || !context.followAction) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const {
|
|
15
|
+
value,
|
|
16
|
+
...data
|
|
17
|
+
} = context.followAction;
|
|
18
|
+
const message = value ? messages.follow : messages.unfollow;
|
|
19
|
+
const icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
|
|
20
|
+
label: "Follow"
|
|
21
|
+
}) : /*#__PURE__*/React.createElement(UnfollowIcon, {
|
|
22
|
+
label: "Unfollow"
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/React.createElement(ServerAction, _extends({
|
|
25
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, message),
|
|
26
|
+
icon: icon,
|
|
27
|
+
testId: "smart-action-follow-action",
|
|
28
|
+
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, message)
|
|
29
|
+
}, data, props));
|
|
30
|
+
};
|
|
31
|
+
export default FollowAction;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import Icon from '@atlaskit/icon';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
const UnfollowGlyph = props => /*#__PURE__*/React.createElement("svg", {
|
|
5
|
+
width: "16",
|
|
6
|
+
height: "16",
|
|
7
|
+
viewBox: "0 0 16 16",
|
|
8
|
+
"data-testid": props['data-testid'],
|
|
9
|
+
"aria-label": props['aria-label'],
|
|
10
|
+
className: props.className,
|
|
11
|
+
role: "presentation",
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
14
|
+
d: "M14 4.66667H11.3333C10.9652 4.66667 10.6667 4.96514 10.6667 5.33333C10.6667 5.70152 10.9652 6 11.3333 6H14C14.3682 6 14.6667 5.70152 14.6667 5.33333C14.6667 4.96514 14.3682 4.66667 14 4.66667Z",
|
|
15
|
+
fill: "currentColor"
|
|
16
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
17
|
+
fillRule: "evenodd",
|
|
18
|
+
clipRule: "evenodd",
|
|
19
|
+
d: "M3.33334 9.33333C3.33334 8.59667 3.93468 8 4.67268 8H9.99401C10.734 8 11.3333 8.596 11.3333 9.33733V12.2973C11.3333 14.5673 3.33334 14.5673 3.33334 12.2973V9.33333Z",
|
|
20
|
+
fill: "currentColor"
|
|
21
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
22
|
+
d: "M7.33334 7.33333C8.8061 7.33333 10 6.13943 10 4.66667C10 3.19391 8.8061 2 7.33334 2C5.86058 2 4.66668 3.19391 4.66668 4.66667C4.66668 6.13943 5.86058 7.33333 7.33334 7.33333Z",
|
|
23
|
+
fill: "currentColor"
|
|
24
|
+
}));
|
|
25
|
+
const UnfollowIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({
|
|
26
|
+
glyph: UnfollowGlyph
|
|
27
|
+
}, props));
|
|
28
|
+
export default UnfollowIcon;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ActionName } from '../../../../constants';
|
|
2
2
|
import { createDataAction, createUIAction } from './utils';
|
|
3
|
+
export { default as FollowAction } from './follow-action';
|
|
4
|
+
|
|
3
5
|
// Attention: Keep the export name and action name the same.
|
|
4
6
|
// This will help reducing the code for mapping action inside
|
|
5
7
|
// createAction and renderActionItems
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Creates a DeleteAction component. Accepts default ActionProps, but defaults
|
|
8
11
|
* the icon to a cross icon.
|
|
@@ -6,13 +6,14 @@ import { css, jsx } from '@emotion/react';
|
|
|
6
6
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
7
7
|
import Tooltip from '@atlaskit/tooltip';
|
|
8
8
|
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
9
|
-
import {
|
|
9
|
+
import { SmartLinkSize } from '../../../../../constants';
|
|
10
10
|
import Button from '@atlaskit/button/standard-button';
|
|
11
11
|
import MoreIcon from '@atlaskit/icon/glyph/more';
|
|
12
12
|
import { sizeToButtonSpacing } from '../../utils';
|
|
13
13
|
import { messages } from '../../../../../messages';
|
|
14
14
|
import { useFlexibleUiContext, useFlexibleUiOptionContext } from '../../../../../state/flexible-ui-context';
|
|
15
15
|
import ActionGroupItem from './action-group-item';
|
|
16
|
+
import { filterActionItems } from '../utils';
|
|
16
17
|
const styles = css`
|
|
17
18
|
display: inline-flex;
|
|
18
19
|
line-height: 1rem;
|
|
@@ -37,22 +38,6 @@ const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance,
|
|
|
37
38
|
asDropDownItems: asDropDownItems,
|
|
38
39
|
onActionItemClick: onActionItemClick
|
|
39
40
|
}));
|
|
40
|
-
const filterActionItems = (items = [], context) => {
|
|
41
|
-
return items.filter(item => {
|
|
42
|
-
switch (item.name) {
|
|
43
|
-
// Action that require data from the data context to render.
|
|
44
|
-
case ActionName.DownloadAction:
|
|
45
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
|
|
46
|
-
case ActionName.PreviewAction:
|
|
47
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.previewAction);
|
|
48
|
-
case ActionName.ViewAction:
|
|
49
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
|
|
50
|
-
default:
|
|
51
|
-
// Named and custom actions that user defines.
|
|
52
|
-
return Boolean(ActionName[item.name]);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
41
|
|
|
57
42
|
/**
|
|
58
43
|
* Creates a group of Action components. Accepts an array of Actions, in addition to some styling
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
|
|
5
5
|
import Block from '../block';
|
|
6
6
|
import ElementGroup from '../element-group';
|
|
7
7
|
import { Provider } from '../../elements';
|
|
8
8
|
import ActionGroup from '../action-group';
|
|
9
|
+
import { filterActionItems } from '../utils';
|
|
10
|
+
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
9
11
|
const getActionGroupStyles = size => {
|
|
10
12
|
if (size === SmartLinkSize.XLarge) {
|
|
11
13
|
// The biggest height of the action button exceeds the max line-height
|
|
@@ -32,6 +34,11 @@ const FooterBlock = props => {
|
|
|
32
34
|
testId = 'smart-footer-block',
|
|
33
35
|
onActionMenuOpenChange
|
|
34
36
|
} = props;
|
|
37
|
+
const context = useFlexibleUiContext();
|
|
38
|
+
const hasActions = useMemo(() => {
|
|
39
|
+
var _filterActionItems;
|
|
40
|
+
return ((_filterActionItems = filterActionItems(actions, context)) === null || _filterActionItems === void 0 ? void 0 : _filterActionItems.length) > 0;
|
|
41
|
+
}, [actions, context]);
|
|
35
42
|
const onDropdownOpenChange = useCallback(isOpen => {
|
|
36
43
|
if (onActionMenuOpenChange) {
|
|
37
44
|
onActionMenuOpenChange({
|
|
@@ -46,7 +53,7 @@ const FooterBlock = props => {
|
|
|
46
53
|
testId: `${testId}-resolved-view`
|
|
47
54
|
}), /*#__PURE__*/React.createElement(Provider, {
|
|
48
55
|
testId: `${testId}-provider`
|
|
49
|
-
}), actions &&
|
|
56
|
+
}), actions && hasActions ? /*#__PURE__*/React.createElement(ElementGroup, {
|
|
50
57
|
testId: "smart-element-group-actions",
|
|
51
58
|
align: SmartLinkAlignment.Right,
|
|
52
59
|
direction: SmartLinkDirection.Horizontal,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
4
|
+
import { ActionName, ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
5
5
|
import * as Elements from '../elements';
|
|
6
6
|
import { isFlexibleUiElement } from '../../../../utils/flexible';
|
|
7
7
|
import ActionGroup from './action-group';
|
|
@@ -111,6 +111,24 @@ export const isJSXElementNull = children => {
|
|
|
111
111
|
return Boolean(children.type() === null);
|
|
112
112
|
};
|
|
113
113
|
const isElementOrElementGroup = node => /*#__PURE__*/React.isValidElement(node) && (isFlexibleUiElement(node) || node.type === ElementGroup);
|
|
114
|
+
export const filterActionItems = (items = [], context) => {
|
|
115
|
+
return items.filter(item => {
|
|
116
|
+
switch (item.name) {
|
|
117
|
+
// Action that require data from the data context to render.
|
|
118
|
+
case ActionName.DownloadAction:
|
|
119
|
+
return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
|
|
120
|
+
case ActionName.FollowAction:
|
|
121
|
+
return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
|
|
122
|
+
case ActionName.PreviewAction:
|
|
123
|
+
return Boolean(context === null || context === void 0 ? void 0 : context.previewAction);
|
|
124
|
+
case ActionName.ViewAction:
|
|
125
|
+
return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
|
|
126
|
+
default:
|
|
127
|
+
// Named and custom actions that user defines.
|
|
128
|
+
return Boolean(ActionName[item.name]);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
|
114
132
|
export const renderChildren = (children, size) => React.Children.map(children, child => {
|
|
115
133
|
if (isElementOrElementGroup(child) || isActionGroup(child)) {
|
|
116
134
|
const node = child;
|
|
@@ -142,15 +142,8 @@ export const hasWhiteSpace = str => {
|
|
|
142
142
|
return str.search(/\s/) >= 0;
|
|
143
143
|
};
|
|
144
144
|
export const openEmbedModalWithFlexibleUiIcon = ({
|
|
145
|
-
analytics,
|
|
146
|
-
downloadUrl,
|
|
147
145
|
linkIcon,
|
|
148
|
-
|
|
149
|
-
providerName,
|
|
150
|
-
src,
|
|
151
|
-
title,
|
|
152
|
-
url,
|
|
153
|
-
isSupportTheming
|
|
146
|
+
...props
|
|
154
147
|
}) => {
|
|
155
148
|
const icon = {
|
|
156
149
|
icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
|
|
@@ -159,18 +152,11 @@ export const openEmbedModalWithFlexibleUiIcon = ({
|
|
|
159
152
|
isFlexibleUi: true
|
|
160
153
|
};
|
|
161
154
|
return openEmbedModal({
|
|
162
|
-
|
|
163
|
-
download: downloadUrl,
|
|
155
|
+
...props,
|
|
164
156
|
icon,
|
|
165
157
|
// Flex should not send origin as block card. It should be able to support
|
|
166
158
|
// its internal parent components like hover card, block card and
|
|
167
159
|
// itself as a standalone. To be investigated and fix in EDM-7520.
|
|
168
|
-
origin: 'smartLinkCard'
|
|
169
|
-
providerName,
|
|
170
|
-
onClose,
|
|
171
|
-
src,
|
|
172
|
-
title,
|
|
173
|
-
url,
|
|
174
|
-
isSupportTheming
|
|
160
|
+
origin: 'smartLinkCard'
|
|
175
161
|
});
|
|
176
162
|
};
|
|
@@ -13,6 +13,7 @@ import { getContextByStatus, getRetryOptions } from './utils';
|
|
|
13
13
|
*/
|
|
14
14
|
const FlexibleCard = ({
|
|
15
15
|
analytics,
|
|
16
|
+
appearance = 'flexible',
|
|
16
17
|
cardState,
|
|
17
18
|
children,
|
|
18
19
|
id,
|
|
@@ -28,6 +29,7 @@ const FlexibleCard = ({
|
|
|
28
29
|
ui,
|
|
29
30
|
url
|
|
30
31
|
}) => {
|
|
32
|
+
var _details$meta2;
|
|
31
33
|
const {
|
|
32
34
|
status: cardType,
|
|
33
35
|
details
|
|
@@ -45,6 +47,14 @@ const FlexibleCard = ({
|
|
|
45
47
|
const {
|
|
46
48
|
title
|
|
47
49
|
} = context || {};
|
|
50
|
+
const analyticsContext = useMemo(() => {
|
|
51
|
+
var _details$meta;
|
|
52
|
+
return analytics ? {
|
|
53
|
+
...analytics,
|
|
54
|
+
display: appearance,
|
|
55
|
+
extensionKey: details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.key
|
|
56
|
+
} : undefined;
|
|
57
|
+
}, [analytics, appearance, details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.key]);
|
|
48
58
|
useEffect(() => {
|
|
49
59
|
switch (status) {
|
|
50
60
|
case SmartLinkStatus.Resolved:
|
|
@@ -70,7 +80,7 @@ const FlexibleCard = ({
|
|
|
70
80
|
}
|
|
71
81
|
}, [onError, onResolve, status, title, url]);
|
|
72
82
|
return /*#__PURE__*/React.createElement(FlexibleUiAnalyticsContext.Provider, {
|
|
73
|
-
value:
|
|
83
|
+
value: analyticsContext
|
|
74
84
|
}, /*#__PURE__*/React.createElement(FlexibleUiOptionContext.Provider, {
|
|
75
85
|
value: ui
|
|
76
86
|
}, /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|