@atlaskit/smart-card 23.5.0 → 23.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/state/actions/index.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +12 -4
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +18 -6
- package/dist/cjs/view/HoverCard/utils.js +41 -2
- package/dist/es2019/state/actions/index.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +22 -3
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +14 -4
- package/dist/es2019/view/HoverCard/utils.js +20 -0
- package/dist/esm/state/actions/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +11 -4
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +17 -6
- package/dist/esm/view/HoverCard/utils.js +34 -0
- package/dist/types/view/FlexibleCard/components/elements/lozenge/types.d.ts +5 -0
- package/dist/types/view/HoverCard/utils.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 23.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0b8bfb1a2d9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0b8bfb1a2d9) - Force http call (and not use cache) when reload action is called
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 23.5.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`1070e536838`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1070e536838) - [ux] Hover Preview: Add experiment for actionable element
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 23.5.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -160,7 +160,7 @@ var useSmartCardActions = function useSmartCardActions(id, url, analytics) {
|
|
|
160
160
|
break;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
return _context.abrupt("return", connections.client.fetchData(resourceUrl).then(function (response) {
|
|
163
|
+
return _context.abrupt("return", connections.client.fetchData(resourceUrl, isReloading).then(function (response) {
|
|
164
164
|
return handleResolvedLinkResponse(resourceUrl, response, isReloading, isMetadataRequest);
|
|
165
165
|
}).catch(function (error) {
|
|
166
166
|
return handleResolvedLinkError(resourceUrl, error, undefined, isMetadataRequest);
|
package/dist/cjs/version.json
CHANGED
|
@@ -15,9 +15,12 @@ var _react2 = require("@emotion/react");
|
|
|
15
15
|
|
|
16
16
|
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
|
|
19
|
+
|
|
20
|
+
var _templateObject, _templateObject2;
|
|
19
21
|
|
|
20
22
|
var styles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height: inherit;\n"])));
|
|
23
|
+
var actionStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n"])));
|
|
21
24
|
/**
|
|
22
25
|
* A base element that displays a Lozenge.
|
|
23
26
|
* @internal
|
|
@@ -29,6 +32,7 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
29
32
|
var _ref$appearance = _ref.appearance,
|
|
30
33
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
31
34
|
name = _ref.name,
|
|
35
|
+
onClick = _ref.onClick,
|
|
32
36
|
overrideCss = _ref.overrideCss,
|
|
33
37
|
text = _ref.text,
|
|
34
38
|
_ref$testId = _ref.testId,
|
|
@@ -39,15 +43,19 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
return (0, _react2.jsx)("span", {
|
|
42
|
-
css: [styles, overrideCss],
|
|
46
|
+
css: [styles, onClick ? actionStyles : undefined, overrideCss],
|
|
43
47
|
"data-fit-to-content": true,
|
|
44
48
|
"data-smart-element": name,
|
|
45
49
|
"data-smart-element-lozenge": true,
|
|
46
|
-
"data-testid": testId
|
|
50
|
+
"data-testid": testId,
|
|
51
|
+
onClick: onClick
|
|
47
52
|
}, (0, _react2.jsx)(_lozenge.default, {
|
|
48
53
|
appearance: appearance,
|
|
49
54
|
testId: "".concat(testId, "-lozenge")
|
|
50
|
-
}, text)
|
|
55
|
+
}, text, onClick && (0, _react2.jsx)(_chevronDown.default, {
|
|
56
|
+
label: "action",
|
|
57
|
+
testId: "".concat(testId, "-action")
|
|
58
|
+
})));
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
var _default = Lozenge;
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.toFooterActions = exports.getOpenAction = exports.default = void 0;
|
|
11
11
|
|
|
12
|
+
var _linkProvider = require("@atlaskit/link-provider");
|
|
13
|
+
|
|
12
14
|
var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
|
|
13
15
|
|
|
14
16
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
@@ -17,7 +19,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
19
|
|
|
18
20
|
var _constants = require("../../../constants");
|
|
19
21
|
|
|
20
|
-
var
|
|
22
|
+
var _extractMetadata = require("../../../extractors/hover/extractMetadata");
|
|
21
23
|
|
|
22
24
|
var _actions = require("../../../state/actions");
|
|
23
25
|
|
|
@@ -97,6 +99,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
97
99
|
onResolve = _ref.onResolve,
|
|
98
100
|
renderers = _ref.renderers,
|
|
99
101
|
url = _ref.url;
|
|
102
|
+
var showActionableElement = (0, _linkProvider.useFeatureFlag)('enableActionableElement');
|
|
100
103
|
var actions = (0, _actions.useSmartCardActions)(id, url, analytics);
|
|
101
104
|
(0, _react.useEffect)(function () {
|
|
102
105
|
actions.loadMetadata();
|
|
@@ -129,12 +132,21 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
129
132
|
return toFooterActions(cardActions, onActionClick);
|
|
130
133
|
}, [cardActions, onActionClick]);
|
|
131
134
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
132
|
-
var types = data ? (0, _extractors.extractType)(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
133
135
|
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
var _useMemo = (0, _react.useMemo)(function () {
|
|
137
|
+
var types = data ? (0, _extractors.extractType)(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
138
|
+
|
|
139
|
+
var metadata = (0, _extractMetadata.extractMetadata)((0, _utils2.getSimulatedMetadata)(extensionKey, types));
|
|
140
|
+
var primary = showActionableElement ? (0, _utils2.toActionableMetadata)(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
141
|
+
return {
|
|
142
|
+
primary: primary,
|
|
143
|
+
secondary: metadata.secondary,
|
|
144
|
+
subtitle: metadata.subtitle
|
|
145
|
+
};
|
|
146
|
+
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]),
|
|
147
|
+
primary = _useMemo.primary,
|
|
148
|
+
secondary = _useMemo.secondary,
|
|
149
|
+
subtitle = _useMemo.subtitle;
|
|
138
150
|
|
|
139
151
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
140
152
|
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports.getSimulatedMetadata = exports.SMART_CARD_ANALYTICS_DISPLAY = void 0;
|
|
8
|
+
exports.toActionableMetadata = exports.getSimulatedMetadata = exports.SMART_CARD_ANALYTICS_DISPLAY = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
11
|
|
|
8
12
|
var _constants = require("../../constants");
|
|
9
13
|
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
10
18
|
var SMART_CARD_ANALYTICS_DISPLAY = 'flexible';
|
|
11
19
|
exports.SMART_CARD_ANALYTICS_DISPLAY = SMART_CARD_ANALYTICS_DISPLAY;
|
|
12
20
|
|
|
@@ -92,4 +100,35 @@ var getSimulatedMetadata = function getSimulatedMetadata() {
|
|
|
92
100
|
}
|
|
93
101
|
};
|
|
94
102
|
|
|
95
|
-
exports.getSimulatedMetadata = getSimulatedMetadata;
|
|
103
|
+
exports.getSimulatedMetadata = getSimulatedMetadata;
|
|
104
|
+
|
|
105
|
+
var toActionableMetadata = function toActionableMetadata(onActionClick, extensionKey) {
|
|
106
|
+
var types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
107
|
+
var cardActions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
108
|
+
var elementItems = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
109
|
+
|
|
110
|
+
// Actionable State for Jira issue
|
|
111
|
+
if (extensionKey === 'jira-object-provider' && types !== null && types !== void 0 && types.includes('atlassian:Task')) {
|
|
112
|
+
var previewAction = cardActions.find(function (action) {
|
|
113
|
+
return action.id === 'preview-content';
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (previewAction) {
|
|
117
|
+
return elementItems.map(function (elementItem) {
|
|
118
|
+
return elementItem.name === _constants.ElementName.State ? _objectSpread(_objectSpread({}, elementItem), {}, {
|
|
119
|
+
onClick: function onClick() {
|
|
120
|
+
if (onActionClick) {
|
|
121
|
+
onActionClick(previewAction.id);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return previewAction.invoke();
|
|
125
|
+
}
|
|
126
|
+
}) : elementItem;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return elementItems;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
exports.toActionableMetadata = toActionableMetadata;
|
|
@@ -113,11 +113,11 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
113
113
|
}
|
|
114
114
|
}, [dispatch, handleResolvedLinkError, hasAuthFlowSupported, setMetadataStatus]);
|
|
115
115
|
const resolve = useCallback(async (resourceUrl = url, isReloading = false, isMetadataRequest = false) => {
|
|
116
|
-
// Request JSON-LD data for the card from ORS,
|
|
116
|
+
// Request JSON-LD data for the card from ORS, if it has extended
|
|
117
117
|
// its cache lifespan OR there is no data for it currently. Once the data
|
|
118
118
|
// has come back asynchronously, dispatch the resolved action for the card.
|
|
119
119
|
if (isReloading || !hasData || isMetadataRequest) {
|
|
120
|
-
return connections.client.fetchData(resourceUrl).then(response => handleResolvedLinkResponse(resourceUrl, response, isReloading, isMetadataRequest)).catch(error => handleResolvedLinkError(resourceUrl, error, undefined, isMetadataRequest));
|
|
120
|
+
return connections.client.fetchData(resourceUrl, isReloading).then(response => handleResolvedLinkResponse(resourceUrl, response, isReloading, isMetadataRequest)).catch(error => handleResolvedLinkError(resourceUrl, error, undefined, isMetadataRequest));
|
|
121
121
|
} else {
|
|
122
122
|
addMetadataToExperience('smart-link-rendered', id, {
|
|
123
123
|
cached: true
|
package/dist/es2019/version.json
CHANGED
|
@@ -2,10 +2,24 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import AtlaskitLozenge from '@atlaskit/lozenge';
|
|
5
|
+
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
5
6
|
const styles = css`
|
|
6
7
|
display: inline-flex;
|
|
7
8
|
line-height: inherit;
|
|
8
9
|
`;
|
|
10
|
+
const actionStyles = css`
|
|
11
|
+
> span > span {
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
margin-right: -2px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
svg {
|
|
18
|
+
width: unset;
|
|
19
|
+
height: unset;
|
|
20
|
+
margin: -4px 0;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
9
23
|
/**
|
|
10
24
|
* A base element that displays a Lozenge.
|
|
11
25
|
* @internal
|
|
@@ -16,6 +30,7 @@ const styles = css`
|
|
|
16
30
|
const Lozenge = ({
|
|
17
31
|
appearance = 'default',
|
|
18
32
|
name,
|
|
33
|
+
onClick,
|
|
19
34
|
overrideCss,
|
|
20
35
|
text,
|
|
21
36
|
testId = 'smart-element-lozenge'
|
|
@@ -25,15 +40,19 @@ const Lozenge = ({
|
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
return jsx("span", {
|
|
28
|
-
css: [styles, overrideCss],
|
|
43
|
+
css: [styles, onClick ? actionStyles : undefined, overrideCss],
|
|
29
44
|
"data-fit-to-content": true,
|
|
30
45
|
"data-smart-element": name,
|
|
31
46
|
"data-smart-element-lozenge": true,
|
|
32
|
-
"data-testid": testId
|
|
47
|
+
"data-testid": testId,
|
|
48
|
+
onClick: onClick
|
|
33
49
|
}, jsx(AtlaskitLozenge, {
|
|
34
50
|
appearance: appearance,
|
|
35
51
|
testId: `${testId}-lozenge`
|
|
36
|
-
}, text
|
|
52
|
+
}, text, onClick && jsx(ChevronDownIcon, {
|
|
53
|
+
label: "action",
|
|
54
|
+
testId: `${testId}-action`
|
|
55
|
+
})));
|
|
37
56
|
};
|
|
38
57
|
|
|
39
58
|
export default Lozenge;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
1
2
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
2
3
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
3
4
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
@@ -9,7 +10,7 @@ import { isSpecialEvent } from '../../../utils';
|
|
|
9
10
|
import FlexibleCard from '../../FlexibleCard';
|
|
10
11
|
import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
11
12
|
import { flexibleUiOptions, footerBlockCss, metadataBlockCss, titleBlockCss, hiddenSnippetStyles } from '../styled';
|
|
12
|
-
import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
13
|
+
import { toActionableMetadata, getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
13
14
|
import HoverCardLoadingView from './HoverCardLoadingView';
|
|
14
15
|
import SnippetOrPreview from './SnippetOrPreview';
|
|
15
16
|
export const getOpenAction = (url, analytics, onActionClick) => ({
|
|
@@ -56,6 +57,7 @@ const HoverCardContent = ({
|
|
|
56
57
|
}) => {
|
|
57
58
|
var _cardState$details;
|
|
58
59
|
|
|
60
|
+
const showActionableElement = useFeatureFlag('enableActionableElement');
|
|
59
61
|
const actions = useSmartCardActions(id, url, analytics);
|
|
60
62
|
useEffect(() => {
|
|
61
63
|
actions.loadMetadata();
|
|
@@ -82,13 +84,21 @@ const HoverCardContent = ({
|
|
|
82
84
|
const titleActions = useMemo(() => [getOpenAction(url, analytics, onActionClick)], [url, analytics, onActionClick]);
|
|
83
85
|
const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick), [cardActions, onActionClick]);
|
|
84
86
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
85
|
-
const types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
86
|
-
|
|
87
87
|
const {
|
|
88
88
|
primary,
|
|
89
89
|
secondary,
|
|
90
90
|
subtitle
|
|
91
|
-
} =
|
|
91
|
+
} = useMemo(() => {
|
|
92
|
+
const types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
93
|
+
|
|
94
|
+
const metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
95
|
+
const primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
96
|
+
return {
|
|
97
|
+
primary,
|
|
98
|
+
secondary: metadata.secondary,
|
|
99
|
+
subtitle: metadata.subtitle
|
|
100
|
+
};
|
|
101
|
+
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]);
|
|
92
102
|
const titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
93
103
|
const snippetHeight = React.useRef(0);
|
|
94
104
|
const snippetBlockRef = useRef(null);
|
|
@@ -77,4 +77,24 @@ export const getSimulatedMetadata = (extensionKey = '', types = []) => {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
};
|
|
81
|
+
export const toActionableMetadata = (onActionClick, extensionKey, types = [], cardActions = [], elementItems = []) => {
|
|
82
|
+
// Actionable State for Jira issue
|
|
83
|
+
if (extensionKey === 'jira-object-provider' && types !== null && types !== void 0 && types.includes('atlassian:Task')) {
|
|
84
|
+
const previewAction = cardActions.find(action => action.id === 'preview-content');
|
|
85
|
+
|
|
86
|
+
if (previewAction) {
|
|
87
|
+
return elementItems.map(elementItem => elementItem.name === ElementName.State ? { ...elementItem,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
if (onActionClick) {
|
|
90
|
+
onActionClick(previewAction.id);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return previewAction.invoke();
|
|
94
|
+
}
|
|
95
|
+
} : elementItem);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return elementItems;
|
|
80
100
|
};
|
|
@@ -133,7 +133,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
133
133
|
break;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
return _context.abrupt("return", connections.client.fetchData(resourceUrl).then(function (response) {
|
|
136
|
+
return _context.abrupt("return", connections.client.fetchData(resourceUrl, isReloading).then(function (response) {
|
|
137
137
|
return handleResolvedLinkResponse(resourceUrl, response, isReloading, isMetadataRequest);
|
|
138
138
|
}).catch(function (error) {
|
|
139
139
|
return handleResolvedLinkError(resourceUrl, error, undefined, isMetadataRequest);
|
package/dist/esm/version.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject;
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import AtlaskitLozenge from '@atlaskit/lozenge';
|
|
9
|
+
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
9
10
|
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: inherit;\n"])));
|
|
11
|
+
var actionStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n"])));
|
|
10
12
|
/**
|
|
11
13
|
* A base element that displays a Lozenge.
|
|
12
14
|
* @internal
|
|
@@ -18,6 +20,7 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
18
20
|
var _ref$appearance = _ref.appearance,
|
|
19
21
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
20
22
|
name = _ref.name,
|
|
23
|
+
onClick = _ref.onClick,
|
|
21
24
|
overrideCss = _ref.overrideCss,
|
|
22
25
|
text = _ref.text,
|
|
23
26
|
_ref$testId = _ref.testId,
|
|
@@ -28,15 +31,19 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
return jsx("span", {
|
|
31
|
-
css: [styles, overrideCss],
|
|
34
|
+
css: [styles, onClick ? actionStyles : undefined, overrideCss],
|
|
32
35
|
"data-fit-to-content": true,
|
|
33
36
|
"data-smart-element": name,
|
|
34
37
|
"data-smart-element-lozenge": true,
|
|
35
|
-
"data-testid": testId
|
|
38
|
+
"data-testid": testId,
|
|
39
|
+
onClick: onClick
|
|
36
40
|
}, jsx(AtlaskitLozenge, {
|
|
37
41
|
appearance: appearance,
|
|
38
42
|
testId: "".concat(testId, "-lozenge")
|
|
39
|
-
}, text
|
|
43
|
+
}, text, onClick && jsx(ChevronDownIcon, {
|
|
44
|
+
label: "action",
|
|
45
|
+
testId: "".concat(testId, "-action")
|
|
46
|
+
})));
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
export default Lozenge;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
1
2
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
2
3
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
3
4
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
@@ -9,7 +10,7 @@ import { isSpecialEvent } from '../../../utils';
|
|
|
9
10
|
import FlexibleCard from '../../FlexibleCard';
|
|
10
11
|
import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
11
12
|
import { flexibleUiOptions, footerBlockCss, metadataBlockCss, titleBlockCss, hiddenSnippetStyles } from '../styled';
|
|
12
|
-
import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
13
|
+
import { toActionableMetadata, getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
13
14
|
import HoverCardLoadingView from './HoverCardLoadingView';
|
|
14
15
|
import SnippetOrPreview from './SnippetOrPreview';
|
|
15
16
|
export var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
|
|
@@ -63,6 +64,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
63
64
|
onResolve = _ref.onResolve,
|
|
64
65
|
renderers = _ref.renderers,
|
|
65
66
|
url = _ref.url;
|
|
67
|
+
var showActionableElement = useFeatureFlag('enableActionableElement');
|
|
66
68
|
var actions = useSmartCardActions(id, url, analytics);
|
|
67
69
|
useEffect(function () {
|
|
68
70
|
actions.loadMetadata();
|
|
@@ -95,12 +97,21 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
95
97
|
return toFooterActions(cardActions, onActionClick);
|
|
96
98
|
}, [cardActions, onActionClick]);
|
|
97
99
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
98
|
-
var types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
99
100
|
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
var _useMemo = useMemo(function () {
|
|
102
|
+
var types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
103
|
+
|
|
104
|
+
var metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
105
|
+
var primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
106
|
+
return {
|
|
107
|
+
primary: primary,
|
|
108
|
+
secondary: metadata.secondary,
|
|
109
|
+
subtitle: metadata.subtitle
|
|
110
|
+
};
|
|
111
|
+
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]),
|
|
112
|
+
primary = _useMemo.primary,
|
|
113
|
+
secondary = _useMemo.secondary,
|
|
114
|
+
subtitle = _useMemo.subtitle;
|
|
104
115
|
|
|
105
116
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
106
117
|
var snippetHeight = React.useRef(0);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
1
7
|
import { ElementName } from '../../constants';
|
|
2
8
|
export var SMART_CARD_ANALYTICS_DISPLAY = 'flexible';
|
|
3
9
|
export var getSimulatedMetadata = function getSimulatedMetadata() {
|
|
@@ -80,4 +86,32 @@ export var getSimulatedMetadata = function getSimulatedMetadata() {
|
|
|
80
86
|
}
|
|
81
87
|
};
|
|
82
88
|
}
|
|
89
|
+
};
|
|
90
|
+
export var toActionableMetadata = function toActionableMetadata(onActionClick, extensionKey) {
|
|
91
|
+
var types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
92
|
+
var cardActions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
93
|
+
var elementItems = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
94
|
+
|
|
95
|
+
// Actionable State for Jira issue
|
|
96
|
+
if (extensionKey === 'jira-object-provider' && types !== null && types !== void 0 && types.includes('atlassian:Task')) {
|
|
97
|
+
var previewAction = cardActions.find(function (action) {
|
|
98
|
+
return action.id === 'preview-content';
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (previewAction) {
|
|
102
|
+
return elementItems.map(function (elementItem) {
|
|
103
|
+
return elementItem.name === ElementName.State ? _objectSpread(_objectSpread({}, elementItem), {}, {
|
|
104
|
+
onClick: function onClick() {
|
|
105
|
+
if (onActionClick) {
|
|
106
|
+
onActionClick(previewAction.id);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return previewAction.invoke();
|
|
110
|
+
}
|
|
111
|
+
}) : elementItem;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return elementItems;
|
|
83
117
|
};
|
|
@@ -6,6 +6,11 @@ export declare type LozengeProps = ElementProps & {
|
|
|
6
6
|
* Determines the appearance of the Atlaskit lozenge.
|
|
7
7
|
*/
|
|
8
8
|
appearance?: LozengeAppearance;
|
|
9
|
+
/**
|
|
10
|
+
* DO NOT USE! This is an experiment code and may be removed at any given time.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
onClick?: () => void;
|
|
9
14
|
/**
|
|
10
15
|
* The text to display within the lozenge.
|
|
11
16
|
*/
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { JsonLd } from 'json-ld-types';
|
|
2
|
+
import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
|
|
3
|
+
import { ElementItem } from '../FlexibleCard/components/blocks/types';
|
|
2
4
|
export declare const SMART_CARD_ANALYTICS_DISPLAY = "flexible";
|
|
3
5
|
export declare const getSimulatedMetadata: (extensionKey?: string, types?: JsonLd.Primitives.ObjectType[]) => JsonLd.Primitives.Property<any>;
|
|
6
|
+
export declare const toActionableMetadata: (onActionClick: (actionId: string) => void, extensionKey?: string | undefined, types?: JsonLd.Primitives.ObjectType[], cardActions?: LinkAction[], elementItems?: ElementItem[]) => ElementItem[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "23.5.
|
|
3
|
+
"version": "23.5.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@atlaskit/icon-object": "^6.2.0",
|
|
34
34
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
35
35
|
"@atlaskit/in-product-testing": "^0.1.0",
|
|
36
|
-
"@atlaskit/linking-common": "^1.
|
|
36
|
+
"@atlaskit/linking-common": "^1.14.0",
|
|
37
37
|
"@atlaskit/logo": "^13.10.0",
|
|
38
38
|
"@atlaskit/lozenge": "^11.3.0",
|
|
39
39
|
"@atlaskit/media-common": "^2.17.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"uuid": "^3.1.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@atlaskit/link-provider": "^1.3.
|
|
61
|
+
"@atlaskit/link-provider": "^1.3.6",
|
|
62
62
|
"react": "^16.8.0",
|
|
63
63
|
"react-dom": "^16.8.0",
|
|
64
64
|
"react-intl-next": "npm:react-intl@^5.18.1"
|