@atlaskit/smart-card 46.3.0 → 46.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +14 -1
- package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/async.js +37 -0
- package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
- package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.js +293 -0
- package/dist/cjs/view/InlineCard/common/rovo-actions-cta/index.js +109 -3
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +14 -1
- package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/async.js +21 -0
- package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
- package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.js +267 -0
- package/dist/es2019/view/InlineCard/common/rovo-actions-cta/index.js +93 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +14 -1
- package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/async.js +26 -0
- package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
- package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.js +284 -0
- package/dist/esm/view/InlineCard/common/rovo-actions-cta/index.js +107 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.d.ts +1 -1
- package/dist/types/view/InlineCard/common/one-click-chat-spotlight/async.d.ts +6 -0
- package/dist/types/view/InlineCard/common/one-click-chat-spotlight/index.d.ts +12 -0
- package/dist/types/view/InlineCard/common/rovo-actions-cta/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
/** Keep the existing action usable during SSR, loading and chunk failures. */
|
|
3
|
+
export function OneClickChatSpotlightLoader(props) {
|
|
4
|
+
const [Spotlight, setSpotlight] = useState();
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
let active = true;
|
|
7
|
+
import( /* webpackChunkName: "@atlaskit-internal_smartcard-one-click-chat-spotlight" */'./index').then(({
|
|
8
|
+
OneClickChatSpotlight
|
|
9
|
+
}) => {
|
|
10
|
+
if (active) {
|
|
11
|
+
setSpotlight(() => OneClickChatSpotlight);
|
|
12
|
+
}
|
|
13
|
+
}).catch(() => {
|
|
14
|
+
// An optional spotlight must not break the existing inline action.
|
|
15
|
+
});
|
|
16
|
+
return () => {
|
|
17
|
+
active = false;
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return Spotlight ? /*#__PURE__*/React.createElement(Spotlight, props) : /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
|
|
21
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
2
|
+
._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}
|
|
3
|
+
._v564k6bl{transition:var(--ds-button-hovered,background-color border-color .15s cubic-bezier(.4,1,.6,1))}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6d8yml{border-color:var(--ds-border-accent-gray,#7d818a)}._154iidpf{top:0}
|
|
7
|
+
._154iu2gc{top:var(--ds-space-100,8px)}
|
|
8
|
+
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
9
|
+
._18m91wug{overflow-y:auto}
|
|
10
|
+
._19bvu2gc{padding-left:var(--ds-space-100,8px)}
|
|
11
|
+
._19bvv77o{padding-left:var(--ds-space-025,2px)}
|
|
12
|
+
._1bsb7vkz{width:1pc}
|
|
13
|
+
._1bsbkpet{width:296px}
|
|
14
|
+
._1reo1wug{overflow-x:auto}
|
|
15
|
+
._1xi2u2gc{right:var(--ds-space-100,8px)}
|
|
16
|
+
._4t3iftgi{height:8px}
|
|
17
|
+
._94n5idpf{bottom:0}
|
|
18
|
+
._bfhk1aqn{background-color:var(--ds-background-neutral-bold,#292a2e)}
|
|
19
|
+
._ca0qu2gc{padding-top:var(--ds-space-100,8px)}
|
|
20
|
+
._ca0qv77o{padding-top:var(--ds-space-025,2px)}
|
|
21
|
+
._kqswh2mm{position:relative}
|
|
22
|
+
._kqswstnw{position:absolute}
|
|
23
|
+
._lcxvglyw{pointer-events:none}
|
|
24
|
+
._mkrz1oyg{clip-path:polygon(50% 0,100% 100%,0 100%)}
|
|
25
|
+
._n3tdu2gc{padding-bottom:var(--ds-space-100,8px)}
|
|
26
|
+
._n3tdv77o{padding-bottom:var(--ds-space-025,2px)}
|
|
27
|
+
._p12f1osq{max-width:100%}
|
|
28
|
+
._syaz15cr{color:var(--ds-text-inverse,#fff)}
|
|
29
|
+
._t9ec1sub{transform:rotate(180deg)}
|
|
30
|
+
._u5f31ejb{padding-right:var(--ds-space-300,24px)}
|
|
31
|
+
._u5f3u2gc{padding-right:var(--ds-space-100,8px)}
|
|
32
|
+
._u5f3v77o{padding-right:var(--ds-space-025,2px)}
|
|
33
|
+
._vchhusvi{box-sizing:border-box}
|
|
34
|
+
._irr31ibz:hover{background-color:var(--ds-background-neutral-bold-hovered,#3b3d42)}
|
|
35
|
+
._1ggl5xtf:active{transition:var(--ds-button-pressed,background-color border-color .15s cubic-bezier(.4,1,.6,1))}
|
|
36
|
+
._1di6of27:active{background-color:var(--ds-background-neutral-bold-pressed,#505258)}
|
|
@@ -0,0 +1,267 @@
|
|
|
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, { createContext, forwardRef, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
7
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
|
|
8
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
9
|
+
import CrossIcon from '@atlaskit/icon/core/cross';
|
|
10
|
+
import { Popup } from '@atlaskit/popup/popup';
|
|
11
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
12
|
+
import { Inline } from '@atlaskit/primitives/compiled/inline';
|
|
13
|
+
import { Pressable } from '@atlaskit/primitives/compiled/pressable';
|
|
14
|
+
import { Stack } from '@atlaskit/primitives/compiled/stack';
|
|
15
|
+
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
16
|
+
import { EVENT_CHANNEL } from '../../../../common/analytics/constants';
|
|
17
|
+
import { getExtensionKey } from '../../../../state/getExtensionKey';
|
|
18
|
+
import useOneClickChatSpotlightEligibility from '../../../../state/hooks/use-one-click-chat-spotlight-eligibility';
|
|
19
|
+
import useRovoConfig from '../../../../state/hooks/use-rovo-config';
|
|
20
|
+
import { useSmartCardState } from '../../../../state/store';
|
|
21
|
+
const messages = defineMessages({
|
|
22
|
+
heading: {
|
|
23
|
+
id: 'smart-card.one-click-chat-spotlight-v2.heading.ai-non-final',
|
|
24
|
+
defaultMessage: 'Explore this link with Rovo',
|
|
25
|
+
description: 'Accessible name of a spotlight introducing the Rovo action beside a resolved Smart Link.'
|
|
26
|
+
},
|
|
27
|
+
drive: {
|
|
28
|
+
id: 'smart-card.one-click-chat-spotlight-v2.drive.ai-non-final',
|
|
29
|
+
defaultMessage: 'Discover insights from your Google Drive Smart Link using Rovo',
|
|
30
|
+
description: 'Spotlight text explaining that the inline action summarizes the linked Google Drive content.'
|
|
31
|
+
},
|
|
32
|
+
github: {
|
|
33
|
+
id: 'smart-card.one-click-chat-spotlight-v2.github.ai-non-final',
|
|
34
|
+
defaultMessage: 'Discover insights from your GitHub Smart Link using Rovo',
|
|
35
|
+
description: 'Spotlight text explaining that the inline action explains the linked GitHub code.'
|
|
36
|
+
},
|
|
37
|
+
dismiss: {
|
|
38
|
+
id: 'smart-card.one-click-chat-spotlight-v2.dismiss.ai-non-final',
|
|
39
|
+
defaultMessage: 'Dismiss spotlight',
|
|
40
|
+
description: 'Dismiss button in the Smart Link spotlight. Hides this spotlight for seven days.'
|
|
41
|
+
},
|
|
42
|
+
action: {
|
|
43
|
+
id: 'smart-card.one-click-chat-spotlight-v2.action.ai-non-final',
|
|
44
|
+
defaultMessage: 'Try Now',
|
|
45
|
+
description: 'Button in the spotlight that invokes the same Rovo action as the highlighted inline button.'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const styles = {
|
|
49
|
+
surface: "_1reo1wug _18m91wug _kqswh2mm _1bsbkpet _p12f1osq _vchhusvi _ca0qu2gc _n3tdu2gc _19bvu2gc _u5f3u2gc",
|
|
50
|
+
card: "_2rko1qi0 _bfhk1aqn _syaz15cr _16qs130s",
|
|
51
|
+
caret: "_kqswstnw _1bsb7vkz _4t3iftgi _bfhk1aqn _mkrz1oyg _lcxvglyw",
|
|
52
|
+
below: "_154iidpf",
|
|
53
|
+
above: "_94n5idpf _t9ec1sub",
|
|
54
|
+
close: "_2rko12b0 _v564k6bl _kqswstnw _154iu2gc _1xi2u2gc _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _syaz15cr _bfhk1aqn _irr31ibz _1ggl5xtf _1di6of27",
|
|
55
|
+
content: "_kqswh2mm",
|
|
56
|
+
body: "_u5f31ejb",
|
|
57
|
+
action: "_2rko12b0 _v564k6bl _1h6d8yml _1dqonqa1 _189ee4h9 _syaz15cr _bfhk1aqn _ca0qv77o _n3tdv77o _19bvu2gc _u5f3u2gc _irr31ibz _1ggl5xtf _1di6of27"
|
|
58
|
+
};
|
|
59
|
+
const TargetContext = /*#__PURE__*/createContext(null);
|
|
60
|
+
|
|
61
|
+
// Keep Popup's inline trigger, dismissal and focus handling. The design-system Spotlight
|
|
62
|
+
// target renders a block element; the Smart Link action must stay inline.
|
|
63
|
+
const SpotlightSurface = /*#__PURE__*/forwardRef(({
|
|
64
|
+
children,
|
|
65
|
+
style,
|
|
66
|
+
shouldFitViewport: _fit,
|
|
67
|
+
shouldRenderToParent: _parent,
|
|
68
|
+
shouldFitContainer: _container,
|
|
69
|
+
appearance: _appearance,
|
|
70
|
+
xcss: _xcss,
|
|
71
|
+
isReferenceHidden: _hidden,
|
|
72
|
+
...props
|
|
73
|
+
}, forwardedRef) => {
|
|
74
|
+
const target = useContext(TargetContext);
|
|
75
|
+
const surface = useRef(null);
|
|
76
|
+
const [caret, setCaret] = useState({
|
|
77
|
+
above: false,
|
|
78
|
+
left: 24
|
|
79
|
+
});
|
|
80
|
+
const ref = useCallback(node => {
|
|
81
|
+
surface.current = node;
|
|
82
|
+
if (typeof forwardedRef === 'function') forwardedRef(node);else if (forwardedRef) forwardedRef.current = node;
|
|
83
|
+
}, [forwardedRef]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const element = surface.current;
|
|
86
|
+
const anchor = target === null || target === void 0 ? void 0 : target.current;
|
|
87
|
+
if (!element || !anchor) return;
|
|
88
|
+
let frame = 0;
|
|
89
|
+
const measure = () => {
|
|
90
|
+
const card = element.getBoundingClientRect();
|
|
91
|
+
const trigger = anchor.getBoundingClientRect();
|
|
92
|
+
if (!card.width) return;
|
|
93
|
+
const above = card.bottom <= trigger.top;
|
|
94
|
+
const left = Math.max(16, Math.min(card.width - 32, trigger.left + trigger.width / 2 - card.left - 8));
|
|
95
|
+
setCaret(previous => previous.above === above && previous.left === left ? previous : {
|
|
96
|
+
above,
|
|
97
|
+
left
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const schedule = () => {
|
|
101
|
+
cancelAnimationFrame(frame);
|
|
102
|
+
frame = requestAnimationFrame(measure);
|
|
103
|
+
};
|
|
104
|
+
const observer = new ResizeObserver(schedule);
|
|
105
|
+
observer.observe(element);
|
|
106
|
+
observer.observe(anchor);
|
|
107
|
+
window.addEventListener('resize', schedule);
|
|
108
|
+
window.addEventListener('scroll', schedule, true);
|
|
109
|
+
schedule();
|
|
110
|
+
return () => {
|
|
111
|
+
cancelAnimationFrame(frame);
|
|
112
|
+
observer.disconnect();
|
|
113
|
+
window.removeEventListener('resize', schedule);
|
|
114
|
+
window.removeEventListener('scroll', schedule, true);
|
|
115
|
+
};
|
|
116
|
+
}, [target]);
|
|
117
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
118
|
+
ref: ref,
|
|
119
|
+
style: style,
|
|
120
|
+
className: ax([styles.surface])
|
|
121
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
122
|
+
"aria-hidden": "true",
|
|
123
|
+
style: {
|
|
124
|
+
left: caret.left
|
|
125
|
+
},
|
|
126
|
+
className: ax([styles.caret, caret.above ? styles.above : styles.below])
|
|
127
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
128
|
+
xcss: styles.card
|
|
129
|
+
}, children));
|
|
130
|
+
});
|
|
131
|
+
function VisibleSpotlightCard({
|
|
132
|
+
onShown,
|
|
133
|
+
body,
|
|
134
|
+
dismissLabel,
|
|
135
|
+
actionLabel,
|
|
136
|
+
onDismiss,
|
|
137
|
+
onAction
|
|
138
|
+
}) {
|
|
139
|
+
useEffect(() => onShown(), [onShown]);
|
|
140
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
141
|
+
testId: "one-click-chat-spotlight-v2",
|
|
142
|
+
xcss: styles.content,
|
|
143
|
+
padding: "space.150"
|
|
144
|
+
}, /*#__PURE__*/React.createElement(Pressable, {
|
|
145
|
+
xcss: styles.close,
|
|
146
|
+
onClick: onDismiss,
|
|
147
|
+
"aria-label": dismissLabel
|
|
148
|
+
}, /*#__PURE__*/React.createElement(CrossIcon, {
|
|
149
|
+
label: "",
|
|
150
|
+
size: "small"
|
|
151
|
+
})), /*#__PURE__*/React.createElement(Stack, {
|
|
152
|
+
space: "space.050"
|
|
153
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
154
|
+
xcss: styles.body
|
|
155
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
156
|
+
color: "color.text.inverse"
|
|
157
|
+
}, body)), /*#__PURE__*/React.createElement(Inline, {
|
|
158
|
+
alignInline: "end"
|
|
159
|
+
}, /*#__PURE__*/React.createElement(Pressable, {
|
|
160
|
+
xcss: styles.action,
|
|
161
|
+
onClick: onAction
|
|
162
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
163
|
+
color: "color.text.inverse"
|
|
164
|
+
}, actionLabel)))));
|
|
165
|
+
}
|
|
166
|
+
export function OneClickChatSpotlight({
|
|
167
|
+
children,
|
|
168
|
+
url,
|
|
169
|
+
actionOptions,
|
|
170
|
+
onInvoke
|
|
171
|
+
}) {
|
|
172
|
+
const intl = useIntl();
|
|
173
|
+
const target = useRef(null);
|
|
174
|
+
const [isOpportunity, setOpportunity] = useState(false);
|
|
175
|
+
const {
|
|
176
|
+
createAnalyticsEvent
|
|
177
|
+
} = useAnalyticsEvents();
|
|
178
|
+
const {
|
|
179
|
+
product
|
|
180
|
+
} = useRovoConfig();
|
|
181
|
+
const card = useSmartCardState(url !== null && url !== void 0 ? url : '');
|
|
182
|
+
const provider = getExtensionKey(card.details);
|
|
183
|
+
const onInteraction = useCallback(interaction => {
|
|
184
|
+
createAnalyticsEvent({
|
|
185
|
+
eventType: interaction === 'impression' ? 'track' : 'ui',
|
|
186
|
+
action: interaction === 'impression' ? 'viewed' : interaction,
|
|
187
|
+
actionSubject: 'oneClickChatSpotlight',
|
|
188
|
+
actionSubjectId: 'oneClickChatSpotlightV2',
|
|
189
|
+
attributes: {
|
|
190
|
+
provider: provider === 'google-object-provider' ? 'google-drive' : 'github',
|
|
191
|
+
product: product === 'CONFLUENCE' ? 'confluence_web' : 'jira_web',
|
|
192
|
+
appearance: 'inline',
|
|
193
|
+
cohort: 'treatment',
|
|
194
|
+
variant: 'v2'
|
|
195
|
+
}
|
|
196
|
+
}).fire(EVENT_CHANNEL);
|
|
197
|
+
}, [createAnalyticsEvent, provider, product]);
|
|
198
|
+
const spotlight = useOneClickChatSpotlightEligibility({
|
|
199
|
+
url,
|
|
200
|
+
actionOptions,
|
|
201
|
+
isOpportunity,
|
|
202
|
+
onInteraction
|
|
203
|
+
});
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
const element = target.current;
|
|
206
|
+
const doc = getDocument();
|
|
207
|
+
if (!element || !doc || typeof IntersectionObserver === 'undefined') {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
let intersects = false;
|
|
211
|
+
const update = () => setOpportunity(intersects && doc.visibilityState === 'visible');
|
|
212
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
213
|
+
intersects = entry.isIntersecting;
|
|
214
|
+
update();
|
|
215
|
+
});
|
|
216
|
+
observer.observe(element);
|
|
217
|
+
doc.addEventListener('visibilitychange', update);
|
|
218
|
+
return () => {
|
|
219
|
+
observer.disconnect();
|
|
220
|
+
doc.removeEventListener('visibilitychange', update);
|
|
221
|
+
};
|
|
222
|
+
}, []);
|
|
223
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
224
|
+
ref: target,
|
|
225
|
+
role: "none",
|
|
226
|
+
onClick: event => {
|
|
227
|
+
// Top-layer popups remain inside the Smart Link's anchor in the DOM.
|
|
228
|
+
event.preventDefault();
|
|
229
|
+
event.stopPropagation();
|
|
230
|
+
}
|
|
231
|
+
// Match the enclosing Smart Link's keypress handler; leave Escape keydown for Popup.
|
|
232
|
+
,
|
|
233
|
+
onKeyPress: event => event.stopPropagation()
|
|
234
|
+
}, /*#__PURE__*/React.createElement(TargetContext.Provider, {
|
|
235
|
+
value: target
|
|
236
|
+
}, /*#__PURE__*/React.createElement(Popup, {
|
|
237
|
+
popupComponent: SpotlightSurface,
|
|
238
|
+
shouldFitViewport: true,
|
|
239
|
+
isOpen: spotlight.isEligible,
|
|
240
|
+
onClose: spotlight.onDismiss,
|
|
241
|
+
placement: "bottom-start",
|
|
242
|
+
role: "dialog",
|
|
243
|
+
label: intl.formatMessage(messages.heading),
|
|
244
|
+
trigger: ({
|
|
245
|
+
ref
|
|
246
|
+
}) => /*#__PURE__*/React.createElement("span", {
|
|
247
|
+
ref: ref,
|
|
248
|
+
onClickCapture: () => {
|
|
249
|
+
if (spotlight.isEligible) {
|
|
250
|
+
spotlight.onClick();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, children),
|
|
254
|
+
content: () => /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
|
|
255
|
+
onShown: spotlight.onShown,
|
|
256
|
+
body: intl.formatMessage(provider === 'google-object-provider' ? messages.drive : messages.github),
|
|
257
|
+
dismissLabel: intl.formatMessage(messages.dismiss),
|
|
258
|
+
actionLabel: intl.formatMessage(messages.action),
|
|
259
|
+
onDismiss: spotlight.onDismiss,
|
|
260
|
+
onAction: () => {
|
|
261
|
+
if (spotlight.onClick()) {
|
|
262
|
+
onInvoke();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
})));
|
|
267
|
+
}
|
|
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
4
4
|
import React, { useCallback, useMemo } from 'react';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
6
|
import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
8
|
import { Box, Text } from '@atlaskit/primitives/compiled';
|
|
8
9
|
import extractRovoChatAction from '../../../../extractors/flexible/actions/extract-rovo-chat-action';
|
|
9
10
|
import { getExtensionKey } from '../../../../state/getExtensionKey';
|
|
@@ -13,10 +14,14 @@ import useRovoConfig from '../../../../state/hooks/use-rovo-config';
|
|
|
13
14
|
import { useSmartCardState } from '../../../../state/store';
|
|
14
15
|
import { getPromptAction, RovoChatPromptKey } from '../../../common/rovo-chat-utils';
|
|
15
16
|
import { ActionButton } from '../action-button';
|
|
17
|
+
import { OneClickChatSpotlightLoader } from '../one-click-chat-spotlight/async';
|
|
16
18
|
const styles = {
|
|
17
19
|
text: "_19bv12x7 _1e0c116y _4cvr1h6o _s7n4nkob _19pk1i6y"
|
|
18
20
|
};
|
|
19
|
-
|
|
21
|
+
|
|
22
|
+
// Keep the master implementation intact while the spotlight rollout is disabled.
|
|
23
|
+
export const InlineRovoActionButton = props => fg('platform_sl_one_click_chat_spotlight_v2_fg') ? /*#__PURE__*/React.createElement(InlineRovoActionButtonWithSpotlight, props) : /*#__PURE__*/React.createElement(InlineRovoActionButtonLegacy, props);
|
|
24
|
+
const InlineRovoActionButtonLegacy = ({
|
|
20
25
|
testId,
|
|
21
26
|
url,
|
|
22
27
|
actionOptions
|
|
@@ -93,4 +98,91 @@ export const InlineRovoActionButton = ({
|
|
|
93
98
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
94
99
|
size: "small"
|
|
95
100
|
}, content))) : null;
|
|
101
|
+
};
|
|
102
|
+
const InlineRovoActionButtonWithSpotlight = ({
|
|
103
|
+
testId,
|
|
104
|
+
url,
|
|
105
|
+
actionOptions
|
|
106
|
+
}) => {
|
|
107
|
+
const {
|
|
108
|
+
sendPromptMessage,
|
|
109
|
+
isRovoChatEnabled
|
|
110
|
+
} = useRovoChat();
|
|
111
|
+
const intl = useIntl();
|
|
112
|
+
const cardState = useSmartCardState(url !== null && url !== void 0 ? url : '');
|
|
113
|
+
const extensionKey = getExtensionKey(cardState.details);
|
|
114
|
+
const rovoConfig = useRovoConfig();
|
|
115
|
+
const rovoChatAction = useMemo(() => {
|
|
116
|
+
return cardState.details && extractRovoChatAction({
|
|
117
|
+
response: cardState.details,
|
|
118
|
+
actionOptions,
|
|
119
|
+
rovoConfig
|
|
120
|
+
});
|
|
121
|
+
}, [cardState.details, rovoConfig, actionOptions]);
|
|
122
|
+
const provider = useMemo(() => {
|
|
123
|
+
return cardState.details && extractSmartLinkProvider(cardState.details);
|
|
124
|
+
}, [cardState.details]);
|
|
125
|
+
const invoke = useInvokeClientAction({});
|
|
126
|
+
const promptKey = useMemo(() => {
|
|
127
|
+
var _cardState$details3, _cardState$details3$d, _cardState$details3$d2, _cardState$details4, _cardState$details4$d, _cardState$details4$d2;
|
|
128
|
+
if (extensionKey === 'google-object-provider' && (_cardState$details3 = cardState.details) !== null && _cardState$details3 !== void 0 && (_cardState$details3$d = _cardState$details3.data) !== null && _cardState$details3$d !== void 0 && (_cardState$details3$d2 = _cardState$details3$d['@type']) !== null && _cardState$details3$d2 !== void 0 && _cardState$details3$d2.includes('schema:SpreadsheetDigitalDocument')) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
switch (extensionKey) {
|
|
132
|
+
case 'google-object-provider':
|
|
133
|
+
if ((_cardState$details4 = cardState.details) !== null && _cardState$details4 !== void 0 && (_cardState$details4$d = _cardState$details4.data) !== null && _cardState$details4$d !== void 0 && (_cardState$details4$d2 = _cardState$details4$d['@type']) !== null && _cardState$details4$d2 !== void 0 && _cardState$details4$d2.includes('schema:PresentationDigitalDocument')) {
|
|
134
|
+
return RovoChatPromptKey.SUMMARIZE_PRESENTATION;
|
|
135
|
+
}
|
|
136
|
+
return RovoChatPromptKey.SUMMARIZE_DOCUMENT;
|
|
137
|
+
case 'onedrive-object-provider':
|
|
138
|
+
return RovoChatPromptKey.SUMMARIZE_DOCUMENT;
|
|
139
|
+
case 'github-object-provider':
|
|
140
|
+
case 'gitlab-object-provider':
|
|
141
|
+
return RovoChatPromptKey.EXPLAIN_CODE;
|
|
142
|
+
case 'slack-object-provider':
|
|
143
|
+
case 'ms-teams-object-provider':
|
|
144
|
+
return RovoChatPromptKey.CATCH_UP;
|
|
145
|
+
case 'salesforce-object-provider':
|
|
146
|
+
return RovoChatPromptKey.SALESFORCE_PREP;
|
|
147
|
+
}
|
|
148
|
+
}, [extensionKey, cardState]);
|
|
149
|
+
const {
|
|
150
|
+
data: promptData,
|
|
151
|
+
content,
|
|
152
|
+
icon
|
|
153
|
+
} = promptKey ? getPromptAction({
|
|
154
|
+
promptKey,
|
|
155
|
+
intl,
|
|
156
|
+
url,
|
|
157
|
+
iconSize: 'small',
|
|
158
|
+
provider: provider === null || provider === void 0 ? void 0 : provider.text
|
|
159
|
+
}) || {} : {};
|
|
160
|
+
const invokePrompt = useCallback(() => {
|
|
161
|
+
if (isRovoChatEnabled && promptData && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction) {
|
|
162
|
+
invoke({
|
|
163
|
+
...rovoChatAction.invokeAction,
|
|
164
|
+
actionFn: async () => sendPromptMessage(promptData),
|
|
165
|
+
prompt: promptKey
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}, [sendPromptMessage, isRovoChatEnabled, promptData, rovoChatAction, promptKey, invoke]);
|
|
169
|
+
const handleClick = useCallback(event => {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
event.stopPropagation();
|
|
172
|
+
invokePrompt();
|
|
173
|
+
}, [invokePrompt]);
|
|
174
|
+
const button = promptData && content ? /*#__PURE__*/React.createElement(ActionButton, {
|
|
175
|
+
onClick: handleClick,
|
|
176
|
+
testId: testId
|
|
177
|
+
}, icon, /*#__PURE__*/React.createElement(Box, {
|
|
178
|
+
xcss: styles.text
|
|
179
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
180
|
+
size: "small"
|
|
181
|
+
}, content))) : null;
|
|
182
|
+
return button && isRovoChatEnabled && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction ? /*#__PURE__*/React.createElement(OneClickChatSpotlightLoader, {
|
|
183
|
+
key: url,
|
|
184
|
+
url: url,
|
|
185
|
+
actionOptions: actionOptions,
|
|
186
|
+
onInvoke: invokePrompt
|
|
187
|
+
}, button) : button;
|
|
96
188
|
};
|
|
@@ -9,7 +9,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
9
9
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
10
10
|
const PACKAGE_DATA = {
|
|
11
11
|
packageName: "@atlaskit/smart-card",
|
|
12
|
-
packageVersion: "46.
|
|
12
|
+
packageVersion: "46.3.0",
|
|
13
13
|
componentName: 'linkUrl'
|
|
14
14
|
};
|
|
15
15
|
const LinkUrl = ({
|
|
@@ -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.3.0" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -8,6 +8,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
8
8
|
import { Popup } from '@atlaskit/popup/popup';
|
|
9
9
|
import { ActionName, CardDisplay } from '../../../constants';
|
|
10
10
|
import { useSmartCardActions } from '../../../state/actions';
|
|
11
|
+
import { isSpotlightActive } from '../../../state/hooks/use-one-click-chat-spotlight-eligibility/suppression';
|
|
11
12
|
import { useSmartLinkRenderers } from '../../../state/renderers';
|
|
12
13
|
import { useSmartCardState as useLinkState } from '../../../state/store';
|
|
13
14
|
import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
|
|
@@ -158,6 +159,13 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
158
159
|
}
|
|
159
160
|
}, [linkState.metadataStatus, linkState.status, loadMetadata, register]);
|
|
160
161
|
var initShowCard = useCallback(function (event) {
|
|
162
|
+
// Popup events bubble through the enclosing Smart Link, including portals.
|
|
163
|
+
// A second top-layer popup can light-dismiss the spotlight before its click runs.
|
|
164
|
+
if (fg('platform_sl_one_click_chat_spotlight_v2_fg') && isSpotlightActive()) {
|
|
165
|
+
initHideCard();
|
|
166
|
+
hideCard();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
161
169
|
// clearing out fadeOutTimeoutId in case it's already counting down to hide the card
|
|
162
170
|
if (fadeOutTimeoutId.current) {
|
|
163
171
|
clearTimeout(fadeOutTimeoutId.current);
|
|
@@ -178,6 +186,11 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
178
186
|
}
|
|
179
187
|
} else {
|
|
180
188
|
fadeInTimeoutId.current = setTimeout(function () {
|
|
189
|
+
// The spotlight may mount while this hover delay is pending.
|
|
190
|
+
if (fg('platform_sl_one_click_chat_spotlight_v2_fg') && isSpotlightActive()) {
|
|
191
|
+
fadeInTimeoutId.current = undefined;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
181
194
|
if (handleSetIsOpen) {
|
|
182
195
|
handleSetIsOpen(true);
|
|
183
196
|
} else {
|
|
@@ -186,7 +199,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
186
199
|
}, fadeInDelay);
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
|
-
}, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen]);
|
|
202
|
+
}, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen, initHideCard, hideCard]);
|
|
190
203
|
var onActionClick = useCallback(function (actionId) {
|
|
191
204
|
if (actionId === ActionName.PreviewAction || actionId === ActionName.AutomationAction) {
|
|
192
205
|
hideCard();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
/** Keep the existing action usable during SSR, loading and chunk failures. */
|
|
4
|
+
export function OneClickChatSpotlightLoader(props) {
|
|
5
|
+
var _useState = useState(),
|
|
6
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7
|
+
Spotlight = _useState2[0],
|
|
8
|
+
setSpotlight = _useState2[1];
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
var active = true;
|
|
11
|
+
import( /* webpackChunkName: "@atlaskit-internal_smartcard-one-click-chat-spotlight" */'./index').then(function (_ref) {
|
|
12
|
+
var OneClickChatSpotlight = _ref.OneClickChatSpotlight;
|
|
13
|
+
if (active) {
|
|
14
|
+
setSpotlight(function () {
|
|
15
|
+
return OneClickChatSpotlight;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}).catch(function () {
|
|
19
|
+
// An optional spotlight must not break the existing inline action.
|
|
20
|
+
});
|
|
21
|
+
return function () {
|
|
22
|
+
active = false;
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return Spotlight ? /*#__PURE__*/React.createElement(Spotlight, props) : /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
2
|
+
._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}
|
|
3
|
+
._v564k6bl{transition:var(--ds-button-hovered,background-color border-color .15s cubic-bezier(.4,1,.6,1))}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6d8yml{border-color:var(--ds-border-accent-gray,#7d818a)}._154iidpf{top:0}
|
|
7
|
+
._154iu2gc{top:var(--ds-space-100,8px)}
|
|
8
|
+
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
9
|
+
._18m91wug{overflow-y:auto}
|
|
10
|
+
._19bvu2gc{padding-left:var(--ds-space-100,8px)}
|
|
11
|
+
._19bvv77o{padding-left:var(--ds-space-025,2px)}
|
|
12
|
+
._1bsb7vkz{width:1pc}
|
|
13
|
+
._1bsbkpet{width:296px}
|
|
14
|
+
._1reo1wug{overflow-x:auto}
|
|
15
|
+
._1xi2u2gc{right:var(--ds-space-100,8px)}
|
|
16
|
+
._4t3iftgi{height:8px}
|
|
17
|
+
._94n5idpf{bottom:0}
|
|
18
|
+
._bfhk1aqn{background-color:var(--ds-background-neutral-bold,#292a2e)}
|
|
19
|
+
._ca0qu2gc{padding-top:var(--ds-space-100,8px)}
|
|
20
|
+
._ca0qv77o{padding-top:var(--ds-space-025,2px)}
|
|
21
|
+
._kqswh2mm{position:relative}
|
|
22
|
+
._kqswstnw{position:absolute}
|
|
23
|
+
._lcxvglyw{pointer-events:none}
|
|
24
|
+
._mkrz1oyg{clip-path:polygon(50% 0,100% 100%,0 100%)}
|
|
25
|
+
._n3tdu2gc{padding-bottom:var(--ds-space-100,8px)}
|
|
26
|
+
._n3tdv77o{padding-bottom:var(--ds-space-025,2px)}
|
|
27
|
+
._p12f1osq{max-width:100%}
|
|
28
|
+
._syaz15cr{color:var(--ds-text-inverse,#fff)}
|
|
29
|
+
._t9ec1sub{transform:rotate(180deg)}
|
|
30
|
+
._u5f31ejb{padding-right:var(--ds-space-300,24px)}
|
|
31
|
+
._u5f3u2gc{padding-right:var(--ds-space-100,8px)}
|
|
32
|
+
._u5f3v77o{padding-right:var(--ds-space-025,2px)}
|
|
33
|
+
._vchhusvi{box-sizing:border-box}
|
|
34
|
+
._irr31ibz:hover{background-color:var(--ds-background-neutral-bold-hovered,#3b3d42)}
|
|
35
|
+
._1ggl5xtf:active{transition:var(--ds-button-pressed,background-color border-color .15s cubic-bezier(.4,1,.6,1))}
|
|
36
|
+
._1di6of27:active{background-color:var(--ds-background-neutral-bold-pressed,#505258)}
|