@atlaskit/smart-card 26.13.1 → 26.14.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 +12 -0
- package/dist/cjs/constants.js +5 -0
- package/dist/cjs/extractors/flexible/index.js +5 -0
- package/dist/cjs/extractors/flexible/utils.js +23 -2
- package/dist/cjs/extractors/hover/extractMetadata.js +2 -1
- package/dist/cjs/messages.js +10 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +21 -37
- package/dist/cjs/view/BlockCard/views/flexible/styled.js +15 -0
- package/dist/cjs/view/BlockCard/views/flexible/utils.js +116 -0
- package/dist/cjs/view/EmbedModal/utils.js +30 -56
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +2 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/index.js +33 -4
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +1 -2
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +20 -0
- package/dist/cjs/view/FlexibleCard/components/utils.js +37 -2
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +28 -12
- package/dist/cjs/view/HoverCard/utils.js +102 -3
- package/dist/es2019/constants.js +6 -0
- package/dist/es2019/extractors/flexible/index.js +7 -2
- package/dist/es2019/extractors/flexible/utils.js +18 -1
- package/dist/es2019/extractors/hover/extractMetadata.js +1 -1
- package/dist/es2019/messages.js +10 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +24 -38
- package/dist/es2019/view/BlockCard/views/flexible/styled.js +14 -0
- package/dist/es2019/view/BlockCard/views/flexible/utils.js +108 -0
- package/dist/es2019/view/EmbedModal/utils.js +14 -46
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +2 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +5 -0
- package/dist/es2019/view/FlexibleCard/components/elements/index.js +24 -0
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +2 -3
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +25 -0
- package/dist/es2019/view/FlexibleCard/components/utils.js +35 -0
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +30 -14
- package/dist/es2019/view/HoverCard/utils.js +100 -1
- package/dist/esm/constants.js +6 -0
- package/dist/esm/extractors/flexible/index.js +7 -2
- package/dist/esm/extractors/flexible/utils.js +18 -1
- package/dist/esm/extractors/hover/extractMetadata.js +1 -1
- package/dist/esm/messages.js +10 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +23 -38
- package/dist/esm/view/BlockCard/views/flexible/styled.js +7 -0
- package/dist/esm/view/BlockCard/views/flexible/utils.js +108 -0
- package/dist/esm/view/EmbedModal/utils.js +29 -53
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +2 -2
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/index.js +24 -0
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +2 -3
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +20 -0
- package/dist/esm/view/FlexibleCard/components/utils.js +34 -0
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +30 -14
- package/dist/esm/view/HoverCard/utils.js +98 -1
- package/dist/types/constants.d.ts +5 -0
- package/dist/types/extractors/flexible/utils.d.ts +5 -0
- package/dist/types/extractors/hover/extractMetadata.d.ts +2 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/state/flexible-ui-context/types.d.ts +25 -0
- package/dist/types/view/BlockCard/views/flexible/styled.d.ts +2 -0
- package/dist/types/view/BlockCard/views/flexible/utils.d.ts +10 -0
- package/dist/types/view/EmbedModal/utils.d.ts +2 -10
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -4
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +35 -2
- package/dist/types/view/FlexibleCard/components/elements/index.d.ts +24 -0
- package/dist/types/view/FlexibleCard/components/utils.d.ts +64 -0
- package/dist/types/view/HoverCard/utils.d.ts +1 -0
- package/dist/types-ts4.5/constants.d.ts +5 -0
- package/dist/types-ts4.5/extractors/flexible/utils.d.ts +5 -0
- package/dist/types-ts4.5/extractors/hover/extractMetadata.d.ts +2 -0
- package/dist/types-ts4.5/messages.d.ts +1 -1
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +25 -0
- package/dist/types-ts4.5/view/BlockCard/views/flexible/styled.d.ts +2 -0
- package/dist/types-ts4.5/view/BlockCard/views/flexible/utils.d.ts +10 -0
- package/dist/types-ts4.5/view/EmbedModal/utils.d.ts +2 -10
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -4
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +35 -2
- package/dist/types-ts4.5/view/FlexibleCard/components/elements/index.d.ts +24 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +64 -0
- package/dist/types-ts4.5/view/HoverCard/utils.d.ts +1 -0
- package/package.json +4 -1
- package/report.api.md +40 -0
- package/tmp/api-report-tmp.d.ts +36 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import React, { useEffect, useState } from 'react';
|
|
2
3
|
import FlexibleCard from '../../../FlexibleCard';
|
|
3
4
|
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
5
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
|
|
5
|
-
import {
|
|
6
|
+
import { metadataBlockCss, titleBlockCss } from './styled';
|
|
7
|
+
import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition, SmartLinkSize } from '../../../../constants';
|
|
6
8
|
import uuid from 'uuid';
|
|
7
|
-
import {
|
|
9
|
+
import { getSimulatedMetadata, getSimulatedBetterMetadata } from './utils';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* This view represents a Block card that has an 'Resolved' status.
|
|
10
14
|
* @see SmartLinkStatus
|
|
@@ -23,36 +27,16 @@ const FlexibleResolvedView = ({
|
|
|
23
27
|
url,
|
|
24
28
|
analytics
|
|
25
29
|
}) => {
|
|
26
|
-
var _cardState$details, _cardState$details2;
|
|
27
30
|
const [isPreviewBlockErrored, setIsPreviewBlockErrored] = useState(false);
|
|
28
31
|
useEffect(() => {
|
|
29
32
|
setIsPreviewBlockErrored(false);
|
|
30
33
|
}, [url, cardState]);
|
|
31
34
|
const [analyticsId] = useState(() => id ? id : uuid());
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
name: ElementName.CommentCount
|
|
38
|
-
}, {
|
|
39
|
-
name: ElementName.ReactCount
|
|
40
|
-
}, {
|
|
41
|
-
name: ElementName.SubscriberCount
|
|
42
|
-
}, {
|
|
43
|
-
name: ElementName.ViewCount
|
|
44
|
-
}, {
|
|
45
|
-
name: ElementName.VoteCount
|
|
46
|
-
}, {
|
|
47
|
-
name: ElementName.ChecklistProgress
|
|
48
|
-
}, {
|
|
49
|
-
name: ElementName.DueOn
|
|
50
|
-
}];
|
|
51
|
-
const metadata = cardState !== null && cardState !== void 0 && (_cardState$details = cardState.details) !== null && _cardState$details !== void 0 && _cardState$details.data && extractOwnedBy(cardState === null || cardState === void 0 ? void 0 : (_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.data) ? [{
|
|
52
|
-
name: ElementName.OwnedBy
|
|
53
|
-
}, ...baseMetadata] : [{
|
|
54
|
-
name: ElementName.ModifiedBy
|
|
55
|
-
}, ...baseMetadata];
|
|
35
|
+
const {
|
|
36
|
+
titleMetadata,
|
|
37
|
+
topMetadata,
|
|
38
|
+
bottomMetadata
|
|
39
|
+
} = getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') ? getSimulatedBetterMetadata(cardState.details) : getSimulatedMetadata(cardState.details);
|
|
56
40
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
57
41
|
analytics: analytics,
|
|
58
42
|
appearance: "block",
|
|
@@ -64,25 +48,27 @@ const FlexibleResolvedView = ({
|
|
|
64
48
|
testId: testId,
|
|
65
49
|
ui: ui,
|
|
66
50
|
url: url
|
|
67
|
-
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
51
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, _extends({
|
|
68
52
|
position: SmartLinkPosition.Center,
|
|
69
|
-
metadata:
|
|
70
|
-
name: ElementName.AuthorGroup
|
|
71
|
-
}, {
|
|
72
|
-
name: ElementName.Priority
|
|
73
|
-
}, {
|
|
74
|
-
name: ElementName.State
|
|
75
|
-
}],
|
|
53
|
+
metadata: titleMetadata,
|
|
76
54
|
hideRetry: true,
|
|
77
55
|
subtitle: [{
|
|
78
56
|
name: ElementName.Location
|
|
79
57
|
}],
|
|
80
58
|
metadataPosition: SmartLinkPosition.Top,
|
|
81
59
|
anchorTarget: anchorTarget
|
|
82
|
-
}
|
|
83
|
-
|
|
60
|
+
}, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
|
|
61
|
+
overrideCss: titleBlockCss,
|
|
62
|
+
size: SmartLinkSize.Large
|
|
63
|
+
})), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
|
|
64
|
+
primary: topMetadata,
|
|
65
|
+
maxLines: 1
|
|
66
|
+
}, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
|
|
67
|
+
overrideCss: metadataBlockCss
|
|
68
|
+
})), /*#__PURE__*/React.createElement(SnippetBlock, null), getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
69
|
+
primary: bottomMetadata,
|
|
84
70
|
maxLines: 1
|
|
85
|
-
}),
|
|
71
|
+
}), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
|
|
86
72
|
placement: MediaPlacement.Right,
|
|
87
73
|
ignoreContainerPadding: true,
|
|
88
74
|
onError: () => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
// in editor prosemirror adds padding-left so we need to overwrite it
|
|
4
|
+
export const metadataBlockCss = css`
|
|
5
|
+
/* primary element group */
|
|
6
|
+
[data-smart-element-avatar-group] {
|
|
7
|
+
> ul {
|
|
8
|
+
padding-left: 0px;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
export const titleBlockCss = css`
|
|
13
|
+
gap: 0.5em;
|
|
14
|
+
`;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ElementName } from '../../../../constants';
|
|
2
|
+
import { extractOwnedBy, extractAssignedTo } from '../../../../extractors/flexible/utils';
|
|
3
|
+
import { getExtensionKey } from '../../../../state/helpers';
|
|
4
|
+
const baseTopMetadata = [{
|
|
5
|
+
name: ElementName.ModifiedOn
|
|
6
|
+
}, {
|
|
7
|
+
name: ElementName.AttachmentCount
|
|
8
|
+
}, {
|
|
9
|
+
name: ElementName.SubscriberCount
|
|
10
|
+
}, {
|
|
11
|
+
name: ElementName.VoteCount
|
|
12
|
+
}, {
|
|
13
|
+
name: ElementName.DueOn
|
|
14
|
+
}, {
|
|
15
|
+
name: ElementName.ReadTime
|
|
16
|
+
}];
|
|
17
|
+
const baseBottomMetaData = [{
|
|
18
|
+
name: ElementName.ReactCount
|
|
19
|
+
}, {
|
|
20
|
+
name: ElementName.CommentCount
|
|
21
|
+
}, {
|
|
22
|
+
name: ElementName.ViewCount
|
|
23
|
+
}, {
|
|
24
|
+
name: ElementName.Priority
|
|
25
|
+
}, {
|
|
26
|
+
name: ElementName.SubTasksProgress
|
|
27
|
+
}, {
|
|
28
|
+
name: ElementName.ChecklistProgress
|
|
29
|
+
}];
|
|
30
|
+
export const getSimulatedBetterMetadata = cardDetails => {
|
|
31
|
+
var _getExtensionKey;
|
|
32
|
+
const extensionKey = (_getExtensionKey = getExtensionKey(cardDetails)) !== null && _getExtensionKey !== void 0 ? _getExtensionKey : '';
|
|
33
|
+
const data = cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data;
|
|
34
|
+
const defaultTitleMetadata = [{
|
|
35
|
+
name: ElementName.State
|
|
36
|
+
}];
|
|
37
|
+
const defaultTopMetadata = [{
|
|
38
|
+
name: ElementName.AuthorGroup
|
|
39
|
+
}, {
|
|
40
|
+
name: ElementName.CreatedBy
|
|
41
|
+
}, ...baseTopMetadata];
|
|
42
|
+
const defaultBottomMetadata = baseBottomMetaData;
|
|
43
|
+
switch (extensionKey) {
|
|
44
|
+
case 'confluence-object-provider':
|
|
45
|
+
return {
|
|
46
|
+
titleMetadata: defaultTitleMetadata,
|
|
47
|
+
topMetadata: extractOwnedBy(data) ? [{
|
|
48
|
+
name: ElementName.OwnedByGroup
|
|
49
|
+
}, {
|
|
50
|
+
name: ElementName.OwnedBy
|
|
51
|
+
}, ...baseTopMetadata] : defaultTopMetadata,
|
|
52
|
+
bottomMetadata: defaultBottomMetadata
|
|
53
|
+
};
|
|
54
|
+
case 'jira-object-provider':
|
|
55
|
+
return {
|
|
56
|
+
titleMetadata: defaultTitleMetadata,
|
|
57
|
+
topMetadata: extractAssignedTo(data) ? [{
|
|
58
|
+
name: ElementName.AssignedToGroup
|
|
59
|
+
}, {
|
|
60
|
+
name: ElementName.AssignedTo
|
|
61
|
+
}, ...baseTopMetadata] : defaultTopMetadata,
|
|
62
|
+
bottomMetadata: defaultBottomMetadata
|
|
63
|
+
};
|
|
64
|
+
default:
|
|
65
|
+
return {
|
|
66
|
+
titleMetadata: defaultTitleMetadata,
|
|
67
|
+
topMetadata: defaultTopMetadata,
|
|
68
|
+
bottomMetadata: defaultBottomMetadata
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const getSimulatedMetadata = cardDetails => {
|
|
73
|
+
const baseMetadata = [{
|
|
74
|
+
name: ElementName.ModifiedOn
|
|
75
|
+
}, {
|
|
76
|
+
name: ElementName.AttachmentCount
|
|
77
|
+
}, {
|
|
78
|
+
name: ElementName.CommentCount
|
|
79
|
+
}, {
|
|
80
|
+
name: ElementName.ReactCount
|
|
81
|
+
}, {
|
|
82
|
+
name: ElementName.SubscriberCount
|
|
83
|
+
}, {
|
|
84
|
+
name: ElementName.ViewCount
|
|
85
|
+
}, {
|
|
86
|
+
name: ElementName.VoteCount
|
|
87
|
+
}, {
|
|
88
|
+
name: ElementName.ChecklistProgress
|
|
89
|
+
}, {
|
|
90
|
+
name: ElementName.DueOn
|
|
91
|
+
}];
|
|
92
|
+
const topMetadata = cardDetails !== null && cardDetails !== void 0 && cardDetails.data && extractOwnedBy(cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data) ? [{
|
|
93
|
+
name: ElementName.OwnedBy
|
|
94
|
+
}, ...baseMetadata] : [{
|
|
95
|
+
name: ElementName.ModifiedBy
|
|
96
|
+
}, ...baseMetadata];
|
|
97
|
+
const titleMetadata = [{
|
|
98
|
+
name: ElementName.AuthorGroup
|
|
99
|
+
}, {
|
|
100
|
+
name: ElementName.Priority
|
|
101
|
+
}, {
|
|
102
|
+
name: ElementName.State
|
|
103
|
+
}];
|
|
104
|
+
return {
|
|
105
|
+
titleMetadata,
|
|
106
|
+
topMetadata
|
|
107
|
+
};
|
|
108
|
+
};
|
|
@@ -2,41 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
import { IntlProvider } from 'react-intl-next';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const openPreviewModal = ({
|
|
8
|
-
analytics,
|
|
9
|
-
downloadUrl: download,
|
|
10
|
-
isSupportTheming,
|
|
11
|
-
linkIcon,
|
|
12
|
-
onClose = () => {},
|
|
13
|
-
providerName,
|
|
14
|
-
src,
|
|
15
|
-
title,
|
|
16
|
-
url
|
|
17
|
-
}) => {
|
|
18
|
-
const EmbedIcon = {
|
|
19
|
-
icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
|
|
20
|
-
size: SmartLinkSize.Large
|
|
21
|
-
})),
|
|
22
|
-
isFlexibleUi: true
|
|
23
|
-
};
|
|
24
|
-
return previewFunction({
|
|
25
|
-
popupMountPointId: 'twp-editor-preview-iframe',
|
|
26
|
-
showModal: true,
|
|
27
|
-
iframeName: 'twp-editor-preview-iframe',
|
|
28
|
-
onClose,
|
|
29
|
-
download,
|
|
30
|
-
icon: EmbedIcon,
|
|
31
|
-
providerName: providerName || 'Preview',
|
|
32
|
-
src,
|
|
33
|
-
title,
|
|
34
|
-
url,
|
|
35
|
-
analytics,
|
|
36
|
-
origin: 'smartLinkCard',
|
|
37
|
-
isSupportTheming
|
|
38
|
-
});
|
|
39
|
-
};
|
|
5
|
+
const IFRAME_NAME = 'twp-editor-preview-iframe';
|
|
6
|
+
const POPUP_MOUNT_POINT_ID = 'twp-editor-preview-iframe';
|
|
40
7
|
|
|
41
8
|
/*
|
|
42
9
|
Explanatory note:
|
|
@@ -51,30 +18,31 @@ export const openPreviewModal = ({
|
|
|
51
18
|
you find an elegant solution around this, you should definitely feel free to
|
|
52
19
|
refactor it.
|
|
53
20
|
*/
|
|
54
|
-
export async function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}) {
|
|
21
|
+
export async function openEmbedModal({
|
|
22
|
+
onClose = () => {},
|
|
23
|
+
...props
|
|
24
|
+
} = {}) {
|
|
59
25
|
let popupMountPoint;
|
|
60
|
-
popupMountPoint = document.getElementById(
|
|
26
|
+
popupMountPoint = document.getElementById(POPUP_MOUNT_POINT_ID);
|
|
61
27
|
if (!popupMountPoint) {
|
|
62
28
|
popupMountPoint = document.createElement('div');
|
|
63
|
-
popupMountPoint.id =
|
|
29
|
+
popupMountPoint.id = POPUP_MOUNT_POINT_ID;
|
|
64
30
|
popupMountPoint.setAttribute('data-testid', 'preview-modal');
|
|
65
31
|
document.body.appendChild(popupMountPoint);
|
|
66
32
|
}
|
|
67
33
|
let Modal = await import('./index');
|
|
68
34
|
ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
69
35
|
locale: "en"
|
|
70
|
-
}, /*#__PURE__*/React.createElement(Modal.default, _extends({},
|
|
36
|
+
}, /*#__PURE__*/React.createElement(Modal.default, _extends({}, props, {
|
|
37
|
+
iframeName: IFRAME_NAME,
|
|
71
38
|
onClose: _context => {
|
|
72
39
|
if (popupMountPoint) {
|
|
73
40
|
ReactDOM.unmountComponentAtNode(popupMountPoint);
|
|
74
41
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
42
|
+
if (onClose) {
|
|
43
|
+
onClose(_context);
|
|
77
44
|
}
|
|
78
|
-
}
|
|
45
|
+
},
|
|
46
|
+
showModal: true
|
|
79
47
|
}))), popupMountPoint);
|
|
80
48
|
}
|
|
@@ -3,10 +3,10 @@ import React from 'react';
|
|
|
3
3
|
import Action from '../index';
|
|
4
4
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
5
5
|
import { useSmartLinkAnalytics } from '../../../../../../state';
|
|
6
|
-
import { openPreviewModal } from '../../../../../EmbedModal/utils';
|
|
7
6
|
import { FormattedMessage } from 'react-intl-next';
|
|
8
7
|
import { messages } from '../../../../../../messages';
|
|
9
8
|
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
9
|
+
import { openEmbedModalWithFlexibleUiIcon } from '../../../utils';
|
|
10
10
|
const PreviewAction = props => {
|
|
11
11
|
const {
|
|
12
12
|
appearance,
|
|
@@ -26,7 +26,7 @@ const PreviewAction = props => {
|
|
|
26
26
|
const enableImprovedPreviewAction = Boolean(useFeatureFlag('enableImprovedPreviewAction'));
|
|
27
27
|
const previewText = enableImprovedPreviewAction ? messages.preview_improved : messages.preview;
|
|
28
28
|
if (src && url) {
|
|
29
|
-
const embedModal = () =>
|
|
29
|
+
const embedModal = () => openEmbedModalWithFlexibleUiIcon({
|
|
30
30
|
title,
|
|
31
31
|
providerName,
|
|
32
32
|
downloadUrl,
|
|
@@ -10,6 +10,8 @@ import ElementGroup from './element-group';
|
|
|
10
10
|
// Determine whether the element can be display as inline/block.
|
|
11
11
|
|
|
12
12
|
export const ElementDisplaySchema = {
|
|
13
|
+
[ElementName.AssignedTo]: ['inline'],
|
|
14
|
+
[ElementName.AssignedToGroup]: ['inline'],
|
|
13
15
|
[ElementName.AttachmentCount]: ['inline'],
|
|
14
16
|
[ElementName.AuthorGroup]: ['inline'],
|
|
15
17
|
[ElementName.ChecklistProgress]: ['inline'],
|
|
@@ -24,15 +26,18 @@ export const ElementDisplaySchema = {
|
|
|
24
26
|
[ElementName.ModifiedBy]: ['inline'],
|
|
25
27
|
[ElementName.ModifiedOn]: ['inline'],
|
|
26
28
|
[ElementName.OwnedBy]: ['inline'],
|
|
29
|
+
[ElementName.OwnedByGroup]: ['inline'],
|
|
27
30
|
[ElementName.Preview]: ['block'],
|
|
28
31
|
[ElementName.Priority]: ['inline'],
|
|
29
32
|
[ElementName.ProgrammingLanguage]: ['inline'],
|
|
30
33
|
[ElementName.Provider]: ['inline'],
|
|
31
34
|
[ElementName.ReactCount]: ['inline'],
|
|
35
|
+
[ElementName.ReadTime]: ['inline'],
|
|
32
36
|
[ElementName.Snippet]: ['block'],
|
|
33
37
|
[ElementName.SourceBranch]: ['inline'],
|
|
34
38
|
[ElementName.State]: ['inline'],
|
|
35
39
|
[ElementName.SubscriberCount]: ['inline'],
|
|
40
|
+
[ElementName.SubTasksProgress]: ['inline'],
|
|
36
41
|
[ElementName.TargetBranch]: ['inline'],
|
|
37
42
|
[ElementName.Title]: ['inline'],
|
|
38
43
|
[ElementName.ViewCount]: ['inline'],
|
|
@@ -3,6 +3,16 @@ import { ElementName } from '../../../../constants';
|
|
|
3
3
|
// Attention: Keep the export name and element name the same.
|
|
4
4
|
// This will help reducing the code for mapping elements inside
|
|
5
5
|
// createElement and renderElementItems
|
|
6
|
+
/**
|
|
7
|
+
* Creates a AssignedTo text element using the data from AssignedTo in the Flexible UI Context.
|
|
8
|
+
* @see Text
|
|
9
|
+
*/
|
|
10
|
+
export const AssignedTo = createElement(ElementName.AssignedTo);
|
|
11
|
+
/**
|
|
12
|
+
* An AvatarGroup element using the data from AssignedToGroup in the Flexible UI Context.
|
|
13
|
+
* @see AvatarGroup
|
|
14
|
+
*/
|
|
15
|
+
export const AssignedToGroup = createElement(ElementName.AssignedToGroup);
|
|
6
16
|
/**
|
|
7
17
|
* Creates a AttachmentCount Badge element using the data from AttachmentCount in the Flexible UI Context.
|
|
8
18
|
* @see Badge
|
|
@@ -73,6 +83,11 @@ export const ModifiedOn = createElement(ElementName.ModifiedOn);
|
|
|
73
83
|
* @see Text
|
|
74
84
|
*/
|
|
75
85
|
export const OwnedBy = createElement(ElementName.OwnedBy);
|
|
86
|
+
/**
|
|
87
|
+
* An AvatarGroup element using the data from OwnedByGroup in the Flexible UI Context.
|
|
88
|
+
* @see AvatarGroup
|
|
89
|
+
*/
|
|
90
|
+
export const OwnedByGroup = createElement(ElementName.OwnedByGroup);
|
|
76
91
|
/**
|
|
77
92
|
* Creates a Preview element using the data from Preview in the Flexible UI Context.
|
|
78
93
|
* @see Preview
|
|
@@ -98,6 +113,10 @@ export const Provider = createElement(ElementName.Provider);
|
|
|
98
113
|
* @see Badge
|
|
99
114
|
*/
|
|
100
115
|
export const ReactCount = createElement(ElementName.ReactCount);
|
|
116
|
+
/**
|
|
117
|
+
* Creates a ReadTime Text element using the data from readTime in the Flexible UI Context
|
|
118
|
+
*/
|
|
119
|
+
export const ReadTime = createElement(ElementName.ReadTime);
|
|
101
120
|
/**
|
|
102
121
|
* Creates a Snippet element using the data from Snippet in the Flexible UI Context.
|
|
103
122
|
* @see Text
|
|
@@ -118,6 +137,11 @@ export const State = createElement(ElementName.State);
|
|
|
118
137
|
* @see Badge
|
|
119
138
|
*/
|
|
120
139
|
export const SubscriberCount = createElement(ElementName.SubscriberCount);
|
|
140
|
+
/**
|
|
141
|
+
* Create a SubTasks Badge element using the data from subTasks in the Flexible UI Context.
|
|
142
|
+
* @see Badge
|
|
143
|
+
*/
|
|
144
|
+
export const SubTasksProgress = createElement(ElementName.SubTasksProgress);
|
|
121
145
|
/**
|
|
122
146
|
* Creates a TargetBranch Text element using the data from targetBranch in the Flexible UI Context.
|
|
123
147
|
* @see Text
|
|
@@ -6,10 +6,9 @@ import { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
|
6
6
|
import { R50, R500 } from '@atlaskit/theme/colors';
|
|
7
7
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
8
8
|
import { dropdownItemGroupStyles, contentStyles, linkStyles, textStyles } from './styled';
|
|
9
|
-
import { getFormattedMessage } from '../../../../utils';
|
|
9
|
+
import { getFormattedMessage, openEmbedModalWithFlexibleUiIcon } from '../../../../utils';
|
|
10
10
|
import { messages } from '../../../../../../../messages';
|
|
11
11
|
import { useFlexibleUiAnalyticsContext } from '../../../../../../../state/flexible-ui-context';
|
|
12
|
-
import { openPreviewModal } from '../../../../../../EmbedModal/utils';
|
|
13
12
|
import useResolve from '../../../../../../../state/hooks/use-resolve';
|
|
14
13
|
const MAX_LINE_NUMBER = 8;
|
|
15
14
|
const LozengeActionError = ({
|
|
@@ -30,7 +29,7 @@ const LozengeActionError = ({
|
|
|
30
29
|
const handlePreviewOpen = useCallback(() => {
|
|
31
30
|
if (isPreviewAvailable) {
|
|
32
31
|
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionErrorOpenPreviewClickedEvent();
|
|
33
|
-
return
|
|
32
|
+
return openEmbedModalWithFlexibleUiIcon({
|
|
34
33
|
...previewData,
|
|
35
34
|
analytics,
|
|
36
35
|
onClose: handlePreviewClose
|
|
@@ -64,6 +64,15 @@ const elementMappings = {
|
|
|
64
64
|
[ElementName.OwnedBy]: {
|
|
65
65
|
component: Text
|
|
66
66
|
},
|
|
67
|
+
[ElementName.AssignedTo]: {
|
|
68
|
+
component: Text
|
|
69
|
+
},
|
|
70
|
+
[ElementName.AssignedToGroup]: {
|
|
71
|
+
component: AvatarGroup
|
|
72
|
+
},
|
|
73
|
+
[ElementName.OwnedByGroup]: {
|
|
74
|
+
component: AvatarGroup
|
|
75
|
+
},
|
|
67
76
|
[ElementName.CreatedOn]: {
|
|
68
77
|
component: DateTime
|
|
69
78
|
},
|
|
@@ -100,6 +109,9 @@ const elementMappings = {
|
|
|
100
109
|
[ElementName.Provider]: {
|
|
101
110
|
component: Badge
|
|
102
111
|
},
|
|
112
|
+
[ElementName.ReadTime]: {
|
|
113
|
+
component: Text
|
|
114
|
+
},
|
|
103
115
|
[ElementName.Snippet]: {
|
|
104
116
|
component: Text,
|
|
105
117
|
props: {
|
|
@@ -121,6 +133,12 @@ const elementMappings = {
|
|
|
121
133
|
icon: IconType.Subscriber
|
|
122
134
|
}
|
|
123
135
|
},
|
|
136
|
+
[ElementName.SubTasksProgress]: {
|
|
137
|
+
component: Badge,
|
|
138
|
+
props: {
|
|
139
|
+
icon: IconType.CheckItem
|
|
140
|
+
}
|
|
141
|
+
},
|
|
124
142
|
[ElementName.TargetBranch]: {
|
|
125
143
|
component: Text
|
|
126
144
|
},
|
|
@@ -146,7 +164,9 @@ const getData = (elementName, contextKey, context) => {
|
|
|
146
164
|
const data = context[contextKey];
|
|
147
165
|
switch (elementName) {
|
|
148
166
|
case ElementName.AuthorGroup:
|
|
167
|
+
case ElementName.AssignedToGroup:
|
|
149
168
|
case ElementName.CollaboratorGroup:
|
|
169
|
+
case ElementName.OwnedByGroup:
|
|
150
170
|
return toAvatarGroupProps(data);
|
|
151
171
|
case ElementName.AttachmentCount:
|
|
152
172
|
case ElementName.ChecklistProgress:
|
|
@@ -157,9 +177,12 @@ const getData = (elementName, contextKey, context) => {
|
|
|
157
177
|
case ElementName.ProgrammingLanguage:
|
|
158
178
|
case ElementName.SubscriberCount:
|
|
159
179
|
case ElementName.LatestCommit:
|
|
180
|
+
case ElementName.SubTasksProgress:
|
|
160
181
|
return toBadgeProps(data);
|
|
161
182
|
case ElementName.CreatedBy:
|
|
162
183
|
return toFormattedTextProps(messages.created_by, context.createdBy);
|
|
184
|
+
case ElementName.AssignedTo:
|
|
185
|
+
return toFormattedTextProps(messages.assigned_to, context.assignedTo);
|
|
163
186
|
case ElementName.OwnedBy:
|
|
164
187
|
return toFormattedTextProps(messages.owned_by, context.ownedBy);
|
|
165
188
|
case ElementName.CreatedOn:
|
|
@@ -170,6 +193,8 @@ const getData = (elementName, contextKey, context) => {
|
|
|
170
193
|
return toFormattedTextProps(messages.modified_by, context.modifiedBy);
|
|
171
194
|
case ElementName.ModifiedOn:
|
|
172
195
|
return toDateTimeProps('modified', context.modifiedOn);
|
|
196
|
+
case ElementName.ReadTime:
|
|
197
|
+
return toFormattedTextProps(messages.read_time, data);
|
|
173
198
|
case ElementName.Snippet:
|
|
174
199
|
case ElementName.SourceBranch:
|
|
175
200
|
case ElementName.TargetBranch:
|
|
@@ -3,6 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
5
|
import { SmartLinkSize } from '../../../constants';
|
|
6
|
+
import Icon from './elements/icon';
|
|
7
|
+
import { openEmbedModal } from '../../EmbedModal/utils';
|
|
6
8
|
export const sizeToButtonSpacing = {
|
|
7
9
|
[SmartLinkSize.Small]: 'none',
|
|
8
10
|
[SmartLinkSize.Medium]: 'compact',
|
|
@@ -130,4 +132,37 @@ export const getTruncateStyles = (maxLines, lineHeight = '1rem', wordBreak = 'br
|
|
|
130
132
|
`;
|
|
131
133
|
export const hasWhiteSpace = str => {
|
|
132
134
|
return str.search(/\s/) >= 0;
|
|
135
|
+
};
|
|
136
|
+
export const openEmbedModalWithFlexibleUiIcon = ({
|
|
137
|
+
analytics,
|
|
138
|
+
downloadUrl,
|
|
139
|
+
linkIcon,
|
|
140
|
+
onClose,
|
|
141
|
+
providerName,
|
|
142
|
+
src,
|
|
143
|
+
title,
|
|
144
|
+
url,
|
|
145
|
+
isSupportTheming
|
|
146
|
+
}) => {
|
|
147
|
+
const icon = {
|
|
148
|
+
icon: /*#__PURE__*/React.createElement(Icon, _extends({}, linkIcon, {
|
|
149
|
+
size: SmartLinkSize.Large
|
|
150
|
+
})),
|
|
151
|
+
isFlexibleUi: true
|
|
152
|
+
};
|
|
153
|
+
return openEmbedModal({
|
|
154
|
+
analytics,
|
|
155
|
+
download: downloadUrl,
|
|
156
|
+
icon,
|
|
157
|
+
// Flex should not send origin as block card. It should be able to support
|
|
158
|
+
// its internal parent components like hover card, block card and
|
|
159
|
+
// itself as a standalone. To be investigated and fix in EDM-7520.
|
|
160
|
+
origin: 'smartLinkCard',
|
|
161
|
+
providerName,
|
|
162
|
+
onClose,
|
|
163
|
+
src,
|
|
164
|
+
title,
|
|
165
|
+
url,
|
|
166
|
+
isSupportTheming
|
|
167
|
+
});
|
|
133
168
|
};
|
|
@@ -5,11 +5,12 @@ import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../..
|
|
|
5
5
|
import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
|
|
6
6
|
import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
|
|
7
7
|
import FlexibleCard from '../../../../FlexibleCard';
|
|
8
|
-
import { getSimulatedMetadata } from '../../../utils';
|
|
8
|
+
import { getSimulatedMetadata, getSimulatedBetterMetadata } from '../../../utils';
|
|
9
9
|
import SnippetOrPreview from '../../SnippetOrPreview';
|
|
10
|
-
import { extractMetadata } from '../../../../../extractors/hover/extractMetadata';
|
|
10
|
+
import { extractMetadata, elementNamesToItems } from '../../../../../extractors/hover/extractMetadata';
|
|
11
11
|
import { messages } from '../../../../../messages';
|
|
12
12
|
import { FormattedMessage } from 'react-intl-next';
|
|
13
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
export const toFooterActions = (cardActions, onActionClick, enableImprovedPreviewAction) => {
|
|
14
15
|
const appearance = enableImprovedPreviewAction ? {
|
|
15
16
|
appearance: 'primary'
|
|
@@ -67,15 +68,23 @@ const HoverCardResolvedView = ({
|
|
|
67
68
|
const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick, Boolean(enableImprovedPreviewAction)), [cardActions, onActionClick, enableImprovedPreviewAction]);
|
|
68
69
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
69
70
|
const {
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
topPrimary,
|
|
72
|
+
topSecondary,
|
|
73
|
+
bottomPrimary
|
|
72
74
|
} = useMemo(() => {
|
|
73
|
-
|
|
75
|
+
if (getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg')) {
|
|
76
|
+
const betterMetadata = getSimulatedBetterMetadata(extensionKey, data);
|
|
77
|
+
return {
|
|
78
|
+
topPrimary: elementNamesToItems(betterMetadata.topMetadataBlock.primary),
|
|
79
|
+
topSecondary: elementNamesToItems(betterMetadata.topMetadataBlock.secondary),
|
|
80
|
+
bottomPrimary: elementNamesToItems(betterMetadata.bottomMetadataBlock.primary)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
74
83
|
const metadata = extractMetadata(getSimulatedMetadata(extensionKey, data));
|
|
75
84
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
topPrimary: metadata.primary,
|
|
86
|
+
topSecondary: metadata.secondary,
|
|
87
|
+
bottomPrimary: []
|
|
79
88
|
};
|
|
80
89
|
}, [data, extensionKey]);
|
|
81
90
|
const snippetHeight = React.useRef(0);
|
|
@@ -90,17 +99,24 @@ const HoverCardResolvedView = ({
|
|
|
90
99
|
});
|
|
91
100
|
return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
|
|
92
101
|
metadataPosition: SmartLinkPosition.Top
|
|
93
|
-
})), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
94
|
-
primary:
|
|
95
|
-
secondary:
|
|
96
|
-
size: SmartLinkSize.Large,
|
|
102
|
+
})), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
|
|
103
|
+
primary: topPrimary,
|
|
104
|
+
secondary: topSecondary,
|
|
97
105
|
overrideCss: metadataBlockCss,
|
|
98
|
-
maxLines: 1
|
|
99
|
-
|
|
106
|
+
maxLines: 1,
|
|
107
|
+
size: SmartLinkSize.Large
|
|
108
|
+
}, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && {
|
|
109
|
+
size: SmartLinkSize.Medium
|
|
110
|
+
})), body, /*#__PURE__*/React.createElement(SnippetBlock, {
|
|
100
111
|
testId: 'hidden-snippet',
|
|
101
112
|
onRender: onSnippetRender,
|
|
102
113
|
blockRef: snippetBlockRef,
|
|
103
114
|
overrideCss: hiddenSnippetStyles
|
|
115
|
+
}), getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
116
|
+
primary: bottomPrimary,
|
|
117
|
+
size: SmartLinkSize.Large,
|
|
118
|
+
overrideCss: metadataBlockCss,
|
|
119
|
+
maxLines: 1
|
|
104
120
|
}), /*#__PURE__*/React.createElement(FooterBlock, {
|
|
105
121
|
actions: footerActions,
|
|
106
122
|
size: SmartLinkSize.Large,
|