@atlaskit/smart-card 45.5.0 → 45.6.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 +11 -0
- package/dist/cjs/extractors/flexible/actions/extract-rovo-chat-action.js +3 -1
- package/dist/cjs/state/hooks/use-embed-rovo-actions-footer-experiment/index.js +65 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +1 -0
- package/dist/cjs/view/CardWithUrl/experiment-meta-event-attributes/index.js +17 -3
- package/dist/cjs/view/EmbedCard/components/rovo-actions-footer/index.compiled.css +3 -0
- package/dist/cjs/view/EmbedCard/components/rovo-actions-footer/index.js +138 -0
- package/dist/cjs/view/EmbedCard/index.js +2 -0
- package/dist/cjs/view/EmbedCard/views/ResolvedView.compiled.css +6 -0
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +129 -36
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/common/rovo-post-auth-prompts/index.js +15 -0
- package/dist/es2019/extractors/flexible/actions/extract-rovo-chat-action.js +3 -1
- package/dist/es2019/state/hooks/use-embed-rovo-actions-footer-experiment/index.js +58 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +1 -0
- package/dist/es2019/view/CardWithUrl/experiment-meta-event-attributes/index.js +18 -2
- package/dist/es2019/view/EmbedCard/components/rovo-actions-footer/index.compiled.css +3 -0
- package/dist/es2019/view/EmbedCard/components/rovo-actions-footer/index.js +100 -0
- package/dist/es2019/view/EmbedCard/index.js +2 -0
- package/dist/es2019/view/EmbedCard/views/ResolvedView.compiled.css +6 -0
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +94 -13
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/common/rovo-post-auth-prompts/index.js +10 -0
- package/dist/esm/extractors/flexible/actions/extract-rovo-chat-action.js +3 -1
- package/dist/esm/state/hooks/use-embed-rovo-actions-footer-experiment/index.js +58 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +1 -0
- package/dist/esm/view/CardWithUrl/experiment-meta-event-attributes/index.js +17 -3
- package/dist/esm/view/EmbedCard/components/rovo-actions-footer/index.compiled.css +3 -0
- package/dist/esm/view/EmbedCard/components/rovo-actions-footer/index.js +129 -0
- package/dist/esm/view/EmbedCard/index.js +2 -0
- package/dist/esm/view/EmbedCard/views/ResolvedView.compiled.css +6 -0
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +125 -36
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/common/rovo-post-auth-prompts/index.js +9 -0
- package/dist/types/extractors/flexible/actions/extract-rovo-chat-action.d.ts +2 -1
- package/dist/types/state/hooks/use-embed-rovo-actions-footer-experiment/index.d.ts +23 -0
- package/dist/types/view/CardWithUrl/experiment-meta-event-attributes/index.d.ts +5 -2
- package/dist/types/view/EmbedCard/components/rovo-actions-footer/index.d.ts +14 -0
- package/dist/types/view/EmbedCard/views/ResolvedView.d.ts +8 -0
- package/dist/types/view/common/rovo-post-auth-prompts/index.d.ts +5 -0
- package/package.json +9 -2
|
@@ -304,6 +304,7 @@ function Component({
|
|
|
304
304
|
}, [appearance, reload]);
|
|
305
305
|
const handleInvoke = useCallback(opts => actions.invoke(opts, appearance), [actions, appearance]);
|
|
306
306
|
const experimentMetaEventAttributes = useExperimentMetaEventAttributes({
|
|
307
|
+
actionOptions,
|
|
307
308
|
appearance,
|
|
308
309
|
state
|
|
309
310
|
});
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { useSmartLinkContext } from '../../../state';
|
|
3
3
|
import { getExtensionKey } from '../../../state/helpers';
|
|
4
|
+
import { getEmbedRovoActionsFooterExperimentMeta } from '../../../state/hooks/use-embed-rovo-actions-footer-experiment';
|
|
5
|
+
import useRovoConfig from '../../../state/hooks/use-rovo-config';
|
|
4
6
|
import { getSocialProofExperimentMeta, getInlineSocialProofExperimentMeta } from '../../../state/hooks/use-social-proof-experiment';
|
|
7
|
+
import { getIsRovoChatEnabled } from '../../../utils/rovo';
|
|
5
8
|
const useExperimentMetaEventAttributes = ({
|
|
9
|
+
actionOptions,
|
|
6
10
|
appearance,
|
|
7
11
|
state
|
|
8
12
|
}) => {
|
|
13
|
+
var _actionOptions$rovoCh, _actionOptions$rovoCh2;
|
|
9
14
|
const {
|
|
10
15
|
connections: {
|
|
11
16
|
client: {
|
|
@@ -13,12 +18,22 @@ const useExperimentMetaEventAttributes = ({
|
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
} = useSmartLinkContext();
|
|
21
|
+
const {
|
|
22
|
+
rovoOptions,
|
|
23
|
+
product
|
|
24
|
+
} = useRovoConfig();
|
|
16
25
|
const {
|
|
17
26
|
details,
|
|
18
27
|
status
|
|
19
28
|
} = state;
|
|
20
29
|
const extensionKey = getExtensionKey(details);
|
|
21
|
-
|
|
30
|
+
const embedRovoActionsFooterExperimentMeta = appearance === 'embed' && status === 'resolved' ? getEmbedRovoActionsFooterExperimentMeta({
|
|
31
|
+
extensionKey,
|
|
32
|
+
isRovoChatActionOptedIn: (_actionOptions$rovoCh = actionOptions === null || actionOptions === void 0 ? void 0 : (_actionOptions$rovoCh2 = actionOptions.rovoChatAction) === null || _actionOptions$rovoCh2 === void 0 ? void 0 : _actionOptions$rovoCh2.optIn) !== null && _actionOptions$rovoCh !== void 0 ? _actionOptions$rovoCh : false,
|
|
33
|
+
isRovoChatEnabled: getIsRovoChatEnabled(rovoOptions),
|
|
34
|
+
product
|
|
35
|
+
}) : undefined;
|
|
36
|
+
if (!embedRovoActionsFooterExperimentMeta && !fg('social-proof-3p-unauth-block-fg') && !fg('platform_sl_3p_preauth_soc_proof_inline_killswitch')) {
|
|
22
37
|
return undefined;
|
|
23
38
|
}
|
|
24
39
|
const blockSocialProofExperimentMeta = appearance === 'block' && status === 'unauthorized' && fg('social-proof-3p-unauth-block-fg') ? getSocialProofExperimentMeta({
|
|
@@ -31,7 +46,8 @@ const useExperimentMetaEventAttributes = ({
|
|
|
31
46
|
}) : undefined;
|
|
32
47
|
const experimentMeta = {
|
|
33
48
|
...blockSocialProofExperimentMeta,
|
|
34
|
-
...inlineSocialProofExperimentMeta
|
|
49
|
+
...inlineSocialProofExperimentMeta,
|
|
50
|
+
...embedRovoActionsFooterExperimentMeta
|
|
35
51
|
};
|
|
36
52
|
if (Object.keys(experimentMeta).length > 0) {
|
|
37
53
|
return experimentMeta;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import "./index.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import Button from '@atlaskit/button/new';
|
|
7
|
+
import { WidthObserver } from '@atlaskit/width-detector';
|
|
8
|
+
import useInvokeClientAction from '../../../../state/hooks/use-invoke-client-action';
|
|
9
|
+
import useRovoChat from '../../../../state/hooks/use-rovo-chat';
|
|
10
|
+
import { getPromptAction } from '../../../common/rovo-chat-utils';
|
|
11
|
+
import AIEditIcon from '../../../FlexibleCard/assets/ai-edit-icon';
|
|
12
|
+
const HIDE_SECONDARY_ACTIONS_WIDTH = 320;
|
|
13
|
+
const PRIMARY_ACTION_ICON_ONLY_WIDTH = 220;
|
|
14
|
+
const styles = {
|
|
15
|
+
actionGroup: "_zulpidpf _1e0c1txw _2lx2vrvc"
|
|
16
|
+
};
|
|
17
|
+
const RovoPromptButton = ({
|
|
18
|
+
hideContent = false,
|
|
19
|
+
icon,
|
|
20
|
+
onClick,
|
|
21
|
+
promptAction,
|
|
22
|
+
promptKey,
|
|
23
|
+
testId
|
|
24
|
+
}) => {
|
|
25
|
+
const iconBefore = useCallback(() => /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
}, icon), [icon]);
|
|
28
|
+
const label = promptAction.data.name;
|
|
29
|
+
const handleClick = useCallback(event => onClick(event, promptAction.data, promptKey), [onClick, promptAction.data, promptKey]);
|
|
30
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
31
|
+
appearance: "subtle",
|
|
32
|
+
"aria-label": hideContent ? label : undefined,
|
|
33
|
+
iconBefore: iconBefore,
|
|
34
|
+
onClick: handleClick,
|
|
35
|
+
spacing: "compact",
|
|
36
|
+
testId: `${testId}-${promptKey}`
|
|
37
|
+
}, hideContent ? null : label);
|
|
38
|
+
};
|
|
39
|
+
const EmbedRovoActionsFooter = ({
|
|
40
|
+
actionData,
|
|
41
|
+
prompts,
|
|
42
|
+
testId = 'embed-rovo-actions-footer'
|
|
43
|
+
}) => {
|
|
44
|
+
const intl = useIntl();
|
|
45
|
+
const invoke = useInvokeClientAction({});
|
|
46
|
+
const {
|
|
47
|
+
isRovoChatEnabled,
|
|
48
|
+
sendPromptMessage
|
|
49
|
+
} = useRovoChat();
|
|
50
|
+
const [containerWidth, setContainerWidth] = useState(undefined);
|
|
51
|
+
const shouldHideSecondaryActions = containerWidth !== undefined && containerWidth < HIDE_SECONDARY_ACTIONS_WIDTH;
|
|
52
|
+
const shouldHidePrimaryActionContent = containerWidth !== undefined && containerWidth < PRIMARY_ACTION_ICON_ONLY_WIDTH;
|
|
53
|
+
const onClick = useCallback((event, promptData, promptKey) => {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
invoke({
|
|
57
|
+
...actionData.invokeAction,
|
|
58
|
+
actionFn: async () => sendPromptMessage(promptData),
|
|
59
|
+
prompt: promptKey
|
|
60
|
+
});
|
|
61
|
+
}, [actionData.invokeAction, invoke, sendPromptMessage]);
|
|
62
|
+
const promptActions = useMemo(() => prompts.reduce((actions, promptKey) => {
|
|
63
|
+
if (shouldHideSecondaryActions && actions.length > 0) {
|
|
64
|
+
return actions;
|
|
65
|
+
}
|
|
66
|
+
const promptAction = getPromptAction({
|
|
67
|
+
promptKey,
|
|
68
|
+
intl,
|
|
69
|
+
url: actionData.url,
|
|
70
|
+
product: actionData.product,
|
|
71
|
+
iconSize: 'small'
|
|
72
|
+
});
|
|
73
|
+
if (!promptAction) {
|
|
74
|
+
return actions;
|
|
75
|
+
}
|
|
76
|
+
const isPrimaryAction = actions.length === 0;
|
|
77
|
+
actions.push( /*#__PURE__*/React.createElement(RovoPromptButton, {
|
|
78
|
+
hideContent: isPrimaryAction && shouldHidePrimaryActionContent,
|
|
79
|
+
icon: isPrimaryAction ? /*#__PURE__*/React.createElement(AIEditIcon, null) : promptAction.icon,
|
|
80
|
+
key: promptKey,
|
|
81
|
+
onClick: onClick,
|
|
82
|
+
promptAction: promptAction,
|
|
83
|
+
promptKey: promptKey,
|
|
84
|
+
testId: testId
|
|
85
|
+
}));
|
|
86
|
+
return actions;
|
|
87
|
+
}, []), [actionData.product, actionData.url, intl, onClick, prompts, shouldHidePrimaryActionContent, shouldHideSecondaryActions, testId]);
|
|
88
|
+
if (!isRovoChatEnabled || promptActions.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
"data-testid": testId
|
|
93
|
+
}, /*#__PURE__*/React.createElement(WidthObserver, {
|
|
94
|
+
setWidth: setContainerWidth,
|
|
95
|
+
offscreen: true
|
|
96
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: ax([styles.actionGroup])
|
|
98
|
+
}, promptActions));
|
|
99
|
+
};
|
|
100
|
+
export default EmbedRovoActionsFooter;
|
|
@@ -100,6 +100,8 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
100
100
|
}
|
|
101
101
|
if (resolvedViewProps.preview) {
|
|
102
102
|
return /*#__PURE__*/React.createElement(EmbedCardResolvedView, _extends({}, resolvedViewProps, {
|
|
103
|
+
actionOptions: actionOptions,
|
|
104
|
+
details: details,
|
|
103
105
|
isSelected: isSelected,
|
|
104
106
|
frameStyle: frameStyle,
|
|
105
107
|
inheritDimensions: inheritDimensions,
|
|
@@ -1,16 +1,89 @@
|
|
|
1
|
+
/* ResolvedView.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./ResolvedView.compiled.css";
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
2
5
|
import React from 'react';
|
|
6
|
+
import Loadable from 'react-loadable';
|
|
3
7
|
import LinkGlyph from '@atlaskit/icon/core/link';
|
|
4
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
|
|
5
10
|
import { useThemeObserver } from '@atlaskit/tokens';
|
|
11
|
+
import { CardDisplay } from '../../../constants';
|
|
12
|
+
import extractRovoChatAction from '../../../extractors/flexible/actions/extract-rovo-chat-action';
|
|
13
|
+
import { getExtensionKey } from '../../../state/helpers';
|
|
14
|
+
import useEmbedRovoActionsFooterExperiment from '../../../state/hooks/use-embed-rovo-actions-footer-experiment';
|
|
15
|
+
import useRovoConfig from '../../../state/hooks/use-rovo-config';
|
|
6
16
|
import { getPreviewUrlWithTheme, isProfileType } from '../../../utils';
|
|
17
|
+
import { getRovoPostAuthPromptKeys } from '../../common/rovo-post-auth-prompts';
|
|
7
18
|
import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
8
19
|
import { Frame } from '../components/Frame';
|
|
9
20
|
import { ImageIcon } from '../components/ImageIcon';
|
|
10
21
|
import { useEmbedResolvePostMessageListener } from '../useEmbedResolvePostMessageListener';
|
|
22
|
+
const EmbedRovoActionsFooter = Loadable({
|
|
23
|
+
loader: () => import( /* webpackChunkName: "smart-card-embed-rovo-actions-footer" */'../components/rovo-actions-footer').then(module => module.default),
|
|
24
|
+
loading: () => null
|
|
25
|
+
});
|
|
26
|
+
EmbedRovoActionsFooter.displayName = 'lazy(EmbedRovoActionsFooter)';
|
|
27
|
+
const styles = {
|
|
28
|
+
contentWithFooter: "_1e0c1txw _2lx21bp4 _4t3i1osq _1tkeidpf",
|
|
29
|
+
frameWithFooter: "_16jlkb7n _1tkeidpf",
|
|
30
|
+
footer: "_1e0c1txw _1bah1y6m"
|
|
31
|
+
};
|
|
32
|
+
const EmbedFrameWithRovoFooter = ({
|
|
33
|
+
actionOptions,
|
|
34
|
+
details,
|
|
35
|
+
frame,
|
|
36
|
+
link,
|
|
37
|
+
testId
|
|
38
|
+
}) => {
|
|
39
|
+
const {
|
|
40
|
+
rovoOptions,
|
|
41
|
+
product
|
|
42
|
+
} = useRovoConfig();
|
|
43
|
+
const {
|
|
44
|
+
isEnabled: isEmbedRovoActionsFooterEnabled
|
|
45
|
+
} = useEmbedRovoActionsFooterExperiment(link, actionOptions, rovoOptions, product);
|
|
46
|
+
const rovoActionData = React.useMemo(() => isEmbedRovoActionsFooterEnabled && details ? extractRovoChatAction({
|
|
47
|
+
response: details,
|
|
48
|
+
rovoConfig: {
|
|
49
|
+
rovoOptions,
|
|
50
|
+
product
|
|
51
|
+
},
|
|
52
|
+
product,
|
|
53
|
+
actionOptions,
|
|
54
|
+
appearance: CardDisplay.Embed,
|
|
55
|
+
isEmbedRovoActionsFooterExperimentEnabled: isEmbedRovoActionsFooterEnabled
|
|
56
|
+
}) : undefined, [actionOptions, details, isEmbedRovoActionsFooterEnabled, product, rovoOptions]);
|
|
57
|
+
const prompts = React.useMemo(() => {
|
|
58
|
+
if (!isEmbedRovoActionsFooterEnabled) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
return getRovoPostAuthPromptKeys({
|
|
62
|
+
extensionKey: getExtensionKey(details)
|
|
63
|
+
});
|
|
64
|
+
}, [details, isEmbedRovoActionsFooterEnabled]);
|
|
65
|
+
const footer = React.useMemo(() => rovoActionData && prompts.length > 0 ? /*#__PURE__*/React.createElement(EmbedRovoActionsFooter, {
|
|
66
|
+
actionData: rovoActionData,
|
|
67
|
+
prompts: prompts,
|
|
68
|
+
testId: `${testId}-rovo-actions-footer`
|
|
69
|
+
}) : undefined, [prompts, rovoActionData, testId]);
|
|
70
|
+
return footer ? /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: ax([styles.contentWithFooter])
|
|
72
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: ax([styles.frameWithFooter])
|
|
74
|
+
}, frame), /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: ax([styles.footer])
|
|
76
|
+
}, footer)) : frame;
|
|
77
|
+
};
|
|
78
|
+
const EmbedFrameWithoutRovoFooter = ({
|
|
79
|
+
frame
|
|
80
|
+
}) => frame;
|
|
81
|
+
const EmbedFrameWithOptionalRovoFooter = componentWithFG('platform_sl_3p_auth_rovo_embed_footer_kill_switch', EmbedFrameWithRovoFooter, EmbedFrameWithoutRovoFooter);
|
|
11
82
|
export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
83
|
+
actionOptions,
|
|
12
84
|
link,
|
|
13
85
|
context,
|
|
86
|
+
details,
|
|
14
87
|
onClick,
|
|
15
88
|
onAuxClick,
|
|
16
89
|
onContextMenu,
|
|
@@ -64,6 +137,26 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
64
137
|
previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
|
|
65
138
|
}
|
|
66
139
|
const [isMouseOver, setMouseOver] = React.useState(false);
|
|
140
|
+
const frame = /*#__PURE__*/React.createElement(Frame, {
|
|
141
|
+
url: previewUrl,
|
|
142
|
+
isTrusted: isTrusted,
|
|
143
|
+
testId: testId,
|
|
144
|
+
ref: embedIframeRef,
|
|
145
|
+
onIframeDwell: onIframeDwell,
|
|
146
|
+
onIframeFocus: onIframeFocus,
|
|
147
|
+
onIframeMouseEnter: onIframeMouseEnter,
|
|
148
|
+
onIframeMouseLeave: onIframeMouseLeave,
|
|
149
|
+
isMouseOver: isMouseOver,
|
|
150
|
+
title: text,
|
|
151
|
+
extensionKey: extensionKey
|
|
152
|
+
});
|
|
153
|
+
const frameWithFooter = /*#__PURE__*/React.createElement(EmbedFrameWithOptionalRovoFooter, {
|
|
154
|
+
actionOptions: actionOptions,
|
|
155
|
+
details: details,
|
|
156
|
+
frame: frame,
|
|
157
|
+
link: link,
|
|
158
|
+
testId: testId
|
|
159
|
+
});
|
|
67
160
|
return /*#__PURE__*/React.createElement(ExpandedFrame, {
|
|
68
161
|
isSelected: isSelected,
|
|
69
162
|
frameStyle: frameStyle,
|
|
@@ -85,17 +178,5 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
85
178
|
setMouseOver(false);
|
|
86
179
|
onIframeMouseLeave === null || onIframeMouseLeave === void 0 ? void 0 : onIframeMouseLeave();
|
|
87
180
|
}
|
|
88
|
-
},
|
|
89
|
-
url: previewUrl,
|
|
90
|
-
isTrusted: isTrusted,
|
|
91
|
-
testId: testId,
|
|
92
|
-
ref: embedIframeRef,
|
|
93
|
-
onIframeDwell: onIframeDwell,
|
|
94
|
-
onIframeFocus: onIframeFocus,
|
|
95
|
-
onIframeMouseEnter: onIframeMouseEnter,
|
|
96
|
-
onIframeMouseLeave: onIframeMouseLeave,
|
|
97
|
-
isMouseOver: isMouseOver,
|
|
98
|
-
title: text,
|
|
99
|
-
extensionKey: extensionKey
|
|
100
|
-
}));
|
|
181
|
+
}, frameWithFooter);
|
|
101
182
|
});
|
|
@@ -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: "45.
|
|
12
|
+
packageVersion: "45.5.0",
|
|
13
13
|
componentName: 'linkUrl'
|
|
14
14
|
};
|
|
15
15
|
const LinkUrl = ({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RovoChatPromptKey } from '../rovo-chat-utils';
|
|
2
|
+
export const getRovoPostAuthPromptKeys = ({
|
|
3
|
+
extensionKey
|
|
4
|
+
}) => {
|
|
5
|
+
const defaultPrompts = [RovoChatPromptKey.KEY_HIGHLIGHTS];
|
|
6
|
+
if (extensionKey === 'github-object-provider' || extensionKey === 'gitlab-object-provider') {
|
|
7
|
+
return [RovoChatPromptKey.EXPLAIN_CODE, ...defaultPrompts];
|
|
8
|
+
}
|
|
9
|
+
return [RovoChatPromptKey.SUMMARIZE_DOCUMENT, ...defaultPrompts];
|
|
10
|
+
};
|
|
@@ -12,6 +12,7 @@ var extractRovoChatAction = function extractRovoChatAction(_ref) {
|
|
|
12
12
|
var actionOptions = _ref.actionOptions,
|
|
13
13
|
appearance = _ref.appearance,
|
|
14
14
|
id = _ref.id,
|
|
15
|
+
isEmbedRovoActionsFooterExperimentEnabled = _ref.isEmbedRovoActionsFooterExperimentEnabled,
|
|
15
16
|
product = _ref.product,
|
|
16
17
|
response = _ref.response,
|
|
17
18
|
rovoConfig = _ref.rovoConfig;
|
|
@@ -27,7 +28,8 @@ var extractRovoChatAction = function extractRovoChatAction(_ref) {
|
|
|
27
28
|
var isInlineExperimentEnabled = fg('platform_sl_3p_auth_inline_tailored_cta_killswitch') && expValEqualsNoExposure('platform_sl_3p_auth_inline_tailored_cta', 'isEnabled', true);
|
|
28
29
|
var is3PAuthRovoActionEnabled = isGoogleProvider && fg('platform_sl_3p_auth_rovo_action_kill_switch');
|
|
29
30
|
var is3PBlockPostAuthActionsEnabled = extensionKey !== undefined && ELIGIBLE_EXTENSION_KEYS.has(extensionKey) && (rovoConfig === null || rovoConfig === void 0 ? void 0 : rovoConfig.product) === 'CONFLUENCE';
|
|
30
|
-
var
|
|
31
|
+
var is3PEmbedPostAuthActionsEnabled = isEmbedRovoActionsFooterExperimentEnabled === true;
|
|
32
|
+
var isSupportedFeature = is3PAuthRovoActionEnabled || is3PBlockPostAuthActionsEnabled || isInlineExperimentEnabled || is3PEmbedPostAuthActionsEnabled;
|
|
31
33
|
var isOptIn = (actionOptions === null || actionOptions === void 0 || (_actionOptions$rovoCh = actionOptions.rovoChatAction) === null || _actionOptions$rovoCh === void 0 ? void 0 : _actionOptions$rovoCh.optIn) === true;
|
|
32
34
|
var url = extractSmartLinkUrl(response);
|
|
33
35
|
return isSupportedFeature && isOptIn ? {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
6
|
+
import { getIsRovoChatEnabled } from '../../../utils/rovo';
|
|
7
|
+
import { getExtensionKey } from '../../helpers';
|
|
8
|
+
import { useSmartCardState } from '../../store';
|
|
9
|
+
var EMBED_ROVO_ACTIONS_FOOTER_ELIGIBLE_EXTENSION_KEYS = new Set(['google-object-provider', 'onedrive-object-provider', 'github-object-provider', 'gitlab-object-provider']);
|
|
10
|
+
var isEligibleEmbedRovoActionsFooterExtensionKey = function isEligibleEmbedRovoActionsFooterExtensionKey(extensionKey) {
|
|
11
|
+
return extensionKey !== undefined && EMBED_ROVO_ACTIONS_FOOTER_ELIGIBLE_EXTENSION_KEYS.has(extensionKey);
|
|
12
|
+
};
|
|
13
|
+
export var EMBED_ROVO_ACTIONS_FOOTER_EXPERIMENT_KEY = 'platform_sl_3p_auth_rovo_embed_footer_exp';
|
|
14
|
+
var NOT_ENABLED_RESULT = {
|
|
15
|
+
isEnabled: false
|
|
16
|
+
};
|
|
17
|
+
export var isEmbedRovoActionsFooterExperimentEnabled = function isEmbedRovoActionsFooterExperimentEnabled(product) {
|
|
18
|
+
return product === 'CONFLUENCE' && fg('platform_sl_3p_auth_rovo_embed_footer_kill_switch') && expValEquals(EMBED_ROVO_ACTIONS_FOOTER_EXPERIMENT_KEY, 'isEnabled', true);
|
|
19
|
+
};
|
|
20
|
+
var isEmbedRovoActionsFooterKillSwitchEnabled = function isEmbedRovoActionsFooterKillSwitchEnabled(product) {
|
|
21
|
+
return product === 'CONFLUENCE' && fg('platform_sl_3p_auth_rovo_embed_footer_kill_switch');
|
|
22
|
+
};
|
|
23
|
+
var isEmbedRovoActionsFooterExperimentEnabledNoExposure = function isEmbedRovoActionsFooterExperimentEnabledNoExposure(product) {
|
|
24
|
+
return isEmbedRovoActionsFooterKillSwitchEnabled(product) && expValEqualsNoExposure(EMBED_ROVO_ACTIONS_FOOTER_EXPERIMENT_KEY, 'isEnabled', true);
|
|
25
|
+
};
|
|
26
|
+
export var getEmbedRovoActionsFooterExperimentMeta = function getEmbedRovoActionsFooterExperimentMeta(_ref) {
|
|
27
|
+
var extensionKey = _ref.extensionKey,
|
|
28
|
+
isRovoChatActionOptedIn = _ref.isRovoChatActionOptedIn,
|
|
29
|
+
isRovoChatEnabled = _ref.isRovoChatEnabled,
|
|
30
|
+
product = _ref.product;
|
|
31
|
+
var isEligible = isEmbedRovoActionsFooterKillSwitchEnabled(product) && isRovoChatEnabled && isRovoChatActionOptedIn && isEligibleEmbedRovoActionsFooterExtensionKey(extensionKey);
|
|
32
|
+
if (!isEligible) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return _defineProperty({}, EMBED_ROVO_ACTIONS_FOOTER_EXPERIMENT_KEY, {
|
|
36
|
+
isEligible: true,
|
|
37
|
+
isTreatment: isEmbedRovoActionsFooterExperimentEnabledNoExposure(product)
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
var useEmbedRovoActionsFooterExperiment = function useEmbedRovoActionsFooterExperiment(url, actionOptions, rovoOptions, product) {
|
|
41
|
+
var _actionOptions$rovoCh, _actionOptions$rovoCh2;
|
|
42
|
+
var isRovoChatEnabled = getIsRovoChatEnabled(rovoOptions);
|
|
43
|
+
var cardState = useSmartCardState(url !== null && url !== void 0 ? url : '');
|
|
44
|
+
var extensionKey = getExtensionKey(cardState.details);
|
|
45
|
+
var isRovoChatActionOptedIn = (_actionOptions$rovoCh = actionOptions === null || actionOptions === void 0 || (_actionOptions$rovoCh2 = actionOptions.rovoChatAction) === null || _actionOptions$rovoCh2 === void 0 ? void 0 : _actionOptions$rovoCh2.optIn) !== null && _actionOptions$rovoCh !== void 0 ? _actionOptions$rovoCh : false;
|
|
46
|
+
return useMemo(function () {
|
|
47
|
+
if (!isRovoChatEnabled || !url || !isRovoChatActionOptedIn || !extensionKey) {
|
|
48
|
+
return NOT_ENABLED_RESULT;
|
|
49
|
+
}
|
|
50
|
+
if (!isEligibleEmbedRovoActionsFooterExtensionKey(extensionKey)) {
|
|
51
|
+
return NOT_ENABLED_RESULT;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
isEnabled: isEmbedRovoActionsFooterExperimentEnabled(product)
|
|
55
|
+
};
|
|
56
|
+
}, [isRovoChatEnabled, extensionKey, url, isRovoChatActionOptedIn, product]);
|
|
57
|
+
};
|
|
58
|
+
export default useEmbedRovoActionsFooterExperiment;
|
|
@@ -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: "45.
|
|
7
|
+
packageVersion: "45.5.0" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -306,6 +306,7 @@ function Component(_ref) {
|
|
|
306
306
|
return actions.invoke(opts, appearance);
|
|
307
307
|
}, [actions, appearance]);
|
|
308
308
|
var experimentMetaEventAttributes = useExperimentMetaEventAttributes({
|
|
309
|
+
actionOptions: actionOptions,
|
|
309
310
|
appearance: appearance,
|
|
310
311
|
state: state
|
|
311
312
|
});
|
|
@@ -4,16 +4,30 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { useSmartLinkContext } from '../../../state';
|
|
6
6
|
import { getExtensionKey } from '../../../state/helpers';
|
|
7
|
+
import { getEmbedRovoActionsFooterExperimentMeta } from '../../../state/hooks/use-embed-rovo-actions-footer-experiment';
|
|
8
|
+
import useRovoConfig from '../../../state/hooks/use-rovo-config';
|
|
7
9
|
import { getSocialProofExperimentMeta, getInlineSocialProofExperimentMeta } from '../../../state/hooks/use-social-proof-experiment';
|
|
10
|
+
import { getIsRovoChatEnabled } from '../../../utils/rovo';
|
|
8
11
|
var useExperimentMetaEventAttributes = function useExperimentMetaEventAttributes(_ref) {
|
|
9
|
-
var
|
|
12
|
+
var _actionOptions$rovoCh, _actionOptions$rovoCh2;
|
|
13
|
+
var actionOptions = _ref.actionOptions,
|
|
14
|
+
appearance = _ref.appearance,
|
|
10
15
|
state = _ref.state;
|
|
11
16
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
12
17
|
baseUriWithNoTrailingSlash = _useSmartLinkContext.connections.client.baseUrlOverride;
|
|
18
|
+
var _useRovoConfig = useRovoConfig(),
|
|
19
|
+
rovoOptions = _useRovoConfig.rovoOptions,
|
|
20
|
+
product = _useRovoConfig.product;
|
|
13
21
|
var details = state.details,
|
|
14
22
|
status = state.status;
|
|
15
23
|
var extensionKey = getExtensionKey(details);
|
|
16
|
-
|
|
24
|
+
var embedRovoActionsFooterExperimentMeta = appearance === 'embed' && status === 'resolved' ? getEmbedRovoActionsFooterExperimentMeta({
|
|
25
|
+
extensionKey: extensionKey,
|
|
26
|
+
isRovoChatActionOptedIn: (_actionOptions$rovoCh = actionOptions === null || actionOptions === void 0 || (_actionOptions$rovoCh2 = actionOptions.rovoChatAction) === null || _actionOptions$rovoCh2 === void 0 ? void 0 : _actionOptions$rovoCh2.optIn) !== null && _actionOptions$rovoCh !== void 0 ? _actionOptions$rovoCh : false,
|
|
27
|
+
isRovoChatEnabled: getIsRovoChatEnabled(rovoOptions),
|
|
28
|
+
product: product
|
|
29
|
+
}) : undefined;
|
|
30
|
+
if (!embedRovoActionsFooterExperimentMeta && !fg('social-proof-3p-unauth-block-fg') && !fg('platform_sl_3p_preauth_soc_proof_inline_killswitch')) {
|
|
17
31
|
return undefined;
|
|
18
32
|
}
|
|
19
33
|
var blockSocialProofExperimentMeta = appearance === 'block' && status === 'unauthorized' && fg('social-proof-3p-unauth-block-fg') ? getSocialProofExperimentMeta({
|
|
@@ -24,7 +38,7 @@ var useExperimentMetaEventAttributes = function useExperimentMetaEventAttributes
|
|
|
24
38
|
extensionKey: extensionKey,
|
|
25
39
|
baseUriWithNoTrailingSlash: baseUriWithNoTrailingSlash
|
|
26
40
|
}) : undefined;
|
|
27
|
-
var experimentMeta = _objectSpread(_objectSpread({}, blockSocialProofExperimentMeta), inlineSocialProofExperimentMeta);
|
|
41
|
+
var experimentMeta = _objectSpread(_objectSpread(_objectSpread({}, blockSocialProofExperimentMeta), inlineSocialProofExperimentMeta), embedRovoActionsFooterExperimentMeta);
|
|
28
42
|
if (Object.keys(experimentMeta).length > 0) {
|
|
29
43
|
return experimentMeta;
|
|
30
44
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
import "./index.compiled.css";
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
11
|
+
import { useIntl } from 'react-intl';
|
|
12
|
+
import Button from '@atlaskit/button/new';
|
|
13
|
+
import { WidthObserver } from '@atlaskit/width-detector';
|
|
14
|
+
import useInvokeClientAction from '../../../../state/hooks/use-invoke-client-action';
|
|
15
|
+
import useRovoChat from '../../../../state/hooks/use-rovo-chat';
|
|
16
|
+
import { getPromptAction } from '../../../common/rovo-chat-utils';
|
|
17
|
+
import AIEditIcon from '../../../FlexibleCard/assets/ai-edit-icon';
|
|
18
|
+
var HIDE_SECONDARY_ACTIONS_WIDTH = 320;
|
|
19
|
+
var PRIMARY_ACTION_ICON_ONLY_WIDTH = 220;
|
|
20
|
+
var styles = {
|
|
21
|
+
actionGroup: "_zulpidpf _1e0c1txw _2lx2vrvc"
|
|
22
|
+
};
|
|
23
|
+
var RovoPromptButton = function RovoPromptButton(_ref) {
|
|
24
|
+
var _ref$hideContent = _ref.hideContent,
|
|
25
|
+
hideContent = _ref$hideContent === void 0 ? false : _ref$hideContent,
|
|
26
|
+
icon = _ref.icon,
|
|
27
|
+
onClick = _ref.onClick,
|
|
28
|
+
promptAction = _ref.promptAction,
|
|
29
|
+
promptKey = _ref.promptKey,
|
|
30
|
+
testId = _ref.testId;
|
|
31
|
+
var iconBefore = useCallback(function () {
|
|
32
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
33
|
+
"aria-hidden": "true"
|
|
34
|
+
}, icon);
|
|
35
|
+
}, [icon]);
|
|
36
|
+
var label = promptAction.data.name;
|
|
37
|
+
var handleClick = useCallback(function (event) {
|
|
38
|
+
return onClick(event, promptAction.data, promptKey);
|
|
39
|
+
}, [onClick, promptAction.data, promptKey]);
|
|
40
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
41
|
+
appearance: "subtle",
|
|
42
|
+
"aria-label": hideContent ? label : undefined,
|
|
43
|
+
iconBefore: iconBefore,
|
|
44
|
+
onClick: handleClick,
|
|
45
|
+
spacing: "compact",
|
|
46
|
+
testId: "".concat(testId, "-").concat(promptKey)
|
|
47
|
+
}, hideContent ? null : label);
|
|
48
|
+
};
|
|
49
|
+
var EmbedRovoActionsFooter = function EmbedRovoActionsFooter(_ref2) {
|
|
50
|
+
var actionData = _ref2.actionData,
|
|
51
|
+
prompts = _ref2.prompts,
|
|
52
|
+
_ref2$testId = _ref2.testId,
|
|
53
|
+
testId = _ref2$testId === void 0 ? 'embed-rovo-actions-footer' : _ref2$testId;
|
|
54
|
+
var intl = useIntl();
|
|
55
|
+
var invoke = useInvokeClientAction({});
|
|
56
|
+
var _useRovoChat = useRovoChat(),
|
|
57
|
+
isRovoChatEnabled = _useRovoChat.isRovoChatEnabled,
|
|
58
|
+
sendPromptMessage = _useRovoChat.sendPromptMessage;
|
|
59
|
+
var _useState = useState(undefined),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
containerWidth = _useState2[0],
|
|
62
|
+
setContainerWidth = _useState2[1];
|
|
63
|
+
var shouldHideSecondaryActions = containerWidth !== undefined && containerWidth < HIDE_SECONDARY_ACTIONS_WIDTH;
|
|
64
|
+
var shouldHidePrimaryActionContent = containerWidth !== undefined && containerWidth < PRIMARY_ACTION_ICON_ONLY_WIDTH;
|
|
65
|
+
var onClick = useCallback(function (event, promptData, promptKey) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
invoke(_objectSpread(_objectSpread({}, actionData.invokeAction), {}, {
|
|
69
|
+
actionFn: function () {
|
|
70
|
+
var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
71
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
72
|
+
while (1) switch (_context.prev = _context.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
return _context.abrupt("return", sendPromptMessage(promptData));
|
|
75
|
+
case 1:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context.stop();
|
|
78
|
+
}
|
|
79
|
+
}, _callee);
|
|
80
|
+
}));
|
|
81
|
+
function actionFn() {
|
|
82
|
+
return _actionFn.apply(this, arguments);
|
|
83
|
+
}
|
|
84
|
+
return actionFn;
|
|
85
|
+
}(),
|
|
86
|
+
prompt: promptKey
|
|
87
|
+
}));
|
|
88
|
+
}, [actionData.invokeAction, invoke, sendPromptMessage]);
|
|
89
|
+
var promptActions = useMemo(function () {
|
|
90
|
+
return prompts.reduce(function (actions, promptKey) {
|
|
91
|
+
if (shouldHideSecondaryActions && actions.length > 0) {
|
|
92
|
+
return actions;
|
|
93
|
+
}
|
|
94
|
+
var promptAction = getPromptAction({
|
|
95
|
+
promptKey: promptKey,
|
|
96
|
+
intl: intl,
|
|
97
|
+
url: actionData.url,
|
|
98
|
+
product: actionData.product,
|
|
99
|
+
iconSize: 'small'
|
|
100
|
+
});
|
|
101
|
+
if (!promptAction) {
|
|
102
|
+
return actions;
|
|
103
|
+
}
|
|
104
|
+
var isPrimaryAction = actions.length === 0;
|
|
105
|
+
actions.push( /*#__PURE__*/React.createElement(RovoPromptButton, {
|
|
106
|
+
hideContent: isPrimaryAction && shouldHidePrimaryActionContent,
|
|
107
|
+
icon: isPrimaryAction ? /*#__PURE__*/React.createElement(AIEditIcon, null) : promptAction.icon,
|
|
108
|
+
key: promptKey,
|
|
109
|
+
onClick: onClick,
|
|
110
|
+
promptAction: promptAction,
|
|
111
|
+
promptKey: promptKey,
|
|
112
|
+
testId: testId
|
|
113
|
+
}));
|
|
114
|
+
return actions;
|
|
115
|
+
}, []);
|
|
116
|
+
}, [actionData.product, actionData.url, intl, onClick, prompts, shouldHidePrimaryActionContent, shouldHideSecondaryActions, testId]);
|
|
117
|
+
if (!isRovoChatEnabled || promptActions.length === 0) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
"data-testid": testId
|
|
122
|
+
}, /*#__PURE__*/React.createElement(WidthObserver, {
|
|
123
|
+
setWidth: setContainerWidth,
|
|
124
|
+
offscreen: true
|
|
125
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
126
|
+
className: ax([styles.actionGroup])
|
|
127
|
+
}, promptActions));
|
|
128
|
+
};
|
|
129
|
+
export default EmbedRovoActionsFooter;
|
|
@@ -97,6 +97,8 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref2, iframeRef)
|
|
|
97
97
|
}
|
|
98
98
|
if (resolvedViewProps.preview) {
|
|
99
99
|
return /*#__PURE__*/React.createElement(EmbedCardResolvedView, _extends({}, resolvedViewProps, {
|
|
100
|
+
actionOptions: actionOptions,
|
|
101
|
+
details: details,
|
|
100
102
|
isSelected: isSelected,
|
|
101
103
|
frameStyle: frameStyle,
|
|
102
104
|
inheritDimensions: inheritDimensions,
|