@atlaskit/smart-card 26.46.1 → 26.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.46.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#70977](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70977) [`a75838cbc582`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a75838cbc582) - Add AISummary block to hover cards which includes the AISummary action. This block is enabled when isAdminHubAIEnabled is set to true on the card provider, the FF is enabled and the jsonld response includes the correct data.
8
+
3
9
  ## 26.46.1
4
10
 
5
11
  ### Patch Changes
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "26.46.1"
25
+ packageVersion: "26.46.2"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -17,6 +17,7 @@ var _block = _interopRequireDefault(require("../../block"));
17
17
  var _elementGroup = _interopRequireDefault(require("../../element-group"));
18
18
  var _utils = require("../../utils");
19
19
  var _messages = require("../../../../../../messages");
20
+ var _aiIcon = _interopRequireDefault(require("../../../../../common/ai-icon"));
20
21
  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); }
21
22
  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; }
22
23
  var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
@@ -40,7 +41,10 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
40
41
  content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.ai_summarize),
41
42
  name: _constants.ActionName.CustomAction,
42
43
  onClick: onAIActionClick,
43
- testId: "".concat(testId, "-ai-summary-action")
44
+ testId: "".concat(testId, "-ai-summary-action"),
45
+ icon: /*#__PURE__*/_react.default.createElement(_aiIcon.default, {
46
+ label: "AiIcon"
47
+ })
44
48
  };
45
49
  return [aiAction].concat((0, _toConsumableArray2.default)(actions));
46
50
  }, [actions, onAIActionClick, testId]);
@@ -20,6 +20,7 @@ var _messages = require("../../../../../messages");
20
20
  var _reactIntlNext = require("react-intl-next");
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
22
  var _helpers = require("../../../../../state/helpers");
23
+ var _state = require("../../../../../state");
23
24
  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); }
24
25
  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; }
25
26
  var toFooterActions = exports.toFooterActions = function toFooterActions(cardActions, onActionClick) {
@@ -57,7 +58,7 @@ var toFooterActions = exports.toFooterActions = function toFooterActions(cardAct
57
58
  return [followAction].concat((0, _toConsumableArray2.default)(actions));
58
59
  };
59
60
  var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
60
- var _cardState$details;
61
+ var _cardState$details, _cardState$details2;
61
62
  var flexibleCardProps = _ref.flexibleCardProps,
62
63
  titleBlockProps = _ref.titleBlockProps,
63
64
  analytics = _ref.analytics,
@@ -102,6 +103,9 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
102
103
  data: data,
103
104
  fallbackElementHeight: snippetHeight.current
104
105
  });
106
+ var _useSmartLinkContext = (0, _state.useSmartLinkContext)(),
107
+ isAdminHubAIEnabled = _useSmartLinkContext.isAdminHubAIEnabled;
108
+ var showAiView = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.hover-card-ai-summaries') && isAdminHubAIEnabled && ((_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 || (_cardState$details2 = _cardState$details2.meta) === null || _cardState$details2 === void 0 || (_cardState$details2 = _cardState$details2.supportedFeatures) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.includes('AISummary'));
105
109
  return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, flexibleCardProps, imagePreview, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, (0, _extends2.default)({}, titleBlockProps, {
106
110
  metadataPosition: _constants.SmartLinkPosition.Top
107
111
  })), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
@@ -123,7 +127,12 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
123
127
  }), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-hover-card-related-urls') && /*#__PURE__*/_react.default.createElement(_blocks.RelatedUrlsBlock, {
124
128
  url: url,
125
129
  size: _constants.SmartLinkSize.Small
126
- }), /*#__PURE__*/_react.default.createElement(_blocks.FooterBlock, {
130
+ }), showAiView ? /*#__PURE__*/_react.default.createElement(_blocks.AISummaryBlock, {
131
+ metadata: [{
132
+ name: _constants.ElementName.Provider
133
+ }],
134
+ actions: footerActions
135
+ }) : /*#__PURE__*/_react.default.createElement(_blocks.FooterBlock, {
127
136
  actions: footerActions,
128
137
  size: _constants.SmartLinkSize.Large,
129
138
  overrideCss: _styled.footerBlockCss
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.46.1",
20
+ packageVersion: "26.46.2",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "26.46.1"
7
+ packageVersion: "26.46.2"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -8,6 +8,7 @@ import Block from '../../block';
8
8
  import ElementGroup from '../../element-group';
9
9
  import { filterActionItems, getActionGroupStyles, renderElementItems } from '../../utils';
10
10
  import { messages } from '../../../../../../messages';
11
+ import AiIcon from '../../../../../common/ai-icon';
11
12
  const AISummaryBlockResolvedView = props => {
12
13
  const {
13
14
  actions = [],
@@ -29,7 +30,10 @@ const AISummaryBlockResolvedView = props => {
29
30
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summarize),
30
31
  name: ActionName.CustomAction,
31
32
  onClick: onAIActionClick,
32
- testId: `${testId}-ai-summary-action`
33
+ testId: `${testId}-ai-summary-action`,
34
+ icon: /*#__PURE__*/React.createElement(AiIcon, {
35
+ label: "AiIcon"
36
+ })
33
37
  };
34
38
  return [aiAction, ...actions];
35
39
  }, [actions, onAIActionClick, testId]);
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
- import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../../../constants';
4
- import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
3
+ import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize } from '../../../../../constants';
4
+ import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock } from '../../../../FlexibleCard/components/blocks';
5
5
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
6
6
  import FlexibleCard from '../../../../FlexibleCard';
