@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,135 @@
1
+ /* RovoUnauthorisedView.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.default = void 0;
10
+ require("./RovoUnauthorisedView.compiled.css");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var React = _react;
13
+ var _runtime = require("@compiled/react/runtime");
14
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
+ var _reactIntlNext = require("react-intl-next");
16
+ var _new = _interopRequireDefault(require("@atlaskit/button/new"));
17
+ var _icon = require("@atlaskit/icon");
18
+ var _aiSparkle = _interopRequireDefault(require("@atlaskit/icon/core/ai-sparkle"));
19
+ var _appSwitcher = _interopRequireDefault(require("@atlaskit/icon/core/app-switcher"));
20
+ var _globe = _interopRequireDefault(require("@atlaskit/icon/core/globe"));
21
+ var _search = _interopRequireDefault(require("@atlaskit/icon/core/search"));
22
+ var _linkExtractors = require("@atlaskit/link-extractors");
23
+ var _compiled = require("@atlaskit/primitives/compiled");
24
+ var _useAnalyticsEvents2 = require("../../../../../common/analytics/generated/use-analytics-events");
25
+ var _constants = require("../../../../../constants");
26
+ var _messages = require("../../../../../messages");
27
+ var _actions = require("../../../../../state/actions");
28
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
29
+ var ROVO_FEATURES = [{
30
+ icon: _globe.default,
31
+ appearance: 'blue',
32
+ titleMessage: _messages.messages.rovo_unauthorised_feature_document_summaries_title,
33
+ descMessage: _messages.messages.rovo_unauthorised_feature_document_summaries_desc,
34
+ testIdSuffix: 'document-summaries'
35
+ }, {
36
+ icon: _search.default,
37
+ appearance: 'purple',
38
+ titleMessage: _messages.messages.rovo_unauthorised_feature_related_content_title,
39
+ descMessage: _messages.messages.rovo_unauthorised_feature_related_content_desc,
40
+ testIdSuffix: 'related-content'
41
+ }, {
42
+ icon: _aiSparkle.default,
43
+ appearance: 'orange',
44
+ titleMessage: _messages.messages.rovo_unauthorised_feature_smart_suggestions_title,
45
+ descMessage: _messages.messages.rovo_unauthorised_feature_smart_suggestions_desc,
46
+ testIdSuffix: 'smart-suggestions'
47
+ }, {
48
+ icon: _appSwitcher.default,
49
+ appearance: 'teal',
50
+ titleMessage: _messages.messages.rovo_unauthorised_feature_cross_reference_title,
51
+ descMessage: _messages.messages.rovo_unauthorised_feature_cross_reference_desc,
52
+ testIdSuffix: 'cross-reference'
53
+ }];
54
+ var layoutStyles = {
55
+ header: "_bfhkomb0 _syaz15cr _ca0qutpp _u5f3pxbi _n3tdutpp _19bvpxbi _13li1mok _qrwq1mok",
56
+ body: "_ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi",
57
+ footer: "_19pkpxbi _ca0qutpp",
58
+ footerActions: "_zulputpp _1e0c1txw _4cvr1h6o _1bahesu3 _1n261g80"
59
+ };
60
+ var RovoUnauthorisedView = function RovoUnauthorisedView(_ref) {
61
+ var _ref$id = _ref.id,
62
+ id = _ref$id === void 0 ? '' : _ref$id,
63
+ flexibleCardProps = _ref.flexibleCardProps,
64
+ onDismiss = _ref.onDismiss,
65
+ _ref$testId = _ref.testId,
66
+ testId = _ref$testId === void 0 ? 'hover-card-rovo-unauthorised-view' : _ref$testId,
67
+ url = _ref.url;
68
+ var providerName = (0, _react.useMemo)(function () {
69
+ var _extractSmartLinkProv;
70
+ return (_extractSmartLinkProv = (0, _linkExtractors.extractSmartLinkProvider)(flexibleCardProps.cardState.details)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text;
71
+ }, [flexibleCardProps.cardState.details]);
72
+ var _useSmartCardActions = (0, _actions.useSmartCardActions)(id, url),
73
+ authorize = _useSmartCardActions.authorize;
74
+ var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
75
+ fireEvent = _useAnalyticsEvents.fireEvent;
76
+ var handleAuthorize = (0, _react.useCallback)(function () {
77
+ if (authorize) {
78
+ fireEvent('track.applicationAccount.authStarted', {});
79
+ authorize(_constants.CardDisplay.HoverCardPreview);
80
+ }
81
+ }, [authorize, fireEvent]);
82
+ return /*#__PURE__*/React.createElement(_compiled.Box, {
83
+ testId: testId
84
+ }, /*#__PURE__*/React.createElement(_compiled.Box, {
85
+ xcss: layoutStyles.header
86
+ }, /*#__PURE__*/React.createElement(_compiled.Text, {
87
+ weight: "bold",
88
+ size: "medium",
89
+ color: "color.text.inverse"
90
+ }, providerName ? /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.messages.rovo_unauthorised_title, {
91
+ values: {
92
+ context: providerName
93
+ }
94
+ })) : /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, _messages.messages.rovo_unauthorised_title_no_provider))), /*#__PURE__*/React.createElement(_compiled.Box, {
95
+ xcss: layoutStyles.body
96
+ }, /*#__PURE__*/React.createElement(_compiled.Stack, {
97
+ space: "space.050"
98
+ }, /*#__PURE__*/React.createElement(_compiled.Stack, {
99
+ space: "space.200"
100
+ }, ROVO_FEATURES.map(function (feature) {
101
+ return /*#__PURE__*/React.createElement(_compiled.Inline, {
102
+ key: feature.testIdSuffix,
103
+ space: "space.100",
104
+ alignBlock: "center",
105
+ testId: "".concat(testId, "-feature-row-").concat(feature.testIdSuffix)
106
+ }, /*#__PURE__*/React.createElement(_icon.IconTile, {
107
+ icon: feature.icon,
108
+ label: '',
109
+ appearance: feature.appearance,
110
+ size: "medium",
111
+ testId: "".concat(testId, "-feature-").concat(feature.testIdSuffix)
112
+ }), /*#__PURE__*/React.createElement(_compiled.Stack, {
113
+ space: "space.025"
114
+ }, /*#__PURE__*/React.createElement(_compiled.Text, {
115
+ size: "small",
116
+ weight: "bold"
117
+ }, /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, feature.titleMessage)), /*#__PURE__*/React.createElement(_compiled.Text, {
118
+ size: "small",
119
+ color: "color.text.subtlest"
120
+ }, /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, feature.descMessage))));
121
+ })), /*#__PURE__*/React.createElement(_compiled.Box, {
122
+ xcss: layoutStyles.footer
123
+ }, /*#__PURE__*/React.createElement(_compiled.Box, {
124
+ xcss: layoutStyles.footerActions
125
+ }, /*#__PURE__*/React.createElement(_new.default, {
126
+ appearance: "subtle",
127
+ onClick: onDismiss,
128
+ testId: "".concat(testId, "-not-now")
129
+ }, /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, _messages.messages.rovo_unauthorised_not_now)), /*#__PURE__*/React.createElement(_new.default, {
130
+ appearance: "primary",
131
+ onClick: handleAuthorize,
132
+ testId: "".concat(testId, "-connect-account")
133
+ }, /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, _messages.messages.rovo_unauthorised_connect_account)))))));
134
+ };
135
+ var _default = exports.default = RovoUnauthorisedView;
@@ -22,7 +22,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
22
22
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
23
23
  var PACKAGE_DATA = {
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "43.30.0",
25
+ packageVersion: "43.30.1",
26
26
  componentName: 'linkUrl'
27
27
  };
