@atlaskit/smart-card 18.0.20 → 18.0.23
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 +13 -0
- package/dist/cjs/extractors/hover/extractMetadata.js +31 -0
- package/dist/cjs/providers/editor/transformer.js +0 -6
- package/dist/cjs/ssr.js +17 -3
- package/dist/cjs/utils/flexible.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/HoverCard/index.js +11 -2
- package/dist/cjs/view/HoverCard/utils.js +36 -0
- package/dist/es2019/extractors/hover/extractMetadata.js +18 -0
- package/dist/es2019/providers/editor/transformer.js +0 -4
- package/dist/es2019/ssr.js +9 -5
- package/dist/es2019/utils/flexible.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/HoverCard/index.js +27 -18
- package/dist/es2019/view/HoverCard/utils.js +27 -0
- package/dist/esm/extractors/hover/extractMetadata.js +22 -0
- package/dist/esm/providers/editor/transformer.js +0 -6
- package/dist/esm/ssr.js +16 -3
- package/dist/esm/utils/flexible.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/HoverCard/index.js +10 -3
- package/dist/esm/view/HoverCard/utils.js +27 -0
- package/dist/types/extractors/hover/extractMetadata.d.ts +3 -0
- package/dist/types/view/HoverCard/types.d.ts +5 -0
- package/dist/types/view/HoverCard/utils.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 18.0.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8b9f08cbc1c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8b9f08cbc1c) - [ux] Default representation for Slack links was changed from 'block' to 'inline'
|
|
8
|
+
- [`f4811ca8c6a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f4811ca8c6a) - add provider based metadata to hover previews
|
|
9
|
+
|
|
10
|
+
## 18.0.21
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`ffaf122189e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ffaf122189e) - Flexible UI: TitleBlock is now composory to display Flexible UI on Smart Links
|
|
15
|
+
|
|
3
16
|
## 18.0.20
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractMetadata = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../../constants");
|
|
9
|
+
|
|
10
|
+
var elementNamesToItems = function elementNamesToItems(elementNames) {
|
|
11
|
+
return elementNames.filter(function (element) {
|
|
12
|
+
return element in _constants.ElementName;
|
|
13
|
+
}).map(function (elementName) {
|
|
14
|
+
return {
|
|
15
|
+
name: elementName,
|
|
16
|
+
testId: "".concat(elementName.toLowerCase(), "-metadata-element")
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var extractMetadata = function extractMetadata(jsonLd) {
|
|
22
|
+
var _jsonLd$metadata, _metadata$primary, _metadata$secondary;
|
|
23
|
+
|
|
24
|
+
var metadata = (_jsonLd$metadata = jsonLd.metadata) !== null && _jsonLd$metadata !== void 0 ? _jsonLd$metadata : [];
|
|
25
|
+
return {
|
|
26
|
+
primary: elementNamesToItems((_metadata$primary = metadata.primary) !== null && _metadata$primary !== void 0 ? _metadata$primary : []),
|
|
27
|
+
secondary: elementNamesToItems((_metadata$secondary = metadata.secondary) !== null && _metadata$secondary !== void 0 ? _metadata$secondary : [])
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.extractMetadata = extractMetadata;
|
|
@@ -23,10 +23,6 @@ var isJwmView = function isJwmView(url) {
|
|
|
23
23
|
return url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar|list|board)\/?/);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
var isSlackMessage = function isSlackMessage(url) {
|
|
27
|
-
return url.match(/^https:\/\/.+?\.slack\.com\/archives\/[CG][A-Z0-9]+\/p[0-9]+(\?.*)?$/);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
26
|
var Transformer = /*#__PURE__*/function () {
|
|
31
27
|
function Transformer() {
|
|
32
28
|
(0, _classCallCheck2.default)(this, Transformer);
|
|
@@ -68,8 +64,6 @@ var Transformer = /*#__PURE__*/function () {
|
|
|
68
64
|
value: function toAdf(url, appearance) {
|
|
69
65
|
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
70
66
|
return this.buildEmbedAdf(url);
|
|
71
|
-
} else if (isSlackMessage(url)) {
|
|
72
|
-
return this.buildBlockAdf(url);
|
|
73
67
|
} else {
|
|
74
68
|
switch (appearance) {
|
|
75
69
|
case 'inline':
|
package/dist/cjs/ssr.js
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.CardSSR = void 0;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
|
|
14
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
15
|
|
|
@@ -17,12 +17,20 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
17
|
|
|
18
18
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
19
19
|
|
|
20
|
+
var _reactErrorBoundary = require("react-error-boundary");
|
|
21
|
+
|
|
20
22
|
var _component = require("./view/CardWithUrl/component");
|
|
21
23
|
|
|
24
|
+
var _LazyFallback = require("./view/CardWithUrl/component-lazy/LazyFallback");
|
|
25
|
+
|
|
22
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
27
|
|
|
24
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
29
|
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
26
34
|
// SSR friendly version of smart-card
|
|
27
35
|
// simplifies the logic around rendering and loading placeholders and
|
|
28
36
|
// only contains whats necessary to render the card on SSR mode
|
|
@@ -36,10 +44,16 @@ var CardSSR = function CardSSR(props) {
|
|
|
36
44
|
var dispatchAnalytics = function dispatchAnalytics() {}; // we can't dispatch events on SSR, after hydration the we will provide the real callback
|
|
37
45
|
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
var cardProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
40
48
|
id: id,
|
|
41
49
|
dispatchAnalytics: dispatchAnalytics
|
|
42
|
-
})
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
53
|
+
FallbackComponent: function FallbackComponent() {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_LazyFallback.LoadingCardLink, cardProps);
|
|
55
|
+
}
|
|
56
|
+
}, /*#__PURE__*/_react.default.createElement(_component.CardWithUrlContent, cardProps));
|
|
43
57
|
};
|
|
44
58
|
|
|
45
59
|
exports.CardSSR = CardSSR;
|
|
@@ -21,7 +21,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
21
|
|
|
22
22
|
var isFlexibleUiCard = function isFlexibleUiCard(children) {
|
|
23
23
|
if (children && _react.default.Children.toArray(children).some(function (child) {
|
|
24
|
-
return
|
|
24
|
+
return isFlexibleUiTitleBlock(child);
|
|
25
25
|
})) {
|
|
26
26
|
return true;
|
|
27
27
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -41,6 +41,10 @@ var _analytics2 = require("../../state/analytics");
|
|
|
41
41
|
|
|
42
42
|
var _helpers = require("../../state/helpers");
|
|
43
43
|
|
|
44
|
+
var _extractMetadata = require("../../extractors/hover/extractMetadata");
|
|
45
|
+
|
|
46
|
+
var _utils = require("./utils");
|
|
47
|
+
|
|
44
48
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
49
|
|
|
46
50
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -134,7 +138,9 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
134
138
|
};
|
|
135
139
|
}, [url, definitionId, extensionKey, analytics]);
|
|
136
140
|
|
|
137
|
-
var
|
|
141
|
+
var CardComponent = function CardComponent() {
|
|
142
|
+
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
143
|
+
var metadataElements = (0, _extractMetadata.extractMetadata)((0, _utils.getSimulatedMetadata)(extensionKey));
|
|
138
144
|
return (0, _core.jsx)("div", {
|
|
139
145
|
onMouseEnter: initShowCard,
|
|
140
146
|
onMouseLeave: initHideCard,
|
|
@@ -148,6 +154,9 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
148
154
|
}
|
|
149
155
|
}, (0, _core.jsx)(_blocks.TitleBlock, {
|
|
150
156
|
actions: [openAction]
|
|
157
|
+
}), (0, _core.jsx)(_blocks.MetadataBlock, {
|
|
158
|
+
primary: metadataElements.primary,
|
|
159
|
+
secondary: metadataElements.secondary
|
|
151
160
|
}), (0, _core.jsx)(_blocks.SnippetBlock, null), (0, _core.jsx)(_blocks.FooterBlock, {
|
|
152
161
|
actions: smartlinkActions
|
|
153
162
|
})));
|
|
@@ -161,7 +170,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
161
170
|
isOpen: isOpen,
|
|
162
171
|
onClose: onClose,
|
|
163
172
|
placement: "bottom-start",
|
|
164
|
-
content:
|
|
173
|
+
content: CardComponent,
|
|
165
174
|
trigger: function trigger(triggerProps) {
|
|
166
175
|
return (0, _core.jsx)("span", (0, _extends2.default)({}, triggerProps, {
|
|
167
176
|
onMouseEnter: initShowCard,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSimulatedMetadata = void 0;
|
|
7
|
+
|
|
8
|
+
var getSimulatedMetadata = function getSimulatedMetadata(extensionKey) {
|
|
9
|
+
switch (extensionKey) {
|
|
10
|
+
case 'confluence-object-provider':
|
|
11
|
+
return {
|
|
12
|
+
metadata: {
|
|
13
|
+
primary: ['AuthorGroup', 'CreatedBy', 'CommentCount', 'ReactCount'],
|
|
14
|
+
secondary: []
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
case 'jira-object-provider':
|
|
19
|
+
return {
|
|
20
|
+
metadata: {
|
|
21
|
+
primary: ['AuthorGroup', 'State', 'Priority'],
|
|
22
|
+
secondary: []
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
default:
|
|
27
|
+
return {
|
|
28
|
+
metadata: {
|
|
29
|
+
primary: ['ModifiedOn'],
|
|
30
|
+
secondary: []
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.getSimulatedMetadata = getSimulatedMetadata;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementName } from '../../constants';
|
|
2
|
+
|
|
3
|
+
const elementNamesToItems = elementNames => {
|
|
4
|
+
return elementNames.filter(element => element in ElementName).map(elementName => ({
|
|
5
|
+
name: elementName,
|
|
6
|
+
testId: `${elementName.toLowerCase()}-metadata-element`
|
|
7
|
+
}));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const extractMetadata = jsonLd => {
|
|
11
|
+
var _jsonLd$metadata, _metadata$primary, _metadata$secondary;
|
|
12
|
+
|
|
13
|
+
const metadata = (_jsonLd$metadata = jsonLd.metadata) !== null && _jsonLd$metadata !== void 0 ? _jsonLd$metadata : [];
|
|
14
|
+
return {
|
|
15
|
+
primary: elementNamesToItems((_metadata$primary = metadata.primary) !== null && _metadata$primary !== void 0 ? _metadata$primary : []),
|
|
16
|
+
secondary: elementNamesToItems((_metadata$secondary = metadata.secondary) !== null && _metadata$secondary !== void 0 ? _metadata$secondary : [])
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -4,8 +4,6 @@ const isPolarisView = url => url.match(/^https:\/\/.*?\/jira\/polaris\/projects\
|
|
|
4
4
|
|
|
5
5
|
const isJwmView = url => url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar|list|board)\/?/);
|
|
6
6
|
|
|
7
|
-
const isSlackMessage = url => url.match(/^https:\/\/.+?\.slack\.com\/archives\/[CG][A-Z0-9]+\/p[0-9]+(\?.*)?$/);
|
|
8
|
-
|
|
9
7
|
export class Transformer {
|
|
10
8
|
buildInlineAdf(url) {
|
|
11
9
|
return {
|
|
@@ -38,8 +36,6 @@ export class Transformer {
|
|
|
38
36
|
toAdf(url, appearance) {
|
|
39
37
|
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
40
38
|
return this.buildEmbedAdf(url);
|
|
41
|
-
} else if (isSlackMessage(url)) {
|
|
42
|
-
return this.buildBlockAdf(url);
|
|
43
39
|
} else {
|
|
44
40
|
switch (appearance) {
|
|
45
41
|
case 'inline':
|
package/dist/es2019/ssr.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { useState } from 'react';
|
|
4
3
|
import uuid from 'uuid';
|
|
4
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
5
5
|
import { CardWithUrlContent } from './view/CardWithUrl/component';
|
|
6
|
+
import { LoadingCardLink } from './view/CardWithUrl/component-lazy/LazyFallback';
|
|
6
7
|
// SSR friendly version of smart-card
|
|
7
8
|
// simplifies the logic around rendering and loading placeholders and
|
|
8
9
|
// only contains whats necessary to render the card on SSR mode
|
|
@@ -12,8 +13,11 @@ export const CardSSR = props => {
|
|
|
12
13
|
const dispatchAnalytics = () => {}; // we can't dispatch events on SSR, after hydration the we will provide the real callback
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
id
|
|
17
|
-
dispatchAnalytics
|
|
18
|
-
}
|
|
16
|
+
const cardProps = { ...props,
|
|
17
|
+
id,
|
|
18
|
+
dispatchAnalytics
|
|
19
|
+
};
|
|
20
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
21
|
+
FallbackComponent: () => /*#__PURE__*/React.createElement(LoadingCardLink, cardProps)
|
|
22
|
+
}, /*#__PURE__*/React.createElement(CardWithUrlContent, cardProps));
|
|
19
23
|
};
|
|
@@ -3,7 +3,7 @@ import * as Blocks from '../view/FlexibleCard/components/blocks';
|
|
|
3
3
|
import { TitleBlock } from '../view/FlexibleCard/components/blocks';
|
|
4
4
|
import * as Elements from '../view/FlexibleCard/components/elements';
|
|
5
5
|
export const isFlexibleUiCard = children => {
|
|
6
|
-
if (children && React.Children.toArray(children).some(child =>
|
|
6
|
+
if (children && React.Children.toArray(children).some(child => isFlexibleUiTitleBlock(child))) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { jsx } from '@emotion/core';
|
|
5
5
|
import React, { useCallback, useRef, useMemo } from 'react';
|
|
6
|
-
import { TitleBlock, SnippetBlock, FooterBlock } from '../FlexibleCard/components/blocks';
|
|
6
|
+
import { TitleBlock, SnippetBlock, FooterBlock, MetadataBlock } from '../FlexibleCard/components/blocks';
|
|
7
7
|
import { Card } from '../Card';
|
|
8
8
|
import Popup from '@atlaskit/popup';
|
|
9
9
|
import { SmartLinkSize, ActionName } from '../../constants';
|
|
@@ -15,6 +15,8 @@ import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
|
15
15
|
import { useSmartCardState as useLinkState } from '../../state/store';
|
|
16
16
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
17
17
|
import { getExtensionKey, getDefinitionId } from '../../state/helpers';
|
|
18
|
+
import { extractMetadata } from '../../extractors/hover/extractMetadata';
|
|
19
|
+
import { getSimulatedMetadata } from './utils';
|
|
18
20
|
export const HoverCardComponent = ({
|
|
19
21
|
children,
|
|
20
22
|
url,
|
|
@@ -89,22 +91,29 @@ export const HoverCardComponent = ({
|
|
|
89
91
|
};
|
|
90
92
|
}, [url, definitionId, extensionKey, analytics]);
|
|
91
93
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
const CardComponent = () => {
|
|
95
|
+
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
96
|
+
const metadataElements = extractMetadata(getSimulatedMetadata(extensionKey));
|
|
97
|
+
return jsx("div", {
|
|
98
|
+
onMouseEnter: initShowCard,
|
|
99
|
+
onMouseLeave: initHideCard,
|
|
100
|
+
css: HoverCardContainer
|
|
101
|
+
}, jsx(Card, {
|
|
102
|
+
appearance: "block",
|
|
103
|
+
url: url,
|
|
104
|
+
ui: {
|
|
105
|
+
hideElevation: true,
|
|
106
|
+
size: SmartLinkSize.Large
|
|
107
|
+
}
|
|
108
|
+
}, jsx(TitleBlock, {
|
|
109
|
+
actions: [openAction]
|
|
110
|
+
}), jsx(MetadataBlock, {
|
|
111
|
+
primary: metadataElements.primary,
|
|
112
|
+
secondary: metadataElements.secondary
|
|
113
|
+
}), jsx(SnippetBlock, null), jsx(FooterBlock, {
|
|
114
|
+
actions: smartlinkActions
|
|
115
|
+
})));
|
|
116
|
+
};
|
|
108
117
|
|
|
109
118
|
const onClose = useCallback(() => setIsOpen(false), []);
|
|
110
119
|
return jsx(Popup, {
|
|
@@ -112,7 +121,7 @@ export const HoverCardComponent = ({
|
|
|
112
121
|
isOpen: isOpen,
|
|
113
122
|
onClose: onClose,
|
|
114
123
|
placement: "bottom-start",
|
|
115
|
-
content:
|
|
124
|
+
content: CardComponent,
|
|
116
125
|
trigger: triggerProps => jsx("span", _extends({}, triggerProps, {
|
|
117
126
|
onMouseEnter: initShowCard,
|
|
118
127
|
onMouseLeave: initHideCard
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const getSimulatedMetadata = extensionKey => {
|
|
2
|
+
switch (extensionKey) {
|
|
3
|
+
case 'confluence-object-provider':
|
|
4
|
+
return {
|
|
5
|
+
metadata: {
|
|
6
|
+
primary: ['AuthorGroup', 'CreatedBy', 'CommentCount', 'ReactCount'],
|
|
7
|
+
secondary: []
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
case 'jira-object-provider':
|
|
12
|
+
return {
|
|
13
|
+
metadata: {
|
|
14
|
+
primary: ['AuthorGroup', 'State', 'Priority'],
|
|
15
|
+
secondary: []
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
default:
|
|
20
|
+
return {
|
|
21
|
+
metadata: {
|
|
22
|
+
primary: ['ModifiedOn'],
|
|
23
|
+
secondary: []
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ElementName } from '../../constants';
|
|
2
|
+
|
|
3
|
+
var elementNamesToItems = function elementNamesToItems(elementNames) {
|
|
4
|
+
return elementNames.filter(function (element) {
|
|
5
|
+
return element in ElementName;
|
|
6
|
+
}).map(function (elementName) {
|
|
7
|
+
return {
|
|
8
|
+
name: elementName,
|
|
9
|
+
testId: "".concat(elementName.toLowerCase(), "-metadata-element")
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export var extractMetadata = function extractMetadata(jsonLd) {
|
|
15
|
+
var _jsonLd$metadata, _metadata$primary, _metadata$secondary;
|
|
16
|
+
|
|
17
|
+
var metadata = (_jsonLd$metadata = jsonLd.metadata) !== null && _jsonLd$metadata !== void 0 ? _jsonLd$metadata : [];
|
|
18
|
+
return {
|
|
19
|
+
primary: elementNamesToItems((_metadata$primary = metadata.primary) !== null && _metadata$primary !== void 0 ? _metadata$primary : []),
|
|
20
|
+
secondary: elementNamesToItems((_metadata$secondary = metadata.secondary) !== null && _metadata$secondary !== void 0 ? _metadata$secondary : [])
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -13,10 +13,6 @@ var isJwmView = function isJwmView(url) {
|
|
|
13
13
|
return url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar|list|board)\/?/);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
var isSlackMessage = function isSlackMessage(url) {
|
|
17
|
-
return url.match(/^https:\/\/.+?\.slack\.com\/archives\/[CG][A-Z0-9]+\/p[0-9]+(\?.*)?$/);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
16
|
export var Transformer = /*#__PURE__*/function () {
|
|
21
17
|
function Transformer() {
|
|
22
18
|
_classCallCheck(this, Transformer);
|
|
@@ -58,8 +54,6 @@ export var Transformer = /*#__PURE__*/function () {
|
|
|
58
54
|
value: function toAdf(url, appearance) {
|
|
59
55
|
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
60
56
|
return this.buildEmbedAdf(url);
|
|
61
|
-
} else if (isSlackMessage(url)) {
|
|
62
|
-
return this.buildBlockAdf(url);
|
|
63
57
|
} else {
|
|
64
58
|
switch (appearance) {
|
|
65
59
|
case 'inline':
|
package/dist/esm/ssr.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
3
8
|
import React from 'react';
|
|
4
9
|
import { useState } from 'react';
|
|
5
10
|
import uuid from 'uuid';
|
|
11
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
6
12
|
import { CardWithUrlContent } from './view/CardWithUrl/component';
|
|
13
|
+
import { LoadingCardLink } from './view/CardWithUrl/component-lazy/LazyFallback';
|
|
7
14
|
// SSR friendly version of smart-card
|
|
8
15
|
// simplifies the logic around rendering and loading placeholders and
|
|
9
16
|
// only contains whats necessary to render the card on SSR mode
|
|
@@ -17,8 +24,14 @@ export var CardSSR = function CardSSR(props) {
|
|
|
17
24
|
var dispatchAnalytics = function dispatchAnalytics() {}; // we can't dispatch events on SSR, after hydration the we will provide the real callback
|
|
18
25
|
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
var cardProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
21
28
|
id: id,
|
|
22
29
|
dispatchAnalytics: dispatchAnalytics
|
|
23
|
-
})
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
33
|
+
FallbackComponent: function FallbackComponent() {
|
|
34
|
+
return /*#__PURE__*/React.createElement(LoadingCardLink, cardProps);
|
|
35
|
+
}
|
|
36
|
+
}, /*#__PURE__*/React.createElement(CardWithUrlContent, cardProps));
|
|
24
37
|
};
|
|
@@ -4,7 +4,7 @@ import { TitleBlock } from '../view/FlexibleCard/components/blocks';
|
|
|
4
4
|
import * as Elements from '../view/FlexibleCard/components/elements';
|
|
5
5
|
export var isFlexibleUiCard = function isFlexibleUiCard(children) {
|
|
6
6
|
if (children && React.Children.toArray(children).some(function (child) {
|
|
7
|
-
return
|
|
7
|
+
return isFlexibleUiTitleBlock(child);
|
|
8
8
|
})) {
|
|
9
9
|
return true;
|
|
10
10
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
4
4
|
/** @jsx jsx */
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
import React, { useCallback, useRef, useMemo } from 'react';
|
|
7
|
-
import { TitleBlock, SnippetBlock, FooterBlock } from '../FlexibleCard/components/blocks';
|
|
7
|
+
import { TitleBlock, SnippetBlock, FooterBlock, MetadataBlock } from '../FlexibleCard/components/blocks';
|
|
8
8
|
import { Card } from '../Card';
|
|
9
9
|
import Popup from '@atlaskit/popup';
|
|
10
10
|
import { SmartLinkSize, ActionName } from '../../constants';
|
|
@@ -16,6 +16,8 @@ import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
|
16
16
|
import { useSmartCardState as useLinkState } from '../../state/store';
|
|
17
17
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
18
18
|
import { getExtensionKey, getDefinitionId } from '../../state/helpers';
|
|
19
|
+
import { extractMetadata } from '../../extractors/hover/extractMetadata';
|
|
20
|
+
import { getSimulatedMetadata } from './utils';
|
|
19
21
|
export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
20
22
|
var children = _ref.children,
|
|
21
23
|
url = _ref.url,
|
|
@@ -104,7 +106,9 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
104
106
|
};
|
|
105
107
|
}, [url, definitionId, extensionKey, analytics]);
|
|
106
108
|
|
|
107
|
-
var
|
|
109
|
+
var CardComponent = function CardComponent() {
|
|
110
|
+
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
111
|
+
var metadataElements = extractMetadata(getSimulatedMetadata(extensionKey));
|
|
108
112
|
return jsx("div", {
|
|
109
113
|
onMouseEnter: initShowCard,
|
|
110
114
|
onMouseLeave: initHideCard,
|
|
@@ -118,6 +122,9 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
118
122
|
}
|
|
119
123
|
}, jsx(TitleBlock, {
|
|
120
124
|
actions: [openAction]
|
|
125
|
+
}), jsx(MetadataBlock, {
|
|
126
|
+
primary: metadataElements.primary,
|
|
127
|
+
secondary: metadataElements.secondary
|
|
121
128
|
}), jsx(SnippetBlock, null), jsx(FooterBlock, {
|
|
122
129
|
actions: smartlinkActions
|
|
123
130
|
})));
|
|
@@ -131,7 +138,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
131
138
|
isOpen: isOpen,
|
|
132
139
|
onClose: onClose,
|
|
133
140
|
placement: "bottom-start",
|
|
134
|
-
content:
|
|
141
|
+
content: CardComponent,
|
|
135
142
|
trigger: function trigger(triggerProps) {
|
|
136
143
|
return jsx("span", _extends({}, triggerProps, {
|
|
137
144
|
onMouseEnter: initShowCard,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export var getSimulatedMetadata = function getSimulatedMetadata(extensionKey) {
|
|
2
|
+
switch (extensionKey) {
|
|
3
|
+
case 'confluence-object-provider':
|
|
4
|
+
return {
|
|
5
|
+
metadata: {
|
|
6
|
+
primary: ['AuthorGroup', 'CreatedBy', 'CommentCount', 'ReactCount'],
|
|
7
|
+
secondary: []
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
case 'jira-object-provider':
|
|
12
|
+
return {
|
|
13
|
+
metadata: {
|
|
14
|
+
primary: ['AuthorGroup', 'State', 'Priority'],
|
|
15
|
+
secondary: []
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
default:
|
|
20
|
+
return {
|
|
21
|
+
metadata: {
|
|
22
|
+
primary: ['ModifiedOn'],
|
|
23
|
+
secondary: []
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
2
|
+
import { ElementItem } from '../FlexibleCard/components/blocks/types';
|
|
2
3
|
export interface HoverCardProps extends WithAnalyticsEventsProps {
|
|
3
4
|
url: string;
|
|
4
5
|
}
|
|
5
6
|
export declare type PreviewDisplay = 'card' | 'embed';
|
|
6
7
|
export declare type PreviewInvokeMethod = 'keyboard' | 'mouse_hover' | 'mouse_click';
|
|
8
|
+
export interface MetadataOptions {
|
|
9
|
+
primary: Array<ElementItem>;
|
|
10
|
+
secondary: Array<ElementItem>;
|
|
11
|
+
}
|