@atlaskit/smart-card 26.5.4 → 26.5.6

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 (81) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +2 -2
  3. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +3 -4
  4. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +4 -25
  5. package/dist/cjs/utils/analytics/analytics.js +134 -147
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/cjs/view/BlockCard/actions/PreviewAction.js +3 -3
  8. package/dist/cjs/view/BlockCard/index.js +9 -2
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +4 -2
  10. package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenView.js +4 -2
  11. package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +4 -2
  12. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -1
  13. package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +4 -2
  14. package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +10 -5
  15. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +4 -30
  16. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +2 -6
  17. package/dist/cjs/view/HoverCard/utils.js +2 -33
  18. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +1 -4
  19. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +4 -6
  20. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +3 -24
  21. package/dist/es2019/utils/analytics/analytics.js +0 -13
  22. package/dist/es2019/version.json +1 -1
  23. package/dist/es2019/view/BlockCard/actions/PreviewAction.js +1 -2
  24. package/dist/es2019/view/BlockCard/index.js +6 -1
  25. package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +3 -1
  26. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +3 -1
  27. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +3 -1
  28. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -1
  29. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +3 -1
  30. package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +9 -5
  31. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +3 -20
  32. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +3 -7
  33. package/dist/es2019/view/HoverCard/utils.js +0 -20
  34. package/dist/esm/extractors/common/actions/extractPreviewAction.js +2 -2
  35. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +4 -5
  36. package/dist/esm/state/hooks-external/useSmartLinkActions.js +5 -26
  37. package/dist/esm/utils/analytics/analytics.js +130 -142
  38. package/dist/esm/version.json +1 -1
  39. package/dist/esm/view/BlockCard/actions/PreviewAction.js +3 -3
  40. package/dist/esm/view/BlockCard/index.js +9 -2
  41. package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +4 -2
  42. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +4 -2
  43. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +4 -2
  44. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -1
  45. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +4 -2
  46. package/dist/esm/view/FlexibleCard/components/elements/link/index.js +10 -5
  47. package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +4 -27
  48. package/dist/esm/view/HoverCard/components/views/resolved/index.js +3 -7
  49. package/dist/esm/view/HoverCard/utils.js +0 -29
  50. package/dist/types/model/invoke-opts.d.ts +1 -1
  51. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -1
  52. package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +1 -5
  53. package/dist/types/utils/analytics/analytics.d.ts +0 -3
  54. package/dist/types/view/BlockCard/components/Action.d.ts +1 -1
  55. package/dist/types/view/BlockCard/views/flexible/FlexibleErroredView.d.ts +1 -1
  56. package/dist/types/view/BlockCard/views/flexible/FlexibleForbiddenView.d.ts +1 -1
  57. package/dist/types/view/BlockCard/views/flexible/FlexibleNotFoundView.d.ts +1 -1
  58. package/dist/types/view/BlockCard/views/flexible/FlexibleResolvedView.d.ts +1 -1
  59. package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +1 -1
  60. package/dist/types/view/BlockCard/views/flexible/types.d.ts +9 -4
  61. package/dist/types/view/FlexibleCard/components/elements/lozenge/types.d.ts +0 -5
  62. package/dist/types/view/HoverCard/utils.d.ts +0 -3
  63. package/dist/types-ts4.5/model/invoke-opts.d.ts +1 -1
  64. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +2 -1
  65. package/dist/types-ts4.5/state/hooks-external/useSmartLinkActions.d.ts +1 -5
  66. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +0 -3
  67. package/dist/types-ts4.5/view/BlockCard/components/Action.d.ts +1 -1
  68. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleErroredView.d.ts +1 -1
  69. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleForbiddenView.d.ts +1 -1
  70. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleNotFoundView.d.ts +1 -1
  71. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleResolvedView.d.ts +1 -1
  72. package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +1 -1
  73. package/dist/types-ts4.5/view/BlockCard/views/flexible/types.d.ts +9 -4
  74. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/types.d.ts +0 -5
  75. package/dist/types-ts4.5/view/HoverCard/utils.d.ts +0 -3
  76. package/package.json +5 -2
  77. package/dist/cjs/extractors/common/lozenge/extractLozengeText.js +0 -16
  78. package/dist/es2019/extractors/common/lozenge/extractLozengeText.js +0 -10
  79. package/dist/esm/extractors/common/lozenge/extractLozengeText.js +0 -9
  80. package/dist/types/extractors/common/lozenge/extractLozengeText.d.ts +0 -2
  81. package/dist/types-ts4.5/extractors/common/lozenge/extractLozengeText.d.ts +0 -2