28
28
  var Anchor = (0, _click.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 const 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',
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
2
2
  export const context = {
3
3
  componentName: 'smart-cards',
4
4
  packageName: "@atlaskit/smart-card",
5
- packageVersion: "43.30.0"
5
+ packageVersion: "43.30.1"
6
6
  };
7
7
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
8
8
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -3,6 +3,7 @@
3
3
  ._189eidpf{border-width:0}
4
4
  ._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
5
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}
@@ -8,11 +8,14 @@ import { di } from 'react-magnetic-di';
8
8
  import useAISummaryAction from '../../../state/hooks/use-ai-summary-action';
9
9
  import AIPrism from '../../common/ai-prism';
10
10
  import { hoverCardClassName } from './HoverCardContent';
11
- const NEW_CARD_WIDTH_REM = 25;
12
11
  const HoverCardContainerStyle = null;
12
+ const hoverCardShellWidthDefault = null;
13
+ const hoverCardShellWidthSlim = null;
14
+ const hoverCardShellHideLoadingPlaceholder = null;
13
15
  const popupContainerStyles = null;
14
16
  const ConnectedAIPrismContainer = ({
15
17
  children,
18
+ widthAppearance,
16
19
  isAIEnabled = false,
17
20
  testId,
18
21
  url,
@@ -27,9 +30,10 @@ const ConnectedAIPrismContainer = ({
27
30
  useEffect(() => {
28
31
  setShowPrism(status === 'loading');
29
32
  }, [status]);
33
+ const resolvedWidthAppearance = widthAppearance !== null && widthAppearance !== void 0 ? widthAppearance : 'default';
30
34
  const container = /*#__PURE__*/React.createElement("div", _extends({
31
35
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
32
- className: ax(["_11q7glyw _189eidpf _vchhusvi _1bsb1f23 _9spsglyw", !isAIEnabled && "_2rko1mok _bfhk1bhr _16qs130s", hoverCardClassName]),
36
+ className: ax(["_11q7glyw _189eidpf _vchhusvi", resolvedWidthAppearance === 'slim' ? "_1bsbiolt" : "_1bsb1f23", "_9spsglyw", !isAIEnabled && "_2rko1mok _bfhk1bhr _16qs130s", hoverCardClassName]),
33
37
  "data-testid": testId
34
38
  }, props), children);
35
39
  return isAIEnabled ? /*#__PURE__*/React.createElement(AIPrism, {
@@ -39,11 +43,13 @@ const ConnectedAIPrismContainer = ({
39
43
  };
40
44
  const ContentContainer = ({
41
45
  children,
46
+ widthAppearance,
42
47
  isAIEnabled = false,
43
48
  testId,
44
49
  url,
45
50
  ...props
46
51
  }) => /*#__PURE__*/React.createElement(ConnectedAIPrismContainer, _extends({
52
+ widthAppearance: widthAppearance,
47
53
  isAIEnabled: isAIEnabled,
48
54
  url: url,
49
55
  testId: testId
@@ -18,7 +18,10 @@ const CustomPopupContainer = /*#__PURE__*/React.forwardRef(({
18
18
  * Factory function to create a CustomPopupContainer with a specific z-index
19
19
  */
20
20
  export const createCustomPopupContainer = zIndex => {
21
- return /*#__PURE__*/React.forwardRef(({
21
+ return /*#__PURE__*/React.forwardRef(
22
+ // FIXME: ...props spreads all props to the div, including isReferenceHidden, which is not a valid prop for a div.
23
+ // Find another way but adding exceptions with _, __, ___ etc.
24
+ ({
22
25
  children,
23
26
  shouldFitContainer: _,
24
27
  shouldRenderToParent: __,
@@ -193,6 +193,7 @@ export const HoverCardComponent = ({
193
193
  onMouseLeave: initHideCard,
194
194
  cardState: linkState,
195
195
  onActionClick,
196
+ onDismiss: hideCard,
196
197
  onResolve: update,
197
198
  renderers,
198
199
  actionOptions,
@@ -206,7 +207,7 @@ export const HoverCardComponent = ({
206
207
  id: id,
207
208
  source: HOVER_CARD_SOURCE
208
209
  }, /*#__PURE__*/React.createElement(HoverCardContent, hoverCardContentProps));
209
- }, [initShowCard, initHideCard, linkState, onActionClick, renderers, actionOptions, url, id, hoverPreviewOptions]);
210
+ }, [initShowCard, initHideCard, linkState, onActionClick, hideCard, renderers, actionOptions, url, id, hoverPreviewOptions]);
210
211
  const handleKeyDown = useCallback(e => {
211
212
  if (e.key === ' ') {
212
213
  e.preventDefault();
@@ -3,7 +3,8 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { AnalyticsContext, useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
4
4
  import { useSmartLinkContext } from '@atlaskit/link-provider';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
- import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
6
+ import { componentWithCondition, functionUnionWithCondition } from '@atlaskit/platform-feature-flags-react';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
8
9
  import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
9
10
  import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
@@ -21,7 +22,37 @@ import HoverCardForbiddenView from './views/forbidden';
21
22
  import HoverCardResolvedView from './views/resolved';
22
23
  import HoverCardLoadingView from './views/resolving';
23
24
  import HoverCardUnauthorisedView from './views/unauthorised';
25
+ import RovoUnauthorisedView from './views/unauthorised/RovoUnauthorisedView';
24
26
  export const hoverCardClassName = 'smart-links-hover-preview';
27
+ const useIsResolvedView = ({
28
+ cardState,
29
+ hoverPreviewOptions
30
+ }) => {
31
+ var _hoverPreviewOptions$;
32
+ return !(hoverPreviewOptions !== null && hoverPreviewOptions !== void 0 && (_hoverPreviewOptions$ = hoverPreviewOptions.render) !== null && _hoverPreviewOptions$ !== void 0 && _hoverPreviewOptions$.call(hoverPreviewOptions)) && cardState.status === 'resolved';
33
+ };
34
+ const useServices = ({
35
+ url
36
+ }) => {
37
+ const linkState = useSmartCardState(url);
38
+ const services = getServices(linkState.details);
39
+ return services;
40
+ };
41
+ const useIsUnauthorisedView = ({
42
+ cardState,
43
+ url,
44
+ hoverPreviewOptions
45
+ }) => {
46
+ var _hoverPreviewOptions$2;
47
+ const services = useServices({
48
+ 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
+ const useIsShowPreauthBetterHovercard = props => {
53
+ const 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
+ };
25
56
  const HoverCardContent = ({
26
57
  id = '',
27
58
  cardState,
@@ -31,6 +62,7 @@ const HoverCardContent = ({
31
62
  url,
32
63
  onMouseEnter,
33
64
  onMouseLeave,
65
+ onDismiss,
34
66
  actionOptions,
35
67
  hoverPreviewOptions,
36
68
  showRovoResolvedView
@@ -135,82 +167,174 @@ const HoverCardContent = ({
135
167
  children: null
136
168
  };
137
169
  const onClickStopPropagation = useCallback(e => e.stopPropagation(), []);
138
- const getCardView = cardState => {
139
- var _hoverPreviewOptions$;
140
- const overrideView = hoverPreviewOptions === null || hoverPreviewOptions === void 0 ? void 0 : (_hoverPreviewOptions$ = hoverPreviewOptions.render) === null || _hoverPreviewOptions$ === void 0 ? void 0 : _hoverPreviewOptions$.call(hoverPreviewOptions);
141
- if (overrideView) {
142
- return overrideView;
143
- }
144
- if (cardState.status === 'errored' && fg('navx-2478-sl-fix-hover-card-unresolved-view')) {
170
+ const useIsResolvedViewGated = functionUnionWithCondition(() => fg('platform_sl_3p_preauth_better_hovercard_killswitch'), useIsResolvedView, () => undefined);
171
+ const useIsUnauthorisedViewGated = functionUnionWithCondition(() => fg('platform_sl_3p_preauth_better_hovercard_killswitch'), useIsUnauthorisedView, () => undefined);
172
+ const useIsShowPreauthBetterHovercardGated = functionUnionWithCondition(() => fg('platform_sl_3p_preauth_better_hovercard_killswitch'), useIsShowPreauthBetterHovercard, () => undefined);
173
+ const isResolved = useIsResolvedViewGated({
174
+ cardState,
175
+ hoverPreviewOptions
176
+ });
177
+ const isUnauthorised = useIsUnauthorisedViewGated({
178
+ cardState,
179
+ url,
180
+ hoverPreviewOptions
181
+ });
182
+ const showPreauthBetterHovercard = useIsShowPreauthBetterHovercardGated({
183
+ cardState,
184
+ url,
185
+ hoverPreviewOptions
186
+ });
187
+ if (fg('platform_sl_3p_preauth_better_hovercard_killswitch')) {
188
+ const cardView = (_hoverPreviewOptions$3 => {
189
+ const overrideView = hoverPreviewOptions === null || hoverPreviewOptions === void 0 ? void 0 : (_hoverPreviewOptions$3 = hoverPreviewOptions.render) === null || _hoverPreviewOptions$3 === void 0 ? void 0 : _hoverPreviewOptions$3.call(hoverPreviewOptions);
190
+ if (overrideView) {
191
+ return overrideView;
192
+ }
193
+ if (cardState.status === 'errored' && fg('navx-2478-sl-fix-hover-card-unresolved-view')) {
194
+ return null;
195
+ }
196
+ if (fg('navx-2478-sl-fix-hover-card-unresolved-view') ? cardState.status === 'resolving' || cardState.metadataStatus === 'pending' : cardState.metadataStatus === 'pending') {
197
+ return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
198
+ flexibleCardProps: flexibleCardProps,
199
+ titleBlockProps: titleBlockProps
200
+ });
201
+ }
202
+ if (isUnauthorised) {
203
+ if (showPreauthBetterHovercard) {
204
+ return /*#__PURE__*/React.createElement(RovoUnauthorisedView, {
205
+ extensionKey: extensionKey,
206
+ id: id,
207
+ flexibleCardProps: flexibleCardProps,
208
+ onDismiss: onDismiss,
209
+ url: url
210
+ });
211
+ }
212
+ return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
213
+ extensionKey: extensionKey,
214
+ id: id,
215
+ flexibleCardProps: flexibleCardProps,
216
+ url: url
217
+ });
218
+ }
219
+ if (cardState.status === 'forbidden' || cardState.status === 'not_found') {
220
+ return /*#__PURE__*/React.createElement(HoverCardForbiddenView, {
221
+ flexibleCardProps: flexibleCardProps
222
+ });
223
+ }
224
+ if (isResolved) {
225
+ return /*#__PURE__*/React.createElement(HoverCardResolvedView, _extends({}, fg('platform_sl_3p_auth_rovo_action_kill_switch') ? {
226
+ actionOptions,
227
+ showRovoResolvedView
228
+ } : undefined, {
229
+ cardState: cardState,
230
+ extensionKey: extensionKey,
231
+ flexibleCardProps: flexibleCardProps,
232
+ isAISummaryEnabled: isAISummaryEnabled,
233
+ onActionClick: onActionClick,
234
+ titleBlockProps: titleBlockProps,
235
+ url: url
236
+ }));
237
+ }
145
238
  return null;
146
- }
147
- if (fg('navx-2478-sl-fix-hover-card-unresolved-view') ? cardState.status === 'resolving' || cardState.metadataStatus === 'pending' : cardState.metadataStatus === 'pending') {
148
- return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
149
- flexibleCardProps: flexibleCardProps,
150
- titleBlockProps: titleBlockProps
151
- });
152
- }
153
- if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
154
- return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
155
- extensionKey: extensionKey,
156
- id: id,
157
- flexibleCardProps: flexibleCardProps,
158
- url: url
159
- });
160
- }
161
- if (cardState.status === 'forbidden' || cardState.status === 'not_found') {
162
- return /*#__PURE__*/React.createElement(HoverCardForbiddenView, {
163
- flexibleCardProps: flexibleCardProps
164
- });
165
- }
166
- if (cardState.status === 'resolved') {
167
- return /*#__PURE__*/React.createElement(HoverCardResolvedView, _extends({}, fg('platform_sl_3p_auth_rovo_action_kill_switch') ? {
168
- actionOptions,
169
- showRovoResolvedView
170
- } : undefined, {
171
- cardState: cardState,
172
- extensionKey: extensionKey,
173
- flexibleCardProps: flexibleCardProps,
174
- isAISummaryEnabled: isAISummaryEnabled,
175
- onActionClick: onActionClick,
176
- titleBlockProps: titleBlockProps,
177
- url: url
178
- }));
179
- }
180
- return null;
181
- };
182
- const cardView = getCardView(cardState);
183
- return cardView ? /*#__PURE__*/React.createElement(ContentContainer, {
184
- onMouseEnter: onMouseEnter,
185
- onMouseLeave: onMouseLeave,
186
- onClick: onClickStopPropagation,
187
- isAIEnabled: isAISummaryEnabled,
188
- url: url
189
- }, cardView) : null;
239
+ })();
240
+ return cardView ? /*#__PURE__*/React.createElement(ContentContainer, {
241
+ onMouseEnter: onMouseEnter,
242
+ onMouseLeave: onMouseLeave,
243
+ onClick: onClickStopPropagation,
244
+ widthAppearance: showPreauthBetterHovercard ? 'slim' : undefined,
245
+ isAIEnabled: isAISummaryEnabled,
246
+ url: url
247
+ }, cardView) : null;
248
+ } else {
249
+ const getCardView = cardState => {
250
+ var _hoverPreviewOptions$4;
251
+ const overrideView = hoverPreviewOptions === null || hoverPreviewOptions === void 0 ? void 0 : (_hoverPreviewOptions$4 = hoverPreviewOptions.render) === null || _hoverPreviewOptions$4 === void 0 ? void 0 : _hoverPreviewOptions$4.call(hoverPreviewOptions);
252
+ if (overrideView) {
253
+ return overrideView;
254
+ }
255
+ if (cardState.status === 'errored' && fg('navx-2478-sl-fix-hover-card-unresolved-view')) {
256
+ return null;
257
+ }
258
+ if (fg('navx-2478-sl-fix-hover-card-unresolved-view') ? cardState.status === 'resolving' || cardState.metadataStatus === 'pending' : cardState.metadataStatus === 'pending') {
259
+ return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
260
+ flexibleCardProps: flexibleCardProps,
261
+ titleBlockProps: titleBlockProps
262
+ });
263
+ }
264
+ if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
265
+ return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
266
+ extensionKey: extensionKey,
267
+ id: id,
268
+ flexibleCardProps: flexibleCardProps,
269
+ url: url
270
+ });
271
+ }
272
+ if (cardState.status === 'forbidden' || cardState.status === 'not_found') {
273
+ return /*#__PURE__*/React.createElement(HoverCardForbiddenView, {
274
+ flexibleCardProps: flexibleCardProps
275
+ });
276
+ }
277
+ if (cardState.status === 'resolved') {
278
+ return /*#__PURE__*/React.createElement(HoverCardResolvedView, _extends({}, fg('platform_sl_3p_auth_rovo_action_kill_switch') ? {
279
+ actionOptions,
280
+ showRovoResolvedView
281
+ } : undefined, {
282
+ cardState: cardState,
283
+ extensionKey: extensionKey,
284
+ flexibleCardProps: flexibleCardProps,
285
+ isAISummaryEnabled: isAISummaryEnabled,
286
+ onActionClick: onActionClick,
287
+ titleBlockProps: titleBlockProps,
288
+ url: url
289
+ }));
290
+ }
291
+ return null;
292
+ };
293
+ const cardView = getCardView(cardState);
294
+ return cardView ? /*#__PURE__*/React.createElement(ContentContainer, {
295
+ onMouseEnter: onMouseEnter,
296
+ onMouseLeave: onMouseLeave,
297
+ onClick: onClickStopPropagation,
298
+ isAIEnabled: isAISummaryEnabled,
299
+ url: url
300
+ }, cardView) : null;
301
+ }
190
302
  };
191
303
  const HoverCardContentWithViewVariant = props => {
192
- var _props$cardState2, _props$cardState3;
304
+ const {
305
+ cardState,
306
+ actionOptions
307
+ } = props;
193
308
  const rovoConfig = useRovoConfig();
194
- const showRovoResolvedView = useMemo(() => {
195
- var _props$cardState;
196
- return (props === null || props === void 0 ? 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({
197
- response: props === null || props === void 0 ? void 0 : props.cardState.details,
198
- rovoConfig,
199
- actionOptions: props === null || props === void 0 ? void 0 : props.actionOptions
200
- }) !== undefined;
201
- }, [props === null || props === void 0 ? void 0 : props.actionOptions, props === null || props === void 0 ? void 0 : (_props$cardState2 = props.cardState) === null || _props$cardState2 === void 0 ? void 0 : _props$cardState2.details, props === null || props === void 0 ? void 0 : (_props$cardState3 = props.cardState) === null || _props$cardState3 === void 0 ? void 0 : _props$cardState3.status, rovoConfig]);
309
+ const isResolved = useIsResolvedView(props);
310
+ const showPreauthBetterHovercard = useIsShowPreauthBetterHovercard(props);
311
+ const showRovoResolvedView = useMemo(() => isResolved && cardState.details && extractRovoChatAction({
312
+ response: cardState.details,
313
+ rovoConfig,
314
+ actionOptions
315
+ }) !== undefined, [actionOptions, cardState.details, rovoConfig, isResolved]);
202
316
  const data = useMemo(() => {
203
- const viewVariant = showRovoResolvedView && expValEqualsNoExposure('platform_sl_3p_auth_rovo_action', 'isEnabled', true) ? 'rovo-resolved-view' : 'default';
317
+ let viewVariant = 'default';
318
+ if (showRovoResolvedView && expValEqualsNoExposure('platform_sl_3p_auth_rovo_action', 'isEnabled', true)) {
319
+ viewVariant = 'rovo-resolved-view';
320
+ } else if (showPreauthBetterHovercard) {
321
+ viewVariant = 'rovo-unauthorised-view';
322
+ }
204
323
  return {
205
324
  attributes: {
206
325
  viewVariant
207
326
  }
208
327
  };
209
- }, [showRovoResolvedView]);
328
+ }, [showRovoResolvedView, showPreauthBetterHovercard]);
210
329
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
211
330
  data: data
212
331
  }, /*#__PURE__*/React.createElement(HoverCardContent, _extends({}, props, {
213
332
  showRovoResolvedView: showRovoResolvedView
214
333
  })));
215
334
  };
216
- export default componentWithFG('platform_sl_3p_auth_rovo_action_kill_switch', HoverCardContentWithViewVariant, HoverCardContent);
335
+ export default componentWithCondition(() => {
336
+ // We need to read both of them to sutisfy some of the tests that expect both to be checked.
337
+ const flagA = fg('platform_sl_3p_preauth_better_hovercard_killswitch');
338
+ const flagB = fg('platform_sl_3p_auth_rovo_action_kill_switch');
339
+ return flagA || flagB;
340
+ }, HoverCardContentWithViewVariant, HoverCardContent);
@@ -0,0 +1,16 @@
1
+
2
+ ._zulputpp{gap:var(--ds-space-150,9pt)}._13li1mok{border-top-left-radius:var(--ds-radius-large,8px)}
3
+ ._19bvpxbi{padding-left:var(--ds-space-200,1pc)}
4
+ ._19pkpxbi{margin-top:var(--ds-space-200,1pc)}
5
+ ._1bahesu3{justify-content:flex-end}
6
+ ._1e0c1txw{display:flex}
7
+ ._1n261g80{flex-wrap:wrap}
8
+ ._4cvr1h6o{align-items:center}
9
+ ._bfhkomb0{background-color:var(--ds-background-brand-bold,#0052cc)}
10
+ ._ca0qpxbi{padding-top:var(--ds-space-200,1pc)}
11
+ ._ca0qutpp{padding-top:var(--ds-space-150,9pt)}
12
+ ._n3tdpxbi{padding-bottom:var(--ds-space-200,1pc)}
13
+ ._n3tdutpp{padding-bottom:var(--ds-space-150,9pt)}
14
+ ._qrwq1mok{border-top-right-radius:var(--ds-radius-large,8px)}
15
+ ._syaz15cr{color:var(--ds-text-inverse,#fff)}
16
+ ._u5f3pxbi{padding-right:var(--ds-space-200,1pc)}