@atlaskit/smart-card 26.27.1 → 26.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +6 -2
  3. package/dist/cjs/state/helpers.js +11 -2
  4. package/dist/cjs/utils/analytics/analytics.js +5 -3
  5. package/dist/cjs/utils/mocks.js +53 -71
  6. package/dist/cjs/view/CardWithUrl/component.js +4 -2
  7. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +5 -3
  8. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +4 -2
  9. package/dist/cjs/view/FlexibleCard/components/elements/index.js +10 -3
  10. package/dist/cjs/view/FlexibleCard/components/elements/preview/index.js +35 -0
  11. package/dist/cjs/view/FlexibleCard/components/elements/preview/types.js +5 -0
  12. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +5 -2
  13. package/dist/cjs/view/LinkUrl/index.js +1 -1
  14. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +5 -2
  15. package/dist/es2019/state/helpers.js +5 -0
  16. package/dist/es2019/utils/analytics/analytics.js +5 -3
  17. package/dist/es2019/utils/mocks.js +51 -71
  18. package/dist/es2019/view/CardWithUrl/component.js +5 -3
  19. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +4 -2
  20. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +3 -1
  21. package/dist/es2019/view/FlexibleCard/components/elements/index.js +1 -1
  22. package/dist/es2019/view/FlexibleCard/components/elements/preview/index.js +23 -0
  23. package/dist/es2019/view/FlexibleCard/components/elements/preview/types.js +1 -0
  24. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +5 -2
  25. package/dist/es2019/view/LinkUrl/index.js +1 -1
  26. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +6 -2
  27. package/dist/esm/state/helpers.js +7 -0
  28. package/dist/esm/utils/analytics/analytics.js +5 -3
  29. package/dist/esm/utils/mocks.js +53 -71
  30. package/dist/esm/view/CardWithUrl/component.js +5 -3
  31. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +5 -3
  32. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +4 -2
  33. package/dist/esm/view/FlexibleCard/components/elements/index.js +1 -1
  34. package/dist/esm/view/FlexibleCard/components/elements/preview/index.js +24 -0
  35. package/dist/esm/view/FlexibleCard/components/elements/preview/types.js +1 -0
  36. package/dist/esm/view/HoverCard/components/views/resolved/index.js +5 -2
  37. package/dist/esm/view/LinkUrl/index.js +1 -1
  38. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -1
  39. package/dist/types/state/helpers.d.ts +3 -0
  40. package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
  41. package/dist/types/utils/analytics/analytics.d.ts +1 -1
  42. package/dist/types/utils/analytics/types.d.ts +1 -0
  43. package/dist/types/utils/mocks.d.ts +42 -1
  44. package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +1 -1
  45. package/dist/types/view/FlexibleCard/components/blocks/preview-block/types.d.ts +4 -0
  46. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +1 -2
  47. package/dist/types/view/FlexibleCard/components/elements/preview/index.d.ts +5 -0
  48. package/dist/types/view/FlexibleCard/components/elements/preview/types.d.ts +13 -0
  49. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +2 -1
  50. package/dist/types-ts4.5/state/helpers.d.ts +3 -0
  51. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +1 -1
  52. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +1 -1
  53. package/dist/types-ts4.5/utils/analytics/types.d.ts +1 -0
  54. package/dist/types-ts4.5/utils/mocks.d.ts +42 -1
  55. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/preview-block/index.d.ts +1 -1
  56. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/preview-block/types.d.ts +4 -0
  57. package/dist/types-ts4.5/view/FlexibleCard/components/elements/index.d.ts +1 -2
  58. package/dist/types-ts4.5/view/FlexibleCard/components/elements/preview/index.d.ts +5 -0
  59. package/dist/types-ts4.5/view/FlexibleCard/components/elements/preview/types.d.ts +13 -0
  60. package/package.json +5 -5
  61. package/report.api.md +3 -0
  62. package/tmp/api-report-tmp.d.ts +3 -1
@@ -35,6 +35,30 @@ export const mockByUrl = url => {
35
35
  }
36
36
  };
37
37
  };