@@ -29,6 +29,7 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
29
29
  onError = _ref.onError,
30
30
  onResolve = _ref.onResolve,
31
31
  showServerActions = _ref.showServerActions,
32
+ anchorTarget = _ref.anchorTarget,
32
33
  _ref$testId = _ref.testId,
33
34
  testId = _ref$testId === void 0 ? 'smart-block-resolved-view' : _ref$testId,
34
35
  ui = _ref.ui,
@@ -94,7 +95,8 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
94
95
  subtitle: [{
95
96
  name: _constants.ElementName.Location
96
97
  }],
97
- metadataPosition: _constants.SmartLinkPosition.Top
98
+ metadataPosition: _constants.SmartLinkPosition.Top,
99
+ anchorTarget: anchorTarget
98
100
  }), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
99
101
  primary: metadata,
100
102
  maxLines: 1
@@ -31,7 +31,8 @@ var contentStyles = (0, _react2.css)(_templateObject || (_templateObject = (0, _
31
31
  */
32
32
  var FlexibleUnauthorisedView = function FlexibleUnauthorisedView(_ref) {
33
33
  var _cardState$details, _extractProvider;
34
- var analytics = _ref.analytics,
34
+ var anchorTarget = _ref.anchorTarget,
35
+ analytics = _ref.analytics,
35
36
  cardState = _ref.cardState,
36
37
  _ref$extensionKey = _ref.extensionKey,
37
38
  extensionKey = _ref$extensionKey === void 0 ? '' : _ref$extensionKey,
@@ -65,7 +66,8 @@ var FlexibleUnauthorisedView = function FlexibleUnauthorisedView(_ref) {
65
66
  ui: ui,
66
67
  url: url
67
68
  }, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, {
68
- hideRetry: true
69
+ hideRetry: true,
70
+ anchorTarget: anchorTarget
69
71
  }), /*#__PURE__*/_react.default.createElement(_blocks.CustomBlock, {
70
72
  overrideCss: contentStyles,
71
73
  testId: "".concat(testId, "-content")
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
11
  var _react = _interopRequireWildcard(require("react"));
11
12
  var _react2 = require("@emotion/react");
@@ -78,21 +79,25 @@ var Link = function Link(_ref) {
78
79
  theme = _ref$theme === void 0 ? _constants.SmartLinkTheme.Link : _ref$theme,
79
80
  url = _ref.url,
80
81
  onClick = _ref.onClick,
81
- target = _ref.target;
82
+ _ref$target = _ref.target,
83
+ target = _ref$target === void 0 ? '_blank' : _ref$target;
82
84
  var onMouseDown = (0, _useLinkClicked.useMouseDownEvent)();
83
85
  var hasSpace = (0, _react.useMemo)(function () {
84
86
  return text ? (0, _utils.hasWhiteSpace)(text) : false;
85
87
  }, [text]);
86
- var anchor = (0, _react2.jsx)("a", {
88
+ var anchor = (0, _react2.jsx)("a", (0, _extends2.default)({
87
89
  css: [getAnchorStyles(size, theme, getMaxLines(maxLines), hasSpace), overrideCss],
88
90
  "data-smart-element": name,
89
91
  "data-smart-element-link": true,
90
92
  "data-testid": testId,
91
93
  onClick: onClick,
92
94
  onMouseDown: onMouseDown,
93
- href: url,
94
- target: target || '_blank'
95
- }, text);
95
+ href: url
96
+ // We do not want set the target if it is the default value of '_self'. This prevents link
97
+ // click issues in Confluence and Trello which rely on it not being set unless necessary.
98
+ }, target !== '_self' && {
99
+ target: target
100
+ }), text);
96
101
  return (0, _react2.jsx)("span", {
97
102
  css: containerStyles
98
103
  }, hideTooltip || text === undefined ? anchor : withTooltip(anchor, text, testId));
@@ -1,24 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
- var _react = _interopRequireWildcard(require("react"));
9
+ var _react = _interopRequireDefault(require("react"));
12
10
  var _react2 = require("@emotion/react");
13
11
  var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
14
12
  var _lozengeAction = _interopRequireDefault(require("../../common/lozenge-action"));
15
13
  var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
16
- var _templateObject, _templateObject2;
14
+ var _templateObject;
17
15
  /** @jsx jsx */
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
16
  var styles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height: inherit;\n"])));
21
- var actionStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n overflow: visible;\n"])));
22
17
 
23
18
  /**
24
19
  * A base element that displays a Lozenge.
@@ -31,27 +26,11 @@ var Lozenge = function Lozenge(_ref) {
31
26
  _ref$appearance = _ref.appearance,
32
27
  appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
33
28
  name = _ref.name,
34
- onClick = _ref.onClick,
35
29
  overrideCss = _ref.overrideCss,
36
30
  text = _ref.text,
37
31
  _ref$testId = _ref.testId,
38
32
  testId = _ref$testId === void 0 ? 'smart-element-lozenge' : _ref$testId;
39
33
  var ui = (0, _flexibleUiContext.useFlexibleUiOptionContext)();
40
- var _useState = (0, _react.useState)(false),
41
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
42
- isBold = _useState2[0],
43
- setIsBold = _useState2[1];
44
- var onHover = (0, _react.useCallback)(function (isHover) {
45
- if (onClick) {
46
- setIsBold(isHover);
47
- }
48
- }, [onClick]);
49
- var onMouseEnter = (0, _react.useCallback)(function () {
50
- return onHover(true);
51
- }, [onHover]);
52
- var onMouseLeave = (0, _react.useCallback)(function () {
53
- return onHover(false);
54
- }, [onHover]);
55
34
  if (!text) {
56
35
  return null;
57
36
  }
@@ -63,19 +42,14 @@ var Lozenge = function Lozenge(_ref) {
63
42
  zIndex: ui === null || ui === void 0 ? void 0 : ui.zIndex
64
43
  }) : (0, _react2.jsx)(_lozenge.default, {
65
44
  appearance: appearance,
66
- isBold: isBold,
67
45
  testId: "".concat(testId, "-lozenge")
68
46
  }, text);
69
47
  return (0, _react2.jsx)("span", {
70
- css: [styles, onClick ? actionStyles : undefined, overrideCss],
48
+ css: [styles, overrideCss],
71
49
  "data-fit-to-content": true,
72
50
  "data-smart-element": name,
73
51
  "data-smart-element-lozenge": true,
74
- "data-testid": testId,
75
- onClick: onClick,
76
- onMouseEnter: onMouseEnter,
77
- onMouseLeave: onMouseLeave,
78
- tabIndex: onClick ? 0 : -1
52
+ "data-testid": testId
79
53
  }, lozenge);
80
54
  };
81
55
  var _default = Lozenge;
@@ -10,7 +10,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _linkProvider = require("@atlaskit/link-provider");
13
- var _extractors = require("@atlaskit/linking-common/extractors");
14
13
  var _constants = require("../../../../../constants");
15
14
  var _blocks = require("../../../../FlexibleCard/components/blocks");
16
15
  var _styled = require("./styled");
@@ -70,7 +69,6 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
70
69
  cardActions = _ref$cardActions === void 0 ? [] : _ref$cardActions,
71
70
  onActionClick = _ref.onActionClick,
72
71
  extensionKey = _ref.extensionKey;
73
- var showActionableElement = (0, _linkProvider.useFeatureFlag)('enableActionableElement');
74
72
  var enableImprovedPreviewAction = (0, _linkProvider.useFeatureFlag)('enableImprovedPreviewAction');
75
73
  (0, _react.useEffect)(function () {
76
74
  // Since this hover view is only rendered on resolved status,
@@ -85,16 +83,14 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
85
83
  }, [cardActions, onActionClick, enableImprovedPreviewAction]);
86
84
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
87
85
  var _useMemo = (0, _react.useMemo)(function () {
88
- var types = data ? (0, _extractors.extractType)(data) : undefined;
89
86
  //TODO: EDM-3224 deleted simulated and use real JsonLd
90
87
  var metadata = (0, _extractMetadata.extractMetadata)((0, _utils.getSimulatedMetadata)(extensionKey, data));
91
- var primary = showActionableElement ? (0, _utils.toActionableMetadata)(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
92
88
  return {
93
- primary: primary,
89
+ primary: metadata.primary,
94
90
  secondary: metadata.secondary,
95
91
  subtitle: metadata.subtitle
96
92
  };
97
- }, [cardActions, data, extensionKey, onActionClick, showActionableElement]),
93
+ }, [data, extensionKey]),
98
94
  primary = _useMemo.primary,
99
95
  secondary = _useMemo.secondary;
100
96
  var snippetHeight = _react.default.useRef(0);
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.toActionableMetadata = exports.getSimulatedMetadata = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
6
+ exports.getSimulatedMetadata = void 0;
9
7
  var _constants = require("../../constants");
10
8
  var _extractors = require("@atlaskit/linking-common/extractors");
11
9
  var _utils = require("../../extractors/flexible/utils");
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
10
  var getSimulatedMetadata = function getSimulatedMetadata() {
15
11
  var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
16
12
  var data = arguments.length > 1 ? arguments[1] : undefined;
@@ -86,31 +82,4 @@ var getSimulatedMetadata = function getSimulatedMetadata() {
86
82
  };
87
83
  }
88
84
  };
89
- exports.getSimulatedMetadata = getSimulatedMetadata;
90
- var toActionableMetadata = function toActionableMetadata(onActionClick, extensionKey) {
91
- var types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
92
- var cardActions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
93
- var elementItems = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
94
- // Actionable State for Jira issue
95
- if (extensionKey === 'jira-object-provider' && types !== null && types !== void 0 && types.includes('atlassian:Task')) {
96
- var previewAction = cardActions.find(function (action) {
97
- return action.id === 'preview-content';
98
- });
99
- if (previewAction) {
100
- return elementItems.map(function (elementItem) {
101
- return elementItem.name === _constants.ElementName.State ? _objectSpread(_objectSpread({}, elementItem), {}, {
102
- onClick: function onClick() {
103
- if (onActionClick) {
104
- onActionClick(previewAction.id);
105
- }
106
- return previewAction.invoke({
107
- isReloadRequired: true
108
- });
109
- }
110
- }) : elementItem;
111
- });
112
- }
113
- }
114
- return elementItems;
115
- };
116
- exports.toActionableMetadata = toActionableMetadata;
85
+ exports.getSimulatedMetadata = getSimulatedMetadata;
@@ -80,10 +80,7 @@ export const extractPreviewAction = ({
80
80
  // - Promise invoked by the action invocation handler; open preview.
81
81
  previewActionProps.action.promise = previewAction.promise;
82
82
  // - Promise invoked on click of `Preview` on block card; trigger above promise.
83
- previewAction.promise = opts => handleInvoke({
84
- ...previewActionProps,
85
- ...opts
86
- });
83
+ previewAction.promise = () => handleInvoke(previewActionProps);
87
84
  return previewAction;
88
85
  }
89
86
  };
@@ -4,7 +4,7 @@ import { chunkloadFailedEvent, connectFailedEvent, connectSucceededEvent, contex
4
4
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
5
5
  import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
6
6
  import { useSmartLinkContext } from '@atlaskit/link-provider';
7
- import { trackLinkUpdated, trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
7
+ import { trackSmartLinkQuickActionFailed, trackSmartLinkQuickActionStarted, trackSmartLinkQuickActionSuccess, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
8
8
  import { useDispatchAnalytics } from './useDispatchAnalytics';
9
9
  const applyCommonAttributes = (event, commonAttributes) => {
10
10
  if (event && event.attributes) {
@@ -733,12 +733,10 @@ export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocati
733
733
  location
734
734
  }), commonAttributes)),
735
735
  /**
736
- * This fires a tracking event before and after link updated.
736
+ * Removed in EDM-5153: This is an even from an experiment.
737
+ * @deprecated
737
738
  */
738
- linkUpdated: props => dispatchAnalytics(applyCommonAttributes(trackLinkUpdated({
739
- ...commonAttributes,
740
- ...props
741
- }), commonAttributes)),
739
+ linkUpdated: props => {},
742
740
  /**
743
741
  * This fires a tracking event before an action invoke api call is made
744
742
  */
@@ -1,11 +1,10 @@
1
- import { useCallback, useEffect, useMemo, useState } from 'react';
1
+ import { useEffect, useMemo, useState } from 'react';
2
2
  import uuid from 'uuid';
3
3
  import { extractBlockProps as extractCardProps } from '../../extractors/block';
4
4
  import { useSmartCardActions as useLinkActions } from '../actions';
5
5
  import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
6
6
  import { useSmartCardState as useLinkState } from '../store';
7
7
  import { getExtensionKey } from '../helpers';
8
- import { useFeatureFlag } from '@atlaskit/link-provider';
9
8
  export function useSmartLinkActions({
10
9
  url,
11
10
  appearance,
@@ -18,32 +17,12 @@ export function useSmartLinkActions({
18
17
  const linkState = useLinkState(url);
19
18
  const linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
20
19
  const linkActions = useLinkActions(id, url, linkAnalytics);
21
-
22
- // Start: Smart ink Actions experiment
23
- const enableActionableElement = useFeatureFlag('enableActionableElement');
24
- const reload = useCallback(() => linkActions.reload(), [linkActions]);
25
- const handleInvoke = useCallback(opts => {
26
- var _opts$action;
27
- if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
28
- // Reload when embed preview modal close
29
- const {
30
- promise
31
- } = opts.action;
32
- opts.action.type = 'StatusAction';
33
- opts.action.promise = () => promise({
34
- onClose: reload
35
- });
36
- }
37
- return linkActions.invoke(opts, appearance);
38
- }, [appearance, enableActionableElement, linkActions, reload]);
39
- // End: Smart ink Actions experiment
40
-
41
20
  useEffect(() => {
42
21
  if (!linkState.details) {
43
22
  return;
44
23
  }
45
24
  const cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
46
- handleInvoke,
25
+ handleInvoke: opts => linkActions.invoke(opts, appearance),
47
26
  analytics: linkAnalytics,
48
27
  origin,
49
28
  extensionKey: getExtensionKey(linkState.details),
@@ -58,6 +37,6 @@ export function useSmartLinkActions({
58
37
  invoke: action.promise
59
38
  }));
60
39
  setActions(cardActions);
61
- }, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
40
+ }, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
62
41
  return actions;
63
42
  }
@@ -231,19 +231,6 @@ export const trackAppAccountAuthStarted = ({
231
231
  location
232
232
  }
233
233
  });
234
- export const trackLinkUpdated = ({
235
- actionSubjectId,
236
- ...attributes
237
- }) => ({
238
- action: 'updated',
239
- actionSubject: 'link',
240
- actionSubjectId,
241
- eventType: 'track',
242
- attributes: {
243
- ...context,
244
- ...attributes
245
- }
246
- });
247
234
  export const trackSmartLinkQuickActionStarted = ({
248
235
  smartLinkActionType,
249
236
  ...attributes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.4",
3
+ "version": "26.5.6",
4
4
  "sideEffects": false
5
5
  }
@@ -56,13 +56,12 @@ export default (({
56
56
  return {
57
57
  id: 'preview-content',
58
58
  text: /*#__PURE__*/React.createElement(FormattedMessage, previewText),
59
- promise: props => previewFunction({
59
+ promise: () => previewFunction({
60
60
  popupMountPointId: 'twp-editor-preview-iframe',
61
61
  providerName: 'Preview',
62
62
  showModal: true,
63
63
  iframeName: 'twp-editor-preview-iframe',
64
64
  onClose: () => {},
65
- ...props,
66
65
  ...rest
67
66
  })
68
67
  };
@@ -23,6 +23,7 @@ import { tokens } from '../../utils/token';
23
23
  import { css, jsx } from '@emotion/react';
24
24
  import { handleClickCommon } from './utils/handlers';
25
25
  import { useFeatureFlag } from '@atlaskit/link-provider';
26
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
26
27
  export { default as PreviewAction } from './actions/PreviewAction';
27
28
  export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
28
29
  const flexibleBlockCardElevationStyle = css`
@@ -69,6 +70,7 @@ export const BlockCard = ({
69
70
  const ui = {
70
71
  hideElevation: true
71
72
  };
73
+ const anchorTarget = getBooleanFF('platform.linking-platform.smart-card.enable-block-card-clicks-opening-in-same-tab') ? '_self' : undefined;
72
74
  const flexibleProps = {
73
75
  id,
74
76
  cardState,
@@ -81,7 +83,10 @@ export const BlockCard = ({
81
83
  showServerActions,
82
84
  ui,
83
85
  analytics,
84
- extensionKey
86
+ extensionKey,
87
+ ...(anchorTarget ? {
88
+ anchorTarget
89
+ } : {})
85
90
  };
86
91
  switch (status) {
87
92
  case 'pending':
@@ -15,6 +15,7 @@ import Text from '../../../FlexibleCard/components/elements/text';
15
15
  * @see FlexibleCardProps
16
16
  */
17
17
  const FlexibleErroredView = ({
18
+ anchorTarget,
18
19
  cardState,
19
20
  onAuthorize,
20
21
  onError,
@@ -34,7 +35,8 @@ const FlexibleErroredView = ({
34
35
  ui: ui,
35
36
  url: url
36
37
  }, /*#__PURE__*/React.createElement(TitleBlock, {
37
- hideRetry: true
38
+ hideRetry: true,
39
+ anchorTarget: anchorTarget
38
40
  }), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
39
41
  label: "errored-warning-icon",
40
42
  size: "small",
@@ -20,6 +20,7 @@ import { extractRequestAccessContext } from '../../../../extractors/common/conte
20
20
  * @see FlexibleCardProps
21
21
  */
22
22
  const FlexibleForbiddenView = ({
23
+ anchorTarget,
23
24
  cardState,
24
25
  onAuthorize,
25
26
  onClick,
@@ -62,7 +63,8 @@ const FlexibleForbiddenView = ({
62
63
  ui: ui,
63
64
  url: url
64
65
  }, /*#__PURE__*/React.createElement(TitleBlock, {
65
- hideRetry: true
66
+ hideRetry: true,
67
+ anchorTarget: anchorTarget
66
68
  }), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
67
69
  label: "forbidden-lock-icon",
68
70
  size: "small",
@@ -14,6 +14,7 @@ import { CustomBlock } from '../../../FlexibleCard/components/blocks';
14
14
  * @see FlexibleCardProps
15
15
  */
16
16
  const FlexibleNotFoundView = ({
17
+ anchorTarget,
17
18
  cardState,
18
19
  onAuthorize,
19
20
  onError,
@@ -33,7 +34,8 @@ const FlexibleNotFoundView = ({
33
34
  ui: ui,
34
35
  url: url
35
36
  }, /*#__PURE__*/React.createElement(TitleBlock, {
36
- hideRetry: true
37
+ hideRetry: true,
38
+ anchorTarget: anchorTarget
37
39
  }), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
38
40
  label: "not-found-warning-icon",
39
41
  size: "small",
@@ -17,6 +17,7 @@ const FlexibleResolvedView = ({
17
17
  onError,
18
18
  onResolve,
19
19
  showServerActions,
20
+ anchorTarget,
20
21
  testId = 'smart-block-resolved-view',
21
22
  ui,
22
23
  url,
@@ -76,7 +77,8 @@ const FlexibleResolvedView = ({
76
77
  subtitle: [{
77
78
  name: ElementName.Location
78
79
  }],
79
- metadataPosition: SmartLinkPosition.Top
80
+ metadataPosition: SmartLinkPosition.Top,
81
+ anchorTarget: anchorTarget
80
82
  }), /*#__PURE__*/React.createElement(MetadataBlock, {
81
83
  primary: metadata,
82
84
  maxLines: 1
@@ -22,6 +22,7 @@ const contentStyles = css`
22
22
  * @see FlexibleCardProps
23
23
  */
24
24
  const FlexibleUnauthorisedView = ({
25
+ anchorTarget,
25
26
  analytics,
26
27
  cardState,
27
28
  extensionKey = '',
@@ -54,7 +55,8 @@ const FlexibleUnauthorisedView = ({
54
55
  ui: ui,
55
56
  url: url
56
57
  }, /*#__PURE__*/React.createElement(TitleBlock, {
57
- hideRetry: true
58
+ hideRetry: true,
59
+ anchorTarget: anchorTarget
58
60
  }), /*#__PURE__*/React.createElement(CustomBlock, {
59
61
  overrideCss: contentStyles,
60
62
  testId: `${testId}-content`
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  /** @jsx jsx */
2
3
  import React, { useMemo } from 'react';
3
4
  import { css, jsx } from '@emotion/react';
@@ -98,20 +99,23 @@ const Link = ({
98
99
  theme = SmartLinkTheme.Link,
99
100
  url,
100
101
  onClick,
101
- target
102
+ target = '_blank'
102
103
  }) => {
103
104
  const onMouseDown = useMouseDownEvent();
104
105
  const hasSpace = useMemo(() => text ? hasWhiteSpace(text) : false, [text]);
105
- const anchor = jsx("a", {
106
+ const anchor = jsx("a", _extends({
106
107
  css: [getAnchorStyles(size, theme, getMaxLines(maxLines), hasSpace), overrideCss],
107
108
  "data-smart-element": name,
108
109
  "data-smart-element-link": true,
109
110
  "data-testid": testId,
110
111
  onClick: onClick,
111
112
  onMouseDown: onMouseDown,
112
- href: url,
113
- target: target || '_blank'
114
- }, text);
113
+ href: url
114
+ // We do not want set the target if it is the default value of '_self'. This prevents link
115
+ // click issues in Confluence and Trello which rely on it not being set unless necessary.
116
+ }, target !== '_self' && {
117
+ target
118
+ }), text);
115
119
  return jsx("span", {
116
120
  css: containerStyles
117
121
  }, hideTooltip || text === undefined ? anchor : withTooltip(anchor, text, testId));
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import React, { useCallback, useState } from 'react';
2
+ import React from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import AtlaskitLozenge from '@atlaskit/lozenge';
5
5
  import LozengeAction from '../../common/lozenge-action';
@@ -8,9 +8,6 @@ const styles = css`
8
8
  display: inline-flex;
9
9
  line-height: inherit;
10
10
  `;
11
- const actionStyles = css`
12
- overflow: visible;
13
- `;
14
11
 
15
12
  /**
16
13
  * A base element that displays a Lozenge.
@@ -22,20 +19,11 @@ const Lozenge = ({
22
19
  action,
23
20
  appearance = 'default',
24
21
  name,
25
- onClick,
26
22
  overrideCss,
27
23
  text,
28
24
  testId = 'smart-element-lozenge'
29
25
  }) => {
30
26
  const ui = useFlexibleUiOptionContext();
31
- const [isBold, setIsBold] = useState(false);
32
- const onHover = useCallback(isHover => {
33
- if (onClick) {
34
- setIsBold(isHover);
35
- }
36
- }, [onClick]);
37
- const onMouseEnter = useCallback(() => onHover(true), [onHover]);
38
- const onMouseLeave = useCallback(() => onHover(false), [onHover]);
39
27
  if (!text) {
40
28
  return null;
41
29
  }
@@ -47,19 +35,14 @@ const Lozenge = ({
47
35
  zIndex: ui === null || ui === void 0 ? void 0 : ui.zIndex
48
36
  }) : jsx(AtlaskitLozenge, {
49
37
  appearance: appearance,
50
- isBold: isBold,
51
38
  testId: `${testId}-lozenge`
52
39
  }, text);
53
40
  return jsx("span", {
54
- css: [styles, onClick ? actionStyles : undefined, overrideCss],
41
+ css: [styles, overrideCss],
55
42
  "data-fit-to-content": true,
56
43
  "data-smart-element": name,
57
44
  "data-smart-element-lozenge": true,
58
- "data-testid": testId,
59
- onClick: onClick,
60
- onMouseEnter: onMouseEnter,
61
- onMouseLeave: onMouseLeave,
62
- tabIndex: onClick ? 0 : -1
45
+ "data-testid": testId
63
46
  }, lozenge);
64
47
  };
65
48
  export default Lozenge;
@@ -1,12 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { useFeatureFlag } from '@atlaskit/link-provider';
4
- import { extractType } from '@atlaskit/linking-common/extractors';
5
4
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../../../constants';
6
5
  import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
7
6
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
8
7
  import FlexibleCard from '../../../../FlexibleCard';
9
- import { getSimulatedMetadata, toActionableMetadata } from '../../../utils';
8
+ import { getSimulatedMetadata } from '../../../utils';
10
9
  import SnippetOrPreview from '../../SnippetOrPreview';
11
10
  import { extractMetadata } from '../../../../../extractors/hover/extractMetadata';
12
11
  import { messages } from '../../../../../messages';
@@ -56,7 +55,6 @@ const HoverCardResolvedView = ({
56
55
  extensionKey
57
56
  }) => {
58
57
  var _cardState$details;
59
- const showActionableElement = useFeatureFlag('enableActionableElement');
60
58
  const enableImprovedPreviewAction = useFeatureFlag('enableImprovedPreviewAction');
61
59
  useEffect(() => {
62
60
  // Since this hover view is only rendered on resolved status,
@@ -72,16 +70,14 @@ const HoverCardResolvedView = ({
72
70
  primary,
73
71
  secondary
74
72
  } = useMemo(() => {
75
- const types = data ? extractType(data) : undefined;
76
73
  //TODO: EDM-3224 deleted simulated and use real JsonLd
77
74
  const metadata = extractMetadata(getSimulatedMetadata(extensionKey, data));
78
- const primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
79
75
  return {
80
- primary,
76
+ primary: metadata.primary,
81
77
  secondary: metadata.secondary,
82
78
  subtitle: metadata.subtitle
83
79
  };
84
- }, [cardActions, data, extensionKey, onActionClick, showActionableElement]);
80
+ }, [data, extensionKey]);
85
81
  const snippetHeight = React.useRef(0);
86
82
  const snippetBlockRef = useRef(null);
87
83
  const onSnippetRender = useCallback(() => {