@atlaskit/smart-card 33.1.0 → 33.3.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 +16 -0
- package/dist/cjs/extractors/flexible/actions/extract-copy-link-action.js +1 -20
- package/dist/cjs/extractors/flexible/actions/extract-download-action.js +1 -23
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +1 -34
- package/dist/cjs/extractors/flexible/actions/index.js +2 -15
- package/dist/cjs/extractors/flexible/extract-state.js +1 -5
- package/dist/cjs/extractors/flexible/index.js +3 -7
- package/dist/cjs/state/actions/index.js +2 -4
- package/dist/cjs/state/analytics/index.js +1 -8
- package/dist/cjs/state/flexible-ui-context/index.js +1 -10
- package/dist/cjs/state/hooks/use-invoke-client-action/index.js +21 -44
- package/dist/cjs/state/hooks/useSmartLink.js +1 -4
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +5 -21
- package/dist/cjs/state/hooks-external/useSmartLinkReload.js +1 -3
- package/dist/cjs/state/index.js +1 -8
- package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +3 -37
- package/dist/cjs/utils/analytics/analytics.js +2 -144
- package/dist/cjs/utils/analytics/index.js +0 -30
- package/dist/cjs/utils/analytics/types.js +1 -5
- package/dist/cjs/utils/mocks.js +1 -23
- package/dist/cjs/view/BlockCard/index.js +1 -3
- package/dist/cjs/view/BlockCard/views/ResolvedView.js +1 -3
- package/dist/cjs/view/BlockCard/views/UnauthorisedView.js +2 -4
- package/dist/cjs/view/CardWithUrl/component.js +13 -33
- package/dist/cjs/view/CardWithUrl/loader.js +10 -22
- package/dist/cjs/view/EmbedCard/index.js +0 -4
- package/dist/cjs/view/EmbedCard/views/unauthorized-view/index.js +3 -5
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +40 -89
- package/dist/cjs/view/EmbedModal/index.js +9 -68
- package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +27 -67
- package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +5 -44
- package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +5 -51
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +10 -26
- package/dist/cjs/view/FlexibleCard/components/utils.js +1 -28
- package/dist/cjs/view/FlexibleCard/index.js +3 -17
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +1 -3
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -8
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +13 -30
- package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +3 -5
- package/dist/cjs/view/HoverCard/index.js +10 -22
- package/dist/cjs/view/InlineCard/index.js +1 -3
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/flexible/actions/extract-copy-link-action.js +0 -19
- package/dist/es2019/extractors/flexible/actions/extract-download-action.js +0 -21
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +0 -34
- package/dist/es2019/extractors/flexible/actions/index.js +4 -23
- package/dist/es2019/extractors/flexible/extract-state.js +1 -5
- package/dist/es2019/extractors/flexible/index.js +3 -4
- package/dist/es2019/state/actions/index.js +2 -4
- package/dist/es2019/state/analytics/index.js +1 -2
- package/dist/es2019/state/flexible-ui-context/index.js +0 -7
- package/dist/es2019/state/hooks/use-invoke-client-action/index.js +21 -44
- package/dist/es2019/state/hooks/useSmartLink.js +1 -4
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +5 -21
- package/dist/es2019/state/hooks-external/useSmartLinkReload.js +1 -3
- package/dist/es2019/state/index.js +1 -2
- package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +3 -40
- package/dist/es2019/utils/analytics/analytics.js +2 -145
- package/dist/es2019/utils/analytics/index.js +1 -1
- package/dist/es2019/utils/analytics/types.js +0 -1
- package/dist/es2019/utils/mocks.js +1 -23
- package/dist/es2019/view/BlockCard/index.js +1 -3
- package/dist/es2019/view/BlockCard/views/ResolvedView.js +1 -3
- package/dist/es2019/view/BlockCard/views/UnauthorisedView.js +1 -3
- package/dist/es2019/view/CardWithUrl/component.js +14 -34
- package/dist/es2019/view/CardWithUrl/loader.js +11 -23
- package/dist/es2019/view/EmbedCard/index.js +0 -4
- package/dist/es2019/view/EmbedCard/views/unauthorized-view/index.js +1 -3
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +39 -88
- package/dist/es2019/view/EmbedModal/index.js +10 -35
- package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +13 -37
- package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +6 -27
- package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +6 -32
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +6 -24
- package/dist/es2019/view/FlexibleCard/components/utils.js +0 -25
- package/dist/es2019/view/FlexibleCard/index.js +3 -15
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -3
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -8
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +12 -25
- package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +2 -4
- package/dist/es2019/view/HoverCard/index.js +11 -23
- package/dist/es2019/view/InlineCard/index.js +0 -2
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/flexible/actions/extract-copy-link-action.js +0 -19
- package/dist/esm/extractors/flexible/actions/extract-download-action.js +0 -23
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +0 -34
- package/dist/esm/extractors/flexible/actions/index.js +4 -17
- package/dist/esm/extractors/flexible/extract-state.js +1 -5
- package/dist/esm/extractors/flexible/index.js +3 -4
- package/dist/esm/state/actions/index.js +2 -4
- package/dist/esm/state/analytics/index.js +1 -2
- package/dist/esm/state/flexible-ui-context/index.js +0 -9
- package/dist/esm/state/hooks/use-invoke-client-action/index.js +21 -44
- package/dist/esm/state/hooks/useSmartLink.js +1 -4
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +5 -21
- package/dist/esm/state/hooks-external/useSmartLinkReload.js +1 -3
- package/dist/esm/state/index.js +1 -2
- package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +3 -37
- package/dist/esm/utils/analytics/analytics.js +1 -143
- package/dist/esm/utils/analytics/index.js +1 -1
- package/dist/esm/utils/analytics/types.js +0 -1
- package/dist/esm/utils/mocks.js +0 -22
- package/dist/esm/view/BlockCard/index.js +1 -3
- package/dist/esm/view/BlockCard/views/ResolvedView.js +1 -3
- package/dist/esm/view/BlockCard/views/UnauthorisedView.js +2 -4
- package/dist/esm/view/CardWithUrl/component.js +14 -34
- package/dist/esm/view/CardWithUrl/loader.js +10 -22
- package/dist/esm/view/EmbedCard/index.js +0 -4
- package/dist/esm/view/EmbedCard/views/unauthorized-view/index.js +3 -5
- package/dist/esm/view/EmbedModal/components/analytics/index.js +40 -89
- package/dist/esm/view/EmbedModal/index.js +11 -70
- package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +28 -68
- package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +6 -45
- package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +6 -52
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +3 -3
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +6 -26
- package/dist/esm/view/FlexibleCard/components/utils.js +0 -27
- package/dist/esm/view/FlexibleCard/index.js +4 -18
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -3
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -8
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +13 -30
- package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +3 -5
- package/dist/esm/view/HoverCard/index.js +10 -22
- package/dist/esm/view/InlineCard/index.js +1 -3
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/extractors/common/actions/types.d.ts +0 -2
- package/dist/types/extractors/flexible/actions/extract-copy-link-action.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/index.d.ts +0 -6
- package/dist/types/state/actions/index.d.ts +1 -2
- package/dist/types/state/analytics/index.d.ts +0 -2
- package/dist/types/state/flexible-ui-context/index.d.ts +1 -7
- package/dist/types/state/flexible-ui-context/types.d.ts +4 -25
- package/dist/types/state/hooks/use-invoke/types.d.ts +0 -6
- package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +1 -1
- package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +0 -6
- package/dist/types/state/hooks/useSmartLink.d.ts +0 -22
- package/dist/types/state/index.d.ts +0 -1
- package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +1 -1
- package/dist/types/utils/analytics/analytics.d.ts +0 -6
- package/dist/types/utils/analytics/index.d.ts +1 -1
- package/dist/types/utils/analytics/types.d.ts +0 -42
- package/dist/types/utils/mocks.d.ts +0 -22
- package/dist/types/view/BlockCard/index.d.ts +1 -1
- package/dist/types/view/BlockCard/types.d.ts +0 -2
- package/dist/types/view/BlockCard/views/types.d.ts +1 -1
- package/dist/types/view/CardWithUrl/types.d.ts +0 -2
- package/dist/types/view/EmbedCard/types.d.ts +0 -2
- package/dist/types/view/EmbedCard/views/unauthorized-view/index.d.ts +1 -1
- package/dist/types/view/EmbedCard/views/unauthorized-view/types.d.ts +0 -2
- package/dist/types/view/EmbedModal/components/analytics/types.d.ts +0 -2
- package/dist/types/view/EmbedModal/index.d.ts +0 -2
- package/dist/types/view/EmbedModal/types.d.ts +0 -3
- package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +0 -6
- package/dist/types/view/FlexibleCard/components/utils.d.ts +0 -6
- package/dist/types/view/FlexibleCard/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/types.d.ts +0 -6
- package/dist/types/view/HoverCard/components/CustomPopupContainer.d.ts +1 -1
- package/dist/types/view/HoverCard/components/HoverCardContent.d.ts +1 -1
- package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +1 -1
- package/dist/types/view/HoverCard/components/views/resolved/types.d.ts +0 -2
- package/dist/types/view/HoverCard/components/views/unauthorised/index.d.ts +1 -1
- package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +0 -5
- package/dist/types/view/HoverCard/types.d.ts +0 -3
- package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +0 -3
- package/dist/types/view/InlineCard/index.d.ts +1 -1
- package/dist/types/view/InlineCard/types.d.ts +0 -2
- package/dist/types/view/common/UnauthorisedViewContent.d.ts +0 -6
- package/dist/types-ts4.5/extractors/common/actions/types.d.ts +0 -2
- package/dist/types-ts4.5/extractors/flexible/actions/extract-copy-link-action.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/extract-download-action.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/extract-preview-action.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +0 -6
- package/dist/types-ts4.5/state/actions/index.d.ts +1 -2
- package/dist/types-ts4.5/state/analytics/index.d.ts +0 -2
- package/dist/types-ts4.5/state/flexible-ui-context/index.d.ts +1 -7
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +4 -25
- package/dist/types-ts4.5/state/hooks/use-invoke/types.d.ts +0 -6
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +1 -1
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +0 -6
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +0 -22
- package/dist/types-ts4.5/state/index.d.ts +0 -1
- package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +1 -1
- package/dist/types-ts4.5/utils/analytics/analytics.d.ts +0 -6
- package/dist/types-ts4.5/utils/analytics/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/analytics/types.d.ts +0 -42
- package/dist/types-ts4.5/utils/mocks.d.ts +0 -22
- package/dist/types-ts4.5/view/BlockCard/index.d.ts +1 -1
- package/dist/types-ts4.5/view/BlockCard/types.d.ts +0 -2
- package/dist/types-ts4.5/view/BlockCard/views/types.d.ts +1 -1
- package/dist/types-ts4.5/view/CardWithUrl/types.d.ts +0 -2
- package/dist/types-ts4.5/view/EmbedCard/types.d.ts +0 -2
- package/dist/types-ts4.5/view/EmbedCard/views/unauthorized-view/index.d.ts +1 -1
- package/dist/types-ts4.5/view/EmbedCard/views/unauthorized-view/types.d.ts +0 -2
- package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +0 -2
- package/dist/types-ts4.5/view/EmbedModal/index.d.ts +0 -2
- package/dist/types-ts4.5/view/EmbedModal/types.d.ts +0 -3
- package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +0 -6
- package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +0 -6
- package/dist/types-ts4.5/view/FlexibleCard/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +0 -6
- package/dist/types-ts4.5/view/HoverCard/components/CustomPopupContainer.d.ts +1 -1
- package/dist/types-ts4.5/view/HoverCard/components/HoverCardContent.d.ts +1 -1
- package/dist/types-ts4.5/view/HoverCard/components/views/resolved/index.d.ts +1 -1
- package/dist/types-ts4.5/view/HoverCard/components/views/resolved/types.d.ts +0 -2
- package/dist/types-ts4.5/view/HoverCard/components/views/unauthorised/index.d.ts +1 -1
- package/dist/types-ts4.5/view/HoverCard/components/views/unauthorised/types.d.ts +0 -5
- package/dist/types-ts4.5/view/HoverCard/types.d.ts +0 -3
- package/dist/types-ts4.5/view/InlineCard/UnauthorisedView/index.d.ts +0 -3
- package/dist/types-ts4.5/view/InlineCard/index.d.ts +1 -1
- package/dist/types-ts4.5/view/InlineCard/types.d.ts +0 -2
- package/dist/types-ts4.5/view/common/UnauthorisedViewContent.d.ts +0 -6
- package/package.json +1 -4
- package/dist/cjs/extractors/action/extractDownloadActionProps.js +0 -32
- package/dist/cjs/extractors/action/extractPreviewActionProps.js +0 -47
- package/dist/cjs/extractors/action/extractViewActionProps.js +0 -31
- package/dist/cjs/extractors/flexible/actions/extract-view-action.js +0 -27
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +0 -311
- package/dist/es2019/extractors/action/extractDownloadActionProps.js +0 -24
- package/dist/es2019/extractors/action/extractPreviewActionProps.js +0 -36
- package/dist/es2019/extractors/action/extractViewActionProps.js +0 -23
- package/dist/es2019/extractors/flexible/actions/extract-view-action.js +0 -20
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +0 -296
- package/dist/esm/extractors/action/extractDownloadActionProps.js +0 -27
- package/dist/esm/extractors/action/extractPreviewActionProps.js +0 -41
- package/dist/esm/extractors/action/extractViewActionProps.js +0 -26
- package/dist/esm/extractors/flexible/actions/extract-view-action.js +0 -22
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +0 -304
- package/dist/types/extractors/action/extractDownloadActionProps.d.ts +0 -7
- package/dist/types/extractors/action/extractPreviewActionProps.d.ts +0 -7
- package/dist/types/extractors/action/extractViewActionProps.d.ts +0 -7
- package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +0 -7
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +0 -91
- package/dist/types/utils/analytics/__mocks__/analytics.d.ts +0 -2
- package/dist/types/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +0 -3
- package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +0 -7
- package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +0 -7
- package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +0 -7
- package/dist/types-ts4.5/extractors/flexible/actions/extract-view-action.d.ts +0 -7
- package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +0 -91
- package/dist/types-ts4.5/utils/analytics/__mocks__/analytics.d.ts +0 -2
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/__fixtures__/follow-goal-context.d.ts +0 -3
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
5
4
|
import { CardDisplay } from '../../constants';
|
|
6
5
|
import { useSmartLink } from '../../state';
|
|
7
6
|
import { succeedUfoExperience } from '../../state/analytics';
|
|
8
|
-
import {
|
|
7
|
+
import { getClickUrl, getDefinitionId, getExtensionKey, getResourceType, getServices, isFinalState } from '../../state/helpers';
|
|
9
8
|
import { SmartLinkModalProvider } from '../../state/modal';
|
|
10
9
|
import { isSpecialEvent } from '../../utils';
|
|
11
10
|
import { combineActionOptions } from '../../utils/actions/combine-action-options';
|
|
@@ -38,7 +37,6 @@ function Component({
|
|
|
38
37
|
children,
|
|
39
38
|
showHoverPreview,
|
|
40
39
|
hoverPreviewOptions,
|
|
41
|
-
analyticsEvents,
|
|
42
40
|
removeTextHighlightingFromTitle,
|
|
43
41
|
resolvingPlaceholder,
|
|
44
42
|
truncateInline
|
|
@@ -54,17 +52,14 @@ function Component({
|
|
|
54
52
|
const {
|
|
55
53
|
state,
|
|
56
54
|
actions,
|
|
57
|
-
analytics: defaultAnalytics,
|
|
58
55
|
config,
|
|
59
56
|
renderers,
|
|
60
57
|
error
|
|
61
58
|
} = useSmartLink(id, url);
|
|
62
|
-
const analytics = analyticsEvents || defaultAnalytics;
|
|
63
59
|
const definitionId = getDefinitionId(state.details);
|
|
64
60
|
const extensionKey = getExtensionKey(state.details);
|
|
65
61
|
const resourceType = getResourceType(state.details);
|
|
66
62
|
const services = getServices(state.details);
|
|
67
|
-
const canBeDatasource = getCanBeDatasource(state.details);
|
|
68
63
|
let isFlexibleUi = useMemo(() => isFlexibleUiCard(children), [children]);
|
|
69
64
|
const actionOptions = combineActionOptions({
|
|
70
65
|
actionOptions: actionOptionsProp,
|
|
@@ -139,31 +134,20 @@ function Component({
|
|
|
139
134
|
// - the unresolved states: viz. forbidden, not_found, unauthorized, errored.
|
|
140
135
|
useEffect(() => {
|
|
141
136
|
if (isFinalState(state.status)) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
137
|
+
succeedUfoExperience('smart-link-rendered', id || 'NULL', {
|
|
138
|
+
extensionKey,
|
|
139
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
140
|
+
});
|
|
147
141
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} else {
|
|
156
|
-
analytics.ui.renderSuccessEvent({
|
|
157
|
-
display: isFlexibleUi ? 'flexible' : appearance,
|
|
158
|
-
status: state.status,
|
|
159
|
-
id,
|
|
160
|
-
definitionId,
|
|
161
|
-
extensionKey,
|
|
162
|
-
canBeDatasource
|
|
163
|
-
});
|
|
164
|
-
}
|
|
142
|
+
// UFO will disregard this if authentication experience has not yet been started
|
|
143
|
+
succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
|
|
144
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
145
|
+
});
|
|
146
|
+
fireEvent('ui.smartLink.renderSuccess', {
|
|
147
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
148
|
+
});
|
|
165
149
|
}
|
|
166
|
-
}, [
|
|
150
|
+
}, [appearance, extensionKey, fireEvent, id, isFlexibleUi, state.status]);
|
|
167
151
|
const onIframeDwell = useCallback((dwellTime, dwellPercentVisible) => {
|
|
168
152
|
fireEvent('ui.smartLinkIframe.dwelled', {
|
|
169
153
|
id,
|
|
@@ -205,8 +189,7 @@ function Component({
|
|
|
205
189
|
url: url,
|
|
206
190
|
testId: testId,
|
|
207
191
|
onResolve: onResolve,
|
|
208
|
-
onError: onError
|
|
209
|
-
analytics: analytics
|
|
192
|
+
onError: onError
|
|
210
193
|
}, children);
|
|
211
194
|
}
|
|
212
195
|
|
|
@@ -217,7 +200,6 @@ function Component({
|
|
|
217
200
|
switch (appearance) {
|
|
218
201
|
case 'inline':
|
|
219
202
|
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
220
|
-
analytics: analytics,
|
|
221
203
|
id: id,
|
|
222
204
|
url: url,
|
|
223
205
|
renderers: renderers,
|
|
@@ -246,7 +228,6 @@ function Component({
|
|
|
246
228
|
cardState: state,
|
|
247
229
|
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
248
230
|
handleFrameClick: handleClickWrapper,
|
|
249
|
-
analytics: analytics,
|
|
250
231
|
isSelected: isSelected,
|
|
251
232
|
onResolve: onResolve,
|
|
252
233
|
onError: onError,
|
|
@@ -264,7 +245,6 @@ function Component({
|
|
|
264
245
|
handleErrorRetry: handleRetry,
|
|
265
246
|
handleFrameClick: handleClickWrapper,
|
|
266
247
|
handleInvoke: handleInvoke,
|
|
267
|
-
analytics: analytics,
|
|
268
248
|
isSelected: isSelected,
|
|
269
249
|
frameStyle: frameStyle,
|
|
270
250
|
platform: platform,
|
|
@@ -2,9 +2,7 @@ import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
3
|
import { di } from 'react-magnetic-di';
|
|
4
4
|
import uuid from 'uuid';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
7
|
-
import { useSmartLinkAnalytics } from '../../state';
|
|
8
6
|
import { failUfoExperience, startUfoExperience } from '../../state/analytics';
|
|
9
7
|
import { importWithRetry } from '../../utils';
|
|
10
8
|
import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
@@ -51,7 +49,6 @@ export function CardWithURLRenderer(props) {
|
|
|
51
49
|
resolvingPlaceholder,
|
|
52
50
|
truncateInline
|
|
53
51
|
} = props;
|
|
54
|
-
const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', id);
|
|
55
52
|
const isFlexibleUi = isFlexibleUiCard(children);
|
|
56
53
|
const analyticsContext = useSmartLinkAnalyticsContext({
|
|
57
54
|
display: isFlexibleUi ? 'flexible' : appearance,
|
|
@@ -79,32 +76,23 @@ export function CardWithURLRenderer(props) {
|
|
|
79
76
|
definitionId: null
|
|
80
77
|
});
|
|
81
78
|
} else if (error.name !== 'APIError') {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
} else {
|
|
94
|
-
analytics.ui.renderFailedEvent({
|
|
95
|
-
display: isFlexibleUi ? 'flexible' : appearance,
|
|
96
|
-
id,
|
|
97
|
-
error,
|
|
98
|
-
errorInfo
|
|
99
|
-
});
|
|
100
|
-
}
|
|
79
|
+
startUfoExperience('smart-link-rendered', id || 'NULL');
|
|
80
|
+
failUfoExperience('smart-link-rendered', id || 'NULL');
|
|
81
|
+
failUfoExperience('smart-link-authenticated', id || 'NULL');
|
|
82
|
+
fireEvent('ui.smartLink.renderFailed', {
|
|
83
|
+
...(analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes),
|
|
84
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
85
|
+
id: id !== null && id !== void 0 ? id : null,
|
|
86
|
+
error: error,
|
|
87
|
+
errorInfo: errorInfo
|
|
88
|
+
});
|
|
101
89
|
}
|
|
102
90
|
onError && onError({
|
|
103
91
|
status: 'errored',
|
|
104
92
|
url: url !== null && url !== void 0 ? url : '',
|
|
105
93
|
err: error
|
|
106
94
|
});
|
|
107
|
-
}, [
|
|
95
|
+
}, [analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes, appearance, fireEvent, id, isFlexibleUi, onError, url]);
|
|
108
96
|
if (!url) {
|
|
109
97
|
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
110
98
|
}
|
|
@@ -19,7 +19,6 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
19
19
|
handleAuthorize,
|
|
20
20
|
handleErrorRetry,
|
|
21
21
|
handleFrameClick,
|
|
22
|
-
analytics,
|
|
23
22
|
isSelected,
|
|
24
23
|
frameStyle,
|
|
25
24
|
platform,
|
|
@@ -56,7 +55,6 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
56
55
|
onResolve: onResolve,
|
|
57
56
|
renderers: renderers,
|
|
58
57
|
actionOptions: actionOptions,
|
|
59
|
-
analytics: analytics,
|
|
60
58
|
testId: testId ? `${testId}-resolving-view` : 'embed-card-resolving-view'
|
|
61
59
|
});
|
|
62
60
|
case 'resolved':
|
|
@@ -97,7 +95,6 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
97
95
|
onResolve: onResolve,
|
|
98
96
|
renderers: renderers,
|
|
99
97
|
actionOptions: actionOptions,
|
|
100
|
-
analytics: analytics,
|
|
101
98
|
testId: testId
|
|
102
99
|
});
|
|
103
100
|
}
|
|
@@ -110,7 +107,6 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
110
107
|
}
|
|
111
108
|
const unauthorisedViewProps = extractEmbedProps(data, meta, platform);
|
|
112
109
|
return /*#__PURE__*/React.createElement(UnauthorizedView, {
|
|
113
|
-
analytics: analytics,
|
|
114
110
|
context: unauthorisedViewProps.context,
|
|
115
111
|
extensionKey: extensionKey,
|
|
116
112
|
frameStyle: frameStyle,
|
|
@@ -8,7 +8,6 @@ import UnauthorisedViewContent from '../../../common/UnauthorisedViewContent';
|
|
|
8
8
|
import UnresolvedView from '../unresolved-view';
|
|
9
9
|
import { UnauthorizedSVG } from './unauthorized-svg';
|
|
10
10
|
const UnauthorizedView = ({
|
|
11
|
-
analytics,
|
|
12
11
|
context,
|
|
13
12
|
extensionKey,
|
|
14
13
|
isProductIntegrationSupported,
|
|
@@ -43,7 +42,6 @@ const UnauthorizedView = ({
|
|
|
43
42
|
values: values
|
|
44
43
|
})),
|
|
45
44
|
description: /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
46
|
-
analytics: analytics,
|
|
47
45
|
providerName: context === null || context === void 0 ? void 0 : context.text,
|
|
48
46
|
isProductIntegrationSupported: isProductIntegrationSupported,
|
|
49
47
|
testId: testId
|
|
@@ -80,7 +78,7 @@ const UnauthorizedView = ({
|
|
|
80
78
|
title: /*#__PURE__*/React.createElement(FormattedMessage, messages.unauthorised_account_name_no_provider),
|
|
81
79
|
description: /*#__PURE__*/React.createElement(FormattedMessage, messages.unauthorised_account_description_no_provider)
|
|
82
80
|
};
|
|
83
|
-
}, [
|
|
81
|
+
}, [context === null || context === void 0 ? void 0 : context.text, handleOnAuthorizeClick, isProductIntegrationSupported, onAuthorize, testId]);
|
|
84
82
|
return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, unresolvedViewProps, content, {
|
|
85
83
|
icon: context === null || context === void 0 ? void 0 : context.icon,
|
|
86
84
|
image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : /*#__PURE__*/React.createElement(UnauthorizedSVG, null),
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { CardDisplay } from '../../../../constants';
|
|
5
4
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../../../state/analytics';
|
|
6
5
|
import { EmbedModalSize } from '../../types';
|
|
7
6
|
const getResizeFrom = size => size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
8
7
|
const withAnalytics = Component => props => {
|
|
9
8
|
const {
|
|
10
|
-
analytics,
|
|
11
9
|
fireEvent,
|
|
12
10
|
extensionKey,
|
|
13
11
|
id,
|
|
@@ -18,108 +16,61 @@ const withAnalytics = Component => props => {
|
|
|
18
16
|
origin
|
|
19
17
|
} = props;
|
|
20
18
|
const handleOnOpen = useCallback(context => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
attributes: {
|
|
30
|
-
origin,
|
|
31
|
-
size: context.size
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
|
|
36
|
-
succeedUfoExperience('smart-link-rendered', id || 'NULL', {
|
|
37
|
-
extensionKey,
|
|
38
|
-
display: CardDisplay.EmbedPreview
|
|
39
|
-
});
|
|
19
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('screen.embedPreviewModal.viewed', {
|
|
20
|
+
origin: origin !== null && origin !== void 0 ? origin : null,
|
|
21
|
+
size: context.size
|
|
22
|
+
});
|
|
23
|
+
succeedUfoExperience('smart-link-rendered', id || 'NULL', {
|
|
24
|
+
extensionKey,
|
|
25
|
+
display: CardDisplay.EmbedPreview
|
|
26
|
+
});
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} else {
|
|
49
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderSuccessEvent({
|
|
50
|
-
status: 'resolved',
|
|
51
|
-
display: CardDisplay.EmbedPreview
|
|
52
|
-
});
|
|
53
|
-
}
|
|
28
|
+
// UFO will disregard this if authentication experience has not yet been started
|
|
29
|
+
succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
|
|
30
|
+
display: CardDisplay.EmbedPreview
|
|
31
|
+
});
|
|
32
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderSuccess', {
|
|
33
|
+
display: CardDisplay.EmbedPreview
|
|
34
|
+
});
|
|
54
35
|
if (onOpen) {
|
|
55
36
|
onOpen(context);
|
|
56
37
|
}
|
|
57
|
-
}, [
|
|
38
|
+
}, [fireEvent, extensionKey, id, onOpen, origin]);
|
|
58
39
|
const handleOnOpenFailed = useCallback((error, errorInfo) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderFailedEvent({
|
|
71
|
-
display: CardDisplay.EmbedPreview,
|
|
72
|
-
error,
|
|
73
|
-
errorInfo
|
|
74
|
-
});
|
|
75
|
-
}
|
|
40
|
+
startUfoExperience('smart-link-rendered', id || 'NULL');
|
|
41
|
+
failUfoExperience('smart-link-rendered', id || 'NULL');
|
|
42
|
+
failUfoExperience('smart-link-authenticated', id || 'NULL');
|
|
43
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.smartLink.renderFailed', {
|
|
44
|
+
display: CardDisplay.EmbedPreview,
|
|
45
|
+
error: error,
|
|
46
|
+
errorInfo: errorInfo,
|
|
47
|
+
id: id !== null && id !== void 0 ? id : null
|
|
48
|
+
});
|
|
76
49
|
if (onOpenFailed) {
|
|
77
50
|
onOpenFailed(error, errorInfo);
|
|
78
51
|
}
|
|
79
|
-
}, [
|
|
52
|
+
}, [fireEvent, id, onOpenFailed]);
|
|
80
53
|
const handleOnClose = useCallback(context => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.ui.modalClosedEvent({
|
|
90
|
-
actionSubjectId: 'embedPreview',
|
|
91
|
-
attributes: {
|
|
92
|
-
origin,
|
|
93
|
-
previewTime: context.duration,
|
|
94
|
-
size: context.size
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
54
|
+
var _context$duration;
|
|
55
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.modal.closed.embedPreview', {
|
|
56
|
+
origin: origin !== null && origin !== void 0 ? origin : null,
|
|
57
|
+
previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
|
|
58
|
+
size: context.size
|
|
59
|
+
});
|
|
98
60
|
if (onClose) {
|
|
99
61
|
onClose(context);
|
|
100
62
|
}
|
|
101
|
-
}, [
|
|
63
|
+
}, [fireEvent, onClose, origin]);
|
|
102
64
|
const handleOnResize = useCallback(context => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
} else {
|
|
110
|
-
analytics === null || analytics === void 0 ? void 0 : analytics.ui.buttonClickedEvent({
|
|
111
|
-
actionSubjectId: 'embedPreviewResize',
|
|
112
|
-
attributes: {
|
|
113
|
-
newSize: context.size,
|
|
114
|
-
origin,
|
|
115
|
-
previousSize: getResizeFrom(context.size)
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
65
|
+
fireEvent === null || fireEvent === void 0 ? void 0 : fireEvent('ui.button.clicked.embedPreviewResize', {
|
|
66
|
+
newSize: context.size,
|
|
67
|
+
origin: origin !== null && origin !== void 0 ? origin : null,
|
|
68
|
+
previousSize: getResizeFrom(context.size)
|
|
69
|
+
});
|
|
119
70
|
if (onResize) {
|
|
120
71
|
onResize(context);
|
|
121
72
|
}
|
|
122
|
-
}, [
|
|
73
|
+
}, [fireEvent, onResize, origin]);
|
|
123
74
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
124
75
|
onClose: handleOnClose,
|
|
125
76
|
onOpen: handleOnOpen,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback, useRef, useState } from 'react';
|
|
3
3
|
import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { useThemeObserver } from '@atlaskit/tokens';
|
|
6
|
-
import {
|
|
5
|
+
import { SmartLinkSize } from '../../constants';
|
|
7
6
|
import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
|
|
8
|
-
import {
|
|
7
|
+
import { getPreviewUrlWithTheme } from '../../utils';
|
|
9
8
|
import Icon from '../FlexibleCard/components/elements/icon';
|
|
10
9
|
import withAnalytics from './components/analytics';
|
|
11
10
|
import EmbedContent from './components/embed-content';
|
|
@@ -16,12 +15,8 @@ import { EmbedModalSize } from './types';
|
|
|
16
15
|
const toSize = width => width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
17
16
|
const toWidth = size => size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
18
17
|
const EmbedModal = ({
|
|
19
|
-
analytics,
|
|
20
|
-
download,
|
|
21
18
|
invokeDownloadAction,
|
|
22
|
-
extensionKey,
|
|
23
19
|
fireEvent,
|
|
24
|
-
icon,
|
|
25
20
|
iframeName,
|
|
26
21
|
isSupportTheming,
|
|
27
22
|
isTrusted = false,
|
|
@@ -35,7 +30,6 @@ const EmbedModal = ({
|
|
|
35
30
|
src,
|
|
36
31
|
testId = 'smart-embed-preview-modal',
|
|
37
32
|
title,
|
|
38
|
-
url,
|
|
39
33
|
invokeViewAction
|
|
40
34
|
}) => {
|
|
41
35
|
const defaultWidth = toWidth(size);
|
|
@@ -43,7 +37,6 @@ const EmbedModal = ({
|
|
|
43
37
|
const [width, setWidth] = useState(defaultWidth);
|
|
44
38
|
const openAt = useRef();
|
|
45
39
|
const invoke = useInvokeClientAction({
|
|
46
|
-
analytics,
|
|
47
40
|
fireEvent
|
|
48
41
|
});
|
|
49
42
|
const handleOnOpenComplete = useCallback(() => {
|
|
@@ -76,29 +69,11 @@ const EmbedModal = ({
|
|
|
76
69
|
const themeState = useThemeObserver();
|
|
77
70
|
let previewUrl = src;
|
|
78
71
|
const handleOnViewActionClick = useCallback(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} else {
|
|
82
|
-
invoke({
|
|
83
|
-
actionType: 'ViewAction',
|
|
84
|
-
actionFn: async () => openUrl(url),
|
|
85
|
-
display: CardDisplay.EmbedPreview,
|
|
86
|
-
extensionKey
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}, [extensionKey, invoke, url, invokeViewAction]);
|
|
72
|
+
invokeViewAction && invoke(invokeViewAction);
|
|
73
|
+
}, [invoke, invokeViewAction]);
|
|
90
74
|
const handleOnDownloadActionClick = useCallback(() => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
} else {
|
|
94
|
-
invoke({
|
|
95
|
-
actionType: ActionName.DownloadAction,
|
|
96
|
-
actionFn: async () => downloadUrl(download),
|
|
97
|
-
display: CardDisplay.EmbedPreview,
|
|
98
|
-
extensionKey
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}, [download, invokeDownloadAction, extensionKey, invoke]);
|
|
75
|
+
invokeDownloadAction && invoke(invokeDownloadAction);
|
|
76
|
+
}, [invokeDownloadAction, invoke]);
|
|
102
77
|
if (previewUrl && isSupportTheming) {
|
|
103
78
|
previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
|
|
104
79
|
}
|
|
@@ -110,15 +85,15 @@ const EmbedModal = ({
|
|
|
110
85
|
testId: testId,
|
|
111
86
|
width: width
|
|
112
87
|
}, /*#__PURE__*/React.createElement(LinkInfo, {
|
|
113
|
-
icon:
|
|
88
|
+
icon: linkIcon && {
|
|
114
89
|
icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
|
|
115
90
|
size: SmartLinkSize.Large
|
|
116
91
|
})),
|
|
117
92
|
isFlexibleUi: true
|
|
118
|
-
}
|
|
93
|
+
},
|
|
119
94
|
providerName: providerName,
|
|
120
|
-
onViewButtonClick:
|
|
121
|
-
onDownloadButtonClick:
|
|
95
|
+
onViewButtonClick: invokeViewAction ? handleOnViewActionClick : undefined,
|
|
96
|
+
onDownloadButtonClick: invokeDownloadAction ? handleOnDownloadActionClick : undefined,
|
|
122
97
|
onResizeButtonClick: handleOnResizeClick,
|
|
123
98
|
size: width,
|
|
124
99
|
title: title,
|
|
@@ -2,10 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
4
|
import LinkIcon from '@atlaskit/icon/core/migration/link';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { ActionName } from '../../../../../constants';
|
|
7
6
|
import { messages } from '../../../../../messages';
|
|
8
|
-
import {
|
|
7
|
+
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
9
8
|
import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
|
|
10
9
|
import Action from '../action';
|
|
11
10
|
const CopyLinkAction = ({
|
|
@@ -14,45 +13,22 @@ const CopyLinkAction = ({
|
|
|
14
13
|
}) => {
|
|
15
14
|
var _context$actions;
|
|
16
15
|
const context = useFlexibleUiContext();
|
|
17
|
-
const
|
|
18
|
-
const invoke = useInvokeClientAction({
|
|
19
|
-
analytics
|
|
20
|
-
});
|
|
16
|
+
const invoke = useInvokeClientAction({});
|
|
21
17
|
const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.CopyLinkAction];
|
|
22
18
|
const [tooltipMessage, setTooltipMessage] = useState(messages.copy_url_to_clipboard);
|
|
23
19
|
const onClick = useCallback(() => {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
if (data && data.url) {
|
|
38
|
-
invoke({
|
|
39
|
-
actionType: ActionName.CopyLinkAction,
|
|
40
|
-
actionFn: async () => {
|
|
41
|
-
var _data$url;
|
|
42
|
-
await navigator.clipboard.writeText((_data$url = data.url) !== null && _data$url !== void 0 ? _data$url : '');
|
|
43
|
-
setTooltipMessage(messages.copied_url_to_clipboard);
|
|
44
|
-
},
|
|
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
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (onClickCallback) {
|
|
52
|
-
onClickCallback();
|
|
53
|
-
}
|
|
20
|
+
if (data !== null && data !== void 0 && data.invokeAction) {
|
|
21
|
+
invoke({
|
|
22
|
+
...data.invokeAction,
|
|
23
|
+
actionFn: async () => {
|
|
24
|
+
var _data$invokeAction;
|
|
25
|
+
await ((_data$invokeAction = data.invokeAction) === null || _data$invokeAction === void 0 ? void 0 : _data$invokeAction.actionFn());
|
|
26
|
+
setTooltipMessage(messages.copied_url_to_clipboard);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
|
|
54
30
|
}
|
|
55
|
-
}, [
|
|
31
|
+
}, [data, invoke, onClickCallback]);
|
|
56
32
|
return data ? /*#__PURE__*/React.createElement(Action, _extends({
|
|
57
33
|
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.copy_url_to_clipboard),
|
|
58
34
|
icon: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
@@ -2,12 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
4
|
import DownloadIcon from '@atlaskit/icon/core/migration/download';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { ActionName } from '../../../../../constants';
|
|
7
6
|
import { messages } from '../../../../../messages';
|
|
8
|
-
import {
|
|
7
|
+
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
9
8
|
import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
|
|
10
|
-
import { downloadUrl as download } from '../../../../../utils';
|
|
11
9
|
import Action from '../action';
|
|
12
10
|
const DownloadAction = ({
|
|
13
11
|
onClick: onClickCallback,
|
|
@@ -15,33 +13,14 @@ const DownloadAction = ({
|
|
|
15
13
|
}) => {
|
|
16
14
|
var _context$actions;
|
|
17
15
|
const context = useFlexibleUiContext();
|
|
18
|
-
const
|
|
19
|
-
const invoke = useInvokeClientAction({
|
|
20
|
-
analytics
|
|
21
|
-
});
|
|
16
|
+
const invoke = useInvokeClientAction({});
|
|
22
17
|
const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
|
|
23
18
|
const onClick = useCallback(() => {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
if (data !== null && data !== void 0 && data.downloadUrl) {
|
|
31
|
-
invoke({
|
|
32
|
-
actionType: ActionName.DownloadAction,
|
|
33
|
-
actionFn: async () => download(data === null || data === void 0 ? void 0 : data.downloadUrl),
|
|
34
|
-
// These values have already been set in analytics context.
|
|
35
|
-
// We only pass these here for ufo experience.
|
|
36
|
-
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
37
|
-
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
38
|
-
});
|
|
39
|
-
if (onClickCallback) {
|
|
40
|
-
onClickCallback();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
19
|
+
if (data !== null && data !== void 0 && data.invokeAction) {
|
|
20
|
+
invoke(data.invokeAction);
|
|
21
|
+
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
|
|
43
22
|
}
|
|
44
|
-
}, [
|
|
23
|
+
}, [data, invoke, onClickCallback]);
|
|
45
24
|
const isStackItem = props.as === 'stack-item';
|
|
46
25
|
const label = isStackItem ? messages.download_file : messages.download;
|
|
47
26
|
const tooltipMessage = isStackItem ? messages.download_description : messages.download;
|