@atlaskit/smart-card 16.2.0 → 17.0.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 +95 -0
- package/dist/cjs/client/api.js +6 -4
- package/dist/cjs/client/errors.js +3 -1
- package/dist/cjs/client/types/responses.js +1 -1
- package/dist/cjs/client/utils/environments.js +1 -1
- package/dist/cjs/constants.js +77 -0
- package/dist/cjs/extractors/block/index.js +5 -5
- package/dist/cjs/extractors/common/actions/extractActions.js +2 -2
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +4 -4
- package/dist/cjs/extractors/common/byline/extractByline.js +17 -5
- package/dist/cjs/extractors/common/context/extractAccessContext.js +2 -2
- package/dist/cjs/extractors/common/lozenge/utils.js +1 -1
- package/dist/cjs/extractors/common/utils.js +1 -1
- package/dist/cjs/extractors/constants.js +1 -1
- package/dist/cjs/extractors/embed/index.js +2 -2
- package/dist/cjs/extractors/flexible/index.js +22 -0
- package/dist/cjs/in-product.js +8 -8
- package/dist/cjs/index.js +74 -32
- package/dist/cjs/providers/editor/transformer.js +5 -1
- package/dist/cjs/state/actions/constants.js +1 -1
- package/dist/cjs/state/actions/index.js +1 -1
- package/dist/cjs/state/analytics/index.js +8 -8
- package/dist/cjs/state/analytics/ufoExperiences.js +18 -15
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +12 -4
- package/dist/cjs/state/context/index.js +3 -2
- package/dist/cjs/state/flexible-ui-context/index.js +17 -0
- package/dist/cjs/state/flexible-ui-context/types.js +5 -0
- package/dist/cjs/state/helpers.js +1 -1
- package/dist/cjs/state/index.js +4 -4
- package/dist/cjs/state/reducers/index.js +2 -2
- package/dist/cjs/utils/analytics/analytics.js +9 -9
- package/dist/cjs/utils/analytics/index.js +29 -29
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/mocks.js +1 -1
- package/dist/cjs/utils/performance.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/index.js +1 -1
- package/dist/cjs/view/Card/index.js +9 -2
- package/dist/cjs/view/CardWithUrl/component-lazy/LazyFallback.js +1 -1
- package/dist/cjs/view/CardWithUrl/loader.js +27 -32
- package/dist/cjs/view/EmbedCard/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +87 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/container/index.js +117 -0
- package/dist/cjs/view/FlexibleCard/components/container/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.js +244 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/image-icon/index.js +32 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/image-icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/index.js +144 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +135 -0
- package/dist/cjs/view/FlexibleCard/components/elements/link/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/types.js +5 -0
- package/dist/es2019/constants.js +67 -0
- package/dist/es2019/extractors/block/index.js +2 -2
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/es2019/extractors/common/byline/extractByline.js +16 -5
- package/dist/es2019/extractors/flexible/index.js +14 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/providers/editor/transformer.js +3 -1
- package/dist/es2019/state/actions/index.js +1 -1
- package/dist/es2019/state/analytics/ufoExperiences.js +17 -14
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +18 -4
- package/dist/es2019/state/flexible-ui-context/index.js +3 -0
- package/dist/es2019/state/flexible-ui-context/types.js +1 -0
- package/dist/es2019/utils/analytics/analytics.js +6 -6
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/index.js +2 -2
- package/dist/es2019/view/Card/index.js +8 -2
- package/dist/es2019/view/CardWithUrl/loader.js +30 -37
- package/dist/es2019/view/EmbedCard/index.js +2 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +62 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/container/index.js +89 -0
- package/dist/es2019/view/FlexibleCard/components/container/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.js +175 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/image-icon/index.js +19 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/image-icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/index.js +112 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +118 -0
- package/dist/es2019/view/FlexibleCard/components/elements/link/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/types.js +1 -0
- package/dist/esm/client/api.js +4 -3
- package/dist/esm/client/errors.js +2 -1
- package/dist/esm/constants.js +67 -0
- package/dist/esm/extractors/block/index.js +4 -4
- package/dist/esm/extractors/common/actions/extractActions.js +2 -2
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +4 -4
- package/dist/esm/extractors/common/byline/extractByline.js +16 -5
- package/dist/esm/extractors/common/context/extractAccessContext.js +2 -2
- package/dist/esm/extractors/embed/index.js +2 -2
- package/dist/esm/extractors/flexible/index.js +14 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/providers/editor/transformer.js +5 -1
- package/dist/esm/state/actions/index.js +1 -1
- package/dist/esm/state/analytics/ufoExperiences.js +17 -14
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +13 -5
- package/dist/esm/state/flexible-ui-context/index.js +5 -0
- package/dist/esm/state/flexible-ui-context/types.js +1 -0
- package/dist/esm/state/reducers/index.js +2 -2
- package/dist/esm/utils/analytics/analytics.js +8 -8
- package/dist/esm/utils/analytics/index.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/index.js +2 -2
- package/dist/esm/view/Card/index.js +8 -2
- package/dist/esm/view/CardWithUrl/loader.js +28 -33
- package/dist/esm/view/EmbedCard/index.js +2 -2
- package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +74 -0
- package/dist/esm/view/FlexibleCard/components/blocks/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/container/index.js +102 -0
- package/dist/esm/view/FlexibleCard/components/container/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.js +224 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/image-icon/index.js +20 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/image-icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/index.js +124 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +120 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/types.js +1 -0
- package/dist/types/constants.d.ts +56 -0
- package/dist/types/extractors/block/types.d.ts +1 -1
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +1 -1
- package/dist/types/extractors/flexible/index.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/analytics/ufoExperiences.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -1
- package/dist/types/state/context/provider.d.ts +1 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +4 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +3 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
- package/dist/types/utils/analytics/analytics.d.ts +3 -3
- package/dist/types/utils/test-utils.d.ts +1 -0
- package/dist/types/view/Card/index.d.ts +2 -1
- package/dist/types/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component-lazy/LazyLazilyRenderCard.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component-lazy/index.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component.d.ts +1 -0
- package/dist/types/view/CardWithUrl/loader.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/block/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/container/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/container/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/image-icon/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/image-icon/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/types.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/elements/link/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/link/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/elements/types.d.ts +5 -0
- package/package.json +23 -18
|
@@ -40,7 +40,7 @@ const getInvokeOpts = (key, action, source) => ({
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
export const extractPreviewAction = (
|
|
43
|
+
export const extractPreviewAction = (extensionKey = 'empty-object-provider', viewProps, jsonLd, handleInvoke, handleAnalytics, testId, platform) => {
|
|
44
44
|
// Extract metadata from view props & raw JSON-LD.
|
|
45
45
|
const metadataFromJsonLd = getMetadataFromJsonLd(jsonLd, platform);
|
|
46
46
|
const metadataFromViewProps = getMetadataFromResolvedProps(viewProps);
|
|
@@ -50,7 +50,7 @@ export const extractPreviewAction = (definitionId = 'empty-object-provider', vie
|
|
|
50
50
|
|
|
51
51
|
if (metadataFromJsonLd.src) {
|
|
52
52
|
// Build action using instrumentation hooks.
|
|
53
|
-
const key =
|
|
53
|
+
const key = extensionKey;
|
|
54
54
|
const previewAction = PreviewAction({ ...metadata,
|
|
55
55
|
testId,
|
|
56
56
|
onOpen: () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormattedRelativeTime } from 'react-intl-next';
|
|
3
|
+
import { selectUnit } from '@formatjs/intl-utils';
|
|
3
4
|
import { extractPersonUpdatedBy } from '../person/extractPersonUpdatedBy';
|
|
4
5
|
import { extractPersonCreatedBy } from '../person/extractPersonCreatedBy';
|
|
5
6
|
import { extractDateCreated } from '../date/extractDateCreated';
|
|
@@ -9,15 +10,25 @@ export const extractByline = jsonLd => {
|
|
|
9
10
|
const createdAt = extractDateCreated(jsonLd);
|
|
10
11
|
|
|
11
12
|
if (updatedAt) {
|
|
13
|
+
const {
|
|
14
|
+
value,
|
|
15
|
+
unit
|
|
16
|
+
} = selectUnit(new Date(updatedAt).getTime());
|
|
12
17
|
const updatedBy = extractPersonUpdatedBy(jsonLd);
|
|
13
|
-
return /*#__PURE__*/React.createElement("span", null, "Updated ", updatedBy && `by ${updatedBy.name}`, ' ', /*#__PURE__*/React.createElement(
|
|
14
|
-
value:
|
|
18
|
+
return /*#__PURE__*/React.createElement("span", null, "Updated ", updatedBy && `by ${updatedBy.name}`, ' ', /*#__PURE__*/React.createElement(FormattedRelativeTime, {
|
|
19
|
+
value: value,
|
|
20
|
+
unit: unit
|
|
15
21
|
}));
|
|
16
22
|
} else if (createdAt) {
|
|
23
|
+
const {
|
|
24
|
+
value,
|
|
25
|
+
unit
|
|
26
|
+
} = selectUnit(new Date(createdAt).getTime());
|
|
17
27
|
const createdBy = extractPersonCreatedBy(jsonLd);
|
|
18
28
|
const createdByPerson = extractFirstPerson(createdBy);
|
|
19
|
-
return /*#__PURE__*/React.createElement("span", null, "Created ", createdByPerson && `by ${createdByPerson.name}`, ' ', /*#__PURE__*/React.createElement(
|
|
20
|
-
value:
|
|
29
|
+
return /*#__PURE__*/React.createElement("span", null, "Created ", createdByPerson && `by ${createdByPerson.name}`, ' ', /*#__PURE__*/React.createElement(FormattedRelativeTime, {
|
|
30
|
+
value: value,
|
|
31
|
+
unit: unit
|
|
21
32
|
}));
|
|
22
33
|
}
|
|
23
34
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { extractTitle } from '../common/primitives';
|
|
2
|
+
|
|
3
|
+
const extractFlexibleUiContext = response => {
|
|
4
|
+
if (!response) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const data = response.data;
|
|
9
|
+
return {
|
|
10
|
+
title: extractTitle(data)
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default extractFlexibleUiContext;
|
package/dist/es2019/index.js
CHANGED
|
@@ -9,5 +9,5 @@ export { embedHeaderHeight } from '@atlaskit/media-ui/embeds';
|
|
|
9
9
|
export { SmartLinkEvents } from './utils/analytics/analytics';
|
|
10
10
|
export { useSmartLinkEvents } from './view/SmartLinkEvents/useSmartLinkEvents'; // Classnames for integrators
|
|
11
11
|
|
|
12
|
-
export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName } from '@atlaskit/media-ui/classNames';
|
|
12
|
+
export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, blockCardResolvedViewByClassName, blockCardForbiddenViewLinkClassName, blockCardContentClassName, blockCardContentHeaderClassName, blockCardContentHeaderNameClassName, blockCardNotFoundViewClassName, blockCardErroredViewClassName } from '@atlaskit/media-ui/classNames';
|
|
13
13
|
export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
|
|
@@ -2,6 +2,8 @@ const isJiraRoadMap = url => url.match(/^https:\/\/.*?\/jira\/software\/(c\/)?pr
|
|
|
2
2
|
|
|
3
3
|
const isPolarisView = url => url.match(/^https:\/\/.*?\/jira\/polaris\/projects\/[^\/]+?\/ideas\/view\/\d+$|^https:\/\/.*?\/secure\/JiraProductDiscoveryAnonymous\.jspa\?hash=\w+|^https:\/\/.*?\/jira\/polaris\/share\/\w+/);
|
|
4
4
|
|
|
5
|
+
const isJwmView = url => url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar)\/?/);
|
|
6
|
+
|
|
5
7
|
const isSlackMessage = url => url.match(/^https:\/\/.+?\.slack\.com\/archives\/[CG][A-Z0-9]+\/p[0-9]+(\?.*)?$/);
|
|
6
8
|
|
|
7
9
|
export class Transformer {
|
|
@@ -34,7 +36,7 @@ export class Transformer {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
toAdf(url, appearance) {
|
|
37
|
-
if (isJiraRoadMap(url) || isPolarisView(url)) {
|
|
39
|
+
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
38
40
|
return this.buildEmbedAdf(url);
|
|
39
41
|
} else if (isSlackMessage(url)) {
|
|
40
42
|
return this.buildBlockAdf(url);
|
|
@@ -158,7 +158,7 @@ export const useSmartCardActions = (id, url, analytics) => {
|
|
|
158
158
|
|
|
159
159
|
try {
|
|
160
160
|
// Begin analytics instrumentation.
|
|
161
|
-
analytics.ui.actionClickedEvent(key, action.type, source); // Invoke action - either client-side or server-side.
|
|
161
|
+
analytics.ui.actionClickedEvent(id, key, action.type, source, opts.type); // Invoke action - either client-side or server-side.
|
|
162
162
|
|
|
163
163
|
let response;
|
|
164
164
|
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
2
|
+
const inlineExperience = {
|
|
3
|
+
platform: {
|
|
4
|
+
component: 'smart-links'
|
|
5
|
+
},
|
|
6
|
+
type: ExperienceTypes.Experience,
|
|
7
|
+
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
8
|
+
};
|
|
9
|
+
const renderExperience = {
|
|
10
|
+
platform: {
|
|
11
|
+
component: 'smart-links'
|
|
12
|
+
},
|
|
13
|
+
type: ExperienceTypes.Load,
|
|
14
|
+
performanceType: ExperiencePerformanceTypes.PageSegmentLoad
|
|
15
|
+
};
|
|
2
16
|
const ufoExperiences = {
|
|
3
|
-
'smart-link-rendered': new ConcurrentExperience('smart-link-rendered',
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
platform: {
|
|
7
|
-
component: 'smart-links'
|
|
8
|
-
}
|
|
9
|
-
}),
|
|
10
|
-
'smart-link-authenticated': new ConcurrentExperience('smart-link-authenticated', {
|
|
11
|
-
type: ExperienceTypes.Load,
|
|
12
|
-
performanceType: ExperiencePerformanceTypes.PageSegmentLoad,
|
|
13
|
-
platform: {
|
|
14
|
-
component: 'smart-links'
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
+
'smart-link-rendered': new ConcurrentExperience('smart-link-rendered', renderExperience),
|
|
18
|
+
'smart-link-authenticated': new ConcurrentExperience('smart-link-authenticated', inlineExperience),
|
|
19
|
+
'smart-link-action-invocation': new ConcurrentExperience('smart-link-action-invocation', inlineExperience)
|
|
17
20
|
};
|
|
18
21
|
export const startUfoExperience = (experienceName, id, properties) => {
|
|
19
22
|
const experience = ufoExperiences[experienceName].getInstance(id);
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
3
|
+
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
4
4
|
export const useSmartLinkAnalytics = dispatchAnalytics => {
|
|
5
5
|
const ui = useMemo(() => ({
|
|
6
6
|
authEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey)),
|
|
7
7
|
authAlternateAccountEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey)),
|
|
8
8
|
cardClickedEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey)),
|
|
9
|
-
actionClickedEvent: (
|
|
9
|
+
actionClickedEvent: (id, extensionKey, actionType, display, invokeType) => {
|
|
10
|
+
startUfoExperience('smart-link-action-invocation', id, {
|
|
11
|
+
actionType,
|
|
12
|
+
display,
|
|
13
|
+
extensionKey,
|
|
14
|
+
invokeType
|
|
15
|
+
});
|
|
16
|
+
dispatchAnalytics(uiActionClickedEvent(extensionKey, actionType, display));
|
|
17
|
+
},
|
|
10
18
|
closedAuthEvent: (display, definitionId, extensionKey) => dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey)),
|
|
11
19
|
renderSuccessEvent: (display, id, definitionId, extensionKey) => {
|
|
12
20
|
succeedUfoExperience('smart-link-rendered', id, {
|
|
@@ -23,8 +31,14 @@ export const useSmartLinkAnalytics = dispatchAnalytics => {
|
|
|
23
31
|
const operational = useMemo(() => ({
|
|
24
32
|
resolvedEvent: (id, definitionId, extensionKey, resourceType) => dispatchAnalytics(resolvedEvent(id, definitionId, extensionKey, resourceType)),
|
|
25
33
|
unresolvedEvent: (id, status, definitionId, extensionKey, resourceType) => dispatchAnalytics(unresolvedEvent(id, status, definitionId, extensionKey, resourceType)),
|
|
26
|
-
invokeSucceededEvent: (id, providerKey, actionType, display) =>
|
|
27
|
-
|
|
34
|
+
invokeSucceededEvent: (id, providerKey, actionType, display) => {
|
|
35
|
+
succeedUfoExperience('smart-link-action-invocation', id);
|
|
36
|
+
dispatchAnalytics(invokeSucceededEvent(id, providerKey, actionType, display));
|
|
37
|
+
},
|
|
38
|
+
invokeFailedEvent: (id, providerKey, actionType, display, reason) => {
|
|
39
|
+
failUfoExperience('smart-link-action-invocation', id);
|
|
40
|
+
dispatchAnalytics(invokeFailedEvent(id, providerKey, actionType, display, reason));
|
|
41
|
+
},
|
|
28
42
|
connectSucceededEvent: (id, definitionId, extensionKey) => {
|
|
29
43
|
startUfoExperience('smart-link-authenticated', id, {
|
|
30
44
|
extensionKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -69,7 +69,7 @@ export const unresolvedEvent = (id, status, definitionId, extensionKey, resource
|
|
|
69
69
|
} : undefined
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
export const invokeSucceededEvent = (id,
|
|
72
|
+
export const invokeSucceededEvent = (id, extensionKey, actionType, display) => {
|
|
73
73
|
const measure = getMeasure(id, 'resolved') || {
|
|
74
74
|
duration: undefined
|
|
75
75
|
};
|
|
@@ -81,12 +81,12 @@ export const invokeSucceededEvent = (id, providerKey, actionType, display) => {
|
|
|
81
81
|
id,
|
|
82
82
|
actionType,
|
|
83
83
|
display,
|
|
84
|
-
|
|
84
|
+
extensionKey,
|
|
85
85
|
duration: measure.duration
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
export const invokeFailedEvent = (id,
|
|
89
|
+
export const invokeFailedEvent = (id, extensionKey, actionType, display, reason) => {
|
|
90
90
|
const measure = getMeasure(id, 'errored') || {
|
|
91
91
|
duration: undefined
|
|
92
92
|
};
|
|
@@ -98,7 +98,7 @@ export const invokeFailedEvent = (id, providerKey, actionType, display, reason)
|
|
|
98
98
|
id,
|
|
99
99
|
actionType,
|
|
100
100
|
display,
|
|
101
|
-
|
|
101
|
+
extensionKey,
|
|
102
102
|
duration: measure.duration,
|
|
103
103
|
reason
|
|
104
104
|
}
|
|
@@ -179,13 +179,13 @@ export const uiCardClickedEvent = (display, definitionId, extensionKey) => ({
|
|
|
179
179
|
display
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
|
-
export const uiActionClickedEvent = (
|
|
182
|
+
export const uiActionClickedEvent = (extensionKey, actionType, display) => ({
|
|
183
183
|
action: 'clicked',
|
|
184
184
|
actionSubject: 'smartLinkAction',
|
|
185
185
|
eventType: 'ui',
|
|
186
186
|
attributes: { ...context,
|
|
187
187
|
display,
|
|
188
|
-
|
|
188
|
+
extensionKey,
|
|
189
189
|
actionType: actionType
|
|
190
190
|
}
|
|
191
191
|
});
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { CardLinkView, BlockCardResolvingView, BlockCardErroredView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardResolvedView, BlockCardNotFoundView, AuthorizeAction, ForbiddenAction } from '@atlaskit/media-ui';
|
|
4
|
-
import {
|
|
4
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
5
5
|
import { extractBlockProps } from '../../extractors/block';
|
|
6
6
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
7
7
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
@@ -31,7 +31,7 @@ export const BlockCard = ({
|
|
|
31
31
|
const extractorOpts = {
|
|
32
32
|
handleAnalytics: handlePreviewAnalytics,
|
|
33
33
|
handleInvoke,
|
|
34
|
-
|
|
34
|
+
extensionKey: getExtensionKey(details)
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
switch (status) {
|
|
@@ -4,12 +4,18 @@ import { CardWithDataRenderer } from '../CardWithData/loader';
|
|
|
4
4
|
import { CardWithURLRenderer } from '../CardWithUrl/loader';
|
|
5
5
|
import { isCardWithData } from '../../utils';
|
|
6
6
|
import { context } from '../../utils/analytics';
|
|
7
|
+
import { injectIntl, IntlProvider } from 'react-intl-next';
|
|
7
8
|
|
|
8
9
|
class PlainCard extends React.PureComponent {
|
|
9
10
|
render() {
|
|
10
|
-
|
|
11
|
+
const content = isCardWithData(this.props) ? /*#__PURE__*/React.createElement(CardWithDataRenderer, this.props) : /*#__PURE__*/React.createElement(CardWithURLRenderer, this.props);
|
|
12
|
+
return this.props.intl ? content : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
13
|
+
locale: "en"
|
|
14
|
+
}, content);
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
export const Card = withAnalyticsContext(context)(withAnalyticsEvents()(PlainCard
|
|
19
|
+
export const Card = withAnalyticsContext(context)(withAnalyticsEvents()(injectIntl(PlainCard, {
|
|
20
|
+
enforceContext: false
|
|
21
|
+
})));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { lazy, useEffect, useState, Suspense } from 'react';
|
|
1
|
+
import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
3
|
import { CardLinkView } from '@atlaskit/media-ui';
|
|
4
4
|
import { uiRenderFailedEvent, fireSmartLinkEvent } from '../../utils/analytics';
|
|
@@ -22,8 +22,35 @@ export function CardWithURLRenderer(props) {
|
|
|
22
22
|
clearMeasures(id);
|
|
23
23
|
};
|
|
24
24
|
}, [id]);
|
|
25
|
+
const {
|
|
26
|
+
url,
|
|
27
|
+
appearance,
|
|
28
|
+
isSelected,
|
|
29
|
+
isFrameVisible,
|
|
30
|
+
onClick,
|
|
31
|
+
container,
|
|
32
|
+
onResolve,
|
|
33
|
+
testId,
|
|
34
|
+
showActions,
|
|
35
|
+
inheritDimensions,
|
|
36
|
+
platform,
|
|
37
|
+
embedIframeRef,
|
|
38
|
+
inlinePreloaderStyle,
|
|
39
|
+
createAnalyticsEvent
|
|
40
|
+
} = props; // Wrapper around analytics.
|
|
25
41
|
|
|
26
|
-
const
|
|
42
|
+
const dispatchAnalytics = useCallback(analyticsPayload => {
|
|
43
|
+
if (analyticsPayload && analyticsPayload.attributes) {
|
|
44
|
+
// Update if we haven't already set the display - possible
|
|
45
|
+
// in the case of `preview` which is rendered differently.
|
|
46
|
+
if (!analyticsPayload.attributes.display) {
|
|
47
|
+
analyticsPayload.attributes.display = appearance;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
52
|
+
}, [appearance, createAnalyticsEvent]);
|
|
53
|
+
const logError = useCallback((error, info) => {
|
|
27
54
|
const {
|
|
28
55
|
componentStack
|
|
29
56
|
} = info; // NB: APIErrors are thrown in response to Object Resolver Service.
|
|
@@ -43,41 +70,7 @@ export function CardWithURLRenderer(props) {
|
|
|
43
70
|
failUfoExperience('smart-link-authenticated', id);
|
|
44
71
|
dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
|
|
45
72
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const dispatchAnalytics = analyticsPayload => {
|
|
50
|
-
const {
|
|
51
|
-
appearance,
|
|
52
|
-
createAnalyticsEvent
|
|
53
|
-
} = props;
|
|
54
|
-
|
|
55
|
-
if (analyticsPayload && analyticsPayload.attributes) {
|
|
56
|
-
// Update if we haven't already set the display - possible
|
|
57
|
-
// in the case of `preview` which is rendered differently.
|
|
58
|
-
if (!analyticsPayload.attributes.display) {
|
|
59
|
-
analyticsPayload.attributes.display = appearance;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const {
|
|
67
|
-
url,
|
|
68
|
-
appearance,
|
|
69
|
-
isSelected,
|
|
70
|
-
isFrameVisible,
|
|
71
|
-
onClick,
|
|
72
|
-
container,
|
|
73
|
-
onResolve,
|
|
74
|
-
testId,
|
|
75
|
-
showActions,
|
|
76
|
-
inheritDimensions,
|
|
77
|
-
platform,
|
|
78
|
-
embedIframeRef,
|
|
79
|
-
inlinePreloaderStyle
|
|
80
|
-
} = props;
|
|
73
|
+
}, [appearance, dispatchAnalytics, id]);
|
|
81
74
|
|
|
82
75
|
if (!url) {
|
|
83
76
|
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
@@ -6,7 +6,7 @@ import { extractEmbedProps } from '../../extractors/embed';
|
|
|
6
6
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
7
7
|
import { extractInlineProps } from '../../extractors/inline';
|
|
8
8
|
import { extractBlockProps } from '../../extractors/block';
|
|
9
|
-
import {
|
|
9
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
10
10
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
11
11
|
export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
12
12
|
url,
|
|
@@ -75,7 +75,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
75
75
|
const resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
76
76
|
handleAnalytics,
|
|
77
77
|
handleInvoke,
|
|
78
|
-
|
|
78
|
+
extensionKey: getExtensionKey(details)
|
|
79
79
|
});
|
|
80
80
|
return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedBlockViewProps, {
|
|
81
81
|
isSelected: isSelected,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { SmartLinkDirection, SmartLinkSize } from '../../../../../constants';
|
|
5
|
+
|
|
6
|
+
const getDirectionStyles = direction => {
|
|
7
|
+
switch (direction) {
|
|
8
|
+
case SmartLinkDirection.Vertical:
|
|
9
|
+
return {
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
alignItems: 'flex-start'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
case SmartLinkDirection.Horizontal:
|
|
15
|
+
default:
|
|
16
|
+
return {
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
alignItems: 'center'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getGapSize = size => {
|
|
24
|
+
switch (size) {
|
|
25
|
+
case SmartLinkSize.XLarge:
|
|
26
|
+
return '1.25rem';
|
|
27
|
+
|
|
28
|
+
case SmartLinkSize.Large:
|
|
29
|
+
return '1rem';
|
|
30
|
+
|
|
31
|
+
case SmartLinkSize.Medium:
|
|
32
|
+
return '.5rem';
|
|
33
|
+
|
|
34
|
+
case SmartLinkSize.Small:
|
|
35
|
+
default:
|
|
36
|
+
return '.25rem';
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getBlockStyles = (direction, size) => css({
|
|
41
|
+
display: 'flex',
|
|
42
|
+
gap: getGapSize(size),
|
|
43
|
+
lineHeight: '1rem',
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
...getDirectionStyles(direction),
|
|
46
|
+
'& > *': {
|
|
47
|
+
minWidth: 0
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const Block = ({
|
|
52
|
+
children,
|
|
53
|
+
direction = SmartLinkDirection.Horizontal,
|
|
54
|
+
size = SmartLinkSize.Medium,
|
|
55
|
+
testId = 'smart-block'
|
|
56
|
+
}) => jsx("div", {
|
|
57
|
+
css: getBlockStyles(direction, size),
|
|
58
|
+
"data-smart-block": true,
|
|
59
|
+
"data-testid": testId
|
|
60
|
+
}, children);
|
|
61
|
+
|
|
62
|
+
export default Block;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { N0, N40A, N50A } from '@atlaskit/theme/colors';
|
|
4
|
+
import { css, jsx } from '@emotion/core';
|
|
5
|
+
import { SmartLinkSize } from '../../../../constants';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
7
|
+
|
|
8
|
+
const getElevationStyles = () => ({
|
|
9
|
+
border: `1px solid transparent`,
|
|
10
|
+
borderRadius: '1.5px',
|
|
11
|
+
boxShadow: token('elevation.shadow.raised', `0 1px 1px ${N50A}, 0 0 1px 1px ${N40A}`),
|
|
12
|
+
margin: '2px'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const getGapSize = size => {
|
|
16
|
+
switch (size) {
|
|
17
|
+
case SmartLinkSize.XLarge:
|
|
18
|
+
return '1.25rem';
|
|
19
|
+
|
|
20
|
+
case SmartLinkSize.Large:
|
|
21
|
+
return '1rem';
|
|
22
|
+
|
|
23
|
+
case SmartLinkSize.Medium:
|
|
24
|
+
return '.5rem';
|
|
25
|
+
|
|
26
|
+
case SmartLinkSize.Small:
|
|
27
|
+
default:
|
|
28
|
+
return '.25rem';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getPaddingSize = size => {
|
|
33
|
+
switch (size) {
|
|
34
|
+
case SmartLinkSize.XLarge:
|
|
35
|
+
return '1.5rem';
|
|
36
|
+
|
|
37
|
+
case SmartLinkSize.Large:
|
|
38
|
+
return '1.25rem';
|
|
39
|
+
|
|
40
|
+
case SmartLinkSize.Medium:
|
|
41
|
+
return '1rem';
|
|
42
|
+
|
|
43
|
+
case SmartLinkSize.Small:
|
|
44
|
+
default:
|
|
45
|
+
return '.5rem';
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const getContainerStyles = (size, hideBackground, hideElevation, hidePadding) => {
|
|
50
|
+
const elevation = hideElevation ? {} : getElevationStyles();
|
|
51
|
+
return css({
|
|
52
|
+
backgroundColor: hideBackground ? undefined : token('elevation.surface', N0),
|
|
53
|
+
display: 'flex',
|
|
54
|
+
gap: `${getGapSize(size)} 0`,
|
|
55
|
+
flexDirection: 'column',
|
|
56
|
+
minWidth: 0,
|
|
57
|
+
overflow: 'hidden',
|
|
58
|
+
padding: hidePadding ? undefined : getPaddingSize(size),
|
|
59
|
+
...elevation
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const renderChildren = (children, containerSize) => React.Children.map(children, child => {
|
|
64
|
+
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
65
|
+
const {
|
|
66
|
+
size: blockSize
|
|
67
|
+
} = child.props;
|
|
68
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
69
|
+
size: blockSize || containerSize
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return child;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const Container = ({
|
|
77
|
+
children,
|
|
78
|
+
hideBackground = false,
|
|
79
|
+
hideElevation = false,
|
|
80
|
+
hidePadding = false,
|
|
81
|
+
size = SmartLinkSize.Medium,
|
|
82
|
+
testId = 'smart-links-container'
|
|
83
|
+
}) => jsx("div", {
|
|
84
|
+
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding),
|
|
85
|
+
"data-smart-link-container": true,
|
|
86
|
+
"data-testid": testId
|
|
87
|
+
}, renderChildren(children, size));
|
|
88
|
+
|
|
89
|
+
export default Container;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|