38
+ const errorResponseData = {
39
+ '@context': {
40
+ '@vocab': 'https://www.w3.org/ns/activitystreams#',
41
+ atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
42
+ schema: 'http://schema.org/'
43
+ },
44
+ '@type': 'Object',
45
+ name: 'I love cheese',
46
+ url: 'https://some.url'
47
+ };
48
+ const successfulResponseData = {
49
+ ...errorResponseData,
50
+ summary: 'Here is your serving of cheese: 🧀',
51
+ 'schema:potentialAction': {
52
+ '@id': 'download',
53
+ '@type': 'DownloadAction',
54
+ identifier: 'object-provider',
55
+ name: 'Download'
56
+ },
57
+ 'atlassian:downloadUrl': 'https://some-download.url',
58
+ preview: {
59
+ href: 'https://www.ilovecheese.com'
60
+ }
61
+ };
38
62
  export const mocks = {
39
63
  success: {
40
64
  meta: {
@@ -44,27 +68,7 @@ export const mocks = {
44
68
  definitionId: 'd1',
45
69
  key: 'object-provider'
46
70
  },
47
- data: {
48
- '@context': {
49
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
50
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
51
- schema: 'http://schema.org/'
52
- },
53
- '@type': 'Object',
54
- name: 'I love cheese',
55
- summary: 'Here is your serving of cheese: 🧀',
56
- 'schema:potentialAction': {
57
- '@id': 'download',
58
- '@type': 'DownloadAction',
59
- identifier: 'object-provider',
60
- name: 'Download'
61
- },
62
- 'atlassian:downloadUrl': 'https://some-download.url',
63
- preview: {
64
- href: 'https://www.ilovecheese.com'
65
- },
66
- url: 'https://some.url'
67
- }
71
+ data: successfulResponseData
68
72
  },
69
73
  notFound: {
70
74
  meta: {
@@ -74,16 +78,7 @@ export const mocks = {
74
78
  definitionId: 'd1',
75
79
  key: 'object-provider'
76
80
  },
77
- data: {
78
- '@context': {
79
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
80
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
81
- schema: 'http://schema.org/'
82
- },
83
- '@type': 'Object',
84
- name: 'I love cheese',
85
- url: 'https://some.url'
86
- }
81
+ data: errorResponseData
87
82
  },
88
83
  forbidden: {
89
84
  meta: {
@@ -97,16 +92,7 @@ export const mocks = {
97
92
  definitionId: 'd1',
98
93
  key: 'object-provider'
99
94
  },
100
- data: {
101
- '@context': {
102
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
103
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
104
- schema: 'http://schema.org/'
105
- },
106
- '@type': 'Object',
107
- name: 'I love cheese',
108
- url: 'https://some.url'
109
- }
95
+ data: errorResponseData
110
96
  },
111
97
  forbiddenWithNoAuth: {
112
98
  meta: {
@@ -116,16 +102,7 @@ export const mocks = {
116
102
  definitionId: 'd1',
117
103
  key: 'object-provider'
118
104
  },
119
- data: {
120
- '@context': {
121
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
122
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
123
- schema: 'http://schema.org/'
124
- },
125
- '@type': 'Object',
126
- name: 'I love cheese',
127
- url: 'https://some.url'
128
- }
105
+ data: errorResponseData
129
106
  },
130
107
  unauthorized: {
131
108
  meta: {
@@ -139,16 +116,7 @@ export const mocks = {
139
116
  definitionId: 'd1',
140
117
  key: 'object-provider'
141
118
  },
142
- data: {
143
- '@context': {
144
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
145
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
146
- schema: 'http://schema.org/'
147
- },
148
- '@type': 'Object',
149
- name: 'I love cheese',
150
- url: 'https://some.url'
151
- }
119
+ data: errorResponseData
152
120
  },
153
121
  unauthorizedWithNoAuth: {
154
122
  meta: {
@@ -158,16 +126,7 @@ export const mocks = {
158
126
  definitionId: 'd1',
159
127
  key: 'object-provider'
160
128
  },
161
- data: {
162
- '@context': {
163
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
164
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
165
- schema: 'http://schema.org/'
166
- },
167
- '@type': 'Object',
168
- name: 'I love cheese',
169
- url: 'https://some.url'
170
- }
129
+ data: errorResponseData
171
130
  },
172
131
  actionSuccess: {
173
132
  meta: {
@@ -191,6 +150,27 @@ export const mocks = {
191
150
  product: 'spaghetti-product'
192
151
  }
193
152
  }
153
+ },
154
+ withDatasource: {
155
+ meta: {
156
+ visibility: 'public',
157
+ access: 'granted',
158
+ auth: [],
159
+ definitionId: 'd1',
160
+ key: 'object-provider'
161
+ },
162
+ data: successfulResponseData,
163
+ datasources: [{
164
+ key: 'datasource-jira-issues',
165
+ parameters: {
166
+ jql: '(text ~ "test*" OR summary ~ "test*") order by created DESC',
167
+ cloudId: '16f8b71e'
168
+ },
169
+ id: '1234-test-id-321',
170
+ ari: 'ari:cloud:linking-platform::datasource/1234-test-id-321',
171
+ description: 'For extracting a list of Jira issues using JQL',
172
+ name: 'Jira issues'
173
+ }]
194
174
  }
195
175
  };
196
176
  export const fakeResponse = () => Promise.resolve(mocks.success);
@@ -3,7 +3,7 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { useFeatureFlag } from '@atlaskit/link-provider';
4
4
  import { isSpecialEvent } from '../../utils';
5
5
  import * as measure from '../../utils/performance';
6
- import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
6
+ import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct, getCanBeDatasource } from '../../state/helpers';
7
7
  import { useSmartLink } from '../../state';
8
8
  import { BlockCard } from '../BlockCard';
9
9
  import { InlineCard } from '../InlineCard';
@@ -60,6 +60,7 @@ function Component({
60
60
  const product = getProduct(state.details);
61
61
  const subproduct = getSubproduct(state.details);
62
62
  const services = getServices(state.details);
63
+ const canBeDatasource = getCanBeDatasource(state.details);
63
64
  let isFlexibleUi = useMemo(() => isFlexibleUiCard(children), [children]);
64
65
  const enableFlexibleBlockCardFlag = Boolean(useFeatureFlag('enableFlexibleBlockCard'));
65
66
  const showServerActions = showServerActionsProp && platform !== 'mobile';
@@ -131,10 +132,11 @@ function Component({
131
132
  status: state.status,
132
133
  id,
133
134
  definitionId,
134
- extensionKey
135
+ extensionKey,
136
+ canBeDatasource
135
137
  });
136
138
  }
137
- }, [isFlexibleUi, appearance, state.status, url, definitionId, extensionKey, analytics.ui, id]);
139
+ }, [isFlexibleUi, appearance, state.status, url, definitionId, extensionKey, analytics.ui, id, canBeDatasource]);
138
140
  const onIframeDwell = useCallback((dwellTime, dwellPercentVisible) => {
139
141
  analytics.ui.iframeDwelledEvent({
140
142
  id,
@@ -8,19 +8,21 @@ import PreviewBlockResolvedView from './resolved';
8
8
  /**
9
9
  * Represents a PreviewBlock, which typically contains media or other large format content.
10
10
  * @public
11
- * @param {PreviewBlock} PreviewBlock
11
+ * @param {PreviewBlockProps} PreviewBlock
12
12
  * @see Block
13
13
  */
14
14
  const PreviewBlock = ({
15
15
  status = SmartLinkStatus.Fallback,
16
16
  testId = 'smart-block-preview',
17
+ overrideUrl,
17
18
  ...blockProps
18
19
  }) => {
19
20
  if (status !== SmartLinkStatus.Resolved) {
20
21
  return null;
21
22
  }
22
23
  return jsx(PreviewBlockResolvedView, _extends({}, blockProps, {
23
- testId: testId
24
+ testId: testId,
25
+ overrideUrl: overrideUrl
24
26
  }));
25
27
  };
26
28
  export default PreviewBlock;
@@ -68,6 +68,7 @@ const PreviewBlockResolvedView = ({
68
68
  overrideCss,
69
69
  placement,
70
70
  testId,
71
+ overrideUrl,
71
72
  ...blockProps
72
73
  }) => {
73
74
  const [styles, setStyles] = useState(overrideCss);
@@ -93,7 +94,8 @@ const PreviewBlockResolvedView = ({
93
94
  testId: `${testId}-resolved-view`
94
95
  }), jsx(Preview, {
95
96
  onError: handleOnError,
96
- onLoad: handleOnLoad
97
+ onLoad: handleOnLoad,
98
+ overrideUrl: overrideUrl
97
99
  }));
98
100
  };
99
101
  export default PreviewBlockResolvedView;
@@ -92,7 +92,7 @@ export const OwnedByGroup = createElement(ElementName.OwnedByGroup);
92
92
  * Creates a Preview element using the data from Preview in the Flexible UI Context.
93
93
  * @see Preview
94
94
  */
95
- export const Preview = createElement(ElementName.Preview);
95
+ export { default as Preview } from './preview';
96
96
  /**
97
97
  * Creates a Priority Badge element using the data from Priority in the Flexible UI Context.
98
98
  * @see Badge
@@ -0,0 +1,23 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /** @jsx jsx */
3
+ import React, { useContext } from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import { FlexibleUiContext } from '../../../../../state/flexible-ui-context';
6
+ import { MediaType } from '../../../../../constants';
7
+ import Media from '../media';
8
+ const Preview = props => {
9
+ const {
10
+ overrideUrl,
11
+ ...rest
12
+ } = props !== null && props !== void 0 ? props : {};
13
+ const context = useContext(FlexibleUiContext);
14
+ const data = overrideUrl ? {
15
+ url: overrideUrl,
16
+ type: MediaType.Image
17
+ } : context === null || context === void 0 ? void 0 : context.preview;
18
+ if (!data) {
19
+ return null;
20
+ }
21
+ return jsx(Media, _extends({}, rest, data));
22
+ };
23
+ export default Preview;
@@ -10,6 +10,7 @@ import { extractMetadata, elementNamesToItems } from '../../../../../extractors/
10
10
  import { messages } from '../../../../../messages';
11
11
  import { FormattedMessage } from 'react-intl-next';
12
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
+ import { getCanBeDatasource } from '../../../../../state/helpers';
13
14
  export const toFooterActions = (cardActions, onActionClick) => {
14
15
  const followAction = {
15
16
  hideIcon: true,
@@ -56,14 +57,16 @@ const HoverCardResolvedView = ({
56
57
  extensionKey
57
58
  }) => {
58
59
  var _cardState$details;
60
+ const canBeDatasource = getCanBeDatasource(cardState.details);
59
61
  useEffect(() => {
60
62
  // Since this hover view is only rendered on resolved status,
61
63
  // there is no need to check for statuses.
62
64
  analytics.ui.renderSuccessEvent({
63
65
  display: CardDisplay.HoverCardPreview,
64
- status: cardState.status
66
+ status: cardState.status,
67
+ canBeDatasource
65
68
  });
66
- }, [analytics.ui, cardState.status]);
69
+ }, [analytics.ui, cardState.status, canBeDatasource]);
67
70
  const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick), [cardActions, onActionClick]);
68
71
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
69
72
  const {
@@ -8,7 +8,7 @@ import LinkWarningModal from './LinkWarningModal';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
9
  const PACKAGE_DATA = {
10
10
  packageName: "@atlaskit/smart-card",
11
- packageVersion: "26.27.1",
11
+ packageVersion: "26.28.0",
12
12
  componentName: 'linkUrl'
13
13
  };
14
14
  const Link = withLinkClickedEvent('a');
@@ -346,6 +346,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
346
346
  * @param id The unique ID for this Smart Link.
347
347
  * @param definitionId The definitionId of the Smart Link resolver invoked.
348
348
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
349
+ * @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
349
350
  */
350
351
  renderSuccessEvent: function renderSuccessEvent(_ref9) {
351
352
  var display = _ref9.display,
@@ -356,7 +357,9 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
356
357
  resourceType = _ref9.resourceType,
357
358
  destinationProduct = _ref9.destinationProduct,
358
359
  destinationSubproduct = _ref9.destinationSubproduct,
359
- location = _ref9.location;
360
+ location = _ref9.location,
361
+ _ref9$canBeDatasource = _ref9.canBeDatasource,
362
+ canBeDatasource = _ref9$canBeDatasource === void 0 ? false : _ref9$canBeDatasource;
360
363
  var experienceId = id ? id : defaultId;
361
364
  succeedUfoExperience('smart-link-rendered', experienceId, {
362
365
  extensionKey: extensionKey,
@@ -375,7 +378,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatch
375
378
  resourceType: resourceType,
376
379
  destinationProduct: destinationProduct,
377
380
  destinationSubproduct: destinationSubproduct,
378
- location: location
381
+ location: location,
382
+ canBeDatasource: canBeDatasource
379
383
  }), commonAttributes));
380
384
  },
381
385
  /**
@@ -55,4 +55,11 @@ export var getStatusDetails = function getStatusDetails(details) {
55
55
  };
56
56
  export var isFinalState = function isFinalState(status) {
57
57
  return ['unauthorized', 'forbidden', 'errored', 'resolved', 'not_found'].indexOf(status) > -1;
58
+ };
59
+ export var getDatasources = function getDatasources(details) {
60
+ return details === null || details === void 0 ? void 0 : details.datasources;
61
+ };
62
+ export var getCanBeDatasource = function getCanBeDatasource(details) {
63
+ var datasources = getDatasources(details);
64
+ return !!datasources && datasources.length > 0;
58
65
  };
@@ -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.27.1"
18
+ packageVersion: "26.28.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -487,7 +487,8 @@ export var uiRenderSuccessEvent = function uiRenderSuccessEvent(_ref20) {
487
487
  definitionId = _ref20.definitionId,
488
488
  destinationProduct = _ref20.destinationProduct,
489
489
  destinationSubproduct = _ref20.destinationSubproduct,
490
- location = _ref20.location;
490
+ location = _ref20.location,
491
+ canBeDatasource = _ref20.canBeDatasource;
491
492
  return {
492
493
  action: 'renderSuccess',
493
494
  actionSubject: 'smartLink',
@@ -499,7 +500,8 @@ export var uiRenderSuccessEvent = function uiRenderSuccessEvent(_ref20) {
499
500
  destinationProduct: destinationProduct,
500
501
  destinationSubproduct: destinationSubproduct,
501
502
  location: location,
502
- display: display
503
+ display: display,
504
+ canBeDatasource: canBeDatasource
503
505
  })
504
506
  };
505
507
  };
@@ -4,9 +4,12 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
13
  import { CardClient } from '@atlaskit/link-provider';
11
14
  export var mockContext = {
12
15
  '@vocab': 'https://www.w3.org/ns/activitystreams#',
@@ -44,6 +47,29 @@ export var mockByUrl = function mockByUrl(url) {
44
47
  }
45
48
  };
46
49
  };
50
+ var errorResponseData = {
51
+ '@context': {
52
+ '@vocab': 'https://www.w3.org/ns/activitystreams#',
53
+ atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
54
+ schema: 'http://schema.org/'
55
+ },
56
+ '@type': 'Object',
57
+ name: 'I love cheese',
58
+ url: 'https://some.url'
59
+ };
60
+ var successfulResponseData = _objectSpread(_objectSpread({}, errorResponseData), {}, {
61
+ summary: 'Here is your serving of cheese: 🧀',
62
+ 'schema:potentialAction': {
63
+ '@id': 'download',
64
+ '@type': 'DownloadAction',
65
+ identifier: 'object-provider',
66
+ name: 'Download'
67
+ },
68
+ 'atlassian:downloadUrl': 'https://some-download.url',
69
+ preview: {
70
+ href: 'https://www.ilovecheese.com'
71
+ }
72
+ });
47
73
  export var mocks = {
48
74
  success: {
49
75
  meta: {
@@ -53,27 +79,7 @@ export var mocks = {
53
79
  definitionId: 'd1',
54
80
  key: 'object-provider'
55
81
  },
56
- data: {
57
- '@context': {
58
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
59
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
60
- schema: 'http://schema.org/'
61
- },
62
- '@type': 'Object',
63
- name: 'I love cheese',
64
- summary: 'Here is your serving of cheese: 🧀',
65
- 'schema:potentialAction': {
66
- '@id': 'download',
67
- '@type': 'DownloadAction',
68
- identifier: 'object-provider',
69
- name: 'Download'
70
- },
71
- 'atlassian:downloadUrl': 'https://some-download.url',
72
- preview: {
73
- href: 'https://www.ilovecheese.com'
74
- },
75
- url: 'https://some.url'
76
- }
82
+ data: successfulResponseData
77
83
  },
78
84
  notFound: {
79
85
  meta: {
@@ -83,16 +89,7 @@ export var mocks = {
83
89
  definitionId: 'd1',
84
90
  key: 'object-provider'
85
91
  },
86
- data: {
87
- '@context': {
88
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
89
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
90
- schema: 'http://schema.org/'
91
- },
92
- '@type': 'Object',
93
- name: 'I love cheese',
94
- url: 'https://some.url'
95
- }
92
+ data: errorResponseData
96
93
  },
97
94
  forbidden: {
98
95
  meta: {
@@ -106,16 +103,7 @@ export var mocks = {
106
103
  definitionId: 'd1',
107
104
  key: 'object-provider'
108
105
  },
109
- data: {
110
- '@context': {
111
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
112
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
113
- schema: 'http://schema.org/'
114
- },
115
- '@type': 'Object',
116
- name: 'I love cheese',
117
- url: 'https://some.url'
118
- }
106
+ data: errorResponseData
119
107
  },
120
108
  forbiddenWithNoAuth: {
121
109
  meta: {
@@ -125,16 +113,7 @@ export var mocks = {
125
113
  definitionId: 'd1',
126
114
  key: 'object-provider'
127
115
  },
128
- data: {
129
- '@context': {
130
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
131
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
132
- schema: 'http://schema.org/'
133
- },
134
- '@type': 'Object',
135
- name: 'I love cheese',
136
- url: 'https://some.url'
137
- }
116
+ data: errorResponseData
138
117
  },
139
118
  unauthorized: {
140
119
  meta: {
@@ -148,16 +127,7 @@ export var mocks = {
148
127
  definitionId: 'd1',
149
128
  key: 'object-provider'
150
129
  },
151
- data: {
152
- '@context': {
153
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
154
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
155
- schema: 'http://schema.org/'
156
- },
157
- '@type': 'Object',
158
- name: 'I love cheese',
159
- url: 'https://some.url'
160
- }
130
+ data: errorResponseData
161
131
  },
162
132
  unauthorizedWithNoAuth: {
163
133
  meta: {
@@ -167,16 +137,7 @@ export var mocks = {
167
137
  definitionId: 'd1',
168
138
  key: 'object-provider'
169
139
  },
170
- data: {
171
- '@context': {
172
- '@vocab': 'https://www.w3.org/ns/activitystreams#',
173
- atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
174
- schema: 'http://schema.org/'
175
- },
176
- '@type': 'Object',
177
- name: 'I love cheese',
178
- url: 'https://some.url'
179
- }
140
+ data: errorResponseData
180
141
  },
181
142
  actionSuccess: {
182
143
  meta: {
@@ -200,6 +161,27 @@ export var mocks = {
200
161
  product: 'spaghetti-product'
201
162
  }
202
163
  }
164
+ },
165
+ withDatasource: {
166
+ meta: {
167
+ visibility: 'public',
168
+ access: 'granted',
169
+ auth: [],
170
+ definitionId: 'd1',
171
+ key: 'object-provider'
172
+ },
173
+ data: successfulResponseData,
174
+ datasources: [{
175
+ key: 'datasource-jira-issues',
176
+ parameters: {
177
+ jql: '(text ~ "test*" OR summary ~ "test*") order by created DESC',
178
+ cloudId: '16f8b71e'
179
+ },
180
+ id: '1234-test-id-321',
181
+ ari: 'ari:cloud:linking-platform::datasource/1234-test-id-321',
182
+ description: 'For extracting a list of Jira issues using JQL',
183
+ name: 'Jira issues'
184
+ }]
203
185
  }
204
186
  };
205
187
  export var fakeResponse = function fakeResponse() {
@@ -3,7 +3,7 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { useFeatureFlag } from '@atlaskit/link-provider';
4
4
  import { isSpecialEvent } from '../../utils';
5
5
  import * as measure from '../../utils/performance';
6
- import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
6
+ import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct, getCanBeDatasource } from '../../state/helpers';
7
7
  import { useSmartLink } from '../../state';
8
8
  import { BlockCard } from '../BlockCard';
9
9
  import { InlineCard } from '../InlineCard';
@@ -57,6 +57,7 @@ function Component(_ref) {
57
57
  var product = getProduct(state.details);
58
58
  var subproduct = getSubproduct(state.details);
59
59
  var services = getServices(state.details);
60
+ var canBeDatasource = getCanBeDatasource(state.details);
60
61
  var isFlexibleUi = useMemo(function () {
61
62
  return isFlexibleUiCard(children);
62
63
  }, [children]);
@@ -134,10 +135,11 @@ function Component(_ref) {
134
135
  status: state.status,
135
136
  id: id,
136
137
  definitionId: definitionId,
137
- extensionKey: extensionKey
138
+ extensionKey: extensionKey,
139
+ canBeDatasource: canBeDatasource
138
140
  });
139
141
  }
140
- }, [isFlexibleUi, appearance, state.status, url, definitionId, extensionKey, analytics.ui, id]);
142
+ }, [isFlexibleUi, appearance, state.status, url, definitionId, extensionKey, analytics.ui, id, canBeDatasource]);
141
143
  var onIframeDwell = useCallback(function (dwellTime, dwellPercentVisible) {
142
144
  analytics.ui.iframeDwelledEvent({
143
145
  id: id,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["status", "testId"];
3
+ var _excluded = ["status", "testId", "overrideUrl"];
4
4
  /** @jsx jsx */
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
@@ -10,7 +10,7 @@ import PreviewBlockResolvedView from './resolved';
10
10
  /**
11
11
  * Represents a PreviewBlock, which typically contains media or other large format content.
12
12
  * @public
13
- * @param {PreviewBlock} PreviewBlock
13
+ * @param {PreviewBlockProps} PreviewBlock
14
14
  * @see Block
15
15
  */
16
16
  var PreviewBlock = function PreviewBlock(_ref) {
@@ -18,12 +18,14 @@ var PreviewBlock = function PreviewBlock(_ref) {
18
18
  status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
19
19
  _ref$testId = _ref.testId,
20
20
  testId = _ref$testId === void 0 ? 'smart-block-preview' : _ref$testId,
21
+ overrideUrl = _ref.overrideUrl,
21
22
  blockProps = _objectWithoutProperties(_ref, _excluded);
22
23
  if (status !== SmartLinkStatus.Resolved) {
23
24
  return null;
24
25
  }
25
26
  return jsx(PreviewBlockResolvedView, _extends({}, blockProps, {
26
- testId: testId
27
+ testId: testId,
28
+ overrideUrl: overrideUrl
27
29
  }));
28
30
  };
29
31
  export default PreviewBlock;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
- var _excluded = ["ignoreContainerPadding", "onError", "overrideCss", "placement", "testId"];
5
+ var _excluded = ["ignoreContainerPadding", "onError", "overrideCss", "placement", "testId", "overrideUrl"];
6
6
  var _templateObject, _templateObject2, _templateObject3;
7
7
  /** @jsx jsx */
8
8
  import React, { useCallback, useEffect, useState } from 'react';
@@ -49,6 +49,7 @@ var PreviewBlockResolvedView = function PreviewBlockResolvedView(_ref) {
49
49
  overrideCss = _ref.overrideCss,
50
50
  placement = _ref.placement,
51
51
  testId = _ref.testId,
52
+ overrideUrl = _ref.overrideUrl,
52
53
  blockProps = _objectWithoutProperties(_ref, _excluded);
53
54
  var _useState = useState(overrideCss),
54
55
  _useState2 = _slicedToArray(_useState, 2),
@@ -73,7 +74,8 @@ var PreviewBlockResolvedView = function PreviewBlockResolvedView(_ref) {
73
74
  testId: "".concat(testId, "-resolved-view")
74
75
  }), jsx(Preview, {
75
76
  onError: handleOnError,
76
- onLoad: handleOnLoad
77
+ onLoad: handleOnLoad,
78
+ overrideUrl: overrideUrl
77
79
  }));
78
80
  };
79
81
  export default PreviewBlockResolvedView;