@atlaskit/smart-card 43.30.1 → 43.31.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/__tests__/vr-tests/__snapshots__/hover-card/hover-card-unauthorised--default--platform-sl-3p-preauth-better-hovercard-true.png +3 -0
  3. package/dist/cjs/messages.js +60 -0
  4. package/dist/cjs/utils/analytics/analytics.js +1 -1
  5. package/dist/cjs/view/HoverCard/components/ContentContainer.compiled.css +2 -1
  6. package/dist/cjs/view/HoverCard/components/ContentContainer.js +11 -9
  7. package/dist/cjs/view/HoverCard/components/CustomPopupContainer.js +4 -1
  8. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -1
  9. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +206 -73
  10. package/dist/cjs/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.compiled.css +16 -0
  11. package/dist/cjs/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.js +135 -0
  12. package/dist/cjs/view/LinkUrl/index.js +1 -1
  13. package/dist/es2019/__tests__/vr-tests/__snapshots__/hover-card/hover-card-unauthorised--default--platform-sl-3p-preauth-better-hovercard-true.png +3 -0
  14. package/dist/es2019/messages.js +60 -0
  15. package/dist/es2019/utils/analytics/analytics.js +1 -1
  16. package/dist/es2019/view/HoverCard/components/ContentContainer.compiled.css +1 -0
  17. package/dist/es2019/view/HoverCard/components/ContentContainer.js +8 -2
  18. package/dist/es2019/view/HoverCard/components/CustomPopupContainer.js +4 -1
  19. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +2 -1
  20. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +188 -64
  21. package/dist/es2019/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.compiled.css +16 -0
  22. package/dist/es2019/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.js +125 -0
  23. package/dist/es2019/view/LinkUrl/index.js +1 -1
  24. package/dist/esm/__tests__/vr-tests/__snapshots__/hover-card/hover-card-unauthorised--default--platform-sl-3p-preauth-better-hovercard-true.png +3 -0
  25. package/dist/esm/messages.js +60 -0
  26. package/dist/esm/utils/analytics/analytics.js +1 -1
  27. package/dist/esm/view/HoverCard/components/ContentContainer.compiled.css +2 -1
  28. package/dist/esm/view/HoverCard/components/ContentContainer.js +11 -9
  29. package/dist/esm/view/HoverCard/components/CustomPopupContainer.js +4 -1
  30. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +2 -1
  31. package/dist/esm/view/HoverCard/components/HoverCardContent.js +207 -74
  32. package/dist/esm/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.compiled.css +16 -0
  33. package/dist/esm/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.js +126 -0
  34. package/dist/esm/view/LinkUrl/index.js +1 -1
  35. package/dist/types/messages.d.ts +1 -1
  36. package/dist/types/view/HoverCard/components/ContentContainer.d.ts +1 -1
  37. package/dist/types/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.d.ts +3 -0
  38. package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +4 -0
  39. package/dist/types/view/HoverCard/types.d.ts +9 -0
  40. package/dist/types-ts4.5/messages.d.ts +1 -1
  41. package/dist/types-ts4.5/view/HoverCard/components/ContentContainer.d.ts +1 -1
  42. package/dist/types-ts4.5/view/HoverCard/components/views/unauthorised/RovoUnauthorisedView.d.ts +3 -0
  43. package/dist/types-ts4.5/view/HoverCard/components/views/unauthorised/types.d.ts +4 -0
  44. package/dist/types-ts4.5/view/HoverCard/types.d.ts +9 -0
  45. package/package.json +7 -4
  46. /package/dist/cjs/__tests__/vr-tests/__snapshots__/hover-card/{hover-card-unauthorised--default.png → hover-card-unauthorised--default--platform-sl-3p-preauth-better-hovercard-false.png} +0 -0
  47. /package/dist/es2019/__tests__/vr-tests/__snapshots__/hover-card/{hover-card-unauthorised--default.png → hover-card-unauthorised--default--platform-sl-3p-preauth-better-hovercard-false.png} +0 -0
  48. /package/dist/esm/__tests__/vr-tests/__snapshots__/hover-card/{hover-card-unauthorised--default.png → hover-card-unauthorised--default--platform-sl-3p-preauth-better-hovercard-false.png} +0 -0
