@atlaskit/smart-card 26.9.18 → 26.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/loader.js +2 -32
- package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +3 -3
- package/dist/cjs/view/FlexibleCard/components/container/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/utils.js +3 -3
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +2 -1
- package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +3 -2
- package/dist/es2019/state/analytics/useDispatchAnalytics.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/loader.js +2 -32
- package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +3 -3
- package/dist/es2019/view/FlexibleCard/components/container/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/utils.js +3 -3
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +3 -2
- package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +3 -2
- package/dist/esm/state/analytics/useDispatchAnalytics.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/loader.js +2 -32
- package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +3 -3
- package/dist/esm/view/FlexibleCard/components/container/index.js +1 -1
- package/dist/esm/view/FlexibleCard/utils.js +3 -3
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +3 -2
- package/dist/esm/view/InlineCard/UnauthorisedView/index.js +3 -2
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fa12a765333`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa12a765333) - Cleansup a FF introduced in 26.3.5 (platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop) providing default display attribute now prefers analytics context instead of passing a dispatch function as prop.
|
|
8
|
+
|
|
9
|
+
## 26.9.19
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`928615c211b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/928615c211b) - Fix connect button appear when user cannot not connect (no auth flow)
|
|
14
|
+
|
|
3
15
|
## 26.9.18
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/version.json
CHANGED
|
@@ -9,11 +9,9 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
-
var _analytics = require("../../utils/analytics");
|
|
14
12
|
var _performance = require("../../utils/performance");
|
|
15
13
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
16
|
-
var
|
|
14
|
+
var _analytics = require("../../state/analytics");
|
|
17
15
|
var _LazyFallback = require("./component-lazy/LazyFallback");
|
|
18
16
|
var _utils = require("../../utils");
|
|
19
17
|
var _flexible = require("../../utils/flexible");
|
|
@@ -56,7 +54,6 @@ function CardWithURLRenderer(props) {
|
|
|
56
54
|
embedIframeRef = props.embedIframeRef,
|
|
57
55
|
embedIframeUrlType = props.embedIframeUrlType,
|
|
58
56
|
inlinePreloaderStyle = props.inlinePreloaderStyle,
|
|
59
|
-
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
60
57
|
children = props.children,
|
|
61
58
|
ui = props.ui,
|
|
62
59
|
showHoverPreview = props.showHoverPreview,
|
|
@@ -64,33 +61,7 @@ function CardWithURLRenderer(props) {
|
|
|
64
61
|
analyticsEvents = props.analyticsEvents,
|
|
65
62
|
placeholder = props.placeholder,
|
|
66
63
|
fallbackComponent = props.fallbackComponent;
|
|
67
|
-
|
|
68
|
-
// Wrapper around analytics.
|
|
69
|
-
var dispatchAnalytics = (0, _react.useMemo)(function () {
|
|
70
|
-
/**
|
|
71
|
-
* If feature flag is on, return `undefined` for dispatch, which will be passed down
|
|
72
|
-
* to the components as undefined and the fallback method will be used instead to dispatch
|
|
73
|
-
* analytics events:
|
|
74
|
-
* packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
|
|
75
|
-
*
|
|
76
|
-
* For FF cleanup, we should be able to remove the prop from all the places where this is
|
|
77
|
-
* being passed down to.
|
|
78
|
-
*/
|
|
79
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
return function (analyticsPayload) {
|
|
83
|
-
if (analyticsPayload && analyticsPayload.attributes) {
|
|
84
|
-
// Update if we haven't already set the display - possible
|
|
85
|
-
// in the case of `preview` which is rendered differently.
|
|
86
|
-
if (!analyticsPayload.attributes.display) {
|
|
87
|
-
analyticsPayload.attributes.display = appearance;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
(0, _analytics.fireSmartLinkEvent)(analyticsPayload, createAnalyticsEvent);
|
|
91
|
-
};
|
|
92
|
-
}, [appearance, createAnalyticsEvent]);
|
|
93
|
-
var analytics = (0, _analytics2.useSmartLinkAnalytics)(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
|
|
64
|
+
var analytics = (0, _analytics.useSmartLinkAnalytics)(url !== null && url !== void 0 ? url : '', undefined, id);
|
|
94
65
|
var isFlexibleUi = (0, _flexible.isFlexibleUiCard)(children);
|
|
95
66
|
var errorHandler = (0, _react.useCallback)(function (error, info) {
|
|
96
67
|
var componentStack = info.componentStack;
|
|
@@ -140,7 +111,6 @@ function CardWithURLRenderer(props) {
|
|
|
140
111
|
isSelected: isSelected,
|
|
141
112
|
isFrameVisible: isFrameVisible,
|
|
142
113
|
frameStyle: frameStyle,
|
|
143
|
-
dispatchAnalytics: dispatchAnalytics,
|
|
144
114
|
container: container,
|
|
145
115
|
onResolve: onResolve,
|
|
146
116
|
onError: onError,
|
|
@@ -52,12 +52,12 @@ var EmbedCardUnauthorisedView = function EmbedCardUnauthorisedView(_ref) {
|
|
|
52
52
|
title: "connect_link_account_card_name",
|
|
53
53
|
description: "connect_unauthorised_account_description",
|
|
54
54
|
context: context && context.text,
|
|
55
|
-
button: {
|
|
55
|
+
button: onAuthorise ? {
|
|
56
56
|
appearance: 'primary',
|
|
57
57
|
text: 'connect_unauthorised_account_action',
|
|
58
58
|
testId: 'connect-account'
|
|
59
|
-
},
|
|
60
|
-
onClick: handleOnAuthorizeClick,
|
|
59
|
+
} : undefined,
|
|
60
|
+
onClick: onAuthorise ? handleOnAuthorizeClick : undefined,
|
|
61
61
|
testId: testId
|
|
62
62
|
}, /*#__PURE__*/_react.default.createElement(_UnauthorisedViewContent.default, {
|
|
63
63
|
analytics: analytics,
|
|
@@ -166,7 +166,7 @@ var Container = function Container(_ref3) {
|
|
|
166
166
|
var context = (0, _react.useContext)(_flexibleUiContext.FlexibleUiContext);
|
|
167
167
|
var childrenOptions = getChildrenOptions(children, context);
|
|
168
168
|
var canShowHoverPreview = showHoverPreview && status === 'resolved';
|
|
169
|
-
var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized';
|
|
169
|
+
var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
|
|
170
170
|
var container = (0, _react2.jsx)("div", {
|
|
171
171
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
172
172
|
"data-smart-link-container": true,
|
|
@@ -89,11 +89,11 @@ var getRetryOptions = function getRetryOptions(url, status, response, onAuthoriz
|
|
|
89
89
|
values: values
|
|
90
90
|
};
|
|
91
91
|
case _constants.SmartLinkStatus.Unauthorized:
|
|
92
|
-
return {
|
|
92
|
+
return onAuthorize ? {
|
|
93
93
|
descriptor: _messages.messages.connect_link_account_card_name,
|
|
94
|
-
onClick:
|
|
94
|
+
onClick: (0, _utils.handleOnClick)(onAuthorize),
|
|
95
95
|
values: values
|
|
96
|
-
};
|
|
96
|
+
} : undefined;
|
|
97
97
|
case _constants.SmartLinkStatus.NotFound:
|
|
98
98
|
return {
|
|
99
99
|
descriptor: _messages.messages.cannot_find_link
|
|
@@ -91,6 +91,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
91
91
|
}, [cardState.details]);
|
|
92
92
|
var linkState = (0, _store.useSmartCardState)(url);
|
|
93
93
|
var linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
94
|
+
var services = (0, _helpers.getServices)(linkState.details);
|
|
94
95
|
var statusRef = (0, _react2.useRef)(linkStatus);
|
|
95
96
|
var analyticsRef = (0, _react2.useRef)(analytics);
|
|
96
97
|
(0, _react2.useEffect)(function () {
|
|
@@ -173,7 +174,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
173
174
|
titleBlockProps: titleBlockProps
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
|
-
if (cardState.status === 'unauthorized') {
|
|
177
|
+
if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
|
|
177
178
|
return (0, _react.jsx)(_unauthorised.default, {
|
|
178
179
|
analytics: analytics,
|
|
179
180
|
extensionKey: extensionKey,
|
|
@@ -79,6 +79,7 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
|
|
|
79
79
|
var _this$props3 = this.props,
|
|
80
80
|
url = _this$props3.url,
|
|
81
81
|
icon = _this$props3.icon,
|
|
82
|
+
onAuthorise = _this$props3.onAuthorise,
|
|
82
83
|
onClick = _this$props3.onClick,
|
|
83
84
|
isSelected = _this$props3.isSelected,
|
|
84
85
|
_this$props3$testId = _this$props3.testId,
|
|
@@ -96,10 +97,10 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
|
|
|
96
97
|
onClick: onClick,
|
|
97
98
|
titleColor: "var(--ds-text-subtle, ".concat(_colors.N500, ")")
|
|
98
99
|
}));
|
|
99
|
-
if (showAuthTooltip) {
|
|
100
|
+
if (onAuthorise && showAuthTooltip) {
|
|
100
101
|
return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
|
|
101
102
|
url: url,
|
|
102
|
-
onAuthorize:
|
|
103
|
+
onAuthorize: onAuthorise,
|
|
103
104
|
id: this.props.id
|
|
104
105
|
}, inlineCardUnauthenticatedView);
|
|
105
106
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
3
|
import { ANALYTICS_CHANNEL } from '../../utils/analytics';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Hook designed to use a handler if provided (ideally not)
|
|
6
7
|
* Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React, { lazy, useEffect, useState, Suspense, useCallback
|
|
1
|
+
import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
5
3
|
import { clearMarks, clearMeasures } from '../../utils/performance';
|
|
6
4
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
7
5
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
@@ -36,7 +34,6 @@ export function CardWithURLRenderer(props) {
|
|
|
36
34
|
embedIframeRef,
|
|
37
35
|
embedIframeUrlType,
|
|
38
36
|
inlinePreloaderStyle,
|
|
39
|
-
createAnalyticsEvent,
|
|
40
37
|
children,
|
|
41
38
|
ui,
|
|
42
39
|
showHoverPreview,
|
|
@@ -45,33 +42,7 @@ export function CardWithURLRenderer(props) {
|
|
|
45
42
|
placeholder,
|
|
46
43
|
fallbackComponent
|
|
47
44
|
} = props;
|
|
48
|
-
|
|
49
|
-
// Wrapper around analytics.
|
|
50
|
-
const dispatchAnalytics = useMemo(() => {
|
|
51
|
-
/**
|
|
52
|
-
* If feature flag is on, return `undefined` for dispatch, which will be passed down
|
|
53
|
-
* to the components as undefined and the fallback method will be used instead to dispatch
|
|
54
|
-
* analytics events:
|
|
55
|
-
* packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
|
|
56
|
-
*
|
|
57
|
-
* For FF cleanup, we should be able to remove the prop from all the places where this is
|
|
58
|
-
* being passed down to.
|
|
59
|
-
*/
|
|
60
|
-
if (getBooleanFF('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
return analyticsPayload => {
|
|
64
|
-
if (analyticsPayload && analyticsPayload.attributes) {
|
|
65
|
-
// Update if we haven't already set the display - possible
|
|
66
|
-
// in the case of `preview` which is rendered differently.
|
|
67
|
-
if (!analyticsPayload.attributes.display) {
|
|
68
|
-
analyticsPayload.attributes.display = appearance;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
72
|
-
};
|
|
73
|
-
}, [appearance, createAnalyticsEvent]);
|
|
74
|
-
const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
|
|
45
|
+
const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', undefined, id);
|
|
75
46
|
const isFlexibleUi = isFlexibleUiCard(children);
|
|
76
47
|
const errorHandler = useCallback((error, info) => {
|
|
77
48
|
const {
|
|
@@ -119,7 +90,6 @@ export function CardWithURLRenderer(props) {
|
|
|
119
90
|
isSelected,
|
|
120
91
|
isFrameVisible,
|
|
121
92
|
frameStyle,
|
|
122
|
-
dispatchAnalytics,
|
|
123
93
|
container,
|
|
124
94
|
onResolve,
|
|
125
95
|
onError,
|
|
@@ -42,12 +42,12 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
42
42
|
title: "connect_link_account_card_name",
|
|
43
43
|
description: "connect_unauthorised_account_description",
|
|
44
44
|
context: context && context.text,
|
|
45
|
-
button: {
|
|
45
|
+
button: onAuthorise ? {
|
|
46
46
|
appearance: 'primary',
|
|
47
47
|
text: 'connect_unauthorised_account_action',
|
|
48
48
|
testId: 'connect-account'
|
|
49
|
-
},
|
|
50
|
-
onClick: handleOnAuthorizeClick,
|
|
49
|
+
} : undefined,
|
|
50
|
+
onClick: onAuthorise ? handleOnAuthorizeClick : undefined,
|
|
51
51
|
testId: testId
|
|
52
52
|
}, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
53
53
|
analytics: analytics,
|
|
@@ -187,7 +187,7 @@ const Container = ({
|
|
|
187
187
|
const context = useContext(FlexibleUiContext);
|
|
188
188
|
const childrenOptions = getChildrenOptions(children, context);
|
|
189
189
|
const canShowHoverPreview = showHoverPreview && status === 'resolved';
|
|
190
|
-
const canShowAuthTooltip = showAuthTooltip && status === 'unauthorized';
|
|
190
|
+
const canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
|
|
191
191
|
const container = jsx("div", {
|
|
192
192
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
193
193
|
"data-smart-link-container": true,
|
|
@@ -82,11 +82,11 @@ export const getRetryOptions = (url, status, response, onAuthorize) => {
|
|
|
82
82
|
values
|
|
83
83
|
};
|
|
84
84
|
case SmartLinkStatus.Unauthorized:
|
|
85
|
-
return {
|
|
85
|
+
return onAuthorize ? {
|
|
86
86
|
descriptor: messages.connect_link_account_card_name,
|
|
87
|
-
onClick:
|
|
87
|
+
onClick: handleOnClick(onAuthorize),
|
|
88
88
|
values
|
|
89
|
-
};
|
|
89
|
+
} : undefined;
|
|
90
90
|
case SmartLinkStatus.NotFound:
|
|
91
91
|
return {
|
|
92
92
|
descriptor: messages.cannot_find_link
|
|
@@ -6,7 +6,7 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
|
6
6
|
import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
7
7
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
8
8
|
import { useSmartLinkAnalytics } from '../../../state/analytics';
|
|
9
|
-
import { getExtensionKey } from '../../../state/helpers';
|
|
9
|
+
import { getExtensionKey, getServices } from '../../../state/helpers';
|
|
10
10
|
import { isSpecialEvent } from '../../../utils';
|
|
11
11
|
import { HoverCardContainer, flexibleUiOptions, titleBlockCss } from '../styled';
|
|
12
12
|
import { getSimulatedMetadata } from '../utils';
|
|
@@ -53,6 +53,7 @@ const HoverCardContent = ({
|
|
|
53
53
|
const extensionKey = useMemo(() => getExtensionKey(cardState.details), [cardState.details]);
|
|
54
54
|
const linkState = useSmartCardState(url);
|
|
55
55
|
const linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
56
|
+
const services = getServices(linkState.details);
|
|
56
57
|
const statusRef = useRef(linkStatus);
|
|
57
58
|
const analyticsRef = useRef(analytics);
|
|
58
59
|
useEffect(() => {
|
|
@@ -132,7 +133,7 @@ const HoverCardContent = ({
|
|
|
132
133
|
titleBlockProps: titleBlockProps
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
|
-
if (cardState.status === 'unauthorized') {
|
|
136
|
+
if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
|
|
136
137
|
return jsx(HoverCardUnauthorisedView, {
|
|
137
138
|
analytics: analytics,
|
|
138
139
|
extensionKey: extensionKey,
|
|
@@ -56,6 +56,7 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
56
56
|
const {
|
|
57
57
|
url,
|
|
58
58
|
icon,
|
|
59
|
+
onAuthorise,
|
|
59
60
|
onClick,
|
|
60
61
|
isSelected,
|
|
61
62
|
testId = 'inline-card-unauthorized-view',
|
|
@@ -72,10 +73,10 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
72
73
|
onClick: onClick,
|
|
73
74
|
titleColor: `var(--ds-text-subtle, ${N500})`
|
|
74
75
|
}));
|
|
75
|
-
if (showAuthTooltip) {
|
|
76
|
+
if (onAuthorise && showAuthTooltip) {
|
|
76
77
|
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
77
78
|
url: url,
|
|
78
|
-
onAuthorize:
|
|
79
|
+
onAuthorize: onAuthorise,
|
|
79
80
|
id: this.props.id
|
|
80
81
|
}, inlineCardUnauthenticatedView);
|
|
81
82
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
3
|
import { ANALYTICS_CHANNEL } from '../../utils/analytics';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Hook designed to use a handler if provided (ideally not)
|
|
6
7
|
* Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
|
package/dist/esm/version.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { lazy, useEffect, useState, Suspense, useCallback
|
|
2
|
+
import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
|
|
3
3
|
import uuid from 'uuid';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
|
-
import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
6
4
|
import { clearMarks, clearMeasures } from '../../utils/performance';
|
|
7
5
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
6
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
@@ -44,7 +42,6 @@ export function CardWithURLRenderer(props) {
|
|
|
44
42
|
embedIframeRef = props.embedIframeRef,
|
|
45
43
|
embedIframeUrlType = props.embedIframeUrlType,
|
|
46
44
|
inlinePreloaderStyle = props.inlinePreloaderStyle,
|
|
47
|
-
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
48
45
|
children = props.children,
|
|
49
46
|
ui = props.ui,
|
|
50
47
|
showHoverPreview = props.showHoverPreview,
|
|
@@ -52,33 +49,7 @@ export function CardWithURLRenderer(props) {
|
|
|
52
49
|
analyticsEvents = props.analyticsEvents,
|
|
53
50
|
placeholder = props.placeholder,
|
|
54
51
|
fallbackComponent = props.fallbackComponent;
|
|
55
|
-
|
|
56
|
-
// Wrapper around analytics.
|
|
57
|
-
var dispatchAnalytics = useMemo(function () {
|
|
58
|
-
/**
|
|
59
|
-
* If feature flag is on, return `undefined` for dispatch, which will be passed down
|
|
60
|
-
* to the components as undefined and the fallback method will be used instead to dispatch
|
|
61
|
-
* analytics events:
|
|
62
|
-
* packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
|
|
63
|
-
*
|
|
64
|
-
* For FF cleanup, we should be able to remove the prop from all the places where this is
|
|
65
|
-
* being passed down to.
|
|
66
|
-
*/
|
|
67
|
-
if (getBooleanFF('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
return function (analyticsPayload) {
|
|
71
|
-
if (analyticsPayload && analyticsPayload.attributes) {
|
|
72
|
-
// Update if we haven't already set the display - possible
|
|
73
|
-
// in the case of `preview` which is rendered differently.
|
|
74
|
-
if (!analyticsPayload.attributes.display) {
|
|
75
|
-
analyticsPayload.attributes.display = appearance;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
79
|
-
};
|
|
80
|
-
}, [appearance, createAnalyticsEvent]);
|
|
81
|
-
var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
|
|
52
|
+
var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', undefined, id);
|
|
82
53
|
var isFlexibleUi = isFlexibleUiCard(children);
|
|
83
54
|
var errorHandler = useCallback(function (error, info) {
|
|
84
55
|
var componentStack = info.componentStack;
|
|
@@ -128,7 +99,6 @@ export function CardWithURLRenderer(props) {
|
|
|
128
99
|
isSelected: isSelected,
|
|
129
100
|
isFrameVisible: isFrameVisible,
|
|
130
101
|
frameStyle: frameStyle,
|
|
131
|
-
dispatchAnalytics: dispatchAnalytics,
|
|
132
102
|
container: container,
|
|
133
103
|
onResolve: onResolve,
|
|
134
104
|
onError: onError,
|
|
@@ -42,12 +42,12 @@ export var EmbedCardUnauthorisedView = function EmbedCardUnauthorisedView(_ref)
|
|
|
42
42
|
title: "connect_link_account_card_name",
|
|
43
43
|
description: "connect_unauthorised_account_description",
|
|
44
44
|
context: context && context.text,
|
|
45
|
-
button: {
|
|
45
|
+
button: onAuthorise ? {
|
|
46
46
|
appearance: 'primary',
|
|
47
47
|
text: 'connect_unauthorised_account_action',
|
|
48
48
|
testId: 'connect-account'
|
|
49
|
-
},
|
|
50
|
-
onClick: handleOnAuthorizeClick,
|
|
49
|
+
} : undefined,
|
|
50
|
+
onClick: onAuthorise ? handleOnAuthorizeClick : undefined,
|
|
51
51
|
testId: testId
|
|
52
52
|
}, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
53
53
|
analytics: analytics,
|
|
@@ -155,7 +155,7 @@ var Container = function Container(_ref3) {
|
|
|
155
155
|
var context = useContext(FlexibleUiContext);
|
|
156
156
|
var childrenOptions = getChildrenOptions(children, context);
|
|
157
157
|
var canShowHoverPreview = showHoverPreview && status === 'resolved';
|
|
158
|
-
var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized';
|
|
158
|
+
var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
|
|
159
159
|
var container = jsx("div", {
|
|
160
160
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
161
161
|
"data-smart-link-container": true,
|
|
@@ -81,11 +81,11 @@ export var getRetryOptions = function getRetryOptions(url, status, response, onA
|
|
|
81
81
|
values: values
|
|
82
82
|
};
|
|
83
83
|
case SmartLinkStatus.Unauthorized:
|
|
84
|
-
return {
|
|
84
|
+
return onAuthorize ? {
|
|
85
85
|
descriptor: messages.connect_link_account_card_name,
|
|
86
|
-
onClick:
|
|
86
|
+
onClick: handleOnClick(onAuthorize),
|
|
87
87
|
values: values
|
|
88
|
-
};
|
|
88
|
+
} : undefined;
|
|
89
89
|
case SmartLinkStatus.NotFound:
|
|
90
90
|
return {
|
|
91
91
|
descriptor: messages.cannot_find_link
|
|
@@ -8,7 +8,7 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
|
8
8
|
import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
9
9
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
10
10
|
import { useSmartLinkAnalytics } from '../../../state/analytics';
|
|
11
|
-
import { getExtensionKey } from '../../../state/helpers';
|
|
11
|
+
import { getExtensionKey, getServices } from '../../../state/helpers';
|
|
12
12
|
import { isSpecialEvent } from '../../../utils';
|
|
13
13
|
import { HoverCardContainer, flexibleUiOptions, titleBlockCss } from '../styled';
|
|
14
14
|
import { getSimulatedMetadata } from '../utils';
|
|
@@ -78,6 +78,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
78
78
|
}, [cardState.details]);
|
|
79
79
|
var linkState = useSmartCardState(url);
|
|
80
80
|
var linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
81
|
+
var services = getServices(linkState.details);
|
|
81
82
|
var statusRef = useRef(linkStatus);
|
|
82
83
|
var analyticsRef = useRef(analytics);
|
|
83
84
|
useEffect(function () {
|
|
@@ -160,7 +161,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
160
161
|
titleBlockProps: titleBlockProps
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
|
-
if (cardState.status === 'unauthorized') {
|
|
164
|
+
if (cardState.status === 'unauthorized' && services !== null && services !== void 0 && services.length) {
|
|
164
165
|
return jsx(HoverCardUnauthorisedView, {
|
|
165
166
|
analytics: analytics,
|
|
166
167
|
extensionKey: extensionKey,
|
|
@@ -72,6 +72,7 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
|
|
|
72
72
|
var _this$props3 = this.props,
|
|
73
73
|
url = _this$props3.url,
|
|
74
74
|
icon = _this$props3.icon,
|
|
75
|
+
onAuthorise = _this$props3.onAuthorise,
|
|
75
76
|
onClick = _this$props3.onClick,
|
|
76
77
|
isSelected = _this$props3.isSelected,
|
|
77
78
|
_this$props3$testId = _this$props3.testId,
|
|
@@ -89,10 +90,10 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
|
|
|
89
90
|
onClick: onClick,
|
|
90
91
|
titleColor: "var(--ds-text-subtle, ".concat(N500, ")")
|
|
91
92
|
}));
|
|
92
|
-
if (showAuthTooltip) {
|
|
93
|
+
if (onAuthorise && showAuthTooltip) {
|
|
93
94
|
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
94
95
|
url: url,
|
|
95
|
-
onAuthorize:
|
|
96
|
+
onAuthorize: onAuthorise,
|
|
96
97
|
id: this.props.id
|
|
97
98
|
}, inlineCardUnauthenticatedView);
|
|
98
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.10.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -134,9 +134,6 @@
|
|
|
134
134
|
".": "./src/index.ts"
|
|
135
135
|
},
|
|
136
136
|
"platform-feature-flags": {
|
|
137
|
-
"platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop": {
|
|
138
|
-
"type": "boolean"
|
|
139
|
-
},
|
|
140
137
|
"platform.linking-platform.smart-card.enable-block-card-clicks-opening-in-same-tab": {
|
|
141
138
|
"type": "boolean"
|
|
142
139
|
},
|