7
7
  import { getSimulatedBetterMetadata } from '../../../utils';
@@ -11,6 +11,7 @@ import { messages } from '../../../../../messages';
11
11
  import { FormattedMessage } from 'react-intl-next';
12
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
13
  import { getCanBeDatasource } from '../../../../../state/helpers';
14
+ import { useSmartLinkContext } from '../../../../../state';
14
15
  export const toFooterActions = (cardActions, onActionClick) => {
15
16
  const followAction = {
16
17
  hideIcon: true,
@@ -55,7 +56,7 @@ const HoverCardResolvedView = ({
55
56
  extensionKey,
56
57
  url
57
58
  }) => {
58
- var _cardState$details;
59
+ var _cardState$details, _cardState$details2, _cardState$details2$m, _cardState$details2$m2;
59
60
  const canBeDatasource = getCanBeDatasource(cardState.details);
60
61
  useEffect(() => {
61
62
  // Since this hover view is only rendered on resolved status,
@@ -90,6 +91,10 @@ const HoverCardResolvedView = ({
90
91
  data: data,
91
92
  fallbackElementHeight: snippetHeight.current
92
93
  });
94
+ const {
95
+ isAdminHubAIEnabled
96
+ } = useSmartLinkContext();
97
+ const showAiView = getBooleanFF('platform.linking-platform.smart-card.hover-card-ai-summaries') && isAdminHubAIEnabled && ((_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 ? void 0 : (_cardState$details2$m = _cardState$details2.meta) === null || _cardState$details2$m === void 0 ? void 0 : (_cardState$details2$m2 = _cardState$details2$m.supportedFeatures) === null || _cardState$details2$m2 === void 0 ? void 0 : _cardState$details2$m2.includes('AISummary'));
93
98
  return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
94
99
  metadataPosition: SmartLinkPosition.Top
95
100
  })), /*#__PURE__*/React.createElement(MetadataBlock, {
@@ -111,7 +116,12 @@ const HoverCardResolvedView = ({
111
116
  }), getBooleanFF('platform.linking-platform.smart-card.enable-hover-card-related-urls') && /*#__PURE__*/React.createElement(RelatedUrlsBlock, {
112
117
  url: url,
113
118
  size: SmartLinkSize.Small
114
- }), /*#__PURE__*/React.createElement(FooterBlock, {
119
+ }), showAiView ? /*#__PURE__*/React.createElement(AISummaryBlock, {
120
+ metadata: [{
121
+ name: ElementName.Provider
122
+ }],
123
+ actions: footerActions
124
+ }) : /*#__PURE__*/React.createElement(FooterBlock, {
115
125
  actions: footerActions,
116
126
  size: SmartLinkSize.Large,
117
127
  overrideCss: footerBlockCss
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.46.1",
10
+ packageVersion: "26.46.2",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.46.1"
18
+ packageVersion: "26.46.2"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -9,6 +9,7 @@ import Block from '../../block';
9
9
  import ElementGroup from '../../element-group';
10
10
  import { filterActionItems, getActionGroupStyles, renderElementItems } from '../../utils';
11
11
  import { messages } from '../../../../../../messages';
12
+ import AiIcon from '../../../../../common/ai-icon';
12
13
  var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
13
14
  var _props$actions = props.actions,
14
15
  actions = _props$actions === void 0 ? [] : _props$actions,
@@ -30,7 +31,10 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
30
31
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summarize),
31
32
  name: ActionName.CustomAction,
32
33
  onClick: onAIActionClick,
33
- testId: "".concat(testId, "-ai-summary-action")
34
+ testId: "".concat(testId, "-ai-summary-action"),
35
+ icon: /*#__PURE__*/React.createElement(AiIcon, {
36
+ label: "AiIcon"
37
+ })
34
38
  };
35
39
  return [aiAction].concat(_toConsumableArray(actions));
36
40
  }, [actions, onAIActionClick, testId]);
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
4
- import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../../../constants';
5
- import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
4
+ import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize } from '../../../../../constants';
5
+ import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock } from '../../../../FlexibleCard/components/blocks';
6
6
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
7
7
  import FlexibleCard from '../../../../FlexibleCard';
8
8
  import { getSimulatedBetterMetadata } from '../../../utils';
@@ -12,6 +12,7 @@ import { messages } from '../../../../../messages';
12
12
  import { FormattedMessage } from 'react-intl-next';
13
13
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
14
  import { getCanBeDatasource } from '../../../../../state/helpers';
15
+ import { useSmartLinkContext } from '../../../../../state';
15
16
  export var toFooterActions = function toFooterActions(cardActions, onActionClick) {
16
17
  var followAction = {
17
18
  hideIcon: true,
@@ -47,7 +48,7 @@ export var toFooterActions = function toFooterActions(cardActions, onActionClick
47
48
  return [followAction].concat(_toConsumableArray(actions));
48
49
  };
49
50
  var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
50
- var _cardState$details;
51
+ var _cardState$details, _cardState$details2;
51
52
  var flexibleCardProps = _ref.flexibleCardProps,
52
53
  titleBlockProps = _ref.titleBlockProps,
53
54
  analytics = _ref.analytics,
@@ -92,6 +93,9 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
92
93
  data: data,
93
94
  fallbackElementHeight: snippetHeight.current
94
95
  });
96
+ var _useSmartLinkContext = useSmartLinkContext(),
97
+ isAdminHubAIEnabled = _useSmartLinkContext.isAdminHubAIEnabled;
98
+ var showAiView = getBooleanFF('platform.linking-platform.smart-card.hover-card-ai-summaries') && isAdminHubAIEnabled && ((_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 || (_cardState$details2 = _cardState$details2.meta) === null || _cardState$details2 === void 0 || (_cardState$details2 = _cardState$details2.supportedFeatures) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.includes('AISummary'));
95
99
  return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
96
100
  metadataPosition: SmartLinkPosition.Top
97
101
  })), /*#__PURE__*/React.createElement(MetadataBlock, {
@@ -113,7 +117,12 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
113
117
  }), getBooleanFF('platform.linking-platform.smart-card.enable-hover-card-related-urls') && /*#__PURE__*/React.createElement(RelatedUrlsBlock, {
114
118
  url: url,
115
119
  size: SmartLinkSize.Small
116
- }), /*#__PURE__*/React.createElement(FooterBlock, {
120
+ }), showAiView ? /*#__PURE__*/React.createElement(AISummaryBlock, {
121
+ metadata: [{
122
+ name: ElementName.Provider
123
+ }],
124
+ actions: footerActions
125
+ }) : /*#__PURE__*/React.createElement(FooterBlock, {
117
126
  actions: footerActions,
118
127
  size: SmartLinkSize.Large,
119
128
  overrideCss: footerBlockCss
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.46.1",
13
+ packageVersion: "26.46.2",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -0,0 +1,2 @@
1
+ declare const mockAtlasProjectWithAISummary: any;
2
+ export default mockAtlasProjectWithAISummary;
@@ -0,0 +1,2 @@
1
+ declare const mockAtlasProjectWithAISummary: any;
2
+ export default mockAtlasProjectWithAISummary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.46.1",
3
+ "version": "26.46.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,12 +26,12 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@atlaskit/analytics-gas-types": "^5.1.0",
29
- "@atlaskit/analytics-next": "^9.1.0",
29
+ "@atlaskit/analytics-next": "^9.2.0",
30
30
  "@atlaskit/avatar": "^21.4.0",
31
31
  "@atlaskit/avatar-group": "^9.5.0",
32
32
  "@atlaskit/badge": "^15.2.0",
33
- "@atlaskit/button": "^17.2.0",
34
- "@atlaskit/dropdown-menu": "^12.2.0",
33
+ "@atlaskit/button": "^17.3.0",
34
+ "@atlaskit/dropdown-menu": "^12.4.0",
35
35
  "@atlaskit/icon": "^22.0.0",
36
36
  "@atlaskit/icon-file-type": "^6.4.0",
37
37
  "@atlaskit/icon-object": "^6.3.0",
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/modal-dialog": "^12.10.0",
48
48
  "@atlaskit/outbound-auth-flow-client": "^3.4.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.1",
50
- "@atlaskit/popup": "^1.11.0",
50
+ "@atlaskit/popup": "^1.12.0",
51
51
  "@atlaskit/primitives": "^2.0.0",
52
52
  "@atlaskit/spinner": "^16.0.0",
53
53
  "@atlaskit/theme": "^12.6.0",
@@ -82,7 +82,7 @@
82
82
  "@atlaskit/media-test-helpers": "^33.0.0",
83
83
  "@atlaskit/visual-regression": "*",
84
84
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
85
- "@atlassian/feature-flags-test-utils": "^0.1.1",
85
+ "@atlassian/feature-flags-test-utils": "^0.2.0",
86
86
  "@testing-library/dom": "^8.17.1",
87
87
  "@testing-library/jest-dom": "^5.16.5",
88
88
  "@testing-library/react": "^12.1.5",
@@ -154,6 +154,9 @@
154
154
  },
155
155
  "platform.linking-platform.smart-card.disable-jira-status-action": {
156
156
  "type": "boolean"
157
+ },
158
+ "platform.linking-platform.smart-card.hover-card-ai-summaries": {
159
+ "type": "boolean"
157
160
  }
158
161
  },
159
162
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"