@@ -0,0 +1,125 @@
1
+ /* RovoUnauthorisedView.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import "./RovoUnauthorisedView.compiled.css";
4
+ import * as React from 'react';
5
+ import { ax, ix } from "@compiled/react/runtime";
6
+ import { useCallback, useMemo } from 'react';
7
+ import { FormattedMessage } from 'react-intl-next';
8
+ import Button from '@atlaskit/button/new';
9
+ import { IconTile } from '@atlaskit/icon';
10
+ import AiSparkleIcon from '@atlaskit/icon/core/ai-sparkle';
11
+ import AppSwitcherIcon from '@atlaskit/icon/core/app-switcher';
12
+ import GlobeIcon from '@atlaskit/icon/core/globe';
13
+ import SearchIcon from '@atlaskit/icon/core/search';
14
+ import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
15
+ import { Box, Inline, Stack, Text } from '@atlaskit/primitives/compiled';
16
+ import { useAnalyticsEvents } from '../../../../../common/analytics/generated/use-analytics-events';
17
+ import { CardDisplay } from '../../../../../constants';
18
+ import { messages } from '../../../../../messages';
19
+ import { useSmartCardActions } from '../../../../../state/actions';
20
+ const ROVO_FEATURES = [{
21
+ icon: GlobeIcon,
22
+ appearance: 'blue',
23
+ titleMessage: messages.rovo_unauthorised_feature_document_summaries_title,
24
+ descMessage: messages.rovo_unauthorised_feature_document_summaries_desc,
25
+ testIdSuffix: 'document-summaries'
26
+ }, {
27
+ icon: SearchIcon,
28
+ appearance: 'purple',
29
+ titleMessage: messages.rovo_unauthorised_feature_related_content_title,
30
+ descMessage: messages.rovo_unauthorised_feature_related_content_desc,
31
+ testIdSuffix: 'related-content'
32
+ }, {
33
+ icon: AiSparkleIcon,
34
+ appearance: 'orange',
35
+ titleMessage: messages.rovo_unauthorised_feature_smart_suggestions_title,
36
+ descMessage: messages.rovo_unauthorised_feature_smart_suggestions_desc,
37
+ testIdSuffix: 'smart-suggestions'
38
+ }, {
39
+ icon: AppSwitcherIcon,
40
+ appearance: 'teal',
41
+ titleMessage: messages.rovo_unauthorised_feature_cross_reference_title,
42
+ descMessage: messages.rovo_unauthorised_feature_cross_reference_desc,
43
+ testIdSuffix: 'cross-reference'
44
+ }];
45
+ const layoutStyles = {
46
+ header: "_bfhkomb0 _syaz15cr _ca0qutpp _u5f3pxbi _n3tdutpp _19bvpxbi _13li1mok _qrwq1mok",
47
+ body: "_ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi",
48
+ footer: "_19pkpxbi _ca0qutpp",
49
+ footerActions: "_zulputpp _1e0c1txw _4cvr1h6o _1bahesu3 _1n261g80"
50
+ };
51
+ const RovoUnauthorisedView = ({
52
+ id = '',
53
+ flexibleCardProps,
54
+ onDismiss,
55
+ testId = 'hover-card-rovo-unauthorised-view',
56
+ url
57
+ }) => {
58
+ const providerName = useMemo(() => {
59
+ var _extractSmartLinkProv;
60
+ return (_extractSmartLinkProv = extractSmartLinkProvider(flexibleCardProps.cardState.details)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text;
61
+ }, [flexibleCardProps.cardState.details]);
62
+ const {
63
+ authorize
64
+ } = useSmartCardActions(id, url);
65
+ const {
66
+ fireEvent
67
+ } = useAnalyticsEvents();
68
+ const handleAuthorize = useCallback(() => {
69
+ if (authorize) {
70
+ fireEvent('track.applicationAccount.authStarted', {});
71
+ authorize(CardDisplay.HoverCardPreview);
72
+ }
73
+ }, [authorize, fireEvent]);
74
+ return /*#__PURE__*/React.createElement(Box, {
75
+ testId: testId
76
+ }, /*#__PURE__*/React.createElement(Box, {
77
+ xcss: layoutStyles.header
78
+ }, /*#__PURE__*/React.createElement(Text, {
79
+ weight: "bold",
80
+ size: "medium",
81
+ color: "color.text.inverse"
82
+ }, providerName ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.rovo_unauthorised_title, {
83
+ values: {
84
+ context: providerName
85
+ }
86
+ })) : /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_title_no_provider))), /*#__PURE__*/React.createElement(Box, {
87
+ xcss: layoutStyles.body
88
+ }, /*#__PURE__*/React.createElement(Stack, {
89
+ space: "space.050"
90
+ }, /*#__PURE__*/React.createElement(Stack, {
91
+ space: "space.200"
92
+ }, ROVO_FEATURES.map(feature => /*#__PURE__*/React.createElement(Inline, {
93
+ key: feature.testIdSuffix,
94
+ space: "space.100",
95
+ alignBlock: "center",
96
+ testId: `${testId}-feature-row-${feature.testIdSuffix}`
97
+ }, /*#__PURE__*/React.createElement(IconTile, {
98
+ icon: feature.icon,
99
+ label: '',
100
+ appearance: feature.appearance,
101
+ size: "medium",
102
+ testId: `${testId}-feature-${feature.testIdSuffix}`
103
+ }), /*#__PURE__*/React.createElement(Stack, {
104
+ space: "space.025"
105
+ }, /*#__PURE__*/React.createElement(Text, {
106
+ size: "small",
107
+ weight: "bold"
108
+ }, /*#__PURE__*/React.createElement(FormattedMessage, feature.titleMessage)), /*#__PURE__*/React.createElement(Text, {
109
+ size: "small",
110
+ color: "color.text.subtlest"
111
+ }, /*#__PURE__*/React.createElement(FormattedMessage, feature.descMessage)))))), /*#__PURE__*/React.createElement(Box, {
112
+ xcss: layoutStyles.footer
113
+ }, /*#__PURE__*/React.createElement(Box, {
114
+ xcss: layoutStyles.footerActions
115
+ }, /*#__PURE__*/React.createElement(Button, {
116
+ appearance: "subtle",
117
+ onClick: onDismiss,
118
+ testId: `${testId}-not-now`
119
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_not_now)), /*#__PURE__*/React.createElement(Button, {
120
+ appearance: "primary",
121
+ onClick: handleAuthorize,
122
+ testId: `${testId}-connect-account`
123
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.rovo_unauthorised_connect_account)))))));
124
+ };
125
+ export default RovoUnauthorisedView;
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
12
12
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
13
13
  const PACKAGE_DATA = {
14
14
  packageName: "@atlaskit/smart-card",
15
- packageVersion: "43.30.0",
15
+ packageVersion: "43.30.1",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  const Anchor = withLinkClickedEvent('a');
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5bd2bf44f51ef4f4f937b41a6c83ac5896a79db1a5e180e7de8eed93453f22c
3
+ size 42310
@@ -851,6 +851,66 @@ export var messages = defineMessages({
851
851
  defaultMessage: 'Uses AI. Verify Results.',
852
852
  description: 'Shown on a Rovo summary to indicate that the summary was generated by AI and should be verified by the user for accuracy.'
853
853
  },
854
+ rovo_unauthorised_title: {
855
+ id: 'fabric.linking.rovo_unauthorised.title',
856
+ defaultMessage: 'Get smarter workflows by connecting your {context} account',
857
+ description: 'Banner headline in Rovo unauthorised hover card header. {context} is the third-party provider name (e.g. Google).'
858
+ },
859
+ rovo_unauthorised_title_no_provider: {
860
+ id: 'fabric.linking.rovo_unauthorised.title_no_provider',
861
+ defaultMessage: 'Get smarter workflows by connecting your account',
862
+ description: 'Banner headline in Rovo unauthorised hover card header when the provider name is unknown.'
863
+ },
864
+ rovo_unauthorised_feature_document_summaries_title: {
865
+ id: 'fabric.linking.rovo_unauthorised.feature.document_summaries.title',
866
+ defaultMessage: 'Quick summaries',
867
+ description: 'Feature title in Rovo unauthorised view.'
868
+ },
869
+ rovo_unauthorised_feature_document_summaries_desc: {
870
+ id: 'fabric.linking.rovo_unauthorised.feature.document_summaries.desc',
871
+ defaultMessage: 'Understand long docs in seconds',
872
+ description: 'Feature description in Rovo unauthorised view.'
873
+ },
874
+ rovo_unauthorised_feature_smart_suggestions_title: {
875
+ id: 'fabric.linking.rovo_unauthorised.feature.smart_suggestions.title',
876
+ defaultMessage: 'Smart suggestions',
877
+ description: 'Feature title in Rovo unauthorised view.'
878
+ },
879
+ rovo_unauthorised_feature_smart_suggestions_desc: {
880
+ id: 'fabric.linking.rovo_unauthorised.feature.smart_suggestions.desc',
881
+ defaultMessage: 'Strengthen your drafts with actionable feedback',
882
+ description: 'Feature description in Rovo unauthorised view.'
883
+ },
884
+ rovo_unauthorised_feature_cross_reference_title: {
885
+ id: 'fabric.linking.rovo_unauthorised.feature.cross_reference.title',
886
+ defaultMessage: 'Tracked link mentions',
887
+ description: 'Feature title in Rovo unauthorised view.'
888
+ },
889
+ rovo_unauthorised_feature_cross_reference_desc: {
890
+ id: 'fabric.linking.rovo_unauthorised.feature.cross_reference.desc',
891
+ defaultMessage: 'Never miss where your work is referenced',
892
+ description: 'Feature description in Rovo unauthorised view.'
893
+ },
894
+ rovo_unauthorised_feature_related_content_title: {
895
+ id: 'fabric.linking.rovo_unauthorised.feature.related_content.title',
896
+ defaultMessage: 'Related content',
897
+ description: 'Feature title in Rovo unauthorised view.'
898
+ },
899
+ rovo_unauthorised_feature_related_content_desc: {
900
+ id: 'fabric.linking.rovo_unauthorised.feature.related_content.desc',
901
+ defaultMessage: 'Find relevant work and why it matters',
902
+ description: 'Feature description in Rovo unauthorised view.'
903
+ },
904
+ rovo_unauthorised_connect_account: {
905
+ id: 'fabric.linking.rovo_unauthorised.connect_account',
906
+ defaultMessage: 'Connect',
907
+ description: 'Primary action button in Rovo unauthorised hover card.'
908
+ },
909
+ rovo_unauthorised_not_now: {
910
+ id: 'fabric.linking.rovo_unauthorised.not_now',
911
+ defaultMessage: 'Maybe later',
912
+ description: 'Secondary action in Rovo unauthorised hover card.'
913
+ },
854
914
  rovo_prompt_context_generic: {
855
915
  id: 'fabric.linking.rovo_prompt_context_confluence_page.non-final',
856
916
  defaultMessage: 'page',
@@ -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: "43.30.0"
7
+ packageVersion: "43.30.1"
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -2,7 +2,8 @@
2
2
  ._2rko1mok{border-radius:var(--ds-radius-large,8px)}
3
3
  ._189eidpf{border-width:0}
4
4
  ._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
5
- ._1bsby0ve{width:var(--_1rzblqv)}
5
+ ._1bsb1f23{width:25rem}
6
+ ._1bsbiolt{width:22rem}
6
7
  ._9spsglyw .smart-link-loading-placeholder{display:none}
7
8
  ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
8
9
  ._vchhusvi{box-sizing:border-box}
@@ -2,8 +2,8 @@
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["children", "isAIEnabled", "testId", "url"],
6
- _excluded2 = ["children", "isAIEnabled", "testId", "url"];
5
+ var _excluded = ["children", "widthAppearance", "isAIEnabled", "testId", "url"],
6
+ _excluded2 = ["children", "widthAppearance", "isAIEnabled", "testId", "url"];
7
7
  import "./ContentContainer.compiled.css";
8
8
  import * as React from 'react';
9
9
  import { ax, ix } from "@compiled/react/runtime";
@@ -12,11 +12,14 @@ import { di } from 'react-magnetic-di';
12
12
  import useAISummaryAction from '../../../state/hooks/use-ai-summary-action';
13
13
  import AIPrism from '../../common/ai-prism';
14
14
  import { hoverCardClassName } from './HoverCardContent';
15
- var NEW_CARD_WIDTH_REM = 25;
16
15
  var HoverCardContainerStyle = null;
16
+ var hoverCardShellWidthDefault = null;
17
+ var hoverCardShellWidthSlim = null;
18
+ var hoverCardShellHideLoadingPlaceholder = null;
17
19
  var popupContainerStyles = null;
18
20
  var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
19
21
  var children = _ref.children,
22
+ widthAppearance = _ref.widthAppearance,
20
23
  _ref$isAIEnabled = _ref.isAIEnabled,
21
24
  isAIEnabled = _ref$isAIEnabled === void 0 ? false : _ref$isAIEnabled,
22
25
  testId = _ref.testId,
@@ -31,15 +34,12 @@ var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
31
34
  useEffect(function () {
32
35
  setShowPrism(status === 'loading');
33
36
  }, [status]);
37
+ var resolvedWidthAppearance = widthAppearance !== null && widthAppearance !== void 0 ? widthAppearance : 'default';
34
38
  var container = /*#__PURE__*/React.createElement("div", _extends({
35
39
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
36
- className: ax(["_11q7glyw _189eidpf _vchhusvi _1bsby0ve _9spsglyw", !isAIEnabled && "_2rko1mok _bfhk1bhr _16qs130s", hoverCardClassName]),
40
+ className: ax(["_11q7glyw _189eidpf _vchhusvi", resolvedWidthAppearance === 'slim' ? "_1bsbiolt" : "_1bsb1f23", "_9spsglyw", !isAIEnabled && "_2rko1mok _bfhk1bhr _16qs130s", hoverCardClassName]),
37
41
  "data-testid": testId
38
- }, props, {
39
- style: {
40
- "--_1rzblqv": ix("".concat(NEW_CARD_WIDTH_REM, "rem"))
41
- }
42
- }), children);
42
+ }, props), children);
43
43
  return isAIEnabled ? /*#__PURE__*/React.createElement(AIPrism, {
44
44
  isVisible: showPrism,
45
45
  testId: "".concat(testId, "-prism")
@@ -47,12 +47,14 @@ var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
47
47
  };
48
48
  var ContentContainer = function ContentContainer(_ref2) {
49
49
  var children = _ref2.children,
50
+ widthAppearance = _ref2.widthAppearance,
50
51
  _ref2$isAIEnabled = _ref2.isAIEnabled,
51
52
  isAIEnabled = _ref2$isAIEnabled === void 0 ? false : _ref2$isAIEnabled,
52
53
  testId = _ref2.testId,
53
54
  url = _ref2.url,
54
55
  props = _objectWithoutProperties(_ref2, _excluded2);
55
56
  return /*#__PURE__*/React.createElement(ConnectedAIPrismContainer, _extends({
57
+ widthAppearance: widthAppearance,
56
58
  isAIEnabled: isAIEnabled,
57
59
  url: url,
58
60
  testId: testId
@@ -25,7 +25,10 @@ var CustomPopupContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
25
25
  * Factory function to create a CustomPopupContainer with a specific z-index
26
26
  */
27
27
  export var createCustomPopupContainer = function createCustomPopupContainer(zIndex) {
28
- return /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
28
+ return /*#__PURE__*/React.forwardRef(
29
+ // FIXME: ...props spreads all props to the div, including isReferenceHidden, which is not a valid prop for a div.
30
+ // Find another way but adding exceptions with _, __, ___ etc.
31
+ function (_ref2, ref) {
29
32
  var children = _ref2.children,
30
33
  _ = _ref2.shouldFitContainer,
31
34
  __ = _ref2.shouldRenderToParent,
@@ -210,6 +210,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
210
210
  onMouseLeave: initHideCard,
211
211
  cardState: linkState,
212
212
  onActionClick: onActionClick,
213
+ onDismiss: hideCard,
213
214
  onResolve: update,
214
215
  renderers: renderers,
215
216
  actionOptions: actionOptions,
@@ -223,7 +224,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
223
224
  id: id,
224
225
  source: HOVER_CARD_SOURCE
225
226
  }, /*#__PURE__*/React.createElement(HoverCardContent, hoverCardContentProps));
226
- }, [initShowCard, initHideCard, linkState, onActionClick, renderers, actionOptions, url, id, hoverPreviewOptions]);
227
+ }, [initShowCard, initHideCard, linkState, onActionClick, hideCard, renderers, actionOptions, url, id, hoverPreviewOptions]);
227
228
  var handleKeyDown = useCallback(function (e) {
228
229
  if (e.key === ' ') {
229
230
  e.preventDefault();
@@ -6,7 +6,8 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
6
6
  import { AnalyticsContext, useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
7
7
  import { useSmartLinkContext } from '@atlaskit/link-provider';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
9
+ import { componentWithCondition, functionUnionWithCondition } from '@atlaskit/platform-feature-flags-react';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
11
12
  import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
12
13
  import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
@@ -24,21 +25,49 @@ import HoverCardForbiddenView from './views/forbidden';
24
25
  import HoverCardResolvedView from './views/resolved';
25
26
  import HoverCardLoadingView from './views/resolving';
26
27
  import HoverCardUnauthorisedView from './views/unauthorised';
28
+ import RovoUnauthorisedView from './views/unauthorised/RovoUnauthorisedView';
27
29
  export var hoverCardClassName = 'smart-links-hover-preview';
28
- var HoverCardContent = function HoverCardContent(_ref) {
30
+ var useIsResolvedView = function useIsResolvedView(_ref) {
31
+ var _hoverPreviewOptions$;
32
+ var cardState = _ref.cardState,
33
+ hoverPreviewOptions = _ref.hoverPreviewOptions;
34
+ return !(hoverPreviewOptions !== null && hoverPreviewOptions !== void 0 && (_hoverPreviewOptions$ = hoverPreviewOptions.render) !== null && _hoverPreviewOptions$ !== void 0 && _hoverPreviewOptions$.call(hoverPreviewOptions)) && cardState.status === 'resolved';
35
+ };
36
+ var useServices = function useServices(_ref2) {
37
+ var url = _ref2.url;
38
+ var linkState = useSmartCardState(url);
39
+ var services = getServices(linkState.details);
40
+ return services;
41
+ };
42
+ var useIsUnauthorisedView = function useIsUnauthorisedView(_ref3) {
43
+ var _hoverPreviewOptions$2;
44
+ var cardState = _ref3.cardState,
45
+ url = _ref3.url,
46
+ hoverPreviewOptions = _ref3.hoverPreviewOptions;
47
+ var services = useServices({
48
+ url: url
49
+ });
50
+ return !(hoverPreviewOptions !== null && hoverPreviewOptions !== void 0 && (_hoverPreviewOptions$2 = hoverPreviewOptions.render) !== null && _hoverPreviewOptions$2 !== void 0 && _hoverPreviewOptions$2.call(hoverPreviewOptions)) && cardState.status === 'unauthorized' && Boolean(services === null || services === void 0 ? void 0 : services.length);
51
+ };
52
+ var useIsShowPreauthBetterHovercard = function useIsShowPreauthBetterHovercard(props) {
53
+ var rovoConfig = useRovoConfig();
54
+ return Boolean(useIsUnauthorisedView(props) && (rovoConfig === null || rovoConfig === void 0 ? void 0 : rovoConfig.isRovoEnabled) && expValEquals('platform_sl_3p_preauth_better_hovercard', 'isEnabled', true));
55
+ };
56
+ var HoverCardContent = function HoverCardContent(_ref4) {
29
57
  var _linkState$status, _cardState$details;
30
- var _ref$id = _ref.id,
31
- id = _ref$id === void 0 ? '' : _ref$id,
32
- cardState = _ref.cardState,
33
- onActionClick = _ref.onActionClick,
34
- onResolve = _ref.onResolve,
35
- renderers = _ref.renderers,
36
- url = _ref.url,
37
- onMouseEnter = _ref.onMouseEnter,
38
- onMouseLeave = _ref.onMouseLeave,
39
- actionOptions = _ref.actionOptions,
40
- hoverPreviewOptions = _ref.hoverPreviewOptions,
41
- showRovoResolvedView = _ref.showRovoResolvedView;
58
+ var _ref4$id = _ref4.id,
59
+ id = _ref4$id === void 0 ? '' : _ref4$id,
60
+ cardState = _ref4.cardState,
61
+ onActionClick = _ref4.onActionClick,
62
+ onResolve = _ref4.onResolve,
63
+ renderers = _ref4.renderers,
64
+ url = _ref4.url,
65
+ onMouseEnter = _ref4.onMouseEnter,
66
+ onMouseLeave = _ref4.onMouseLeave,
67
+ onDismiss = _ref4.onDismiss,
68
+ actionOptions = _ref4.actionOptions,
69
+ hoverPreviewOptions = _ref4.hoverPreviewOptions,
70
+ showRovoResolvedView = _ref4.showRovoResolvedView;
42
71
  var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
43
72
  createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
44
73
  var _useAnalyticsEvents = useAnalyticsEvents(),
@@ -139,82 +168,186 @@ var HoverCardContent = function HoverCardContent(_ref) {
139
168
  var onClickStopPropagation = useCallback(function (e) {
140
169
  return e.stopPropagation();
141
170
  }, []);
142
- var getCardView = function getCardView(cardState) {
143
- var _hoverPreviewOptions$;
144
- var overrideView = hoverPreviewOptions === null || hoverPreviewOptions === void 0 || (_hoverPreviewOptions$ = hoverPreviewOptions.render) === null || _hoverPreviewOptions$ === void 0 ? void 0 : _hoverPreviewOptions$.call(hoverPreviewOptions);
145
- if (overrideView) {
146
- return overrideView;
147
- }
148
- if (cardState.status === 'errored' && fg('navx-2478-sl-fix-hover-card-unresolved-view')) {
171
+ var useIsResolvedViewGated = functionUnionWithCondition(function () {
172
+ return fg('platform_sl_3p_preauth_better_hovercard_killswitch');
173
+ }, useIsResolvedView, function () {
174
+ return undefined;
175
+ });
176
+ var useIsUnauthorisedViewGated = functionUnionWithCondition(function () {
177
+ return fg('platform_sl_3p_preauth_better_hovercard_killswitch');
178
+ }, useIsUnauthorisedView, function () {
179
+ return undefined;
180
+ });
181
+ var useIsShowPreauthBetterHovercardGated = functionUnionWithCondition(function () {
182
+ return fg('platform_sl_3p_preauth_better_hovercard_killswitch');
183
+ }, useIsShowPreauthBetterHovercard, function () {
184
+ return undefined;
185
+ });
186
+ var isResolved = useIsResolvedViewGated({
187
+ cardState: cardState,
188
+ hoverPreviewOptions: hoverPreviewOptions
189
+ });
190
+ var isUnauthorised = useIsUnauthorisedViewGated({
191
+ cardState: cardState,
192
+ url: url,
193
+ hoverPreviewOptions: hoverPreviewOptions
194
+ });
195
+ var showPreauthBetterHovercard = useIsShowPreauthBetterHovercardGated({
196
+ cardState: cardState,
197
+ url: url,
198
+ hoverPreviewOptions: hoverPreviewOptions
199
+ });
200
+ if (fg('platform_sl_3p_preauth_better_hovercard_killswitch')) {
201
+ var cardView = function (_hoverPreviewOptions$3) {
202
+ var overrideView = hoverPreviewOptions === null || hoverPreviewOptions === void 0 || (_hoverPreviewOptions$3 = hoverPreviewOptions.render) === null || _hoverPreviewOptions$3 === void 0 ? void 0 : _hoverPreviewOptions$3.call(hoverPreviewOptions);
203
+ if (overrideView) {
204
+ return overrideView;
205
+ }
206
+ if (cardState.status === 'errored' && fg('navx-2478-sl-fix-hover-card-unresolved-view')) {
207
+ return null;
208
+ }
209
+ if (fg('navx-2478-sl-fix-hover-card-unresolved-view') ? cardState.status === 'resolving' || cardState.metadataStatus === 'pending' : cardState.metadataStatus === 'pending') {
210
+ return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
211
+ flexibleCardProps: flexibleCardProps,
212
+ titleBlockProps: titleBlockProps
213
+ });
214
+ }
215
+ if (isUnauthorised) {
216
+ if (showPreauthBetterHovercard) {
217
+ return /*#__PURE__*/React.createElement(RovoUnauthorisedView, {
218
+ extensionKey: extensionKey,
219
+ id: id,
220
+ flexibleCardProps: flexibleCardProps,
221
+ onDismiss: onDismiss,
222
+ url: url
223
+ });
224
+ }
225
+ return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
226
+ extensionKey: extensionKey,
227
+ id: id,
228
+ flexibleCardProps: flexibleCardProps,
229
+ url: url
230
+ });
231
+ }
232
+ if (cardState.status === 'forbidden' || cardState.status === 'not_found') {
233
+ return /*#__PURE__*/React.createElement(HoverCardForbiddenView, {
234
+ flexibleCardProps: flexibleCardProps
235
+ });
236
+ }
237
+ if (isResolved) {
238
+ return /*#__PURE__*/React.createElement(HoverCardResolvedView, _extends({}, fg('platform_sl_3p_auth_rovo_action_kill_switch') ? {
239
+ actionOptions: actionOptions,
240
+ showRovoResolvedView: showRovoResolvedView
241
+ } : undefined, {
242
+ cardState: cardState,
243
+ extensionKey: extensionKey,
244
+ flexibleCardProps: flexibleCardProps,
245
+ isAISummaryEnabled: isAISummaryEnabled,
246
+ onActionClick: onActionClick,
247
+ titleBlockProps: titleBlockProps,
248
+ url: url
249
+ }));
250
+ }
149
251
  return null;
150
- }
151
- if (fg('navx-2478-sl-fix-hover-card-unresolved-view') ? cardState.status === 'resolving' || cardState.metadataStatus === 'pending' : cardState.metadataStatus === 'pending') {
152
- return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
153
- flexibleCardProps: flexibleCardProps,
154
- titleBlockProps: titleBlockProps
155
- });
156
- }
157
- if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
158
- return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
159
- extensionKey: extensionKey,
160
- id: id,
161
- flexibleCardProps: flexibleCardProps,
162
- url: url
163
- });
164
- }
165
- if (cardState.status === 'forbidden' || cardState.status === 'not_found') {
166
- return /*#__PURE__*/React.createElement(HoverCardForbiddenView, {
167
- flexibleCardProps: flexibleCardProps
168
- });
169
- }
170
- if (cardState.status === 'resolved') {
171
- return /*#__PURE__*/React.createElement(HoverCardResolvedView, _extends({}, fg('platform_sl_3p_auth_rovo_action_kill_switch') ? {
172
- actionOptions: actionOptions,
173
- showRovoResolvedView: showRovoResolvedView
174
- } : undefined, {
175
- cardState: cardState,
176
- extensionKey: extensionKey,
177
- flexibleCardProps: flexibleCardProps,
178
- isAISummaryEnabled: isAISummaryEnabled,
179
- onActionClick: onActionClick,
180
- titleBlockProps: titleBlockProps,
181
- url: url
182
- }));
183
- }
184
- return null;
185
- };
186
- var cardView = getCardView(cardState);
187
- return cardView ? /*#__PURE__*/React.createElement(ContentContainer, {
188
- onMouseEnter: onMouseEnter,
189
- onMouseLeave: onMouseLeave,
190
- onClick: onClickStopPropagation,
191
- isAIEnabled: isAISummaryEnabled,
192
- url: url
193
- }, cardView) : null;
252
+ }();
253
+ return cardView ? /*#__PURE__*/React.createElement(ContentContainer, {
254
+ onMouseEnter: onMouseEnter,
255
+ onMouseLeave: onMouseLeave,
256
+ onClick: onClickStopPropagation,
257
+ widthAppearance: showPreauthBetterHovercard ? 'slim' : undefined,
258
+ isAIEnabled: isAISummaryEnabled,
259
+ url: url
260
+ }, cardView) : null;
261
+ } else {
262
+ var getCardView = function getCardView(cardState) {
263
+ var _hoverPreviewOptions$4;
264
+ var overrideView = hoverPreviewOptions === null || hoverPreviewOptions === void 0 || (_hoverPreviewOptions$4 = hoverPreviewOptions.render) === null || _hoverPreviewOptions$4 === void 0 ? void 0 : _hoverPreviewOptions$4.call(hoverPreviewOptions);
265
+ if (overrideView) {
266
+ return overrideView;
267
+ }
268
+ if (cardState.status === 'errored' && fg('navx-2478-sl-fix-hover-card-unresolved-view')) {
269
+ return null;
270
+ }
271
+ if (fg('navx-2478-sl-fix-hover-card-unresolved-view') ? cardState.status === 'resolving' || cardState.metadataStatus === 'pending' : cardState.metadataStatus === 'pending') {
272
+ return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
273
+ flexibleCardProps: flexibleCardProps,
274
+ titleBlockProps: titleBlockProps
275
+ });
276
+ }
277
+ if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
278
+ return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
279
+ extensionKey: extensionKey,
280
+ id: id,
281
+ flexibleCardProps: flexibleCardProps,
282
+ url: url
283
+ });
284
+ }
285
+ if (cardState.status === 'forbidden' || cardState.status === 'not_found') {
286
+ return /*#__PURE__*/React.createElement(HoverCardForbiddenView, {
287
+ flexibleCardProps: flexibleCardProps
288
+ });
289
+ }
290
+ if (cardState.status === 'resolved') {
291
+ return /*#__PURE__*/React.createElement(HoverCardResolvedView, _extends({}, fg('platform_sl_3p_auth_rovo_action_kill_switch') ? {
292
+ actionOptions: actionOptions,
293
+ showRovoResolvedView: showRovoResolvedView
294
+ } : undefined, {
295
+ cardState: cardState,
296
+ extensionKey: extensionKey,
297
+ flexibleCardProps: flexibleCardProps,
298
+ isAISummaryEnabled: isAISummaryEnabled,
299
+ onActionClick: onActionClick,
300
+ titleBlockProps: titleBlockProps,
301
+ url: url
302
+ }));
303
+ }
304
+ return null;
305
+ };
306
+ var _cardView = getCardView(cardState);
307
+ return _cardView ? /*#__PURE__*/React.createElement(ContentContainer, {
308
+ onMouseEnter: onMouseEnter,
309
+ onMouseLeave: onMouseLeave,
310
+ onClick: onClickStopPropagation,
311
+ isAIEnabled: isAISummaryEnabled,
312
+ url: url
313
+ }, _cardView) : null;
314
+ }
194
315
  };
