@atlaskit/smart-card 45.27.0 → 45.28.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 +25 -0
- package/analytics.spec.yaml +23 -0
- package/dist/cjs/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/text-only--light-mode.png +3 -0
- package/dist/cjs/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/with-image--light-mode.png +3 -0
- package/dist/cjs/common/analytics/generated/use-analytics-events.js +1 -1
- package/dist/cjs/entry-points/pre-auth-value-proposition-modal.js +12 -0
- package/dist/cjs/state/hooks/use-one-click-chat-spotlight-eligibility/evaluate.js +76 -0
- package/dist/cjs/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.js +144 -0
- package/dist/cjs/state/services/pre-auth-value-proposition-modal/index.js +122 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/PreAuthValuePropositionModal/IllustrationPane.compiled.css +30 -0
- package/dist/cjs/view/PreAuthValuePropositionModal/IllustrationPane.js +58 -0
- package/dist/cjs/view/PreAuthValuePropositionModal/assets/graphics-with-grid-no-provider-icons-2x.png +0 -0
- package/dist/cjs/view/PreAuthValuePropositionModal/index.compiled.css +17 -0
- package/dist/cjs/view/PreAuthValuePropositionModal/index.js +304 -0
- package/dist/es2019/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/text-only--light-mode.png +3 -0
- package/dist/es2019/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/with-image--light-mode.png +3 -0
- package/dist/es2019/common/analytics/generated/use-analytics-events.js +1 -1
- package/dist/es2019/entry-points/pre-auth-value-proposition-modal.js +1 -0
- package/dist/es2019/state/hooks/use-one-click-chat-spotlight-eligibility/evaluate.js +63 -0
- package/dist/es2019/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.js +103 -0
- package/dist/es2019/state/services/pre-auth-value-proposition-modal/index.js +97 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/PreAuthValuePropositionModal/IllustrationPane.compiled.css +30 -0
- package/dist/es2019/view/PreAuthValuePropositionModal/IllustrationPane.js +51 -0
- package/dist/es2019/view/PreAuthValuePropositionModal/assets/graphics-with-grid-no-provider-icons-2x.png +0 -0
- package/dist/es2019/view/PreAuthValuePropositionModal/index.compiled.css +17 -0
- package/dist/es2019/view/PreAuthValuePropositionModal/index.js +282 -0
- package/dist/esm/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/text-only--light-mode.png +3 -0
- package/dist/esm/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/with-image--light-mode.png +3 -0
- package/dist/esm/common/analytics/generated/use-analytics-events.js +1 -1
- package/dist/esm/entry-points/pre-auth-value-proposition-modal.js +1 -0
- package/dist/esm/state/hooks/use-one-click-chat-spotlight-eligibility/evaluate.js +68 -0
- package/dist/esm/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.js +134 -0
- package/dist/esm/state/services/pre-auth-value-proposition-modal/index.js +115 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/PreAuthValuePropositionModal/IllustrationPane.compiled.css +30 -0
- package/dist/esm/view/PreAuthValuePropositionModal/IllustrationPane.js +52 -0
- package/dist/esm/view/PreAuthValuePropositionModal/assets/graphics-with-grid-no-provider-icons-2x.png +0 -0
- package/dist/esm/view/PreAuthValuePropositionModal/index.compiled.css +17 -0
- package/dist/esm/view/PreAuthValuePropositionModal/index.js +293 -0
- package/dist/types/common/analytics/generated/analytics.types.d.ts +14 -1
- package/dist/types/entry-points/pre-auth-value-proposition-modal.d.ts +1 -0
- package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/evaluate.d.ts +29 -0
- package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.d.ts +13 -0
- package/dist/types/state/services/pre-auth-value-proposition-modal/index.d.ts +11 -0
- package/dist/types/view/PreAuthValuePropositionModal/IllustrationPane.d.ts +10 -0
- package/dist/types/view/PreAuthValuePropositionModal/index.d.ts +5 -0
- package/package.json +1 -1
- package/pre-auth-value-proposition-modal/package.json +10 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* IllustrationPane.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
import "./IllustrationPane.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
6
|
+
|
|
7
|
+
// Asset imports require an explicit extension for TypeScript and ESLint resolution.
|
|
8
|
+
// oxlint-disable-next-line import/extensions
|
|
9
|
+
import illustrationWithoutProviderIcons from './assets/graphics-with-grid-no-provider-icons-2x.png';
|
|
10
|
+
const styles = {
|
|
11
|
+
illustration: "_1e0c1ule _4t3ikbql _1bsb1kdj",
|
|
12
|
+
illustrationLayer: "_1reo15vq _18m915vq _1ein1kw7 _5fbc1kw7 _4t3ikbql _kqswh2mm _1bsb1kdj",
|
|
13
|
+
rightPane: "_1reo15vq _18m915vq _4cvr1h6o _1ein1kw7 _5fbc1kw7 _1e0c1txw _1o9zidpf _4t3i1osq _1bah1h6o _1bsb1kdj"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Pixel offsets and rotations are from the Figma illustration, not space tokens.
|
|
17
|
+
const illustrationIconStyles = {
|
|
18
|
+
footer: "_4t3io7ao _1ltv1uvc _kqswstnw _154invl5 _t9ec1b7d _1bsbo7ao",
|
|
19
|
+
searchFirst: "_4t3il52n _1ltv5rga _kqswstnw _154intd2 _t9ec751h _1bsbl52n",
|
|
20
|
+
searchSecond: "_4t3il52n _1ltvs0l4 _kqswstnw _154i1rp4 _t9ec751h _1bsbl52n",
|
|
21
|
+
top: "_1reo15vq _18m915vq _4t3i1ylp _1ltvvbgk _kqswstnw _154i18e8 _1bsb1ylp"
|
|
22
|
+
};
|
|
23
|
+
const IllustrationPane = ({
|
|
24
|
+
renderProviderIcon
|
|
25
|
+
}) => /*#__PURE__*/React.createElement(Box, {
|
|
26
|
+
xcss: styles.rightPane
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
28
|
+
xcss: styles.illustrationLayer
|
|
29
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
30
|
+
alt: "",
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
"data-testid": "pre-auth-value-proposition-modal-illustration",
|
|
33
|
+
height: 450,
|
|
34
|
+
src: illustrationWithoutProviderIcons,
|
|
35
|
+
srcSet: `${illustrationWithoutProviderIcons} 2x`,
|
|
36
|
+
width: 400,
|
|
37
|
+
className: ax([styles.illustration])
|
|
38
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
className: ax([illustrationIconStyles.top])
|
|
41
|
+
}, renderProviderIcon(40, 'pre-auth-value-proposition-modal-illustration-icon')), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
"aria-hidden": "true",
|
|
43
|
+
className: ax([illustrationIconStyles.searchFirst])
|
|
44
|
+
}, renderProviderIcon(17, 'pre-auth-value-proposition-modal-illustration-icon')), /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
className: ax([illustrationIconStyles.searchSecond])
|
|
47
|
+
}, renderProviderIcon(17, 'pre-auth-value-proposition-modal-illustration-icon')), /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
className: ax([illustrationIconStyles.footer])
|
|
50
|
+
}, renderProviderIcon(15, 'pre-auth-value-proposition-modal-illustration-icon'))));
|
|
51
|
+
export default IllustrationPane;
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
._2rko1kw7{border-radius:inherit}
|
|
2
|
+
._zulp1ejb{gap:var(--ds-space-300,24px)}
|
|
3
|
+
._zulppxbi{gap:var(--ds-space-200,1pc)}._16jlkb7n{flex-grow:1}
|
|
4
|
+
._18m915vq{overflow-y:hidden}
|
|
5
|
+
._19bv1jfw{padding-left:var(--ds-space-500,40px)}
|
|
6
|
+
._1bsb1kdj{width:25pc}
|
|
7
|
+
._1bsbnklw{width:20pc}
|
|
8
|
+
._1e0c1txw{display:flex}
|
|
9
|
+
._1o9zidpf{flex-shrink:0}
|
|
10
|
+
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._2lx21bp4{flex-direction:column}
|
|
12
|
+
._4cvr1fhb{align-items:stretch}
|
|
13
|
+
._4cvr1h6o{align-items:center}
|
|
14
|
+
._4t3i1osq{height:100%}
|
|
15
|
+
._ca0q1jfw{padding-top:var(--ds-space-500,40px)}
|
|
16
|
+
._n3td1jfw{padding-bottom:var(--ds-space-500,40px)}
|
|
17
|
+
._u5f31jfw{padding-right:var(--ds-space-500,40px)}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./index.compiled.css";
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
7
|
+
import Button from '@atlaskit/button/default/button';
|
|
8
|
+
import Heading from '@atlaskit/heading/heading';
|
|
9
|
+
import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
|
|
10
|
+
import ModalBody from '@atlaskit/modal-dialog/modal-body';
|
|
11
|
+
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
12
|
+
import ModalTitle from '@atlaskit/modal-dialog/modal-title';
|
|
13
|
+
import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
|
|
14
|
+
import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
|
|
15
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
16
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
17
|
+
import { Stack } from '@atlaskit/primitives/compiled/stack';
|
|
18
|
+
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
19
|
+
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
20
|
+
import { messages as smartCardMessages } from '../../messages';
|
|
21
|
+
import { getExtensionKey, getServices } from '../../state/helpers';
|
|
22
|
+
import useSocialProof from '../../state/hooks/use-social-proof';
|
|
23
|
+
import { useSmartLink } from '../../state/hooks/useSmartLink';
|
|
24
|
+
import { preAuthValuePropositionModalService } from '../../state/services/pre-auth-value-proposition-modal';
|
|
25
|
+
import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
26
|
+
import ImageIcon from '../common/image-icon';
|
|
27
|
+
const IllustrationPane = /*#__PURE__*/lazy(() => import( /* webpackChunkName: "@atlaskit-internal_smart-card-pre-auth-value-proposition-illustration" */'./IllustrationPane'));
|
|
28
|
+
const SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD = 30;
|
|
29
|
+
const SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
|
|
30
|
+
const messages = defineMessages({
|
|
31
|
+
close: {
|
|
32
|
+
id: 'smart-card.view.PreAuthValuePropositionModal.close',
|
|
33
|
+
defaultMessage: 'Close',
|
|
34
|
+
description: 'Closes the pre-auth value proposition modal.'
|
|
35
|
+
},
|
|
36
|
+
connect: {
|
|
37
|
+
id: 'smart-card.view.PreAuthValuePropositionModal.connect',
|
|
38
|
+
defaultMessage: 'Connect {providerName}',
|
|
39
|
+
description: 'Connect button in the pre-auth value proposition modal. providerName is supplied by the Smart Link response.'
|
|
40
|
+
},
|
|
41
|
+
embedBenefit: {
|
|
42
|
+
id: 'smart-card.view.PreAuthValuePropositionModal.embedBenefit',
|
|
43
|
+
defaultMessage: '<b>Embed</b> richer link previews without leaving your workflow',
|
|
44
|
+
description: 'Explains the benefit of embedding richer Smart Link previews without leaving the current workflow.'
|
|
45
|
+
},
|
|
46
|
+
searchBenefit: {
|
|
47
|
+
id: 'smart-card.view.PreAuthValuePropositionModal.searchBenefit',
|
|
48
|
+
defaultMessage: '<b>Search</b> across {providerName} and Atlassian content in one place',
|
|
49
|
+
description: 'Explains the cross-product search benefit. providerName is supplied by the Smart Link response.'
|
|
50
|
+
},
|
|
51
|
+
seeBenefit: {
|
|
52
|
+
id: 'smart-card.view.PreAuthValuePropositionModal.seeBenefit',
|
|
53
|
+
defaultMessage: '<b>See</b> Rovo answers grounded in your {providerName} content',
|
|
54
|
+
description: 'Explains the Rovo benefit. providerName is supplied by the Smart Link response.'
|
|
55
|
+
},
|
|
56
|
+
title: {
|
|
57
|
+
id: 'smart-card.view.PreAuthValuePropositionModal.title',
|
|
58
|
+
defaultMessage: 'Connect {providerName}',
|
|
59
|
+
description: 'Title for the pre-auth value proposition modal. providerName is supplied by the Smart Link response.'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const styles = {
|
|
63
|
+
bodyCopy: "_1bsbnklw",
|
|
64
|
+
content: "_zulp1ejb _1e0c1txw _2lx21bp4 _4t3i1osq _n3td1jfw _19bv1jfw _u5f31jfw _ca0q1jfw",
|
|
65
|
+
copyColumn: "_zulppxbi _1e0c1txw _2lx21bp4 _16jlkb7n",
|
|
66
|
+
leftPane: "_1e0c1txw _2lx21bp4 _1o9zidpf _4t3i1osq _1bsb1kdj",
|
|
67
|
+
providerIcon: "_4cvr1h6o _1e0c1txw _1o9zidpf",
|
|
68
|
+
splitLayout: "_2rko1kw7 _1reo15vq _18m915vq _4cvr1fhb _1e0c1txw _4t3i1osq"
|
|
69
|
+
};
|
|
70
|
+
const bold = chunks => /*#__PURE__*/React.createElement(Text, {
|
|
71
|
+
as: "strong"
|
|
72
|
+
}, chunks);
|
|
73
|
+
const getModalCloseMethod = event => 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
|
|
74
|
+
const ModalCopy = ({
|
|
75
|
+
connectedPct,
|
|
76
|
+
isSocialProofAvailable,
|
|
77
|
+
onClose,
|
|
78
|
+
onConnect,
|
|
79
|
+
providerIcon,
|
|
80
|
+
providerName
|
|
81
|
+
}) => {
|
|
82
|
+
const messageValues = {
|
|
83
|
+
b: bold,
|
|
84
|
+
providerName
|
|
85
|
+
};
|
|
86
|
+
const isSocialProofUsageHighEnough = connectedPct !== undefined && connectedPct >= SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD;
|
|
87
|
+
return /*#__PURE__*/React.createElement(ModalBody, {
|
|
88
|
+
hasInlinePadding: false
|
|
89
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
90
|
+
xcss: styles.content
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
92
|
+
xcss: styles.copyColumn
|
|
93
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
94
|
+
space: "space.250"
|
|
95
|
+
}, providerIcon && /*#__PURE__*/React.createElement(Box, {
|
|
96
|
+
xcss: styles.providerIcon
|
|
97
|
+
}, providerIcon), /*#__PURE__*/React.createElement(ModalTitle, {
|
|
98
|
+
isMultiline: false
|
|
99
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
100
|
+
as: "span",
|
|
101
|
+
color: "color.text",
|
|
102
|
+
size: "large"
|
|
103
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.title, {
|
|
104
|
+
values: {
|
|
105
|
+
providerName
|
|
106
|
+
}
|
|
107
|
+
}))))), /*#__PURE__*/React.createElement(Box, {
|
|
108
|
+
xcss: styles.bodyCopy
|
|
109
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
110
|
+
space: "space.200"
|
|
111
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
112
|
+
as: "p",
|
|
113
|
+
color: "color.text",
|
|
114
|
+
size: "large"
|
|
115
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.seeBenefit, {
|
|
116
|
+
values: messageValues
|
|
117
|
+
}))), /*#__PURE__*/React.createElement(Text, {
|
|
118
|
+
as: "p",
|
|
119
|
+
color: "color.text",
|
|
120
|
+
size: "large"
|
|
121
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.searchBenefit, {
|
|
122
|
+
values: messageValues
|
|
123
|
+
}))), /*#__PURE__*/React.createElement(Text, {
|
|
124
|
+
as: "p",
|
|
125
|
+
color: "color.text",
|
|
126
|
+
size: "large"
|
|
127
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.embedBenefit, {
|
|
128
|
+
values: messageValues
|
|
129
|
+
})))))), isSocialProofAvailable && /*#__PURE__*/React.createElement(Text, {
|
|
130
|
+
as: "p",
|
|
131
|
+
color: "color.text.subtlest",
|
|
132
|
+
size: "small",
|
|
133
|
+
testId: "pre-auth-value-proposition-modal-social-proof"
|
|
134
|
+
}, isSocialProofUsageHighEnough ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, smartCardMessages.social_proof_inline_cta_tag_high_with_context, {
|
|
135
|
+
values: {
|
|
136
|
+
connectedPct,
|
|
137
|
+
context: providerName,
|
|
138
|
+
b: bold
|
|
139
|
+
}
|
|
140
|
+
})) : /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, smartCardMessages.social_proof_inline_cta_tag_low_with_context, {
|
|
141
|
+
values: {
|
|
142
|
+
context: providerName
|
|
143
|
+
}
|
|
144
|
+
}))), /*#__PURE__*/React.createElement(Flex, {
|
|
145
|
+
gap: "space.075",
|
|
146
|
+
justifyContent: "start"
|
|
147
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
148
|
+
appearance: "primary",
|
|
149
|
+
onClick: onConnect,
|
|
150
|
+
autoFocus: true,
|
|
151
|
+
spacing: "default"
|
|
152
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect, {
|
|
153
|
+
values: {
|
|
154
|
+
providerName
|
|
155
|
+
}
|
|
156
|
+
}))), /*#__PURE__*/React.createElement(Button, {
|
|
157
|
+
appearance: "subtle",
|
|
158
|
+
onClick: onClose
|
|
159
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.close)))));
|
|
160
|
+
};
|
|
161
|
+
const PreAuthValuePropositionModalContent = ({
|
|
162
|
+
onFinished,
|
|
163
|
+
url
|
|
164
|
+
}) => {
|
|
165
|
+
var _provider$iconLabel;
|
|
166
|
+
const {
|
|
167
|
+
actions,
|
|
168
|
+
config,
|
|
169
|
+
state
|
|
170
|
+
} = useSmartLink(SMART_LINK_MODAL_ID, url, 'inline');
|
|
171
|
+
const {
|
|
172
|
+
fireEvent
|
|
173
|
+
} = useAnalyticsEvents();
|
|
174
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
175
|
+
const [visibleVariant, setVisibleVariant] = useState('modal_text_only');
|
|
176
|
+
const modalOpenTimeRef = useRef(Date.now());
|
|
177
|
+
const provider = useMemo(() => extractSmartLinkProvider(state.details), [state.details]);
|
|
178
|
+
const providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
179
|
+
const providerIconUrl = typeof (provider === null || provider === void 0 ? void 0 : provider.icon) === 'string' ? provider.icon : undefined;
|
|
180
|
+
const renderProviderIcon = (size, testId, label) => {
|
|
181
|
+
if (providerIconUrl) {
|
|
182
|
+
const sizePx = `${size}px`;
|
|
183
|
+
return /*#__PURE__*/React.createElement(ImageIcon, {
|
|
184
|
+
height: sizePx,
|
|
185
|
+
hideLoadingSkeleton: true,
|
|
186
|
+
label: label !== null && label !== void 0 ? label : '',
|
|
187
|
+
testId: testId,
|
|
188
|
+
url: providerIconUrl,
|
|
189
|
+
width: sizePx
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return provider === null || provider === void 0 ? void 0 : provider.icon;
|
|
193
|
+
};
|
|
194
|
+
const 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);
|
|
195
|
+
const services = getServices(state.details);
|
|
196
|
+
const extensionKey = getExtensionKey(state.details);
|
|
197
|
+
const {
|
|
198
|
+
connectedPct,
|
|
199
|
+
isEnabled: isSocialProofAvailable
|
|
200
|
+
} = useSocialProof(extensionKey, true);
|
|
201
|
+
const hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
|
|
202
|
+
const isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (state.status === 'pending' || state.status === 'resolving') {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (!isBaseEligible || !extensionKey || preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
208
|
+
onFinished();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const experimentVariant = expVal('platform_sl_3p_preauth_value_modal', 'variant', 'control');
|
|
212
|
+
if (experimentVariant === 'modal_text_only' || experimentVariant === 'modal_with_image') {
|
|
213
|
+
preAuthValuePropositionModalService.recordShow(extensionKey);
|
|
214
|
+
setVisibleVariant(experimentVariant);
|
|
215
|
+
setIsOpen(true);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
onFinished();
|
|
219
|
+
}, [extensionKey, isBaseEligible, onFinished, state.status]);
|
|
220
|
+
const dismissModal = useCallback(closeMethod => {
|
|
221
|
+
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
222
|
+
closeMethod,
|
|
223
|
+
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
224
|
+
});
|
|
225
|
+
setIsOpen(false);
|
|
226
|
+
onFinished();
|
|
227
|
+
}, [fireEvent, onFinished]);
|
|
228
|
+
const handleCloseButton = useCallback(() => {
|
|
229
|
+
dismissModal('button');
|
|
230
|
+
}, [dismissModal]);
|
|
231
|
+
const handleModalClose = useCallback(event => {
|
|
232
|
+
dismissModal(getModalCloseMethod(event));
|
|
233
|
+
}, [dismissModal]);
|
|
234
|
+
const handleOpenComplete = useCallback(() => {
|
|
235
|
+
modalOpenTimeRef.current = Date.now();
|
|
236
|
+
fireEvent('ui.modal.opened.preAuthValueProposition', {});
|
|
237
|
+
}, [fireEvent]);
|
|
238
|
+
const connectAccount = useCallback(() => {
|
|
239
|
+
fireEvent('track.applicationAccount.authStarted', {});
|
|
240
|
+
setIsOpen(false);
|
|
241
|
+
actions.authorize('inline');
|
|
242
|
+
onFinished();
|
|
243
|
+
}, [actions, fireEvent, onFinished]);
|
|
244
|
+
if (!isOpen || !providerName) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const modalCopy = /*#__PURE__*/React.createElement(ModalCopy, {
|
|
248
|
+
connectedPct: connectedPct,
|
|
249
|
+
isSocialProofAvailable: isSocialProofAvailable,
|
|
250
|
+
onClose: handleCloseButton,
|
|
251
|
+
onConnect: connectAccount,
|
|
252
|
+
providerIcon: providerIcon,
|
|
253
|
+
providerName: providerName
|
|
254
|
+
});
|
|
255
|
+
const showIllustration = visibleVariant === 'modal_with_image';
|
|
256
|
+
return /*#__PURE__*/React.createElement(ModalTransition, null, /*#__PURE__*/React.createElement(Modal, {
|
|
257
|
+
onClose: handleModalClose,
|
|
258
|
+
onOpenComplete: handleOpenComplete,
|
|
259
|
+
testId: "pre-auth-value-proposition-modal",
|
|
260
|
+
width: showIllustration ? 800 : 400
|
|
261
|
+
}, showIllustration ? /*#__PURE__*/React.createElement(Box, {
|
|
262
|
+
xcss: styles.splitLayout
|
|
263
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
264
|
+
xcss: styles.leftPane
|
|
265
|
+
}, modalCopy), /*#__PURE__*/React.createElement(Suspense, {
|
|
266
|
+
fallback: null
|
|
267
|
+
}, /*#__PURE__*/React.createElement(IllustrationPane, {
|
|
268
|
+
renderProviderIcon: renderProviderIcon
|
|
269
|
+
}))) : modalCopy));
|
|
270
|
+
};
|
|
271
|
+
export const PreAuthValuePropositionModal = ({
|
|
272
|
+
onFinished,
|
|
273
|
+
url
|
|
274
|
+
}) => /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
275
|
+
display: "inline",
|
|
276
|
+
id: SMART_LINK_MODAL_ID,
|
|
277
|
+
source: "preAuthValuePropositionModal",
|
|
278
|
+
url: url
|
|
279
|
+
}, /*#__PURE__*/React.createElement(PreAuthValuePropositionModalContent, {
|
|
280
|
+
onFinished: onFinished,
|
|
281
|
+
url: url
|
|
282
|
+
}));
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates Typescript types for analytics events from analytics.spec.yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::4715d46f4a378244afd94dadfd9e5f51>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
|
|
8
8
|
*/
|
|
9
9
|
import { useCallback } from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PreAuthValuePropositionModal } from '../view/PreAuthValuePropositionModal';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** No link, content, or account identifiers belong in eligibility diagnostics. */
|
|
2
|
+
|
|
3
|
+
export var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;
|
|
4
|
+
var result = function result(reason) {
|
|
5
|
+
return {
|
|
6
|
+
isEligible: reason === 'eligible',
|
|
7
|
+
reason: reason
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Calendar days use the browser's local timezone; seven-day windows use elapsed time. */
|
|
12
|
+
export function evaluateOpportunity(input) {
|
|
13
|
+
if (!input.gateEnabled) {
|
|
14
|
+
return result('gate_off');
|
|
15
|
+
}
|
|
16
|
+
if (input.appearance !== 'inline' || input.status !== 'resolved') {
|
|
17
|
+
return result('not_resolved_inline');
|
|
18
|
+
}
|
|
19
|
+
if (input.provider !== 'google-object-provider' && input.provider !== 'github-object-provider') {
|
|
20
|
+
return result('unsupported_provider');
|
|
21
|
+
}
|
|
22
|
+
if (!input.authorized) {
|
|
23
|
+
return result('provider_unauthorized');
|
|
24
|
+
}
|
|
25
|
+
if (!input.hasAccess) {
|
|
26
|
+
return result('object_inaccessible');
|
|
27
|
+
}
|
|
28
|
+
if (!input.rovoAvailable) {
|
|
29
|
+
return result('rovo_unavailable');
|
|
30
|
+
}
|
|
31
|
+
if (!input.consumerOptedIn) {
|
|
32
|
+
return result('consumer_not_opted_in');
|
|
33
|
+
}
|
|
34
|
+
if (input.product !== 'jira_web' && input.product !== 'confluence_web') {
|
|
35
|
+
return result('unsupported_product');
|
|
36
|
+
}
|
|
37
|
+
if (!input.history) {
|
|
38
|
+
return result('suppression_unavailable');
|
|
39
|
+
}
|
|
40
|
+
if (input.spotlightActive) {
|
|
41
|
+
return result('spotlight_active');
|
|
42
|
+
}
|
|
43
|
+
var _input$history = input.history,
|
|
44
|
+
dismissedAt = _input$history.dismissedAt,
|
|
45
|
+
impressions = _input$history.impressions;
|
|
46
|
+
var cutoff = input.now - SEVEN_DAYS_MS;
|
|
47
|
+
if (dismissedAt !== undefined && dismissedAt > cutoff) {
|
|
48
|
+
return result('dismissal_cooldown');
|
|
49
|
+
}
|
|
50
|
+
var startOfDay = new Date(input.now);
|
|
51
|
+
startOfDay.setHours(0, 0, 0, 0);
|
|
52
|
+
if (impressions.some(function (timestamp) {
|
|
53
|
+
return timestamp >= startOfDay.getTime();
|
|
54
|
+
})) {
|
|
55
|
+
return result('shown_today');
|
|
56
|
+
}
|
|
57
|
+
if (impressions.filter(function (timestamp) {
|
|
58
|
+
return timestamp > cutoff;
|
|
59
|
+
}).length >= 3) {
|
|
60
|
+
return result('weekly_limit');
|
|
61
|
+
}
|
|
62
|
+
return result('eligible');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Pure cohort evaluation, kept separate so suppressed opportunities never expose the experiment. */
|
|
66
|
+
export function evaluateExperiment(value) {
|
|
67
|
+
return result(value === true ? 'eligible' : value === false ? 'control' : 'experiment_unavailable');
|
|
68
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import { StorageClient } from '@atlaskit/frontend-utilities/StorageClient';
|
|
9
|
+
import { SEVEN_DAYS_MS } from './evaluate';
|
|
10
|
+
|
|
11
|
+
/** Shared across inline cards. Account identifiers are held in memory only. */
|
|
12
|
+
var stores = new Map();
|
|
13
|
+
var activeSpotlight;
|
|
14
|
+
var isHistory = function isHistory(value) {
|
|
15
|
+
if (_typeof(value) !== 'object' || value === null || !('impressions' in value)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return Array.isArray(value.impressions) && value.impressions.every(function (timestamp) {
|
|
19
|
+
return typeof timestamp === 'number' && Number.isFinite(timestamp);
|
|
20
|
+
}) && (!('dismissedAt' in value) || value.dismissedAt === undefined || typeof value.dismissedAt === 'number' && Number.isFinite(value.dismissedAt));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Reuses Smart Card's StorageClient, with timestamp-only values and a one-way user namespace. */
|
|
24
|
+
export function createSuppressionStore(storage) {
|
|
25
|
+
var isAvailable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
var blocked = false;
|
|
29
|
+
var read = function read() {
|
|
30
|
+
try {
|
|
31
|
+
var value = storage.getItem('history');
|
|
32
|
+
if (blocked || !isAvailable()) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return value === undefined ? {
|
|
36
|
+
impressions: []
|
|
37
|
+
} : isHistory(value) ? value : undefined;
|
|
38
|
+
} catch (_unused) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var write = function write(history) {
|
|
43
|
+
try {
|
|
44
|
+
storage.setItemWithExpiry('history', history, SEVEN_DAYS_MS);
|
|
45
|
+
// StorageClient can swallow write failures. Verify persistence before counting delivery.
|
|
46
|
+
var persisted = isAvailable() && JSON.stringify(storage.getItem('history')) === JSON.stringify(history);
|
|
47
|
+
blocked = !persisted;
|
|
48
|
+
return persisted;
|
|
49
|
+
} catch (_unused2) {
|
|
50
|
+
blocked = true;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
read: read,
|
|
56
|
+
impress: function impress(now) {
|
|
57
|
+
var history = read();
|
|
58
|
+
return !!history && write(_objectSpread(_objectSpread({}, history), {}, {
|
|
59
|
+
impressions: [].concat(_toConsumableArray(history.impressions.filter(function (timestamp) {
|
|
60
|
+
return timestamp > now - SEVEN_DAYS_MS;
|
|
61
|
+
})), [now])
|
|
62
|
+
}));
|
|
63
|
+
},
|
|
64
|
+
dismiss: function dismiss(now) {
|
|
65
|
+
var history = read();
|
|
66
|
+
return !!history && write(_objectSpread(_objectSpread({}, history), {}, {
|
|
67
|
+
dismissedAt: now
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function getSuppressionStore(accountId) {
|
|
73
|
+
var cached = stores.get(accountId);
|
|
74
|
+
if (cached) {
|
|
75
|
+
return cached;
|
|
76
|
+
}
|
|
77
|
+
var pending = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
78
|
+
var _window$crypto, digest, namespace, available, storage, _t;
|
|
79
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
80
|
+
while (1) switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
_context.prev = 0;
|
|
83
|
+
if (!(typeof window === 'undefined' || !((_window$crypto = window.crypto) !== null && _window$crypto !== void 0 && _window$crypto.subtle))) {
|
|
84
|
+
_context.next = 1;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
return _context.abrupt("return", undefined);
|
|
88
|
+
case 1:
|
|
89
|
+
_context.next = 2;
|
|
90
|
+
return window.crypto.subtle.digest('SHA-256', new TextEncoder().encode("one-click-chat-spotlight-v2:".concat(accountId)));
|
|
91
|
+
case 2:
|
|
92
|
+
digest = _context.sent;
|
|
93
|
+
namespace = Array.from(new Uint8Array(digest), function (byte) {
|
|
94
|
+
return byte.toString(16).padStart(2, '0');
|
|
95
|
+
}).join('');
|
|
96
|
+
available = true;
|
|
97
|
+
storage = new StorageClient("one-click-chat-spotlight-v2:".concat(namespace), {
|
|
98
|
+
handlers: {
|
|
99
|
+
captureException: function captureException() {
|
|
100
|
+
available = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return _context.abrupt("return", createSuppressionStore(storage, function () {
|
|
105
|
+
return available;
|
|
106
|
+
}));
|
|
107
|
+
case 3:
|
|
108
|
+
_context.prev = 3;
|
|
109
|
+
_t = _context["catch"](0);
|
|
110
|
+
return _context.abrupt("return", undefined);
|
|
111
|
+
case 4:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _callee, null, [[0, 3]]);
|
|
116
|
+
}))();
|
|
117
|
+
stores.set(accountId, pending);
|
|
118
|
+
return pending;
|
|
119
|
+
}
|
|
120
|
+
export function claimSpotlight(owner) {
|
|
121
|
+
if (activeSpotlight && activeSpotlight !== owner) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
activeSpotlight = owner;
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
export function releaseSpotlight(owner) {
|
|
128
|
+
if (activeSpotlight === owner) {
|
|
129
|
+
activeSpotlight = undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function isSpotlightActive(owner) {
|
|
133
|
+
return activeSpotlight !== undefined && activeSpotlight !== owner;
|
|
134
|
+
}
|