@atlaskit/smart-card 36.8.0 → 36.8.1

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,14 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 36.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#142166](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142166)
8
+ [`c721be0359308`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c721be0359308) -
9
+ Enable resolve inline-view from nounData behind ff: smart_links_noun_support
10
+ - Updated dependencies
11
+
3
12
  ## 36.8.0
4
13
 
5
14
  ### Minor Changes
@@ -3,14 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.extractInlineProps = exports.extractInlineIcon = void 0;
6
+ exports.extractInlineProps = void 0;
7
7
  var _linkExtractors = require("@atlaskit/link-extractors");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  var _icon = require("../common/icon");
9
10
  var _lozenge = require("../common/lozenge");
10
11
  var _primitives = require("../common/primitives");
11
12
  var _titlePrefix = require("../common/title-prefix");
12
13
  var _constants = require("../constants");
13
- var extractInlineIcon = exports.extractInlineIcon = function extractInlineIcon(jsonLd) {
14
+ var extractInlineIcon = function extractInlineIcon(jsonLd) {
14
15
  var showIconLabel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
15
16
  var provider = (0, _linkExtractors.extractProvider)(jsonLd);
16
17
  if (provider && provider.id) {
@@ -20,8 +21,35 @@ var extractInlineIcon = exports.extractInlineIcon = function extractInlineIcon(j
20
21
  }
21
22
  return (0, _icon.extractIcon)(jsonLd, 'provider', showIconLabel);
22
23
  };
23
- var extractInlineProps = exports.extractInlineProps = function extractInlineProps(jsonLd, renderers, removeTextHighlightingFromTitle) {
24
+ var extractSmartLinkInlineIcon = function extractSmartLinkInlineIcon(response) {
25
+ var showLabel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
26
+ if ((0, _linkExtractors.isEntityPresent)(response)) {
27
+ var provider = (0, _linkExtractors.extractEntityProvider)(response);
28
+ if (provider) {
29
+ return provider.icon;
30
+ }
31
+ // We don't need this for design entities,
32
+ // but we can add it back when we support more nouns
33
+ // it requires extractInlineIcon to be moved to the smart link extractor package.
34
+ // see: https://product-fabric.atlassian.net/browse/EDM-12375
35
+ // return extractSmartLinkIcon(response);
36
+ }
37
+ return extractInlineIcon(response === null || response === void 0 ? void 0 : response.data, showLabel);
38
+ };
39
+ var extractInlineProps = exports.extractInlineProps = function extractInlineProps(response, renderers, removeTextHighlightingFromTitle) {
24
40
  var showLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
41
+ var jsonLd = response === null || response === void 0 ? void 0 : response.data;
42
+ if ((0, _platformFeatureFlags.fg)('smart_links_noun_support')) {
43
+ return {
44
+ icon: extractSmartLinkInlineIcon(response, showLabel),
45
+ link: (0, _linkExtractors.extractSmartLinkUrl)(response),
46
+ title: (0, _linkExtractors.extractSmartLinkTitle)(response, removeTextHighlightingFromTitle),
47
+ // As we migrate to support more nouns we can incorporate these fields
48
+ lozenge: (0, _lozenge.extractLozenge)(jsonLd),
49
+ titleTextColor: (0, _primitives.extractTitleTextColor)(jsonLd),
50
+ titlePrefix: (0, _titlePrefix.extractTitlePrefix)(jsonLd, renderers, 'inline')
51
+ };
52
+ }
25
53
  return {
26
54
  link: (0, _linkExtractors.extractLink)(jsonLd),
27
55
  title: (0, _linkExtractors.extractTitle)(jsonLd, removeTextHighlightingFromTitle),
@@ -8,7 +8,9 @@ exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _react = require("react");
11
+ var _linkExtractors = require("@atlaskit/link-extractors");
11
12
  var _linkProvider = require("@atlaskit/link-provider");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
14
  var _constants = require("../../../constants");
13
15
  var _analytics = require("../../analytics");
14
16
  var _useResponse2 = _interopRequireDefault(require("../use-response"));
@@ -43,7 +45,7 @@ var useResolve = function useResolve() {
43
45
  status: _constants.SmartLinkStatus.Pending,
44
46
  details: undefined
45
47
  }, details = _ref2.details;
46
- hasData = !!(details && details.data);
48
+ hasData = (0, _platformFeatureFlags.fg)('smart_links_noun_support') ? !!(details && details.data || (0, _linkExtractors.isEntityPresent)(details)) : !!(details && details.data);
47
49
  if (!(isReloading || !hasData || isMetadataRequest)) {
48
50
  _context.next = 9;
49
51
  break;
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
11
11
  var context = exports.context = {
12
12
  componentName: 'smart-cards',
13
13
  packageName: "@atlaskit/smart-card",
14
- packageVersion: "36.8.0"
14
+ packageVersion: "36.8.1"
15
15
  };
16
16
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
17
17
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -86,17 +86,45 @@ var successfulResponseData = _objectSpread(_objectSpread({}, errorResponseData),
86
86
  href: 'https://www.ilovecheese.com'
87
87
  }
88
88
  });
89
- var mocks = exports.mocks = {
90
- success: {
91
- meta: {
92
- visibility: 'public',
93
- access: 'granted',
94
- auth: [],
95
- definitionId: 'd1',
96
- key: 'object-provider'
97
- },
98
- data: successfulResponseData
89
+ var jsonLdResponse = {
90
+ meta: {
91
+ visibility: 'public',
92
+ access: 'granted',
93
+ auth: [],
94
+ definitionId: 'd1',
95
+ key: 'object-provider'
99
96
  },
97
+ data: successfulResponseData
98
+ };
99
+ var nounDataResponse = {
100
+ nounData: {
101
+ id: 'I love cheese',
102
+ displayName: 'I love cheese',
103
+ url: 'https://some.url',
104
+ lastUpdatedAt: '2025-01-08T22:26:52.501Z',
105
+ thumbnail: {
106
+ externalUrl: 'https://www.ilovecheese.com'
107
+ },
108
+ 'atlassian:design': {
109
+ liveEmbedUrl: 'https://www.ilovecheese.com',
110
+ type: 'FILE',
111
+ inspectUrl: 'https://www.ilovecheese.com',
112
+ iconUrl: 'https://www.ilovecheese.com'
113
+ }
114
+ }
115
+ };
116
+ var mocks = exports.mocks = {
117
+ success: _objectSpread({}, jsonLdResponse),
118
+ nounDataSuccess: _objectSpread(_objectSpread(_objectSpread({}, jsonLdResponse), nounDataResponse), {}, {
119
+ meta: _objectSpread(_objectSpread({}, jsonLdResponse.meta), {}, {
120
+ generator: {
121
+ name: 'I love cheese',
122
+ icon: {
123
+ url: 'https://www.ilovecheese.com'
124
+ }
125
+ }
126
+ })
127
+ }),
100
128
  notFound: {
101
129
  meta: {
102
130
  visibility: 'not_found',
@@ -106,7 +106,7 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(funct
106
106
  }));
107
107
  } else {
108
108
  if (platform === 'mobile') {
109
- var resolvedInlineViewProps = (0, _inline.extractInlineProps)(data);
109
+ var resolvedInlineViewProps = (0, _inline.extractInlineProps)(details);
110
110
  return /*#__PURE__*/_react.default.createElement(_ResolvedView2.InlineCardResolvedView, (0, _extends2.default)({}, resolvedInlineViewProps, {
111
111
  isSelected: isSelected,
112
112
  testId: testId,
@@ -41,6 +41,7 @@ var _react = _interopRequireWildcard(require("react"));
41
41
  var _analyticsNext = require("@atlaskit/analytics-next");
42
42
  var _linkExtractors = require("@atlaskit/link-extractors");
43
43
  var _linkProvider = require("@atlaskit/link-provider");
44
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
44
45
  var _constants = require("../../constants");
45
46
  var _extractAccessContext = require("../../extractors/common/context/extractAccessContext");
46
47
  var _inline = require("../../extractors/inline");
@@ -85,7 +86,7 @@ var InlineCard = exports.InlineCard = function InlineCard(_ref) {
85
86
  if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
86
87
  showHoverPreview = Boolean(showHoverPreviewFlag);
87
88
  }
88
- var resolvedProps = status === _constants.SmartLinkStatus.Resolved ? (0, _inline.extractInlineProps)(cardDetails, renderers, removeTextHighlightingFromTitle, false) : {};
89
+ var resolvedProps = status === _constants.SmartLinkStatus.Resolved ? (0, _inline.extractInlineProps)(details, renderers, removeTextHighlightingFromTitle, false) : {};
89
90
  (0, _react.useEffect)(function () {
90
91
  switch (status) {
91
92
  case _constants.SmartLinkStatus.Resolved:
@@ -134,7 +135,7 @@ var InlineCard = exports.InlineCard = function InlineCard(_ref) {
134
135
  truncateInline: truncateInline
135
136
  }));
136
137
  case 'unauthorized':
137
- var provider = (0, _linkExtractors.extractProvider)(cardDetails);
138
+ var provider = (0, _platformFeatureFlags.fg)('smart_links_noun_support') ? (0, _linkExtractors.extractSmartLinkProvider)(details) : (0, _linkExtractors.extractProvider)(cardDetails);
138
139
  return /*#__PURE__*/_react.default.createElement(_UnauthorisedView.InlineCardUnauthorizedView, {
139
140
  icon: provider && provider.icon,
140
141
  context: provider && provider.text,
@@ -149,7 +150,7 @@ var InlineCard = exports.InlineCard = function InlineCard(_ref) {
149
150
  truncateInline: truncateInline
150
151
  });
151
152
  case 'forbidden':
152
- var providerForbidden = (0, _linkExtractors.extractProvider)(cardDetails);
153
+ var providerForbidden = (0, _platformFeatureFlags.fg)('smart_links_noun_support') ? (0, _linkExtractors.extractSmartLinkProvider)(details) : (0, _linkExtractors.extractProvider)(cardDetails);
153
154
  var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : (0, _jsonld.getForbiddenJsonLd)().meta;
154
155
  var requestAccessContext = (0, _extractAccessContext.extractRequestAccessContextImproved)({
155
156
  jsonLd: cardMetadata,
@@ -170,7 +171,7 @@ var InlineCard = exports.InlineCard = function InlineCard(_ref) {
170
171
  truncateInline: truncateInline
171
172
  });
172
173
  case 'not_found':
173
- var providerNotFound = (0, _linkExtractors.extractProvider)(cardDetails);
174
+ var providerNotFound = (0, _platformFeatureFlags.fg)('smart_links_noun_support') ? (0, _linkExtractors.extractSmartLinkProvider)(details) : (0, _linkExtractors.extractProvider)(cardDetails);
174
175
  return /*#__PURE__*/_react.default.createElement(_ErroredView.InlineCardErroredView, {
175
176
  url: url,
176
177
  icon: providerNotFound && providerNotFound.icon,
@@ -20,7 +20,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
20
20
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
21
21
  var PACKAGE_DATA = {
22
22
  packageName: "@atlaskit/smart-card",
23
- packageVersion: "36.8.0",
23
+ packageVersion: "36.8.1",
24
24
  componentName: 'linkUrl'
25
25
  };
26
26
  var Anchor = (0, _click.withLinkClickedEvent)('a');
@@ -1,10 +1,13 @@
1
- import { extractLink, extractProvider, extractTitle } from '@atlaskit/link-extractors';
1
+ import { extractEntityProvider, extractLink, extractProvider,
2
+ // extractSmartLinkIcon,
3
+ extractSmartLinkTitle, extractSmartLinkUrl, extractTitle, isEntityPresent } from '@atlaskit/link-extractors';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
2
5
  import { extractIcon } from '../common/icon';
3
6
  import { extractLozenge } from '../common/lozenge';
4
7
  import { extractTitleTextColor } from '../common/primitives';
5
8
  import { extractTitlePrefix } from '../common/title-prefix';
6
9
  import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../constants';
7
- export const extractInlineIcon = (jsonLd, showIconLabel = true) => {
10
+ const extractInlineIcon = (jsonLd, showIconLabel = true) => {
8
11
  const provider = extractProvider(jsonLd);
9
12
  if (provider && provider.id) {
10
13
  if (provider.id === CONFLUENCE_GENERATOR_ID || provider.id === JIRA_GENERATOR_ID) {
@@ -13,11 +16,39 @@ export const extractInlineIcon = (jsonLd, showIconLabel = true) => {
13
16
  }
14
17
  return extractIcon(jsonLd, 'provider', showIconLabel);
15
18
  };
16
- export const extractInlineProps = (jsonLd, renderers, removeTextHighlightingFromTitle, showLabel = true) => ({
17
- link: extractLink(jsonLd),
18
- title: extractTitle(jsonLd, removeTextHighlightingFromTitle),
19
- lozenge: extractLozenge(jsonLd),
20
- icon: extractInlineIcon(jsonLd, showLabel),
21
- titleTextColor: extractTitleTextColor(jsonLd),
22
- titlePrefix: extractTitlePrefix(jsonLd, renderers, 'inline')
23
- });
19
+ const extractSmartLinkInlineIcon = (response, showLabel = true) => {
20
+ if (isEntityPresent(response)) {
21
+ const provider = extractEntityProvider(response);
22
+ if (provider) {
23
+ return provider.icon;
24
+ }
25
+ // We don't need this for design entities,
26
+ // but we can add it back when we support more nouns
27
+ // it requires extractInlineIcon to be moved to the smart link extractor package.
28
+ // see: https://product-fabric.atlassian.net/browse/EDM-12375
29
+ // return extractSmartLinkIcon(response);
30
+ }
31
+ return extractInlineIcon(response === null || response === void 0 ? void 0 : response.data, showLabel);
32
+ };
33
+ export const extractInlineProps = (response, renderers, removeTextHighlightingFromTitle, showLabel = true) => {
34
+ const jsonLd = response === null || response === void 0 ? void 0 : response.data;
35
+ if (fg('smart_links_noun_support')) {
36
+ return {
37
+ icon: extractSmartLinkInlineIcon(response, showLabel),
38
+ link: extractSmartLinkUrl(response),
39
+ title: extractSmartLinkTitle(response, removeTextHighlightingFromTitle),
40
+ // As we migrate to support more nouns we can incorporate these fields
41
+ lozenge: extractLozenge(jsonLd),
42
+ titleTextColor: extractTitleTextColor(jsonLd),
43
+ titlePrefix: extractTitlePrefix(jsonLd, renderers, 'inline')
44
+ };
45
+ }
46
+ return {
47
+ link: extractLink(jsonLd),
48
+ title: extractTitle(jsonLd, removeTextHighlightingFromTitle),
49
+ lozenge: extractLozenge(jsonLd),
50
+ icon: extractInlineIcon(jsonLd, showLabel),
51
+ titleTextColor: extractTitleTextColor(jsonLd),
52
+ titlePrefix: extractTitlePrefix(jsonLd, renderers, 'inline')
53
+ };
54
+ };
@@ -1,5 +1,7 @@
1
1
  import { useCallback } from 'react';
2
+ import { isEntityPresent } from '@atlaskit/link-extractors';
2
3
  import { useSmartLinkContext } from '@atlaskit/link-provider';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
3
5
  import { SmartLinkStatus } from '../../../constants';
4
6
  import { addMetadataToExperience } from '../../analytics';
5
7
  import useResponse from '../use-response';
@@ -26,7 +28,7 @@ const useResolve = () => {
26
28
  status: SmartLinkStatus.Pending,
27
29
  details: undefined
28
30
  };
29
- const hasData = !!(details && details.data);
31
+ const hasData = fg('smart_links_noun_support') ? !!(details && details.data || isEntityPresent(details)) : !!(details && details.data);
30
32
  if (isReloading || !hasData || isMetadataRequest) {
31
33
  return connections.client.fetchData(url, isReloading).then(response => handleResolvedLinkResponse(url, response, isReloading, isMetadataRequest)).catch(error => handleResolvedLinkError(url, error, undefined, isMetadataRequest));
32
34
  } else {
@@ -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: "36.8.0"
5
+ packageVersion: "36.8.1"
6
6
  };
7
7
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
8
8
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -68,16 +68,49 @@ const successfulResponseData = {
68
68
  href: 'https://www.ilovecheese.com'
69
69
  }
70
70
  };
71
+ const jsonLdResponse = {
72
+ meta: {
73
+ visibility: 'public',
74
+ access: 'granted',
75
+ auth: [],
76
+ definitionId: 'd1',
77
+ key: 'object-provider'
78
+ },
79
+ data: successfulResponseData
80
+ };
81
+ const nounDataResponse = {
82
+ nounData: {
83
+ id: 'I love cheese',
84
+ displayName: 'I love cheese',
85
+ url: 'https://some.url',
86
+ lastUpdatedAt: '2025-01-08T22:26:52.501Z',
87
+ thumbnail: {
88
+ externalUrl: 'https://www.ilovecheese.com'
89
+ },
90
+ 'atlassian:design': {
91
+ liveEmbedUrl: 'https://www.ilovecheese.com',
92
+ type: 'FILE',
93
+ inspectUrl: 'https://www.ilovecheese.com',
94
+ iconUrl: 'https://www.ilovecheese.com'
95
+ }
96
+ }
97
+ };
71
98
  export const mocks = {
72
99
  success: {
100
+ ...jsonLdResponse
101
+ },
102
+ nounDataSuccess: {
103
+ ...jsonLdResponse,
104
+ ...nounDataResponse,
73
105
  meta: {
74
- visibility: 'public',
75
- access: 'granted',
76
- auth: [],
77
- definitionId: 'd1',
78
- key: 'object-provider'
79
- },
80
- data: successfulResponseData
106
+ ...jsonLdResponse.meta,
107
+ generator: {
108
+ name: 'I love cheese',
109
+ icon: {
110
+ url: 'https://www.ilovecheese.com'
111
+ }
112
+ }
113
+ }
81
114
  },
82
115
  notFound: {
83
116
  meta: {
@@ -103,7 +103,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
103
103
  }));
104
104
  } else {
105
105
  if (platform === 'mobile') {
106
- const resolvedInlineViewProps = extractInlineProps(data);
106
+ const resolvedInlineViewProps = extractInlineProps(details);
107
107
  return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedInlineViewProps, {
108
108
  isSelected: isSelected,
109
109
  testId: testId,
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useEffect } from 'react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
- import { extractProvider } from '@atlaskit/link-extractors';
4
+ import { extractProvider, extractSmartLinkProvider } from '@atlaskit/link-extractors';
5
5
  import { useFeatureFlag } from '@atlaskit/link-provider';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { SmartLinkStatus } from '../../constants';
7
8
  import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
8
9
  import { extractInlineProps } from '../../extractors/inline';
@@ -50,7 +51,7 @@ export const InlineCard = ({
50
51
  if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
51
52
  showHoverPreview = Boolean(showHoverPreviewFlag);
52
53
  }
53
- const resolvedProps = status === SmartLinkStatus.Resolved ? extractInlineProps(cardDetails, renderers, removeTextHighlightingFromTitle, false) : {};
54
+ const resolvedProps = status === SmartLinkStatus.Resolved ? extractInlineProps(details, renderers, removeTextHighlightingFromTitle, false) : {};
54
55
  useEffect(() => {
55
56
  switch (status) {
56
57
  case SmartLinkStatus.Resolved:
@@ -99,7 +100,7 @@ export const InlineCard = ({
99
100
  truncateInline: truncateInline
100
101
  }));
101
102
  case 'unauthorized':
102
- const provider = extractProvider(cardDetails);
103
+ const provider = fg('smart_links_noun_support') ? extractSmartLinkProvider(details) : extractProvider(cardDetails);
103
104
  return /*#__PURE__*/React.createElement(InlineCardUnauthorizedView, {
104
105
  icon: provider && provider.icon,
105
106
  context: provider && provider.text,
@@ -114,7 +115,7 @@ export const InlineCard = ({
114
115
  truncateInline: truncateInline
115
116
  });
116
117
  case 'forbidden':
117
- const providerForbidden = extractProvider(cardDetails);
118
+ const providerForbidden = fg('smart_links_noun_support') ? extractSmartLinkProvider(details) : extractProvider(cardDetails);
118
119
  const cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
119
120
  const requestAccessContext = extractRequestAccessContextImproved({
120
121
  jsonLd: cardMetadata,
@@ -135,7 +136,7 @@ export const InlineCard = ({
135
136
  truncateInline: truncateInline
136
137
  });
137
138
  case 'not_found':
138
- const providerNotFound = extractProvider(cardDetails);
139
+ const providerNotFound = fg('smart_links_noun_support') ? extractSmartLinkProvider(details) : extractProvider(cardDetails);
139
140
  return /*#__PURE__*/React.createElement(InlineCardErroredView, {
140
141
  url: url,
141
142
  icon: providerNotFound && providerNotFound.icon,
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
10
10
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
11
11
  const PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "36.8.0",
13
+ packageVersion: "36.8.1",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  const Anchor = withLinkClickedEvent('a');
@@ -1,10 +1,13 @@
1
- import { extractLink, extractProvider, extractTitle } from '@atlaskit/link-extractors';
1
+ import { extractEntityProvider, extractLink, extractProvider,
2
+ // extractSmartLinkIcon,
3
+ extractSmartLinkTitle, extractSmartLinkUrl, extractTitle, isEntityPresent } from '@atlaskit/link-extractors';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
2
5
  import { extractIcon } from '../common/icon';
3
6
  import { extractLozenge } from '../common/lozenge';
4
7
  import { extractTitleTextColor } from '../common/primitives';
5
8
  import { extractTitlePrefix } from '../common/title-prefix';
6
9
  import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../constants';
7
- export var extractInlineIcon = function extractInlineIcon(jsonLd) {
10
+ var extractInlineIcon = function extractInlineIcon(jsonLd) {
8
11
  var showIconLabel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
9
12
  var provider = extractProvider(jsonLd);
10
13
  if (provider && provider.id) {
@@ -14,8 +17,35 @@ export var extractInlineIcon = function extractInlineIcon(jsonLd) {
14
17
  }
15
18
  return extractIcon(jsonLd, 'provider', showIconLabel);
16
19
  };
17
- export var extractInlineProps = function extractInlineProps(jsonLd, renderers, removeTextHighlightingFromTitle) {
20
+ var extractSmartLinkInlineIcon = function extractSmartLinkInlineIcon(response) {
21
+ var showLabel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
22
+ if (isEntityPresent(response)) {
23
+ var provider = extractEntityProvider(response);
24
+ if (provider) {
25
+ return provider.icon;
26
+ }
27
+ // We don't need this for design entities,
28
+ // but we can add it back when we support more nouns
29
+ // it requires extractInlineIcon to be moved to the smart link extractor package.
30
+ // see: https://product-fabric.atlassian.net/browse/EDM-12375
31
+ // return extractSmartLinkIcon(response);
32
+ }
33
+ return extractInlineIcon(response === null || response === void 0 ? void 0 : response.data, showLabel);
34
+ };
35
+ export var extractInlineProps = function extractInlineProps(response, renderers, removeTextHighlightingFromTitle) {
18
36
  var showLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
37
+ var jsonLd = response === null || response === void 0 ? void 0 : response.data;
38
+ if (fg('smart_links_noun_support')) {
39
+ return {
40
+ icon: extractSmartLinkInlineIcon(response, showLabel),
41
+ link: extractSmartLinkUrl(response),
42
+ title: extractSmartLinkTitle(response, removeTextHighlightingFromTitle),
43
+ // As we migrate to support more nouns we can incorporate these fields
44
+ lozenge: extractLozenge(jsonLd),
45
+ titleTextColor: extractTitleTextColor(jsonLd),
46
+ titlePrefix: extractTitlePrefix(jsonLd, renderers, 'inline')
47
+ };
48
+ }
19
49
  return {
20
50
  link: extractLink(jsonLd),
21
51
  title: extractTitle(jsonLd, removeTextHighlightingFromTitle),
@@ -1,7 +1,9 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { useCallback } from 'react';
4
+ import { isEntityPresent } from '@atlaskit/link-extractors';
4
5
  import { useSmartLinkContext } from '@atlaskit/link-provider';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
5
7
  import { SmartLinkStatus } from '../../../constants';
6
8
  import { addMetadataToExperience } from '../../analytics';
7
9
  import useResponse from '../use-response';
@@ -36,7 +38,7 @@ var useResolve = function useResolve() {
36
38
  status: SmartLinkStatus.Pending,
37
39
  details: undefined
38
40
  }, details = _ref2.details;
39
- hasData = !!(details && details.data);
41
+ hasData = fg('smart_links_noun_support') ? !!(details && details.data || isEntityPresent(details)) : !!(details && details.data);
40
42
  if (!(isReloading || !hasData || isMetadataRequest)) {
41
43
  _context.next = 9;
42
44
  break;
@@ -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: "36.8.0"
7
+ packageVersion: "36.8.1"
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -79,17 +79,45 @@ var successfulResponseData = _objectSpread(_objectSpread({}, errorResponseData),
79
79
  href: 'https://www.ilovecheese.com'
80
80
  }
81
81
  });
82
- export var mocks = {
83
- success: {
84
- meta: {
85
- visibility: 'public',
86
- access: 'granted',
87
- auth: [],
88
- definitionId: 'd1',
89
- key: 'object-provider'
90
- },
91
- data: successfulResponseData
82
+ var jsonLdResponse = {
83
+ meta: {
84
+ visibility: 'public',
85
+ access: 'granted',
86
+ auth: [],
87
+ definitionId: 'd1',
88
+ key: 'object-provider'
92
89
  },
90
+ data: successfulResponseData
91
+ };
92
+ var nounDataResponse = {
93
+ nounData: {
94
+ id: 'I love cheese',
95
+ displayName: 'I love cheese',
96
+ url: 'https://some.url',
97
+ lastUpdatedAt: '2025-01-08T22:26:52.501Z',
98
+ thumbnail: {
99
+ externalUrl: 'https://www.ilovecheese.com'
100
+ },
101
+ 'atlassian:design': {
102
+ liveEmbedUrl: 'https://www.ilovecheese.com',
103
+ type: 'FILE',
104
+ inspectUrl: 'https://www.ilovecheese.com',
105
+ iconUrl: 'https://www.ilovecheese.com'
106
+ }
107
+ }
108
+ };
109
+ export var mocks = {
110
+ success: _objectSpread({}, jsonLdResponse),
111
+ nounDataSuccess: _objectSpread(_objectSpread(_objectSpread({}, jsonLdResponse), nounDataResponse), {}, {
112
+ meta: _objectSpread(_objectSpread({}, jsonLdResponse.meta), {}, {
113
+ generator: {
114
+ name: 'I love cheese',
115
+ icon: {
116
+ url: 'https://www.ilovecheese.com'
117
+ }
118
+ }
119
+ })
120
+ }),
93
121
  notFound: {
94
122
  meta: {
95
123
  visibility: 'not_found',
@@ -99,7 +99,7 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
99
99
  }));
100
100
  } else {
101
101
  if (platform === 'mobile') {
102
- var resolvedInlineViewProps = extractInlineProps(data);
102
+ var resolvedInlineViewProps = extractInlineProps(details);
103
103
  return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedInlineViewProps, {
104
104
  isSelected: isSelected,
105
105
  testId: testId,
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useEffect } from 'react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
- import { extractProvider } from '@atlaskit/link-extractors';
4
+ import { extractProvider, extractSmartLinkProvider } from '@atlaskit/link-extractors';
5
5
  import { useFeatureFlag } from '@atlaskit/link-provider';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { SmartLinkStatus } from '../../constants';
7
8
  import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
8
9
  import { extractInlineProps } from '../../extractors/inline';
@@ -46,7 +47,7 @@ export var InlineCard = function InlineCard(_ref) {
46
47
  if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
47
48
  showHoverPreview = Boolean(showHoverPreviewFlag);
48
49
  }
49
- var resolvedProps = status === SmartLinkStatus.Resolved ? extractInlineProps(cardDetails, renderers, removeTextHighlightingFromTitle, false) : {};
50
+ var resolvedProps = status === SmartLinkStatus.Resolved ? extractInlineProps(details, renderers, removeTextHighlightingFromTitle, false) : {};
50
51
  useEffect(function () {
51
52
  switch (status) {
52
53
  case SmartLinkStatus.Resolved:
@@ -95,7 +96,7 @@ export var InlineCard = function InlineCard(_ref) {
95
96
  truncateInline: truncateInline
96
97
  }));
97
98
  case 'unauthorized':
98
- var provider = extractProvider(cardDetails);
99
+ var provider = fg('smart_links_noun_support') ? extractSmartLinkProvider(details) : extractProvider(cardDetails);
99
100
  return /*#__PURE__*/React.createElement(InlineCardUnauthorizedView, {
100
101
  icon: provider && provider.icon,
101
102
  context: provider && provider.text,
@@ -110,7 +111,7 @@ export var InlineCard = function InlineCard(_ref) {
110
111
  truncateInline: truncateInline
111
112
  });
112
113
  case 'forbidden':
113
- var providerForbidden = extractProvider(cardDetails);
114
+ var providerForbidden = fg('smart_links_noun_support') ? extractSmartLinkProvider(details) : extractProvider(cardDetails);
114
115
  var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
115
116
  var requestAccessContext = extractRequestAccessContextImproved({
116
117
  jsonLd: cardMetadata,
@@ -131,7 +132,7 @@ export var InlineCard = function InlineCard(_ref) {
131
132
  truncateInline: truncateInline
132
133
  });
133
134
  case 'not_found':
134
- var providerNotFound = extractProvider(cardDetails);
135
+ var providerNotFound = fg('smart_links_noun_support') ? extractSmartLinkProvider(details) : extractProvider(cardDetails);
135
136
  return /*#__PURE__*/React.createElement(InlineCardErroredView, {
136
137
  url: url,
137
138
  icon: providerNotFound && providerNotFound.icon,
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
13
13
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
14
14
  var PACKAGE_DATA = {
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "36.8.0",
16
+ packageVersion: "36.8.1",
17
17
  componentName: 'linkUrl'
18
18
  };
19
19
  var Anchor = withLinkClickedEvent('a');
@@ -1,6 +1,4 @@
1
- /// <reference types="react" />
2
- import { type JsonLd } from '@atlaskit/json-ld-types';
3
1
  import { type CardProviderRenderers } from '@atlaskit/link-provider';
2
+ import { SmartLinkResponse } from '@atlaskit/linking-types';
4
3
  import { type InlineCardResolvedViewProps } from '../../view/InlineCard/ResolvedView';
5
- export declare const extractInlineIcon: (jsonLd: JsonLd.Data.BaseData, showIconLabel?: boolean) => import("react").ReactNode;
6
- export declare const extractInlineProps: (jsonLd: JsonLd.Data.BaseData, renderers?: CardProviderRenderers, removeTextHighlightingFromTitle?: boolean, showLabel?: boolean) => InlineCardResolvedViewProps;
4
+ export declare const extractInlineProps: (response?: SmartLinkResponse, renderers?: CardProviderRenderers, removeTextHighlightingFromTitle?: boolean, showLabel?: boolean) => InlineCardResolvedViewProps;
@@ -1,4 +1,5 @@
1
1
  import { type JsonLd } from '@atlaskit/json-ld-types';
2
+ import { SmartLinkResponse } from '@atlaskit/linking-types';
2
3
  export declare const mockContext: {
3
4
  readonly '@vocab': "https://www.w3.org/ns/activitystreams#";
4
5
  readonly atlassian: "https://schema.atlassian.com/ns/vocabulary#";
@@ -12,6 +13,7 @@ export declare const mockGenerator: {
12
13
  export declare const mockByUrl: (url: string) => JsonLd.Response<JsonLd.Data.BaseData>;
13
14
  export declare const mocks: {
14
15
  success: JsonLd.Response<JsonLd.Data.BaseData>;
16
+ nounDataSuccess: SmartLinkResponse;
15
17
  notFound: JsonLd.Response<JsonLd.Data.BaseData>;
16
18
  forbidden: JsonLd.Response<JsonLd.Data.BaseData>;
17
19
  forbiddenWithNoAuth: JsonLd.Response<JsonLd.Data.BaseData>;
@@ -1,6 +1,4 @@
1
- /// <reference types="react" />
2
- import { type JsonLd } from '@atlaskit/json-ld-types';
3
1
  import { type CardProviderRenderers } from '@atlaskit/link-provider';
2
+ import { SmartLinkResponse } from '@atlaskit/linking-types';
4
3
  import { type InlineCardResolvedViewProps } from '../../view/InlineCard/ResolvedView';
5
- export declare const extractInlineIcon: (jsonLd: JsonLd.Data.BaseData, showIconLabel?: boolean) => import("react").ReactNode;
6
- export declare const extractInlineProps: (jsonLd: JsonLd.Data.BaseData, renderers?: CardProviderRenderers, removeTextHighlightingFromTitle?: boolean, showLabel?: boolean) => InlineCardResolvedViewProps;
4
+ export declare const extractInlineProps: (response?: SmartLinkResponse, renderers?: CardProviderRenderers, removeTextHighlightingFromTitle?: boolean, showLabel?: boolean) => InlineCardResolvedViewProps;
@@ -1,4 +1,5 @@
1
1
  import { type JsonLd } from '@atlaskit/json-ld-types';
2
+ import { SmartLinkResponse } from '@atlaskit/linking-types';
2
3
  export declare const mockContext: {
3
4
  readonly '@vocab': "https://www.w3.org/ns/activitystreams#";
4
5
  readonly atlassian: "https://schema.atlassian.com/ns/vocabulary#";
@@ -12,6 +13,7 @@ export declare const mockGenerator: {
12
13
  export declare const mockByUrl: (url: string) => JsonLd.Response<JsonLd.Data.BaseData>;
13
14
  export declare const mocks: {
14
15
  success: JsonLd.Response<JsonLd.Data.BaseData>;
16
+ nounDataSuccess: SmartLinkResponse;
15
17
  notFound: JsonLd.Response<JsonLd.Data.BaseData>;
16
18
  forbidden: JsonLd.Response<JsonLd.Data.BaseData>;
17
19
  forbiddenWithNoAuth: JsonLd.Response<JsonLd.Data.BaseData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "36.8.0",
3
+ "version": "36.8.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -41,8 +41,8 @@
41
41
  "@atlaskit/heading": "^5.2.0",
42
42
  "@atlaskit/icon": "^25.6.0",
43
43
  "@atlaskit/icon-file-type": "^7.0.0",
44
- "@atlaskit/icon-lab": "^4.8.0",
45
- "@atlaskit/icon-object": "^7.0.0",
44
+ "@atlaskit/icon-lab": "^4.9.0",
45
+ "@atlaskit/icon-object": "^7.1.0",
46
46
  "@atlaskit/icon-priority": "^6.3.0",
47
47
  "@atlaskit/image": "^3.0.0",
48
48
  "@atlaskit/json-ld-types": "^1.1.0",
@@ -50,16 +50,16 @@
50
50
  "@atlaskit/link": "^3.1.0",
51
51
  "@atlaskit/link-analytics": "^9.1.0",
52
52
  "@atlaskit/link-client-extension": "^4.0.0",
53
- "@atlaskit/link-extractors": "^2.1.0",
53
+ "@atlaskit/link-extractors": "^2.2.0",
54
54
  "@atlaskit/linking-common": "^8.0.0",
55
- "@atlaskit/linking-types": "^9.8.0",
55
+ "@atlaskit/linking-types": "^9.9.0",
56
56
  "@atlaskit/logo": "^16.0.0",
57
57
  "@atlaskit/lozenge": "^12.2.0",
58
58
  "@atlaskit/menu": "^3.2.0",
59
59
  "@atlaskit/modal-dialog": "^14.1.0",
60
60
  "@atlaskit/outbound-auth-flow-client": "^3.4.0",
61
61
  "@atlaskit/platform-feature-flags": "^1.1.0",
62
- "@atlaskit/popup": "^4.0.0",
62
+ "@atlaskit/popup": "^4.1.0",
63
63
  "@atlaskit/primitives": "^14.4.0",
64
64
  "@atlaskit/section-message": "^8.2.0",
65
65
  "@atlaskit/select": "^20.3.0",
@@ -97,7 +97,7 @@
97
97
  "@atlaskit/css-reset": "^7.2.0",
98
98
  "@atlaskit/link-test-helpers": "^8.0.0",
99
99
  "@atlaskit/media-test-helpers": "^35.0.0",
100
- "@atlaskit/react-ufo": "^3.5.0",
100
+ "@atlaskit/react-ufo": "^3.6.0",
101
101
  "@atlaskit/ssr": "^0.4.0",
102
102
  "@atlaskit/visual-regression": "^0.10.0",
103
103
  "@atlassian/analytics-tooling": "^0.5.0",
@@ -223,6 +223,9 @@
223
223
  },
224
224
  "platform-linking-flexible-card-openness": {
225
225
  "type": "boolean"
226
+ },
227
+ "smart_links_noun_support": {
228
+ "type": "boolean"
226
229
  }
227
230
  }
228
231
  }