@atlaskit/smart-card 46.15.0 → 46.17.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 +38 -0
- package/analytics.spec.yaml +2 -2
- package/dist/cjs/extractors/action/extract-invoke-preview-action.js +1 -2
- package/dist/cjs/extractors/embed/extract-smart-link-context.js +11 -15
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/card-error-boundary/index.js +53 -47
- package/dist/cjs/view/EmbedCard/views/unresolved-view/index.js +1 -2
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/PreAuthValuePropositionModal/index.js +56 -110
- package/dist/cjs/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +175 -0
- package/dist/es2019/extractors/action/extract-invoke-preview-action.js +1 -2
- package/dist/es2019/extractors/embed/extract-smart-link-context.js +12 -16
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/card-error-boundary/index.js +53 -48
- package/dist/es2019/view/EmbedCard/views/unresolved-view/index.js +1 -2
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/PreAuthValuePropositionModal/index.js +54 -102
- package/dist/es2019/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +160 -0
- package/dist/esm/extractors/action/extract-invoke-preview-action.js +1 -2
- package/dist/esm/extractors/embed/extract-smart-link-context.js +11 -15
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/card-error-boundary/index.js +51 -45
- package/dist/esm/view/EmbedCard/views/unresolved-view/index.js +1 -2
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/PreAuthValuePropositionModal/index.js +56 -110
- package/dist/esm/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +167 -0
- package/dist/types/common/analytics/generated/analytics.types.d.ts +2 -2
- package/dist/types/view/PreAuthValuePropositionModal/index.d.ts +1 -1
- package/dist/types/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.d.ts +31 -0
- package/package.json +7 -4
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
|
|
3
|
+
import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
|
|
4
|
+
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
5
|
+
import { getExtensionKey, getServices } from '../../state/helpers';
|
|
6
|
+
import useSocialProof from '../../state/hooks/use-social-proof';
|
|
7
|
+
import { useSmartLink } from '../../state/hooks/useSmartLink';
|
|
8
|
+
import { preAuthValuePropositionModalService } from '../../state/services/pre-auth-value-proposition-modal';
|
|
9
|
+
export const SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
|
|
10
|
+
const getModalCloseMethod = event => 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Eligibility, assignment and modal actions for one URL attempt.
|
|
14
|
+
* The existing choreographer adapter owns display permission and cleanup.
|
|
15
|
+
*/
|
|
16
|
+
export function usePreAuthValuePropositionModal({
|
|
17
|
+
url,
|
|
18
|
+
onFinished
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
actions,
|
|
22
|
+
config,
|
|
23
|
+
state
|
|
24
|
+
} = useSmartLink(SMART_LINK_MODAL_ID, url, 'inline');
|
|
25
|
+
const {
|
|
26
|
+
fireEvent
|
|
27
|
+
} = useAnalyticsEvents();
|
|
28
|
+
const [isRequested, setIsRequested] = useState(false);
|
|
29
|
+
const finished = useRef(false);
|
|
30
|
+
const hasOpened = useRef(false);
|
|
31
|
+
const hasRecordedShow = useRef(false);
|
|
32
|
+
const [visibleVariant, setVisibleVariant] = useState('modal_text_only');
|
|
33
|
+
const modalOpenTimeRef = useRef(Date.now());
|
|
34
|
+
const provider = useMemo(() => extractSmartLinkProvider(state.details), [state.details]);
|
|
35
|
+
const providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
36
|
+
const services = getServices(state.details);
|
|
37
|
+
const extensionKey = getExtensionKey(state.details);
|
|
38
|
+
const {
|
|
39
|
+
connectedPct,
|
|
40
|
+
isEnabled: isSocialProofAvailable
|
|
41
|
+
} = useSocialProof(extensionKey, true);
|
|
42
|
+
const hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
|
|
43
|
+
const isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
|
|
44
|
+
const finishCoordinatedAttempt = useCallback(() => {
|
|
45
|
+
if (finished.current) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
finished.current = true;
|
|
49
|
+
setIsRequested(false);
|
|
50
|
+
onFinished();
|
|
51
|
+
}, [onFinished]);
|
|
52
|
+
const handleUnavailable = useCallback(() => {
|
|
53
|
+
if (finished.current) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (hasOpened.current) {
|
|
57
|
+
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
58
|
+
closeMethod: 'coordinator',
|
|
59
|
+
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
finishCoordinatedAttempt();
|
|
63
|
+
}, [fireEvent, finishCoordinatedAttempt]);
|
|
64
|
+
const shouldClaim = useCallback(() => {
|
|
65
|
+
// Recheck at offer time: another attempt may have consumed the cap while we waited.
|
|
66
|
+
if (finished.current || !isBaseEligible || !extensionKey || preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const variant = expVal('platform_sl_3p_preauth_value_modal', 'variant', 'control');
|
|
70
|
+
if (variant !== 'modal_text_only' && variant !== 'modal_with_image') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
setVisibleVariant(variant);
|
|
74
|
+
return true;
|
|
75
|
+
}, [extensionKey, isBaseEligible]);
|
|
76
|
+
|
|
77
|
+
// The editor mounts this flow only when platform_sl_3p_preauth_value_modal_killswitch is on.
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (finished.current) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (state.status === 'pending' || state.status === 'resolving') {
|
|
83
|
+
// A previously eligible link that starts resolving again must release its slot.
|
|
84
|
+
if (isRequested) {
|
|
85
|
+
handleUnavailable();
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!isBaseEligible || !extensionKey) {
|
|
90
|
+
handleUnavailable();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (!isRequested) {
|
|
94
|
+
if (preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
95
|
+
finishCoordinatedAttempt();
|
|
96
|
+
} else {
|
|
97
|
+
setIsRequested(true);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, [extensionKey, isBaseEligible, state.status, isRequested, handleUnavailable, finishCoordinatedAttempt]);
|
|
101
|
+
const recordShowOnce = useCallback(() => {
|
|
102
|
+
if (hasRecordedShow.current || !extensionKey) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
hasRecordedShow.current = true;
|
|
106
|
+
preAuthValuePropositionModalService.recordShow(extensionKey);
|
|
107
|
+
}, [extensionKey]);
|
|
108
|
+
const dismissModal = useCallback(closeMethod => {
|
|
109
|
+
if (finished.current) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// A user can dismiss the visible modal before its entrance animation completes.
|
|
113
|
+
recordShowOnce();
|
|
114
|
+
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
115
|
+
closeMethod,
|
|
116
|
+
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
117
|
+
});
|
|
118
|
+
finishCoordinatedAttempt();
|
|
119
|
+
}, [fireEvent, finishCoordinatedAttempt, recordShowOnce]);
|
|
120
|
+
const handleCloseButton = useCallback(() => {
|
|
121
|
+
dismissModal('button');
|
|
122
|
+
}, [dismissModal]);
|
|
123
|
+
const handleModalClose = useCallback(event => {
|
|
124
|
+
dismissModal(getModalCloseMethod(event));
|
|
125
|
+
}, [dismissModal]);
|
|
126
|
+
const handleOpenComplete = useCallback(() => {
|
|
127
|
+
if (finished.current || hasOpened.current || !extensionKey) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
hasOpened.current = true;
|
|
131
|
+
recordShowOnce();
|
|
132
|
+
modalOpenTimeRef.current = Date.now();
|
|
133
|
+
fireEvent('ui.modal.opened.preAuthValueProposition', {});
|
|
134
|
+
}, [fireEvent, extensionKey, recordShowOnce]);
|
|
135
|
+
const connectAccount = useCallback(() => {
|
|
136
|
+
if (finished.current) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
recordShowOnce();
|
|
140
|
+
fireEvent('track.applicationAccount.authStarted', {});
|
|
141
|
+
finishCoordinatedAttempt();
|
|
142
|
+
actions.authorize('inline');
|
|
143
|
+
}, [actions, fireEvent, finishCoordinatedAttempt, recordShowOnce]);
|
|
144
|
+
return {
|
|
145
|
+
isActive: isRequested,
|
|
146
|
+
isEligible: isBaseEligible,
|
|
147
|
+
onUnavailable: handleUnavailable,
|
|
148
|
+
shouldClaim,
|
|
149
|
+
modal: {
|
|
150
|
+
provider,
|
|
151
|
+
variant: visibleVariant,
|
|
152
|
+
connectedPct,
|
|
153
|
+
isSocialProofAvailable,
|
|
154
|
+
onClose: handleModalClose,
|
|
155
|
+
onCloseButton: handleCloseButton,
|
|
156
|
+
onConnect: connectAccount,
|
|
157
|
+
onOpenComplete: handleOpenComplete
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -18,7 +18,6 @@ import { canShowAction } from '../../utils/actions/can-show-action';
|
|
|
18
18
|
import { openEmbedModal } from '../../view/EmbedModal/utils';
|
|
19
19
|
import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
|
|
20
20
|
import { extractIsTrusted } from '../common/meta/extractIsTrusted';
|
|
21
|
-
import { extractLinkIcon } from '../flexible/icon/extract-link-icon';
|
|
22
21
|
import { extractSmartLinkIcon } from '../flexible/icon/extract-smart-link-icon';
|
|
23
22
|
import { extractInvokeDownloadAction } from './extract-invoke-download-action';
|
|
24
23
|
import { extractInvokeViewAction } from './extract-invoke-view-action';
|
|
@@ -118,7 +117,7 @@ export var extractInvokePreviewAction = function extractInvokePreviewAction(para
|
|
|
118
117
|
invokeViewAction: extractInvokeViewAction(param, true),
|
|
119
118
|
isSupportTheming: extractIsSupportTheming(meta),
|
|
120
119
|
isTrusted: extractIsTrusted(meta),
|
|
121
|
-
linkIcon:
|
|
120
|
+
linkIcon: extractSmartLinkIcon(response),
|
|
122
121
|
providerName: (_extractSmartLinkProv = extractSmartLinkProvider(response)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text,
|
|
123
122
|
onClose: onClose,
|
|
124
123
|
origin: origin,
|
|
@@ -4,7 +4,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { extractEntityIcon } from '@atlaskit/link-extractors/extract-entity-icon';
|
|
5
5
|
import { extractEntityProvider } from '@atlaskit/link-extractors/extract-entity-provider';
|
|
6
6
|
import { isEntityPresent } from '@atlaskit/link-extractors/is-entity-present';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
7
|
import { getEmptyJsonLd } from '../../utils/get-empty-json-ld';
|
|
9
8
|
import { generateContext } from '../common/context/generateContext';
|
|
10
9
|
|
|
@@ -13,21 +12,18 @@ import { generateContext } from '../common/context/generateContext';
|
|
|
13
12
|
*/
|
|
14
13
|
export function extractSmartLinkContext(response) {
|
|
15
14
|
if (isEntityPresent(response)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
var entityIcon = extractEntityIcon(response);
|
|
23
|
-
return _objectSpread(_objectSpread({}, entityProvider), {}, {
|
|
24
|
-
icon: (_entityIcon$url = entityIcon === null || entityIcon === void 0 ? void 0 : entityIcon.url) !== null && _entityIcon$url !== void 0 ? _entityIcon$url : entityProvider.icon,
|
|
25
|
-
iconLabel: (_entityIcon$label = entityIcon === null || entityIcon === void 0 ? void 0 : entityIcon.label) !== null && _entityIcon$label !== void 0 ? _entityIcon$label : entityProvider.iconLabel,
|
|
26
|
-
providerIcon: entityProvider.icon,
|
|
27
|
-
providerIconLabel: entityProvider.iconLabel
|
|
28
|
-
});
|
|
15
|
+
var _entityIcon$url, _entityIcon$label;
|
|
16
|
+
var entityProvider = extractEntityProvider(response);
|
|
17
|
+
if (!entityProvider) {
|
|
18
|
+
return undefined;
|
|
29
19
|
}
|
|
30
|
-
|
|
20
|
+
var entityIcon = extractEntityIcon(response);
|
|
21
|
+
return _objectSpread(_objectSpread({}, entityProvider), {}, {
|
|
22
|
+
icon: (_entityIcon$url = entityIcon === null || entityIcon === void 0 ? void 0 : entityIcon.url) !== null && _entityIcon$url !== void 0 ? _entityIcon$url : entityProvider.icon,
|
|
23
|
+
iconLabel: (_entityIcon$label = entityIcon === null || entityIcon === void 0 ? void 0 : entityIcon.label) !== null && _entityIcon$label !== void 0 ? _entityIcon$label : entityProvider.iconLabel,
|
|
24
|
+
providerIcon: entityProvider.icon,
|
|
25
|
+
providerIconLabel: entityProvider.iconLabel
|
|
26
|
+
});
|
|
31
27
|
}
|
|
32
28
|
return generateContext((response === null || response === void 0 ? void 0 : response.data) || getEmptyJsonLd());
|
|
33
29
|
}
|
|
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export var context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card" || '',
|
|
7
|
-
packageVersion: "46.
|
|
7
|
+
packageVersion: "46.16.0" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
5
|
var _excluded = ["children"],
|
|
5
6
|
_excluded2 = ["children", "isFlexibleCard"],
|
|
@@ -38,7 +39,6 @@ var CardErrorBoundaryNew = function CardErrorBoundaryNew(_ref2) {
|
|
|
38
39
|
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
39
40
|
var appearance = props.appearance,
|
|
40
41
|
id = props.id,
|
|
41
|
-
onError = props.onError,
|
|
42
42
|
url = props.url;
|
|
43
43
|
var ErrorFallbackComponent = props.fallbackComponent;
|
|
44
44
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
@@ -48,54 +48,60 @@ var CardErrorBoundaryNew = function CardErrorBoundaryNew(_ref2) {
|
|
|
48
48
|
var store = smartCardContext === null || smartCardContext === void 0 ? void 0 : smartCardContext.store;
|
|
49
49
|
var display = isFlexibleCard ? 'flexible' : appearance;
|
|
50
50
|
|
|
51
|
-
//
|
|
51
|
+
// Analytics parity with CardWithURLRenderer only. Preserve CardSSR's local error
|
|
52
|
+
// containment: forwarding caught errors to the consumer can cause a rethrow.
|
|
52
53
|
var errorHandler = useCallback(function (error, info) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// NB: APIErrors are thrown in response to Object Resolver Service. We do not
|
|
69
|
-
// fire an event for these, as they do not cover failed UI render events.
|
|
70
|
-
// The rest of the errors caught here are unexpected, and correlate
|
|
71
|
-
// to the reliability of the smart-card front-end components.
|
|
72
|
-
// Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
|
|
73
|
-
if (error.name === 'ChunkLoadError') {
|
|
74
|
-
fireEvent('operational.smartLink.chunkLoadFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
|
|
75
|
-
display: display,
|
|
76
|
-
error: error,
|
|
77
|
-
errorInfo: errorInfo,
|
|
78
|
-
definitionId: null
|
|
79
|
-
}));
|
|
80
|
-
} else if (error.name !== 'APIError') {
|
|
81
|
-
startUfoExperience('smart-link-rendered', id, {
|
|
82
|
-
ssr: true
|
|
83
|
-
});
|
|
84
|
-
failUfoExperience('smart-link-rendered', id);
|
|
85
|
-
failUfoExperience('smart-link-authenticated', id);
|
|
86
|
-
fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
|
|
54
|
+
try {
|
|
55
|
+
// Error inspection and diagnostics must never break the local fallback.
|
|
56
|
+
var errorName = error !== null && _typeof(error) === 'object' && 'name' in error ? error.name : undefined;
|
|
57
|
+
// Resolver API errors do not represent failed UI renders.
|
|
58
|
+
if (errorName === 'APIError') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var componentStack = info.componentStack;
|
|
62
|
+
var errorInfo = {
|
|
63
|
+
componentStack: componentStack
|
|
64
|
+
};
|
|
65
|
+
// Read the link state when the error happens: useSmartCardContext does not subscribe
|
|
66
|
+
// to store updates, so a value captured during render can be stale by now.
|
|
67
|
+
var state = store ? getUrl(store, url) : undefined;
|
|
68
|
+
var analyticsContext = getSmartLinkAnalyticsContext({
|
|
87
69
|
display: display,
|
|
88
70
|
id: id,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
71
|
+
response: state === null || state === void 0 ? void 0 : state.details,
|
|
72
|
+
status: state === null || state === void 0 ? void 0 : state.status,
|
|
73
|
+
url: url,
|
|
74
|
+
error: state === null || state === void 0 ? void 0 : state.error
|
|
75
|
+
});
|
|
76
|
+
// NB: APIErrors are thrown in response to Object Resolver Service. We do not
|
|
77
|
+
// fire an event for these, as they do not cover failed UI render events.
|
|
78
|
+
// The rest of the errors caught here are unexpected, and correlate
|
|
79
|
+
// to the reliability of the smart-card front-end components.
|
|
80
|
+
// Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
|
|
81
|
+
if (errorName === 'ChunkLoadError') {
|
|
82
|
+
fireEvent('operational.smartLink.chunkLoadFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
|
|
83
|
+
display: display,
|
|
84
|
+
error: error,
|
|
85
|
+
errorInfo: errorInfo,
|
|
86
|
+
definitionId: null
|
|
87
|
+
}));
|
|
88
|
+
} else {
|
|
89
|
+
startUfoExperience('smart-link-rendered', id, {
|
|
90
|
+
ssr: true
|
|
91
|
+
});
|
|
92
|
+
failUfoExperience('smart-link-rendered', id);
|
|
93
|
+
failUfoExperience('smart-link-authenticated', id);
|
|
94
|
+
fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
|
|
95
|
+
display: display,
|
|
96
|
+
id: id,
|
|
97
|
+
error: error,
|
|
98
|
+
errorInfo: errorInfo
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
} catch (_unused) {
|
|
102
|
+
// Best-effort diagnostics must not escape the card error boundary.
|
|
92
103
|
}
|
|
93
|
-
|
|
94
|
-
status: 'errored',
|
|
95
|
-
url: url,
|
|
96
|
-
err: error
|
|
97
|
-
});
|
|
98
|
-
}, [display, fireEvent, id, onError, store, url]);
|
|
104
|
+
}, [display, fireEvent, id, store, url]);
|
|
99
105
|
var errorBoundaryFallbackComponent = function errorBoundaryFallbackComponent() {
|
|
100
106
|
if (ErrorFallbackComponent) {
|
|
101
107
|
return /*#__PURE__*/React.createElement(ErrorFallbackComponent, null);
|
|
@@ -4,7 +4,6 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
4
4
|
import React, { useMemo } from 'react';
|
|
5
5
|
import Heading from '@atlaskit/heading/heading';
|
|
6
6
|
import LinkGlyph from '@atlaskit/icon/core/link';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
7
|
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
9
8
|
import { ExpandedFrame } from '../../components/ExpandedFrame';
|
|
10
9
|
import { ImageIcon } from '../../components/ImageIcon';
|
|
@@ -28,7 +27,7 @@ var UnresolvedView = function UnresolvedView(_ref) {
|
|
|
28
27
|
url = _ref.url;
|
|
29
28
|
// Unresolved embeds have no entity title. The frame shows the provider name, so
|
|
30
29
|
// pair it with the provider/generator icon rather than the entity-type icon.
|
|
31
|
-
var shouldUseProviderIcon = providerIcon != null
|
|
30
|
+
var shouldUseProviderIcon = providerIcon != null;
|
|
32
31
|
var frameIconUrlOrElement = shouldUseProviderIcon ? providerIcon : iconUrlOrElement;
|
|
33
32
|
var frameIconLabel = shouldUseProviderIcon ? providerIconLabel : undefined;
|
|
34
33
|
var icon = useMemo(function () {
|
|
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
12
12
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
13
13
|
var PACKAGE_DATA = {
|
|
14
14
|
packageName: "@atlaskit/smart-card",
|
|
15
|
-
packageVersion: "46.
|
|
15
|
+
packageVersion: "46.16.0",
|
|
16
16
|
componentName: 'linkUrl'
|
|
17
17
|
};
|
|
18
18
|
var LinkUrl = function LinkUrl(_ref) {
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
/* index.tsx generated by @compiled/babel-plugin v3.0.4 */
|
|
2
|
-
import
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
var _excluded = ["onOpenChange"];
|
|
4
5
|
import "./index.compiled.css";
|
|
5
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
-
import React, { lazy, Suspense,
|
|
7
|
+
import React, { lazy, Suspense, useEffect } from 'react';
|
|
8
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
7
9
|
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
8
10
|
import Button from '@atlaskit/button/default/button';
|
|
9
11
|
import Heading from '@atlaskit/heading/heading';
|
|
10
|
-
import {
|
|
12
|
+
import { ChoreographedContent } from '@atlaskit/link-provider/choreographed-content';
|
|
11
13
|
import ModalBody from '@atlaskit/modal-dialog/modal-body';
|
|
12
14
|
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
13
15
|
import ModalTitle from '@atlaskit/modal-dialog/modal-title';
|
|
14
16
|
import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
|
|
15
|
-
import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
|
|
16
17
|
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
17
18
|
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
18
19
|
import { Stack } from '@atlaskit/primitives/compiled/stack';
|
|
19
20
|
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
20
|
-
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
21
21
|
import { messages as smartCardMessages } from '../../messages';
|
|
22
|
-
import { getExtensionKey, getServices } from '../../state/helpers';
|
|
23
|
-
import useSocialProof from '../../state/hooks/use-social-proof';
|
|
24
|
-
import { useSmartLink } from '../../state/hooks/useSmartLink';
|
|
25
|
-
import { preAuthValuePropositionModalService } from '../../state/services/pre-auth-value-proposition-modal';
|
|
26
22
|
import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
27
23
|
import ImageIcon from '../common/image-icon';
|
|
24
|
+
import { SMART_LINK_MODAL_ID, usePreAuthValuePropositionModal } from './use-pre-auth-value-proposition-modal';
|
|
28
25
|
var IllustrationPane = /*#__PURE__*/lazy(function () {
|
|
29
26
|
return import( /* webpackChunkName: "@atlaskit-internal_smart-card-pre-auth-value-proposition-illustration" */'./IllustrationPane');
|
|
30
27
|
});
|
|
31
28
|
var SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD = 30;
|
|
32
|
-
var SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
|
|
33
29
|
var messages = defineMessages({
|
|
34
30
|
close: {
|
|
35
31
|
id: 'smart-card.view.PreAuthValuePropositionModal.close',
|
|
@@ -77,9 +73,6 @@ var bold = function bold(chunks) {
|
|
|
77
73
|
as: "strong"
|
|
78
74
|
}, chunks);
|
|
79
75
|
};
|
|
80
|
-
var getModalCloseMethod = function getModalCloseMethod(event) {
|
|
81
|
-
return 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
|
|
82
|
-
};
|
|
83
76
|
var ModalCopy = function ModalCopy(_ref) {
|
|
84
77
|
var connectedPct = _ref.connectedPct,
|
|
85
78
|
isSocialProofAvailable = _ref.isSocialProofAvailable,
|
|
@@ -171,40 +164,26 @@ var ModalCopy = function ModalCopy(_ref) {
|
|
|
171
164
|
onClick: onClose
|
|
172
165
|
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.close))))));
|
|
173
166
|
};
|
|
174
|
-
|
|
167
|
+
|
|
168
|
+
/** Mounted only while the existing choreographer grants permission. */
|
|
169
|
+
var ModalContent = function ModalContent(_ref2) {
|
|
175
170
|
var _provider$iconLabel;
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var _useState = useState(false),
|
|
186
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
187
|
-
isOpen = _useState2[0],
|
|
188
|
-
setIsOpen = _useState2[1];
|
|
189
|
-
var _useState3 = useState('modal_text_only'),
|
|
190
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
191
|
-
visibleVariant = _useState4[0],
|
|
192
|
-
setVisibleVariant = _useState4[1];
|
|
193
|
-
var modalOpenTimeRef = useRef(Date.now());
|
|
194
|
-
var provider = useMemo(function () {
|
|
195
|
-
return extractSmartLinkProvider(state.details);
|
|
196
|
-
}, [state.details]);
|
|
197
|
-
var providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
198
|
-
var isVisible = isOpen && Boolean(providerName);
|
|
171
|
+
var provider = _ref2.provider,
|
|
172
|
+
variant = _ref2.variant,
|
|
173
|
+
connectedPct = _ref2.connectedPct,
|
|
174
|
+
isSocialProofAvailable = _ref2.isSocialProofAvailable,
|
|
175
|
+
onClose = _ref2.onClose,
|
|
176
|
+
onCloseButton = _ref2.onCloseButton,
|
|
177
|
+
onConnect = _ref2.onConnect,
|
|
178
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
179
|
+
onOpenChange = _ref2.onOpenChange;
|
|
199
180
|
useEffect(function () {
|
|
200
|
-
if (!isVisible) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
181
|
onOpenChange === null || onOpenChange === void 0 || onOpenChange(true);
|
|
204
182
|
return function () {
|
|
205
183
|
return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
|
|
206
184
|
};
|
|
207
|
-
}, [
|
|
185
|
+
}, [onOpenChange]);
|
|
186
|
+
var providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
208
187
|
var providerIconUrl = typeof (provider === null || provider === void 0 ? void 0 : provider.icon) === 'string' ? provider.icon : undefined;
|
|
209
188
|
var renderProviderIcon = function renderProviderIcon(size, testId, label) {
|
|
210
189
|
if (providerIconUrl) {
|
|
@@ -221,69 +200,18 @@ var PreAuthValuePropositionModalContent = function PreAuthValuePropositionModalC
|
|
|
221
200
|
return provider === null || provider === void 0 ? void 0 : provider.icon;
|
|
222
201
|
};
|
|
223
202
|
var providerIcon = renderProviderIcon(24, 'pre-auth-value-proposition-modal-provider-icon', (_provider$iconLabel = provider === null || provider === void 0 ? void 0 : provider.iconLabel) !== null && _provider$iconLabel !== void 0 ? _provider$iconLabel : providerName);
|
|
224
|
-
var services = getServices(state.details);
|
|
225
|
-
var extensionKey = getExtensionKey(state.details);
|
|
226
|
-
var _useSocialProof = useSocialProof(extensionKey, true),
|
|
227
|
-
connectedPct = _useSocialProof.connectedPct,
|
|
228
|
-
isSocialProofAvailable = _useSocialProof.isEnabled;
|
|
229
|
-
var hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
|
|
230
|
-
var isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
|
|
231
|
-
useEffect(function () {
|
|
232
|
-
if (state.status === 'pending' || state.status === 'resolving') {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (!isBaseEligible || !extensionKey || preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
236
|
-
onFinished();
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
var experimentVariant = expVal('platform_sl_3p_preauth_value_modal', 'variant', 'control');
|
|
240
|
-
if (experimentVariant === 'modal_text_only' || experimentVariant === 'modal_with_image') {
|
|
241
|
-
preAuthValuePropositionModalService.recordShow(extensionKey);
|
|
242
|
-
setVisibleVariant(experimentVariant);
|
|
243
|
-
setIsOpen(true);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
onFinished();
|
|
247
|
-
}, [extensionKey, isBaseEligible, onFinished, state.status]);
|
|
248
|
-
var dismissModal = useCallback(function (closeMethod) {
|
|
249
|
-
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
250
|
-
closeMethod: closeMethod,
|
|
251
|
-
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
252
|
-
});
|
|
253
|
-
setIsOpen(false);
|
|
254
|
-
onFinished();
|
|
255
|
-
}, [fireEvent, onFinished]);
|
|
256
|
-
var handleCloseButton = useCallback(function () {
|
|
257
|
-
dismissModal('button');
|
|
258
|
-
}, [dismissModal]);
|
|
259
|
-
var handleModalClose = useCallback(function (event) {
|
|
260
|
-
dismissModal(getModalCloseMethod(event));
|
|
261
|
-
}, [dismissModal]);
|
|
262
|
-
var handleOpenComplete = useCallback(function () {
|
|
263
|
-
modalOpenTimeRef.current = Date.now();
|
|
264
|
-
fireEvent('ui.modal.opened.preAuthValueProposition', {});
|
|
265
|
-
}, [fireEvent]);
|
|
266
|
-
var connectAccount = useCallback(function () {
|
|
267
|
-
fireEvent('track.applicationAccount.authStarted', {});
|
|
268
|
-
setIsOpen(false);
|
|
269
|
-
actions.authorize('inline');
|
|
270
|
-
onFinished();
|
|
271
|
-
}, [actions, fireEvent, onFinished]);
|
|
272
|
-
if (!isOpen || !providerName) {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
203
|
var modalCopy = /*#__PURE__*/React.createElement(ModalCopy, {
|
|
276
204
|
connectedPct: connectedPct,
|
|
277
205
|
isSocialProofAvailable: isSocialProofAvailable,
|
|
278
|
-
onClose:
|
|
279
|
-
onConnect:
|
|
206
|
+
onClose: onCloseButton,
|
|
207
|
+
onConnect: onConnect,
|
|
280
208
|
providerIcon: providerIcon,
|
|
281
|
-
providerName: providerName
|
|
209
|
+
providerName: providerName !== null && providerName !== void 0 ? providerName : ''
|
|
282
210
|
});
|
|
283
|
-
var showIllustration =
|
|
284
|
-
|
|
285
|
-
onClose:
|
|
286
|
-
onOpenComplete:
|
|
211
|
+
var showIllustration = variant === 'modal_with_image';
|
|
212
|
+
var modal = providerName ? /*#__PURE__*/React.createElement(ModalTransition, null, /*#__PURE__*/React.createElement(Modal, {
|
|
213
|
+
onClose: onClose,
|
|
214
|
+
onOpenComplete: onOpenComplete,
|
|
287
215
|
testId: "pre-auth-value-proposition-modal",
|
|
288
216
|
width: showIllustration ? 800 : 400
|
|
289
217
|
}, showIllustration ? /*#__PURE__*/React.createElement(Box, {
|
|
@@ -294,20 +222,38 @@ var PreAuthValuePropositionModalContent = function PreAuthValuePropositionModalC
|
|
|
294
222
|
fallback: null
|
|
295
223
|
}, /*#__PURE__*/React.createElement(IllustrationPane, {
|
|
296
224
|
renderProviderIcon: renderProviderIcon
|
|
297
|
-
}))) : modalCopy));
|
|
225
|
+
}))) : modalCopy)) : null;
|
|
226
|
+
return modal;
|
|
227
|
+
};
|
|
228
|
+
var PreAuthValuePropositionModalContent = function PreAuthValuePropositionModalContent(_ref3) {
|
|
229
|
+
var onOpenChange = _ref3.onOpenChange,
|
|
230
|
+
options = _objectWithoutProperties(_ref3, _excluded);
|
|
231
|
+
var _usePreAuthValuePropo = usePreAuthValuePropositionModal(options),
|
|
232
|
+
isActive = _usePreAuthValuePropo.isActive,
|
|
233
|
+
isEligible = _usePreAuthValuePropo.isEligible,
|
|
234
|
+
onUnavailable = _usePreAuthValuePropo.onUnavailable,
|
|
235
|
+
shouldClaim = _usePreAuthValuePropo.shouldClaim,
|
|
236
|
+
modal = _usePreAuthValuePropo.modal;
|
|
237
|
+
return /*#__PURE__*/React.createElement(ChoreographedContent, {
|
|
238
|
+
messageId: "smart-link-pre-auth-value-proposition-modal",
|
|
239
|
+
isActive: isActive,
|
|
240
|
+
onUnavailable: onUnavailable,
|
|
241
|
+
shouldClaim: shouldClaim
|
|
242
|
+
}, function (_ref4) {
|
|
243
|
+
var hasPermission = _ref4.hasPermission;
|
|
244
|
+
return hasPermission && isEligible ? /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
245
|
+
fallback: null,
|
|
246
|
+
onError: onUnavailable
|
|
247
|
+
}, /*#__PURE__*/React.createElement(ModalContent, _extends({}, modal, {
|
|
248
|
+
onOpenChange: onOpenChange
|
|
249
|
+
}))) : null;
|
|
250
|
+
});
|
|
298
251
|
};
|
|
299
|
-
export var PreAuthValuePropositionModal = function PreAuthValuePropositionModal(
|
|
300
|
-
var onFinished = _ref3.onFinished,
|
|
301
|
-
onOpenChange = _ref3.onOpenChange,
|
|
302
|
-
url = _ref3.url;
|
|
252
|
+
export var PreAuthValuePropositionModal = function PreAuthValuePropositionModal(props) {
|
|
303
253
|
return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
304
254
|
display: "inline",
|
|
305
255
|
id: SMART_LINK_MODAL_ID,
|
|
306
256
|
source: "preAuthValuePropositionModal",
|
|
307
|
-
url: url
|
|
308
|
-
}, /*#__PURE__*/React.createElement(PreAuthValuePropositionModalContent,
|
|
309
|
-
onFinished: onFinished,
|
|
310
|
-
onOpenChange: onOpenChange,
|
|
311
|
-
url: url
|
|
312
|
-
}));
|
|
257
|
+
url: props.url
|
|
258
|
+
}, /*#__PURE__*/React.createElement(PreAuthValuePropositionModalContent, props));
|
|
313
259
|
};
|