195
316
  var HoverCardContentWithViewVariant = function HoverCardContentWithViewVariant(props) {
196
- var _props$cardState2, _props$cardState3;
317
+ var cardState = props.cardState,
318
+ actionOptions = props.actionOptions;
197
319
  var rovoConfig = useRovoConfig();
320
+ var isResolved = useIsResolvedView(props);
321
+ var showPreauthBetterHovercard = useIsShowPreauthBetterHovercard(props);
198
322
  var showRovoResolvedView = useMemo(function () {
199
- var _props$cardState;
200
- return (props === null || props === void 0 || (_props$cardState = props.cardState) === null || _props$cardState === void 0 ? void 0 : _props$cardState.status) === 'resolved' && (props === null || props === void 0 ? void 0 : props.cardState.details) && extractRovoChatAction({
201
- response: props === null || props === void 0 ? void 0 : props.cardState.details,
323
+ return isResolved && cardState.details && extractRovoChatAction({
324
+ response: cardState.details,
202
325
  rovoConfig: rovoConfig,
203
- actionOptions: props === null || props === void 0 ? void 0 : props.actionOptions
326
+ actionOptions: actionOptions
204
327
  }) !== undefined;
205
- }, [props === null || props === void 0 ? void 0 : props.actionOptions, props === null || props === void 0 || (_props$cardState2 = props.cardState) === null || _props$cardState2 === void 0 ? void 0 : _props$cardState2.details, props === null || props === void 0 || (_props$cardState3 = props.cardState) === null || _props$cardState3 === void 0 ? void 0 : _props$cardState3.status, rovoConfig]);
328
+ }, [actionOptions, cardState.details, rovoConfig, isResolved]);
206
329
  var data = useMemo(function () {
207
- var viewVariant = showRovoResolvedView && expValEqualsNoExposure('platform_sl_3p_auth_rovo_action', 'isEnabled', true) ? 'rovo-resolved-view' : 'default';
330
+ var viewVariant = 'default';
331
+ if (showRovoResolvedView && expValEqualsNoExposure('platform_sl_3p_auth_rovo_action', 'isEnabled', true)) {
332
+ viewVariant = 'rovo-resolved-view';
333
+ } else if (showPreauthBetterHovercard) {
334
+ viewVariant = 'rovo-unauthorised-view';
335
+ }
208
336
  return {
209
337
  attributes: {
210
338
  viewVariant: viewVariant
211
339
  }
212
340
  };
213
- }, [showRovoResolvedView]);
341
+ }, [showRovoResolvedView, showPreauthBetterHovercard]);
214
342
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
215
343
  data: data
216
344
  }, /*#__PURE__*/React.createElement(HoverCardContent, _extends({}, props, {
217
345
  showRovoResolvedView: showRovoResolvedView
218
346
  })));
219
347
  };
220
- export default componentWithFG('platform_sl_3p_auth_rovo_action_kill_switch', HoverCardContentWithViewVariant, HoverCardContent);
348
+ export default componentWithCondition(function () {
349
+ // We need to read both of them to sutisfy some of the tests that expect both to be checked.
350
+ var flagA = fg('platform_sl_3p_preauth_better_hovercard_killswitch');
351
+ var flagB = fg('platform_sl_3p_auth_rovo_action_kill_switch');
352
+ return flagA || flagB;
353
+ }, HoverCardContentWithViewVariant, HoverCardContent);