@atlaskit/smart-card 36.9.0 → 36.10.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 +24 -0
- package/dist/cjs/extractors/common/context/index.js +41 -1
- package/dist/cjs/extractors/common/icon/extractIconFromDocument.js +7 -61
- package/dist/cjs/extractors/embed/index.js +3 -35
- package/dist/cjs/extractors/flexible/extract-preview.js +24 -2
- package/dist/cjs/extractors/flexible/icon/extract-provider-icon.js +40 -2
- package/dist/cjs/extractors/flexible/icon/index.js +15 -1
- package/dist/cjs/extractors/flexible/index.js +77 -3
- package/dist/cjs/extractors/inline/index.js +5 -1
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/index.js +2 -256
- package/dist/cjs/utils/mocks.js +12 -2
- package/dist/cjs/view/BlockCard/views/ErroredView.js +1 -12
- package/dist/cjs/view/BlockCard/views/ForbiddenView.js +2 -11
- package/dist/cjs/view/BlockCard/views/NotFoundView.js +5 -15
- package/dist/cjs/view/BlockCard/views/UnauthorisedView.js +3 -3
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +3 -5
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +12 -36
- package/dist/cjs/view/FlexibleCard/components/common/image-icon/index.js +4 -17
- package/dist/cjs/view/FlexibleCard/components/common/loading-skeleton/index.js +2 -10
- package/dist/cjs/view/FlexibleCard/utils.js +21 -10
- package/dist/cjs/view/HoverCard/components/ImagePreview.js +16 -3
- package/dist/cjs/view/HoverCard/components/views/forbidden/index.js +2 -2
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +2 -2
- package/dist/cjs/view/HoverCard/components/views/resolving/index.js +5 -18
- package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +2 -2
- package/dist/cjs/view/InlineCard/ErroredView/index.js +5 -15
- package/dist/cjs/view/InlineCard/ForbiddenView/index.js +1 -7
- package/dist/cjs/view/InlineCard/Icon.compiled.css +0 -1
- package/dist/cjs/view/InlineCard/Icon.js +4 -24
- package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +7 -15
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/common/context/index.js +36 -1
- package/dist/es2019/extractors/common/icon/extractIconFromDocument.js +6 -61
- package/dist/es2019/extractors/embed/index.js +2 -35
- package/dist/es2019/extractors/flexible/extract-preview.js +25 -2
- package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +42 -2
- package/dist/es2019/extractors/flexible/icon/index.js +14 -0
- package/dist/es2019/extractors/flexible/index.js +75 -5
- package/dist/es2019/extractors/inline/index.js +5 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/index.js +2 -56
- package/dist/es2019/utils/mocks.js +13 -2
- package/dist/es2019/view/BlockCard/views/ErroredView.js +1 -12
- package/dist/es2019/view/BlockCard/views/ForbiddenView.js +3 -12
- package/dist/es2019/view/BlockCard/views/NotFoundView.js +8 -16
- package/dist/es2019/view/BlockCard/views/UnauthorisedView.js +4 -4
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +4 -6
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +11 -33
- package/dist/es2019/view/FlexibleCard/components/common/image-icon/index.js +5 -18
- package/dist/es2019/view/FlexibleCard/components/common/loading-skeleton/index.js +2 -10
- package/dist/es2019/view/FlexibleCard/utils.js +19 -11
- package/dist/es2019/view/HoverCard/components/ImagePreview.js +16 -3
- package/dist/es2019/view/HoverCard/components/views/forbidden/index.js +3 -3
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +2 -2
- package/dist/es2019/view/HoverCard/components/views/resolving/index.js +5 -18
- package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +3 -3
- package/dist/es2019/view/InlineCard/ErroredView/index.js +5 -15
- package/dist/es2019/view/InlineCard/ForbiddenView/index.js +2 -8
- package/dist/es2019/view/InlineCard/Icon.compiled.css +0 -1
- package/dist/es2019/view/InlineCard/Icon.js +0 -19
- package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +8 -16
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/common/context/index.js +38 -1
- package/dist/esm/extractors/common/icon/extractIconFromDocument.js +6 -61
- package/dist/esm/extractors/embed/index.js +2 -34
- package/dist/esm/extractors/flexible/extract-preview.js +25 -2
- package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +41 -2
- package/dist/esm/extractors/flexible/icon/index.js +14 -0
- package/dist/esm/extractors/flexible/index.js +76 -5
- package/dist/esm/extractors/inline/index.js +5 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/index.js +2 -156
- package/dist/esm/utils/mocks.js +12 -2
- package/dist/esm/view/BlockCard/views/ErroredView.js +1 -12
- package/dist/esm/view/BlockCard/views/ForbiddenView.js +3 -12
- package/dist/esm/view/BlockCard/views/NotFoundView.js +6 -16
- package/dist/esm/view/BlockCard/views/UnauthorisedView.js +4 -4
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +3 -5
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +11 -33
- package/dist/esm/view/FlexibleCard/components/common/image-icon/index.js +5 -18
- package/dist/esm/view/FlexibleCard/components/common/loading-skeleton/index.js +2 -10
- package/dist/esm/view/FlexibleCard/utils.js +19 -11
- package/dist/esm/view/HoverCard/components/ImagePreview.js +16 -3
- package/dist/esm/view/HoverCard/components/views/forbidden/index.js +3 -3
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +2 -2
- package/dist/esm/view/HoverCard/components/views/resolving/index.js +5 -18
- package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +3 -3
- package/dist/esm/view/InlineCard/ErroredView/index.js +5 -15
- package/dist/esm/view/InlineCard/ForbiddenView/index.js +2 -8
- package/dist/esm/view/InlineCard/Icon.compiled.css +0 -1
- package/dist/esm/view/InlineCard/Icon.js +3 -23
- package/dist/esm/view/InlineCard/UnauthorisedView/index.js +8 -16
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/__fixtures__/figma-entity.d.ts +58 -0
- package/dist/types/extractors/common/context/index.d.ts +8 -0
- package/dist/types/extractors/flexible/extract-preview.d.ts +5 -0
- package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +5 -0
- package/dist/types/extractors/flexible/icon/index.d.ts +13 -0
- package/dist/types/extractors/flexible/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/blocks/title-block/resolving/index.d.ts +2 -6
- package/dist/types/view/FlexibleCard/components/common/loading-skeleton/index.d.ts +2 -4
- package/dist/types/view/FlexibleCard/components/common/loading-skeleton/types.d.ts +1 -17
- package/dist/types/view/FlexibleCard/types.d.ts +2 -2
- package/dist/types/view/FlexibleCard/utils.d.ts +2 -2
- package/dist/types/view/HoverCard/components/ImagePreview.d.ts +1 -1
- package/dist/types/view/HoverCard/types.d.ts +2 -2
- package/dist/types/view/InlineCard/Icon.d.ts +0 -1
- package/dist/types-ts4.5/__fixtures__/figma-entity.d.ts +58 -0
- package/dist/types-ts4.5/extractors/common/context/index.d.ts +8 -0
- package/dist/types-ts4.5/extractors/flexible/extract-preview.d.ts +5 -0
- package/dist/types-ts4.5/extractors/flexible/icon/extract-provider-icon.d.ts +5 -0
- package/dist/types-ts4.5/extractors/flexible/icon/index.d.ts +13 -0
- package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/resolving/index.d.ts +2 -6
- package/dist/types-ts4.5/view/FlexibleCard/components/common/loading-skeleton/index.d.ts +2 -4
- package/dist/types-ts4.5/view/FlexibleCard/components/common/loading-skeleton/types.d.ts +1 -17
- package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -2
- package/dist/types-ts4.5/view/FlexibleCard/utils.d.ts +2 -2
- package/dist/types-ts4.5/view/HoverCard/components/ImagePreview.d.ts +1 -1
- package/dist/types-ts4.5/view/HoverCard/types.d.ts +2 -2
- package/dist/types-ts4.5/view/InlineCard/Icon.d.ts +0 -1
- package/package.json +8 -8
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.compiled.css +0 -55
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.compiled.css +0 -55
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.compiled.css +0 -55
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { extractProvider } from '@atlaskit/link-extractors';
|
|
1
|
+
import { extractProvider, extractSmartLinkProvider, isEntityPresent } from '@atlaskit/link-extractors';
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { SmartLinkStatus } from '../../constants';
|
|
4
4
|
import { extractRequestAccessContextImproved } from '../../extractors/common/context';
|
|
5
5
|
import extractFlexibleUiContext from '../../extractors/flexible';
|
|
6
|
-
import extractPreview from '../../extractors/flexible/extract-preview';
|
|
6
|
+
import extractPreview, { extractSmartLinkPreviewImage } from '../../extractors/flexible/extract-preview';
|
|
7
7
|
import { extractErrorIcon } from '../../extractors/flexible/icon';
|
|
8
|
-
import extractProviderIcon from '../../extractors/flexible/icon/extract-provider-icon';
|
|
8
|
+
import extractProviderIcon, { extractSmartLinkProviderIcon } from '../../extractors/flexible/icon/extract-provider-icon';
|
|
9
9
|
import { messages } from '../../messages';
|
|
10
10
|
import { handleOnClick } from '../../utils';
|
|
11
11
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
@@ -30,15 +30,23 @@ export const getContextByStatus = params => {
|
|
|
30
30
|
case SmartLinkStatus.Errored:
|
|
31
31
|
case SmartLinkStatus.Fallback:
|
|
32
32
|
default:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (fg('smart_links_noun_support')) {
|
|
34
|
+
if (isEntityPresent(response)) {
|
|
35
|
+
return {
|
|
36
|
+
url,
|
|
37
|
+
title: url,
|
|
38
|
+
linkIcon: extractErrorIcon(response, status),
|
|
39
|
+
preview: extractSmartLinkPreviewImage(response),
|
|
40
|
+
provider: extractSmartLinkProviderIcon(response)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
return {
|
|
37
|
-
linkIcon,
|
|
38
|
-
title: url,
|
|
39
45
|
url,
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
title: url,
|
|
47
|
+
linkIcon: extractErrorIcon(response, status),
|
|
48
|
+
preview: extractPreview(response === null || response === void 0 ? void 0 : response.data),
|
|
49
|
+
provider: extractProviderIcon(response === null || response === void 0 ? void 0 : response.data)
|
|
42
50
|
};
|
|
43
51
|
}
|
|
44
52
|
};
|
|
@@ -63,7 +71,7 @@ const getForbiddenMessageKey = meta => {
|
|
|
63
71
|
export const getRetryOptions = (url, status, response, onAuthorize) => {
|
|
64
72
|
var _response$meta, _access$action, _access$buttonDisable;
|
|
65
73
|
const data = response && response.data || getEmptyJsonLd();
|
|
66
|
-
const provider = extractProvider(data);
|
|
74
|
+
const provider = fg('smart_links_noun_support') ? extractSmartLinkProvider(response) : extractProvider(data);
|
|
67
75
|
const context = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
68
76
|
const values = context ? {
|
|
69
77
|
context
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React, { useCallback, useRef, useState } from 'react';
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
-
import extractPreview from '../../../extractors/flexible/extract-preview';
|
|
3
|
+
import extractPreview, { extractSmartLinkPreviewImage } from '../../../extractors/flexible/extract-preview';
|
|
4
4
|
import { PreviewBlock } from '../../FlexibleCard/components/blocks';
|
|
5
5
|
const ImagePreview = ({
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
fallbackElementHeight,
|
|
7
|
+
response
|
|
8
8
|
}) => {
|
|
9
9
|
const transitionStarted = useRef(false);
|
|
10
10
|
const previewBlockRef = useRef(null);
|
|
11
11
|
const [showPreview, setShowPreview] = useState(true);
|
|
12
12
|
const [dynamicStyles, setDynamicStyles] = useState({});
|
|
13
|
+
const data = response === null || response === void 0 ? void 0 : response.data;
|
|
13
14
|
|
|
14
15
|
// Set Preview to a fixed height to enable transitions
|
|
15
16
|
const onPreviewRender = useCallback(() => {
|
|
@@ -40,6 +41,18 @@ const ImagePreview = ({
|
|
|
40
41
|
const onPreviewTransitionEnd = useCallback(() => {
|
|
41
42
|
setShowPreview(false);
|
|
42
43
|
}, []);
|
|
44
|
+
if (fg('smart_links_noun_support')) {
|
|
45
|
+
return showPreview && extractSmartLinkPreviewImage(response) ? /*#__PURE__*/React.createElement(PreviewBlock, {
|
|
46
|
+
onError: onPreviewError,
|
|
47
|
+
ignoreContainerPadding: true,
|
|
48
|
+
onTransitionEnd: onPreviewTransitionEnd,
|
|
49
|
+
blockRef: previewBlockRef,
|
|
50
|
+
onRender: onPreviewRender
|
|
51
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
52
|
+
,
|
|
53
|
+
style: dynamicStyles
|
|
54
|
+
}) : null;
|
|
55
|
+
}
|
|
43
56
|
return showPreview && data && extractPreview(data) ? /*#__PURE__*/React.createElement(PreviewBlock, {
|
|
44
57
|
onError: onPreviewError,
|
|
45
58
|
ignoreContainerPadding: true,
|
|
@@ -6,7 +6,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
6
6
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
7
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
8
8
|
import Button from '@atlaskit/button';
|
|
9
|
-
import { extractProvider } from '@atlaskit/link-extractors';
|
|
9
|
+
import { extractProvider, extractSmartLinkProvider } from '@atlaskit/link-extractors';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { SmartLinkStatus } from '../../../../../constants';
|
|
12
12
|
import { extractRequestAccessContextImproved } from '../../../../../extractors/common/context/extractAccessContext';
|
|
@@ -26,7 +26,7 @@ const HoverCardForbiddenView = ({
|
|
|
26
26
|
flexibleCardProps,
|
|
27
27
|
testId = 'hover-card-forbidden-view'
|
|
28
28
|
}) => {
|
|
29
|
-
var _cardState$details, _cardState$details2, _extractProvider$text, _extractProvider, _extractRequestAccess;
|
|
29
|
+
var _cardState$details, _cardState$details2, _extractSmartLinkProv, _extractSmartLinkProv2, _extractProvider$text, _extractProvider, _extractRequestAccess;
|
|
30
30
|
const {
|
|
31
31
|
createAnalyticsEvent
|
|
32
32
|
} = useAnalyticsEvents();
|
|
@@ -36,7 +36,7 @@ const HoverCardForbiddenView = ({
|
|
|
36
36
|
} = flexibleCardProps;
|
|
37
37
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
38
38
|
const meta = (_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.meta;
|
|
39
|
-
const product = (_extractProvider$text = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text) !== null && _extractProvider$text !== void 0 ? _extractProvider$text : '';
|
|
39
|
+
const product = fg('smart_links_noun_support') ? (_extractSmartLinkProv = (_extractSmartLinkProv2 = extractSmartLinkProvider(cardState.details)) === null || _extractSmartLinkProv2 === void 0 ? void 0 : _extractSmartLinkProv2.text) !== null && _extractSmartLinkProv !== void 0 ? _extractSmartLinkProv : '' : (_extractProvider$text = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text) !== null && _extractProvider$text !== void 0 ? _extractProvider$text : '';
|
|
40
40
|
const hostname = /*#__PURE__*/React.createElement("b", null, extractHostname(url));
|
|
41
41
|
const {
|
|
42
42
|
action,
|
|
@@ -64,8 +64,8 @@ const HoverCardResolvedView = ({
|
|
|
64
64
|
snippetHeight.current = (_snippetBlockRef$curr = (_snippetBlockRef$curr2 = snippetBlockRef.current) === null || _snippetBlockRef$curr2 === void 0 ? void 0 : _snippetBlockRef$curr2.getBoundingClientRect().height) !== null && _snippetBlockRef$curr !== void 0 ? _snippetBlockRef$curr : 0;
|
|
65
65
|
}, []);
|
|
66
66
|
const imagePreview = ImagePreview({
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
fallbackElementHeight: snippetHeight.current,
|
|
68
|
+
response: cardState.details
|
|
69
69
|
});
|
|
70
70
|
const snippet = imagePreview ? null : /*#__PURE__*/React.createElement(SnippetBlock, {
|
|
71
71
|
status: SmartLinkStatus.Resolved,
|
|
@@ -3,10 +3,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
import "./index.compiled.css";
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { CustomBlock } from '../../../../FlexibleCard/components/blocks';
|
|
8
7
|
import ActionGroup from '../../../../FlexibleCard/components/blocks/action-group';
|
|
9
|
-
import {
|
|
8
|
+
import { LoadingSkeleton } from '../../../../FlexibleCard/components/common/loading-skeleton';
|
|
10
9
|
import Icon from '../../../../FlexibleCard/components/elements/icon';
|
|
11
10
|
import { CARD_WIDTH_REM } from '../../../styled';
|
|
12
11
|
const loadingViewContainer = null;
|
|
@@ -27,7 +26,6 @@ const HoverCardLoadingView = ({
|
|
|
27
26
|
items: actions,
|
|
28
27
|
visibleButtonsNum: 2
|
|
29
28
|
});
|
|
30
|
-
const LoadingSkeleton = fg('platform-smart-card-icon-migration') ? LoadingSkeletonNew : LoadingSkeletonOld;
|
|
31
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
32
30
|
"data-testid": testId,
|
|
33
31
|
className: ax(["_1e0c1txw _2lx21bp4 _ca0q1e9d _u5f31e9d _n3td1e9d _19bv1e9d"])
|
|
@@ -42,28 +40,17 @@ const HoverCardLoadingView = ({
|
|
|
42
40
|
}), /*#__PURE__*/React.createElement("span", {
|
|
43
41
|
"data-testid": `${testId}-title`,
|
|
44
42
|
className: ax(["_16jlkb7n _1o9zidpf _i0dl1wug _4t3i1k92 _e2oo1osq"])
|
|
45
|
-
},
|
|
43
|
+
}, /*#__PURE__*/React.createElement(LoadingSkeleton, {
|
|
46
44
|
height: `${lineHeightRem}rem`
|
|
47
|
-
})
|
|
48
|
-
height: lineHeightRem
|
|
49
|
-
})), actionGroup), fg('platform-smart-card-icon-migration') ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoadingSkeletonNew, {
|
|
45
|
+
})), actionGroup), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoadingSkeleton, {
|
|
50
46
|
width: `${skeletonWidth}rem`,
|
|
51
47
|
height: `${lineHeightRem}rem`
|
|
52
|
-
}), /*#__PURE__*/React.createElement(
|
|
48
|
+
}), /*#__PURE__*/React.createElement(LoadingSkeleton, {
|
|
53
49
|
width: `${skeletonWidth}rem`,
|
|
54
50
|
height: `${lineHeightRem * 3}rem`
|
|
55
|
-
}), /*#__PURE__*/React.createElement(
|
|
51
|
+
}), /*#__PURE__*/React.createElement(LoadingSkeleton, {
|
|
56
52
|
width: `${skeletonWidth}rem`,
|
|
57
53
|
height: `${lineHeightRem}rem`
|
|
58
|
-
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoadingSkeletonOld, {
|
|
59
|
-
width: skeletonWidth,
|
|
60
|
-
height: lineHeightRem
|
|
61
|
-
}), /*#__PURE__*/React.createElement(LoadingSkeletonOld, {
|
|
62
|
-
width: skeletonWidth,
|
|
63
|
-
height: lineHeightRem * 3
|
|
64
|
-
}), /*#__PURE__*/React.createElement(LoadingSkeletonOld, {
|
|
65
|
-
width: skeletonWidth,
|
|
66
|
-
height: lineHeightRem
|
|
67
54
|
}))));
|
|
68
55
|
};
|
|
69
56
|
export default HoverCardLoadingView;
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
6
|
import { useCallback, useMemo } from 'react';
|
|
7
7
|
import { FormattedMessage } from 'react-intl-next';
|
|
8
|
-
import { extractProvider } from '@atlaskit/link-extractors';
|
|
8
|
+
import { extractProvider, extractSmartLinkProvider } from '@atlaskit/link-extractors';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { useAnalyticsEvents } from '../../../../../common/analytics/generated/use-analytics-events';
|
|
11
11
|
import { ActionName, CardDisplay } from '../../../../../constants';
|
|
@@ -29,12 +29,12 @@ const HoverCardUnauthorisedView = ({
|
|
|
29
29
|
testId = 'hover-card-unauthorised-view',
|
|
30
30
|
url
|
|
31
31
|
}) => {
|
|
32
|
-
var _cardState$details, _extractProvider;
|
|
32
|
+
var _cardState$details, _extractSmartLinkProv, _extractProvider;
|
|
33
33
|
const {
|
|
34
34
|
cardState
|
|
35
35
|
} = flexibleCardProps;
|
|
36
36
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
37
|
-
const providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
|
|
37
|
+
const providerName = fg('smart_links_noun_support') ? (_extractSmartLinkProv = extractSmartLinkProvider(cardState.details)) === null || _extractSmartLinkProv === void 0 ? void 0 : _extractSmartLinkProv.text : (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
|
|
38
38
|
const isProductIntegrationSupported = hasAuthScopeOverrides(cardState.details);
|
|
39
39
|
const {
|
|
40
40
|
authorize
|
|
@@ -8,12 +8,10 @@ import ErrorIconCore from '@atlaskit/icon/core/migration/error';
|
|
|
8
8
|
import ErrorIcon from '@atlaskit/icon/utility/migration/error';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
11
|
-
import { R300 } from '@atlaskit/theme/colors';
|
|
12
11
|
import { messages } from '../../../messages';
|
|
13
12
|
import { HoverCard } from '../../HoverCard';
|
|
14
13
|
import { ActionButton } from '../common/action-button';
|
|
15
14
|
import { Frame } from '../Frame';
|
|
16
|
-
import { AKIconWrapper } from '../Icon';
|
|
17
15
|
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
18
16
|
import { IconStyledButtonOldVisualRefresh } from '../styled';
|
|
19
17
|
import withFrameStyleControl from '../utils/withFrameStyleControl';
|
|
@@ -29,21 +27,13 @@ const fallbackIcon = () => {
|
|
|
29
27
|
testId: "errored-view-default-icon"
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
color: "var(--ds-icon-danger, #C9372C)",
|
|
38
|
-
label: "error",
|
|
39
|
-
LEGACY_size: "small",
|
|
40
|
-
testId: "errored-view-default-icon"
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
return /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(ErrorIcon, {
|
|
30
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
31
|
+
as: "span",
|
|
32
|
+
xcss: styles.iconWrapper
|
|
33
|
+
}, /*#__PURE__*/React.createElement(ErrorIcon, {
|
|
34
|
+
color: "var(--ds-icon-danger, #C9372C)",
|
|
44
35
|
label: "error",
|
|
45
36
|
LEGACY_size: "small",
|
|
46
|
-
color: `var(--ds-icon-danger, ${R300})`,
|
|
47
37
|
testId: "errored-view-default-icon"
|
|
48
38
|
}));
|
|
49
39
|
};
|
|
@@ -10,12 +10,11 @@ import LegacyLockIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
|
10
10
|
import Lozenge from '@atlaskit/lozenge';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { Box, Pressable } from '@atlaskit/primitives/compiled';
|
|
13
|
-
import { N500
|
|
13
|
+
import { N500 } from '@atlaskit/theme/colors';
|
|
14
14
|
import { messages } from '../../../messages';
|
|
15
15
|
import { HoverCard } from '../../HoverCard';
|
|
16
16
|
import { ActionButton } from '../common/action-button';
|
|
17
17
|
import { Frame } from '../Frame';
|
|
18
|
-
import { AKIconWrapper } from '../Icon';
|
|
19
18
|
import { IconAndTitleLayout, LozengeWrapper } from '../IconAndTitleLayout';
|
|
20
19
|
import { IconStyledButtonOldVisualRefresh } from '../styled';
|
|
21
20
|
import withFrameStyleControl from '../utils/withFrameStyleControl';
|
|
@@ -33,7 +32,7 @@ const fallbackForbiddenIcon = () => {
|
|
|
33
32
|
testId: "forbidden-view-fallback-icon"
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
37
36
|
as: "span",
|
|
38
37
|
xcss: styles.iconWrapper
|
|
39
38
|
}, /*#__PURE__*/React.createElement(LockLockedIcon, {
|
|
@@ -42,11 +41,6 @@ const fallbackForbiddenIcon = () => {
|
|
|
42
41
|
LEGACY_fallbackIcon: LegacyLockIcon,
|
|
43
42
|
LEGACY_size: "small",
|
|
44
43
|
testId: "forbidden-view-fallback-icon"
|
|
45
|
-
})) : /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LegacyLockIcon, {
|
|
46
|
-
label: "error",
|
|
47
|
-
size: "small",
|
|
48
|
-
primaryColor: `var(--ds-icon-danger, ${R400})`,
|
|
49
|
-
testId: "forbidden-view-fallback-icon"
|
|
50
44
|
}));
|
|
51
45
|
};
|
|
52
46
|
export const InlineCardForbiddenView = ({
|
|
@@ -22,28 +22,9 @@ export const Icon = forwardRef(({
|
|
|
22
22
|
className: ax(["_2rkoyh40 _4t3i7vkz _1bsb7vkz _2hwx1b66 _uiztglyw _kqswstnw _154i1ssb _1ltv1ssb _t9ec1ooe", __cmplp.className])
|
|
23
23
|
}));
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
// TODO: Remove on platform-smart-card-icon-migration cleanup
|
|
27
|
-
// Used for 'untrue' icons which claim to be 16x16 but
|
|
28
|
-
// are less than that in height/width.
|
|
29
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled, @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
30
25
|
if (process.env.NODE_ENV !== 'production') {
|
|
31
26
|
Icon.displayName = 'Icon';
|
|
32
27
|
}
|
|
33
|
-
export const AKIconWrapper = forwardRef(({
|
|
34
|
-
as: C = "span",
|
|
35
|
-
style: __cmpls,
|
|
36
|
-
...__cmplp
|
|
37
|
-
}, __cmplr) => {
|
|
38
|
-
return /*#__PURE__*/React.createElement(C, _extends({}, __cmplp, {
|
|
39
|
-
style: __cmpls,
|
|
40
|
-
ref: __cmplr,
|
|
41
|
-
className: ax(["_2hwx1i6y", __cmplp.className])
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
44
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
45
|
-
AKIconWrapper.displayName = 'AKIconWrapper';
|
|
46
|
-
}
|
|
47
28
|
export const Shimmer = ({
|
|
48
29
|
testId
|
|
49
30
|
}) => {
|
|
@@ -9,13 +9,12 @@ import LockLockedIcon from '@atlaskit/icon/core/lock-locked';
|
|
|
9
9
|
import LegacyLockIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
12
|
-
import { N500
|
|
12
|
+
import { N500 } from '@atlaskit/theme/colors';
|
|
13
13
|
import { useAnalyticsEvents } from '../../../common/analytics/generated/use-analytics-events';
|
|
14
14
|
import { messages } from '../../../messages';
|
|
15
15
|
import { HoverCard } from '../../HoverCard';
|
|
16
16
|
import { ActionButton } from '../common/action-button';
|
|
17
17
|
import { Frame } from '../Frame';
|
|
18
|
-
import { AKIconWrapper } from '../Icon';
|
|
19
18
|
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
20
19
|
import { IconStyledButtonOldVisualRefresh } from '../styled';
|
|
21
20
|
import withFrameStyleControl from '../utils/withFrameStyleControl';
|
|
@@ -31,21 +30,14 @@ const fallbackUnauthorizedIcon = () => {
|
|
|
31
30
|
LEGACY_size: "small"
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
color: "var(--ds-icon-danger, #C9372C)",
|
|
40
|
-
label: "error",
|
|
41
|
-
LEGACY_fallbackIcon: LegacyLockIcon,
|
|
42
|
-
LEGACY_size: "small"
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
return /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LegacyLockIcon, {
|
|
33
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
34
|
+
as: "span",
|
|
35
|
+
xcss: styles.iconWrapper
|
|
36
|
+
}, /*#__PURE__*/React.createElement(LockLockedIcon, {
|
|
37
|
+
color: "var(--ds-icon-danger, #C9372C)",
|
|
46
38
|
label: "error",
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
LEGACY_fallbackIcon: LegacyLockIcon,
|
|
40
|
+
LEGACY_size: "small"
|
|
49
41
|
}));
|
|
50
42
|
};
|
|
51
43
|
export const InlineCardUnauthorizedView = ({
|
|
@@ -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.
|
|
13
|
+
packageVersion: "36.10.1",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import { extractEntityProvider, extractProvider, extractProviderIcon, extractUrlFromIconJsonLd, isEntityPresent } from '@atlaskit/link-extractors';
|
|
5
|
+
import { prioritiseIcon } from '../icon/prioritiseIcon';
|
|
6
|
+
export { extractRequestAccessContextImproved } from './extractAccessContext';
|
|
7
|
+
export function generateContext(jsonLd) {
|
|
8
|
+
var provider = extractProvider(jsonLd);
|
|
9
|
+
if (!provider) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// If no icon is supplied, return existing context
|
|
14
|
+
if (!jsonLd.icon) {
|
|
15
|
+
return provider;
|
|
16
|
+
}
|
|
17
|
+
var generator = jsonLd.generator;
|
|
18
|
+
var icon = prioritiseIcon({
|
|
19
|
+
fileFormatIcon: undefined,
|
|
20
|
+
documentTypeIcon: undefined,
|
|
21
|
+
urlIcon: extractUrlFromIconJsonLd(jsonLd.icon),
|
|
22
|
+
// We still attempt to follow the icon priority function even if no generator (and therefore provider icon) is defined
|
|
23
|
+
providerIcon: generator && typeof generator !== 'string' && generator['@type'] !== 'Link' && extractProviderIcon(generator.icon)
|
|
24
|
+
});
|
|
25
|
+
return _objectSpread(_objectSpread({}, provider), {}, {
|
|
26
|
+
icon: icon ? icon : provider.icon
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Should be moved to link-extractors when jsonLd is deprecated
|
|
32
|
+
*/
|
|
33
|
+
export function extractSmartLinkContext(response) {
|
|
34
|
+
if (isEntityPresent(response)) {
|
|
35
|
+
return extractEntityProvider(response);
|
|
36
|
+
}
|
|
37
|
+
return generateContext(response === null || response === void 0 ? void 0 : response.data);
|
|
38
|
+
}
|
|
@@ -1,69 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import FileIconOld from '@atlaskit/icon-file-type/glyph/generic/16';
|
|
4
|
-
import PresentationIconOld from '@atlaskit/icon-file-type/glyph/presentation/16';
|
|
5
|
-
import SpreadsheetIconOld from '@atlaskit/icon-file-type/glyph/spreadsheet/16';
|
|
6
|
-
import BlogIconOld from '@atlaskit/icon-object/glyph/blog/16';
|
|
7
|
-
import DocumentFilledIconNew from '@atlaskit/icon/core/migration/file--document-filled';
|
|
8
|
-
import DocumentFilledIconOld from '@atlaskit/icon/core/migration/page--document-filled';
|
|
2
|
+
import DocumentFilledIcon from '@atlaskit/icon/core/migration/file--document-filled';
|
|
9
3
|
import { isConfluenceGenerator } from '@atlaskit/link-extractors';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import SpreadsheetIconNew from '../../../common/ui/icons/list-bullet-icon';
|
|
4
|
+
import BlogIcon from '../../../common/ui/icons/blog-icon';
|
|
5
|
+
import PresentationIcon from '../../../common/ui/icons/chart-bar-icon';
|
|
6
|
+
import FileIcon from '../../../common/ui/icons/file-icon';
|
|
7
|
+
import SpreadsheetIcon from '../../../common/ui/icons/list-bullet-icon';
|
|
15
8
|
import LiveDocumentIcon from '../../../common/ui/icons/live-document-icon';
|
|
16
|
-
import
|
|
9
|
+
import DocumentIcon from '../../../common/ui/icons/page-icon';
|
|
17
10
|
import { getIconForFileType } from '../../../utils';
|
|
18
11
|
import { prioritiseIcon } from './prioritiseIcon';
|
|
19
|
-
|
|
20
|
-
// TODO Delete this and rename BlogIconNew to BlogIcon when cleaning platform-smart-card-icon-migration
|
|
21
|
-
var BlogIcon = function BlogIcon(props) {
|
|
22
|
-
if (fg('platform-smart-card-icon-migration')) {
|
|
23
|
-
return /*#__PURE__*/React.createElement(BlogIconNew, props);
|
|
24
|
-
}
|
|
25
|
-
return /*#__PURE__*/React.createElement(BlogIconOld, props);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// TODO Delete this and rename FileIconNew to FileIcon when cleaning platform-smart-card-icon-migration
|
|
29
|
-
var FileIcon = function FileIcon(props) {
|
|
30
|
-
if (fg('platform-smart-card-icon-migration')) {
|
|
31
|
-
return /*#__PURE__*/React.createElement(FileIconNew, props);
|
|
32
|
-
}
|
|
33
|
-
return /*#__PURE__*/React.createElement(FileIconOld, props);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// TODO Delete this and rename DocumentIconNew to DocumentIcon when cleaning platform-smart-card-icon-migration
|
|
37
|
-
var DocumentIcon = function DocumentIcon(props) {
|
|
38
|
-
if (fg('platform-smart-card-icon-migration')) {
|
|
39
|
-
return /*#__PURE__*/React.createElement(DocumentIconNew, props);
|
|
40
|
-
}
|
|
41
|
-
return /*#__PURE__*/React.createElement(DocumentIconOld, props);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// TODO Delete this and rename PresentationIconNew to PresentationIcon when cleaning platform-smart-card-icon-migration
|
|
45
|
-
var PresentationIcon = function PresentationIcon(props) {
|
|
46
|
-
if (fg('platform-smart-card-icon-migration')) {
|
|
47
|
-
return /*#__PURE__*/React.createElement(PresentationIconNew, props);
|
|
48
|
-
}
|
|
49
|
-
return /*#__PURE__*/React.createElement(PresentationIconOld, props);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// TODO Delete this and rename SpreadsheetIconNew to SpreadsheetIcon when cleaning platform-smart-card-icon-migration
|
|
53
|
-
var SpreadsheetIcon = function SpreadsheetIcon(props) {
|
|
54
|
-
if (fg('platform-smart-card-icon-migration')) {
|
|
55
|
-
return /*#__PURE__*/React.createElement(SpreadsheetIconNew, props);
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/React.createElement(SpreadsheetIconOld, props);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// TODO Delete this and rename DocumentFilledIconNew to DocumentFilledIcon when cleaning platform-smart-card-icon-migration
|
|
61
|
-
var DocumentFilledIcon = function DocumentFilledIcon(props) {
|
|
62
|
-
if (fg('platform-smart-card-icon-migration')) {
|
|
63
|
-
return /*#__PURE__*/React.createElement(DocumentFilledIconNew, props);
|
|
64
|
-
}
|
|
65
|
-
return /*#__PURE__*/React.createElement(DocumentFilledIconOld, props);
|
|
66
|
-
};
|
|
67
12
|
/**
|
|
68
13
|
* Extracts an icon for a document pbject
|
|
69
14
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
-
import {
|
|
4
|
+
import { extractLink, extractPreview, extractSmartLinkEmbed, extractSmartLinkTitle, extractSmartLinkUrl, extractTitle } from '@atlaskit/link-extractors';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { getEmptyJsonLd } from '../../utils/jsonld';
|
|
7
|
-
import {
|
|
7
|
+
import { extractSmartLinkContext, generateContext } from '../common/context';
|
|
8
8
|
import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
|
|
9
9
|
import { extractIsTrusted } from '../common/meta/extractIsTrusted';
|
|
10
10
|
var extractEmbedPreview = function extractEmbedPreview(jsonLd, platform, iframeUrlType) {
|
|
@@ -15,38 +15,6 @@ var extractEmbedPreview = function extractEmbedPreview(jsonLd, platform, iframeU
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
function generateContext(jsonLd) {
|
|
19
|
-
var provider = extractProvider(jsonLd);
|
|
20
|
-
if (!provider) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// If no icon is supplied, return existing context
|
|
25
|
-
if (!jsonLd.icon) {
|
|
26
|
-
return provider;
|
|
27
|
-
}
|
|
28
|
-
var generator = jsonLd.generator;
|
|
29
|
-
var icon = prioritiseIcon({
|
|
30
|
-
fileFormatIcon: undefined,
|
|
31
|
-
documentTypeIcon: undefined,
|
|
32
|
-
urlIcon: extractUrlFromIconJsonLd(jsonLd.icon),
|
|
33
|
-
// We still attempt to follow the icon priority function even if no generator (and therefore provider icon) is defined
|
|
34
|
-
providerIcon: generator && typeof generator !== 'string' && generator['@type'] !== 'Link' && extractProviderIcon(generator.icon)
|
|
35
|
-
});
|
|
36
|
-
return _objectSpread(_objectSpread({}, provider), {}, {
|
|
37
|
-
icon: icon ? icon : provider.icon
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* We can migrate this to link extractors once we have deprecated JsonLd
|
|
43
|
-
*/
|
|
44
|
-
function extractSmartLinkContext(response) {
|
|
45
|
-
if (isEntityPresent(response)) {
|
|
46
|
-
return extractEntityProvider(response);
|
|
47
|
-
}
|
|
48
|
-
return generateContext(response === null || response === void 0 ? void 0 : response.data);
|
|
49
|
-
}
|
|
50
18
|
export var extractEmbedProps = function extractEmbedProps(response, platform, iframeUrlType) {
|
|
51
19
|
var meta = response === null || response === void 0 ? void 0 : response.meta;
|
|
52
20
|
var jsonLd = (response === null || response === void 0 ? void 0 : response.data) || getEmptyJsonLd();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractImage } from '@atlaskit/link-extractors';
|
|
1
|
+
import { extractEntity, extractEntityProvider, extractImage, isEntityPresent } from '@atlaskit/link-extractors';
|
|
2
2
|
import { MediaType } from '../../constants';
|
|
3
3
|
var extractPreview = function extractPreview(data) {
|
|
4
4
|
if (!data) {
|
|
@@ -10,4 +10,27 @@ var extractPreview = function extractPreview(data) {
|
|
|
10
10
|
url: url
|
|
11
11
|
} : undefined;
|
|
12
12
|
};
|
|
13
|
-
export default extractPreview;
|
|
13
|
+
export default extractPreview;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Should be moved to link-extractors when jsonLd is deprecated
|
|
17
|
+
*/
|
|
18
|
+
export var extractSmartLinkPreviewImage = function extractSmartLinkPreviewImage(response) {
|
|
19
|
+
if (!response || !(response !== null && response !== void 0 && response.data)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (isEntityPresent(response)) {
|
|
23
|
+
var _entity$thumbnail;
|
|
24
|
+
var entity = extractEntity(response);
|
|
25
|
+
var url = entity === null || entity === void 0 || (_entity$thumbnail = entity.thumbnail) === null || _entity$thumbnail === void 0 ? void 0 : _entity$thumbnail.externalUrl;
|
|
26
|
+
if (!url) {
|
|
27
|
+
var provider = extractEntityProvider(response);
|
|
28
|
+
url = provider === null || provider === void 0 ? void 0 : provider.image;
|
|
29
|
+
}
|
|
30
|
+
return url ? {
|
|
31
|
+
type: MediaType.Image,
|
|
32
|
+
url: url
|
|
33
|
+
} : undefined;
|
|
34
|
+
}
|
|
35
|
+
return extractPreview(response.data);
|
|
36
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractTitle } from '@atlaskit/link-extractors';
|
|
1
|
+
import { extractEntity, extractEntityProvider, extractTitle, isEntityPresent } from '@atlaskit/link-extractors';
|
|
2
2
|
import { IconType } from '../../../constants';
|
|
3
3
|
import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
|
|
4
4
|
import extractUrlIcon from './extract-url-icon';
|
|
@@ -34,4 +34,43 @@ var extractProviderIcon = function extractProviderIcon(data) {
|
|
|
34
34
|
}
|
|
35
35
|
return extractUrlIcon(icon, label);
|
|
36
36
|
};
|
|
37
|
-
export default extractProviderIcon;
|
|
37
|
+
export default extractProviderIcon;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Should be moved to link-extractors when jsonLd is deprecated
|
|
41
|
+
*/
|
|
42
|
+
export var extractSmartLinkProviderIcon = function extractSmartLinkProviderIcon(response) {
|
|
43
|
+
var _extractEntity, _generator$icon;
|
|
44
|
+
if (!response || !(response !== null && response !== void 0 && response.data)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
if (isEntityPresent(response)) {
|
|
48
|
+
var provider = extractEntityProvider(response);
|
|
49
|
+
if (!provider) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
switch (provider.id) {
|
|
53
|
+
case CONFLUENCE_GENERATOR_ID:
|
|
54
|
+
return {
|
|
55
|
+
icon: IconType.Confluence,
|
|
56
|
+
label: provider.text || 'Confluence'
|
|
57
|
+
};
|
|
58
|
+
case JIRA_GENERATOR_ID:
|
|
59
|
+
return {
|
|
60
|
+
icon: IconType.Jira,
|
|
61
|
+
label: provider.text || 'Jira'
|
|
62
|
+
};
|
|
63
|
+
default:
|
|
64
|
+
var _ref = response.meta,
|
|
65
|
+
generator = _ref.generator;
|
|
66
|
+
if (!generator) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
label: generator.name || ((_extractEntity = extractEntity(response)) === null || _extractEntity === void 0 ? void 0 : _extractEntity.displayName),
|
|
71
|
+
url: (_generator$icon = generator.icon) === null || _generator$icon === void 0 ? void 0 : _generator$icon.url
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return extractProviderIcon(response.data);
|
|
76
|
+
};
|