@atlaskit/smart-card 42.3.4 → 42.3.5
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 +11 -0
- package/dist/cjs/state/actions/index.js +6 -8
- package/dist/cjs/state/hooks/useSmartLink.js +3 -3
- package/dist/cjs/state/store/index.js +1 -5
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +15 -14
- package/dist/cjs/view/FlexibleCard/index.js +13 -5
- package/dist/cjs/view/LinkUrl/HyperlinkResolver/index.js +3 -26
- package/dist/cjs/view/LinkUrl/index.js +23 -30
- package/dist/es2019/state/actions/index.js +4 -6
- package/dist/es2019/state/hooks/useSmartLink.js +3 -3
- package/dist/es2019/state/store/index.js +1 -5
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +15 -14
- package/dist/es2019/view/FlexibleCard/index.js +12 -5
- package/dist/es2019/view/LinkUrl/HyperlinkResolver/index.js +3 -27
- package/dist/es2019/view/LinkUrl/index.js +23 -28
- package/dist/esm/state/actions/index.js +6 -8
- package/dist/esm/state/hooks/useSmartLink.js +3 -3
- package/dist/esm/state/store/index.js +1 -5
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +15 -14
- package/dist/esm/view/FlexibleCard/index.js +12 -5
- package/dist/esm/view/LinkUrl/HyperlinkResolver/index.js +3 -26
- package/dist/esm/view/LinkUrl/index.js +23 -28
- package/dist/types/state/actions/index.d.ts +1 -2
- package/dist/types/state/hooks/useSmartLink.d.ts +2 -3
- package/dist/types/state/store/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/index.d.ts +13 -1
- package/dist/types/view/LinkUrl/HyperlinkResolver/index.d.ts +0 -5
- package/dist/types-ts4.5/state/actions/index.d.ts +1 -2
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +2 -3
- package/dist/types-ts4.5/state/store/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/index.d.ts +13 -1
- package/dist/types-ts4.5/view/LinkUrl/HyperlinkResolver/index.d.ts +0 -5
- package/package.json +2 -5
- package/dist/cjs/view/LinkUrl/HyperlinkResolver/error-boundary.js +0 -18
- package/dist/cjs/view/LinkUrl/HyperlinkResolver/resolve-hyperlink.js +0 -70
- package/dist/es2019/view/LinkUrl/HyperlinkResolver/error-boundary.js +0 -9
- package/dist/es2019/view/LinkUrl/HyperlinkResolver/resolve-hyperlink.js +0 -60
- package/dist/esm/view/LinkUrl/HyperlinkResolver/error-boundary.js +0 -11
- package/dist/esm/view/LinkUrl/HyperlinkResolver/resolve-hyperlink.js +0 -62
- package/dist/types/view/LinkUrl/HyperlinkResolver/error-boundary.d.ts +0 -4
- package/dist/types/view/LinkUrl/HyperlinkResolver/resolve-hyperlink.d.ts +0 -3
- package/dist/types-ts4.5/view/LinkUrl/HyperlinkResolver/error-boundary.d.ts +0 -4
- package/dist/types-ts4.5/view/LinkUrl/HyperlinkResolver/resolve-hyperlink.d.ts +0 -3
|
@@ -4,16 +4,15 @@ import { di } from 'react-magnetic-di';
|
|
|
4
4
|
import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
5
|
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
6
6
|
import AKLink from '@atlaskit/link';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { withLinkClickedEvent } from '../../utils/analytics/click';
|
|
9
8
|
import { LinkAnalyticsContext } from '../../utils/analytics/LinkAnalyticsContext';
|
|
10
9
|
import Hyperlink from './Hyperlink';
|
|
11
|
-
import
|
|
10
|
+
import { HyperlinkWithSmartLinkResolver } from './HyperlinkResolver';
|
|
12
11
|
import LinkWarningModal from './LinkWarningModal';
|
|
13
12
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
14
13
|
const PACKAGE_DATA = {
|
|
15
14
|
packageName: "@atlaskit/smart-card",
|
|
16
|
-
packageVersion: "
|
|
15
|
+
packageVersion: "42.3.4",
|
|
17
16
|
componentName: 'linkUrl'
|
|
18
17
|
};
|
|
19
18
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -34,30 +33,28 @@ const LinkUrl = ({
|
|
|
34
33
|
...linkWarningModalProps
|
|
35
34
|
} = useLinkWarningModal();
|
|
36
35
|
const resolveHyperlinkFG = FeatureGates.checkGate('platform_editor_resolve_hyperlinks_killswitch');
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
36
|
+
if (resolveHyperlinkFG) {
|
|
37
|
+
const Link = enableResolve ? HyperlinkWithSmartLinkResolver : Hyperlink;
|
|
38
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LinkAnalyticsContext, {
|
|
39
|
+
url: href,
|
|
40
|
+
display: "url"
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Link, _extends({
|
|
42
|
+
href: href,
|
|
43
|
+
isLinkComponent: isLinkComponent,
|
|
44
|
+
onClick: e => {
|
|
45
|
+
if (!checkSafety) {
|
|
46
|
+
onClick && onClick(e);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
50
|
+
// Only call the onClick if the link is safe
|
|
51
|
+
if (isLinkSafe(e, href)) {
|
|
52
|
+
onClick && onClick(e);
|
|
53
|
+
} else {
|
|
54
|
+
showSafetyWarningModal(e, href);
|
|
58
55
|
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
56
|
+
}
|
|
57
|
+
}, props), children)), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps));
|
|
61
58
|
}
|
|
62
59
|
const Link = isLinkComponent ? LinkComponent : Anchor;
|
|
63
60
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LinkAnalyticsContext, {
|
|
@@ -82,8 +79,6 @@ const LinkUrl = ({
|
|
|
82
79
|
showSafetyWarningModal(e, href);
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
}, props), children)), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps)
|
|
86
|
-
href: href
|
|
87
|
-
}));
|
|
82
|
+
}, props), children)), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps));
|
|
88
83
|
};
|
|
89
84
|
export default withAnalyticsContext(PACKAGE_DATA)(LinkUrl);
|
|
@@ -4,14 +4,13 @@ import { useCallback, useMemo } from 'react';
|
|
|
4
4
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
5
5
|
import { ACTION_RESOLVING, ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
|
|
6
6
|
import { auth } from '@atlaskit/outbound-auth-flow-client';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
9
8
|
import { SmartLinkStatus } from '../../constants';
|
|
10
9
|
import { startUfoExperience } from '../analytics';
|
|
11
10
|
import { getByDefinitionId, getDefinitionId, getExtensionKey, getServices } from '../helpers';
|
|
12
11
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
13
12
|
import useResolve from '../hooks/use-resolve';
|
|
14
|
-
export var useSmartCardActions = function useSmartCardActions(id, url
|
|
13
|
+
export var useSmartCardActions = function useSmartCardActions(id, url) {
|
|
15
14
|
var resolveUrl = useResolve();
|
|
16
15
|
var invokeClientAction = useInvokeClientAction({});
|
|
17
16
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
@@ -21,9 +20,8 @@ export var useSmartCardActions = function useSmartCardActions(id, url, placehold
|
|
|
21
20
|
var getState = store.getState,
|
|
22
21
|
dispatch = store.dispatch;
|
|
23
22
|
var getSmartLinkState = useCallback(function () {
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var _ref = (_ref2 = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : placeholderObject) !== null && _ref2 !== void 0 ? _ref2 : {
|
|
23
|
+
var _getState$url;
|
|
24
|
+
var _ref = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : {
|
|
27
25
|
status: SmartLinkStatus.Pending
|
|
28
26
|
},
|
|
29
27
|
details = _ref.details,
|
|
@@ -34,7 +32,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, placehold
|
|
|
34
32
|
status: status,
|
|
35
33
|
metadataStatus: metadataStatus
|
|
36
34
|
};
|
|
37
|
-
}, [getState, url
|
|
35
|
+
}, [getState, url]);
|
|
38
36
|
var setMetadataStatus = useCallback(function (metadataStatus) {
|
|
39
37
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
40
38
|
url: url
|
|
@@ -147,7 +145,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, placehold
|
|
|
147
145
|
}
|
|
148
146
|
}, [getSmartLinkState, id, reload, fireEvent]);
|
|
149
147
|
var invoke = useCallback( /*#__PURE__*/function () {
|
|
150
|
-
var
|
|
148
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(opts, appearance) {
|
|
151
149
|
var key, action, source;
|
|
152
150
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
153
151
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -174,7 +172,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, placehold
|
|
|
174
172
|
}, _callee2);
|
|
175
173
|
}));
|
|
176
174
|
return function (_x, _x2) {
|
|
177
|
-
return
|
|
175
|
+
return _ref3.apply(this, arguments);
|
|
178
176
|
};
|
|
179
177
|
}(), [invokeClientAction]);
|
|
180
178
|
return useMemo(function () {
|
|
@@ -5,13 +5,13 @@ import { useSmartCardActions as useSmartLinkActions } from '../actions';
|
|
|
5
5
|
import { useSmartLinkConfig } from '../config';
|
|
6
6
|
import { useSmartLinkRenderers } from '../renderers';
|
|
7
7
|
import { useSmartCardState as useSmartLinkState } from '../store';
|
|
8
|
-
export function useSmartLink(id, url
|
|
9
|
-
var state = useSmartLinkState(url
|
|
8
|
+
export function useSmartLink(id, url) {
|
|
9
|
+
var state = useSmartLinkState(url);
|
|
10
10
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
11
11
|
store = _useSmartLinkContext.store,
|
|
12
12
|
isPreviewPanelAvailable = _useSmartLinkContext.isPreviewPanelAvailable,
|
|
13
13
|
openPreviewPanel = _useSmartLinkContext.openPreviewPanel;
|
|
14
|
-
var actions = useSmartLinkActions(id, url
|
|
14
|
+
var actions = useSmartLinkActions(id, url);
|
|
15
15
|
var config = useSmartLinkConfig();
|
|
16
16
|
var renderers = useSmartLinkRenderers();
|
|
17
17
|
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
|
|
2
2
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
var PENDING_STATE = {
|
|
5
4
|
status: 'pending'
|
|
6
5
|
};
|
|
7
|
-
export function useSmartCardState(url
|
|
6
|
+
export function useSmartCardState(url) {
|
|
8
7
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
9
8
|
store = _useSmartLinkContext.store;
|
|
10
9
|
var cardState = useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, function (state) {
|
|
11
10
|
return state[url];
|
|
12
11
|
});
|
|
13
|
-
if (fg('platform_initial_data_for_smart_cards')) {
|
|
14
|
-
return (cardState === null || cardState === void 0 ? void 0 : cardState.status) !== 'resolved' && placeholderData ? placeholderData : cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
15
|
-
}
|
|
16
12
|
return cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
17
13
|
}
|
|
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export var context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "
|
|
7
|
+
packageVersion: "42.3.4"
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -58,22 +58,9 @@ function Component(_ref) {
|
|
|
58
58
|
var isFlexibleUi = useMemo(function () {
|
|
59
59
|
return isFlexibleUiCard(children, ui);
|
|
60
60
|
}, [children, ui]);
|
|
61
|
-
var structuredPlaceholderData = fg('platform_initial_data_for_smart_cards') ?
|
|
62
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
63
|
-
useMemo(function () {
|
|
64
|
-
// execute some basic validation logic to ensure we should consider using placeholder data
|
|
65
|
-
if (appearance === 'inline' && isValidPlaceholderData(placeholderData)) {
|
|
66
|
-
var data = {
|
|
67
|
-
status: 'resolved',
|
|
68
|
-
metadataStatus: undefined,
|
|
69
|
-
details: placeholderData
|
|
70
|
-
};
|
|
71
|
-
return data;
|
|
72
|
-
}
|
|
73
|
-
}, [appearance, placeholderData]) : undefined;
|
|
74
61
|
|
|
75
62
|
// Get state, actions for this card.
|
|
76
|
-
var _useSmartLink = useSmartLink(id, url
|
|
63
|
+
var _useSmartLink = useSmartLink(id, url),
|
|
77
64
|
state = _useSmartLink.state,
|
|
78
65
|
actions = _useSmartLink.actions,
|
|
79
66
|
config = _useSmartLink.config,
|
|
@@ -233,6 +220,19 @@ function Component(_ref) {
|
|
|
233
220
|
display: isFlexibleUi ? 'flexible' : appearance
|
|
234
221
|
});
|
|
235
222
|
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
223
|
+
var structuredPlaceholderData = fg('platform_initial_data_for_smart_cards') ?
|
|
224
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
225
|
+
useMemo(function () {
|
|
226
|
+
// execute some basic validation logic to ensure we should consider using placeholder data
|
|
227
|
+
if (isFlexibleUi && isValidPlaceholderData(placeholderData)) {
|
|
228
|
+
var data = {
|
|
229
|
+
status: 'resolved',
|
|
230
|
+
metadataStatus: undefined,
|
|
231
|
+
details: placeholderData
|
|
232
|
+
};
|
|
233
|
+
return data;
|
|
234
|
+
}
|
|
235
|
+
}, [isFlexibleUi, placeholderData]) : undefined;
|
|
236
236
|
if (isFlexibleUi) {
|
|
237
237
|
var cardState = state;
|
|
238
238
|
if (error) {
|
|
@@ -247,6 +247,7 @@ function Component(_ref) {
|
|
|
247
247
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
248
248
|
id: id,
|
|
249
249
|
cardState: cardState,
|
|
250
|
+
placeholderData: fg('platform_initial_data_for_smart_cards') ? structuredPlaceholderData : undefined,
|
|
250
251
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
251
252
|
onClick: handleClickWrapper,
|
|
252
253
|
origin: "smartLinkCard",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useEffect, useMemo } from 'react';
|
|
3
3
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
5
6
|
import { InternalActionName, SmartLinkStatus } from '../../constants';
|
|
6
7
|
import { FlexibleCardContext } from '../../state/flexible-ui-context';
|
|
@@ -8,6 +9,7 @@ import { useAISummaryConfig } from '../../state/hooks/use-ai-summary-config';
|
|
|
8
9
|
import useResolve from '../../state/hooks/use-resolve';
|
|
9
10
|
import Container from './components/container';
|
|
10
11
|
import { getContextByStatus } from './utils';
|
|
12
|
+
var PENDING_LINK_STATUSES = [SmartLinkStatus.Pending, SmartLinkStatus.Resolving];
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* This represents a Flexible Card: a link represented by a card with metadata.
|
|
@@ -20,6 +22,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
20
22
|
var _ref$appearance = _ref.appearance,
|
|
21
23
|
appearance = _ref$appearance === void 0 ? 'flexible' : _ref$appearance,
|
|
22
24
|
cardState = _ref.cardState,
|
|
25
|
+
placeholderData = _ref.placeholderData,
|
|
23
26
|
children = _ref.children,
|
|
24
27
|
id = _ref.id,
|
|
25
28
|
onAuthorize = _ref.onAuthorize,
|
|
@@ -44,12 +47,16 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
44
47
|
var cardType = cardState.status,
|
|
45
48
|
details = cardState.details;
|
|
46
49
|
var status = cardType;
|
|
50
|
+
var shouldUsePlaceholderData = PENDING_LINK_STATUSES.includes(status) && placeholderData && fg('platform_initial_data_for_smart_cards');
|
|
51
|
+
// if we have placeholder data it means we can internally use it
|
|
52
|
+
// as resolved data until the actual data comes back as one of the final statuses
|
|
53
|
+
var contextStatus = shouldUsePlaceholderData ? SmartLinkStatus.Resolved : status;
|
|
47
54
|
var context = useMemo(function () {
|
|
48
55
|
return getContextByStatus({
|
|
49
56
|
aiSummaryConfig: aiSummaryConfig,
|
|
50
57
|
appearance: appearance,
|
|
51
58
|
fireEvent: fireEvent,
|
|
52
|
-
response: details,
|
|
59
|
+
response: shouldUsePlaceholderData ? placeholderData.details : details,
|
|
53
60
|
id: id,
|
|
54
61
|
onAuthorize: onAuthorize,
|
|
55
62
|
onClick: onClick,
|
|
@@ -57,19 +64,19 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
57
64
|
renderers: renderers,
|
|
58
65
|
resolve: resolve,
|
|
59
66
|
actionOptions: actionOptions,
|
|
60
|
-
status: status,
|
|
67
|
+
status: shouldUsePlaceholderData ? contextStatus : status,
|
|
61
68
|
url: url,
|
|
62
69
|
isPreviewPanelAvailable: isPreviewPanelAvailable,
|
|
63
70
|
openPreviewPanel: openPreviewPanel
|
|
64
71
|
});
|
|
65
|
-
}, [aiSummaryConfig, appearance, fireEvent, details, id, onAuthorize, onClick, origin, renderers, resolve, actionOptions, status, url, isPreviewPanelAvailable, openPreviewPanel]);
|
|
72
|
+
}, [aiSummaryConfig, appearance, fireEvent, shouldUsePlaceholderData, placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.details, details, id, onAuthorize, onClick, origin, renderers, resolve, actionOptions, contextStatus, status, url, isPreviewPanelAvailable, openPreviewPanel]);
|
|
66
73
|
var flexibleCardContext = useMemo(function () {
|
|
67
74
|
return {
|
|
68
75
|
data: context,
|
|
69
|
-
status: status,
|
|
76
|
+
status: fg('platform_initial_data_for_smart_cards') ? contextStatus : status,
|
|
70
77
|
ui: ui
|
|
71
78
|
};
|
|
72
|
-
}, [context, status, ui]);
|
|
79
|
+
}, [context, contextStatus, status, ui]);
|
|
73
80
|
var _ref2 = context || {},
|
|
74
81
|
linkTitle = _ref2.linkTitle;
|
|
75
82
|
var title = linkTitle === null || linkTitle === void 0 ? void 0 : linkTitle.text;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["onClick"];
|
|
4
|
-
import React, { useCallback
|
|
4
|
+
import React, { useCallback } from 'react';
|
|
5
5
|
import { withErrorBoundary as withReactErrorBoundary } from 'react-error-boundary';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
8
7
|
import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
|
|
9
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
-
import { SmartCardContext } from '../../../state';
|
|
11
9
|
import { getFirstPartyIdentifier, getServices, getThirdPartyARI } from '../../../state/helpers';
|
|
12
10
|
import useResolveHyperlink from '../../../state/hooks/use-resolve-hyperlink';
|
|
13
|
-
import useResolveHyperlinkValidator
|
|
11
|
+
import useResolveHyperlinkValidator from '../../../state/hooks/use-resolve-hyperlink/useResolveHyperlinkValidator';
|
|
14
12
|
import withIntlProvider from '../../common/intl-provider';
|
|
15
13
|
import { useFire3PWorkflowsClickEvent } from '../../SmartLinkEvents/useSmartLinkEvents';
|
|
16
14
|
import Hyperlink from '../Hyperlink';
|
|
17
|
-
import withErrorBoundary from './error-boundary';
|
|
18
|
-
import { ResolveHyperlink } from './resolve-hyperlink';
|
|
19
15
|
import HyperlinkUnauthorizedView from './unauthorize-view';
|
|
20
16
|
var HyperlinkFallbackComponent = function HyperlinkFallbackComponent() {
|
|
21
17
|
return null;
|
|
@@ -82,23 +78,4 @@ export var HyperlinkWithSmartLinkResolver = withReactErrorBoundary(withValidator
|
|
|
82
78
|
enforceContext: false
|
|
83
79
|
}), Hyperlink), {
|
|
84
80
|
FallbackComponent: HyperlinkFallbackComponent
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Remove on navx-1834-refactor-resolved-hyperlink cleanup
|
|
88
|
-
|
|
89
|
-
var HyperlinkResolver = function HyperlinkResolver(_ref2) {
|
|
90
|
-
var href = _ref2.href;
|
|
91
|
-
var hasSmartCardProvider = !!useContext(SmartCardContext);
|
|
92
|
-
var isSharePointResolveEnabled = FeatureGates.getExperimentValue('platform_editor_resolve_hyperlinks_confluence', 'isEnabled', false) || FeatureGates.getExperimentValue('platform_editor_resolve_hyperlinks_jira', 'isEnabled', false);
|
|
93
|
-
var isGoogleResolveEnabled = FeatureGates.getExperimentValue('platform_editor_resolve_google_hyperlinks', 'isEnabled', false);
|
|
94
|
-
var shouldResolveSharePoint = isSharePointDomain(href) && isSharePointResolveEnabled;
|
|
95
|
-
var shouldResolveGoogle = isGoogleDomain(href) && isGoogleResolveEnabled;
|
|
96
|
-
var shouldResolveHyperlink = hasSmartCardProvider && (shouldResolveSharePoint || shouldResolveGoogle);
|
|
97
|
-
if (!shouldResolveHyperlink) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
return /*#__PURE__*/React.createElement(ResolveHyperlink, {
|
|
101
|
-
href: href
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
export default withErrorBoundary(HyperlinkResolver);
|
|
81
|
+
});
|
|
@@ -7,16 +7,15 @@ import { di } from 'react-magnetic-di';
|
|
|
7
7
|
import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
8
8
|
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
9
9
|
import AKLink from '@atlaskit/link';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { withLinkClickedEvent } from '../../utils/analytics/click';
|
|
12
11
|
import { LinkAnalyticsContext } from '../../utils/analytics/LinkAnalyticsContext';
|
|
13
12
|
import Hyperlink from './Hyperlink';
|
|
14
|
-
import
|
|
13
|
+
import { HyperlinkWithSmartLinkResolver } from './HyperlinkResolver';
|
|
15
14
|
import LinkWarningModal from './LinkWarningModal';
|
|
16
15
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
17
16
|
var PACKAGE_DATA = {
|
|
18
17
|
packageName: "@atlaskit/smart-card",
|
|
19
|
-
packageVersion: "
|
|
18
|
+
packageVersion: "42.3.4",
|
|
20
19
|
componentName: 'linkUrl'
|
|
21
20
|
};
|
|
22
21
|
var Anchor = withLinkClickedEvent('a');
|
|
@@ -39,30 +38,28 @@ var LinkUrl = function LinkUrl(_ref) {
|
|
|
39
38
|
showSafetyWarningModal = _useLinkWarningModal.showSafetyWarningModal,
|
|
40
39
|
linkWarningModalProps = _objectWithoutProperties(_useLinkWarningModal, _excluded2);
|
|
41
40
|
var resolveHyperlinkFG = FeatureGates.checkGate('platform_editor_resolve_hyperlinks_killswitch');
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
41
|
+
if (resolveHyperlinkFG) {
|
|
42
|
+
var _Link = enableResolve ? HyperlinkWithSmartLinkResolver : Hyperlink;
|
|
43
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LinkAnalyticsContext, {
|
|
44
|
+
url: href,
|
|
45
|
+
display: "url"
|
|
46
|
+
}, /*#__PURE__*/React.createElement(_Link, _extends({
|
|
47
|
+
href: href,
|
|
48
|
+
isLinkComponent: isLinkComponent,
|
|
49
|
+
onClick: function onClick(e) {
|
|
50
|
+
if (!checkSafety) {
|
|
51
|
+
_onClick && _onClick(e);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
55
|
+
// Only call the onClick if the link is safe
|
|
56
|
+
if (isLinkSafe(e, href)) {
|
|
57
|
+
_onClick && _onClick(e);
|
|
58
|
+
} else {
|
|
59
|
+
showSafetyWarningModal(e, href);
|
|
63
60
|
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
61
|
+
}
|
|
62
|
+
}, props), children)), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps));
|
|
66
63
|
}
|
|
67
64
|
var Link = isLinkComponent ? LinkComponent : Anchor;
|
|
68
65
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LinkAnalyticsContext, {
|
|
@@ -87,8 +84,6 @@ var LinkUrl = function LinkUrl(_ref) {
|
|
|
87
84
|
showSafetyWarningModal(e, href);
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
|
-
}, props), children)), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps)
|
|
91
|
-
href: href
|
|
92
|
-
}));
|
|
87
|
+
}, props), children)), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps));
|
|
93
88
|
};
|
|
94
89
|
export default withAnalyticsContext(PACKAGE_DATA)(LinkUrl);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type JsonLd } from '@atlaskit/json-ld-types';
|
|
2
|
-
import { type CardState } from '@atlaskit/linking-common';
|
|
3
2
|
import { type InvokeClientOpts, type InvokeServerOpts } from '../../model/invoke-opts';
|
|
4
3
|
import { type CardInnerAppearance } from '../../view/Card/types';
|
|
5
|
-
export declare const useSmartCardActions: (id: string, url: string
|
|
4
|
+
export declare const useSmartCardActions: (id: string, url: string) => {
|
|
6
5
|
register: () => Promise<void>;
|
|
7
6
|
reload: () => void;
|
|
8
7
|
authorize: (appearance: CardInnerAppearance) => void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
state: CardState;
|
|
1
|
+
export declare function useSmartLink(id: string, url: string): {
|
|
2
|
+
state: import("@atlaskit/linking-common").CardState;
|
|
4
3
|
actions: {
|
|
5
4
|
register: () => Promise<void>;
|
|
6
5
|
reload: () => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type CardState } from '@atlaskit/linking-common';
|
|
2
2
|
export type { CardType } from '@atlaskit/linking-common';
|
|
3
|
-
export declare function useSmartCardState(url: string
|
|
3
|
+
export declare function useSmartCardState(url: string): CardState;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { CardState } from '@atlaskit/linking-common';
|
|
2
3
|
import { type FlexibleCardProps } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* This represents a Flexible Card: a link represented by a card with metadata.
|
|
@@ -6,5 +7,16 @@ import { type FlexibleCardProps } from './types';
|
|
|
6
7
|
* Note: TitleBlock is mandatory for a Flexible Card to render.
|
|
7
8
|
* @see Container
|
|
8
9
|
*/
|
|
9
|
-
declare const FlexibleCard: ({ appearance, cardState, children, id, onAuthorize, onClick, onError, onResolve, origin, renderers, showHoverPreview, hoverPreviewOptions, actionOptions, testId, ui, url, }: FlexibleCardProps
|
|
10
|
+
declare const FlexibleCard: ({ appearance, cardState, placeholderData, children, id, onAuthorize, onClick, onError, onResolve, origin, renderers, showHoverPreview, hoverPreviewOptions, actionOptions, testId, ui, url, }: FlexibleCardProps & {
|
|
11
|
+
/**
|
|
12
|
+
* @experimental
|
|
13
|
+
* This is a new prop that is not part of the public API - DO NOT USE.
|
|
14
|
+
* If provided, the card will display using the respective object for the first render (particularly useful for SSR),
|
|
15
|
+
* while still resolving `url` in the background.
|
|
16
|
+
* Placeholder data should be considered a transient state - in the sense that it will not persisted to the main store -
|
|
17
|
+
* and it will be replaced by the actual data when the given `url` is resolved.
|
|
18
|
+
* ANIP-288: Expose this prop to the public API
|
|
19
|
+
*/
|
|
20
|
+
placeholderData?: CardState;
|
|
21
|
+
}) => React.JSX.Element;
|
|
10
22
|
export default FlexibleCard;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { LinkUrlProps } from '../types';
|
|
3
3
|
export declare const HyperlinkWithSmartLinkResolver: React.ForwardRefExoticComponent<LinkUrlProps & React.RefAttributes<any>>;
|
|
4
|
-
export interface HyperlinkResolverProps {
|
|
5
|
-
href: string;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: (props: HyperlinkResolverProps) => React.JSX.Element;
|
|
8
|
-
export default _default;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type JsonLd } from '@atlaskit/json-ld-types';
|
|
2
|
-
import { type CardState } from '@atlaskit/linking-common';
|
|
3
2
|
import { type InvokeClientOpts, type InvokeServerOpts } from '../../model/invoke-opts';
|
|
4
3
|
import { type CardInnerAppearance } from '../../view/Card/types';
|
|
5
|
-
export declare const useSmartCardActions: (id: string, url: string
|
|
4
|
+
export declare const useSmartCardActions: (id: string, url: string) => {
|
|
6
5
|
register: () => Promise<void>;
|
|
7
6
|
reload: () => void;
|
|
8
7
|
authorize: (appearance: CardInnerAppearance) => void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
state: CardState;
|
|
1
|
+
export declare function useSmartLink(id: string, url: string): {
|
|
2
|
+
state: import("@atlaskit/linking-common").CardState;
|
|
4
3
|
actions: {
|
|
5
4
|
register: () => Promise<void>;
|
|
6
5
|
reload: () => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type CardState } from '@atlaskit/linking-common';
|
|
2
2
|
export type { CardType } from '@atlaskit/linking-common';
|
|
3
|
-
export declare function useSmartCardState(url: string
|
|
3
|
+
export declare function useSmartCardState(url: string): CardState;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { CardState } from '@atlaskit/linking-common';
|
|
2
3
|
import { type FlexibleCardProps } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* This represents a Flexible Card: a link represented by a card with metadata.
|
|
@@ -6,5 +7,16 @@ import { type FlexibleCardProps } from './types';
|
|
|
6
7
|
* Note: TitleBlock is mandatory for a Flexible Card to render.
|
|
7
8
|
* @see Container
|
|
8
9
|
*/
|
|
9
|
-
declare const FlexibleCard: ({ appearance, cardState, children, id, onAuthorize, onClick, onError, onResolve, origin, renderers, showHoverPreview, hoverPreviewOptions, actionOptions, testId, ui, url, }: FlexibleCardProps
|
|
10
|
+
declare const FlexibleCard: ({ appearance, cardState, placeholderData, children, id, onAuthorize, onClick, onError, onResolve, origin, renderers, showHoverPreview, hoverPreviewOptions, actionOptions, testId, ui, url, }: FlexibleCardProps & {
|
|
11
|
+
/**
|
|
12
|
+
* @experimental
|
|
13
|
+
* This is a new prop that is not part of the public API - DO NOT USE.
|
|
14
|
+
* If provided, the card will display using the respective object for the first render (particularly useful for SSR),
|
|
15
|
+
* while still resolving `url` in the background.
|
|
16
|
+
* Placeholder data should be considered a transient state - in the sense that it will not persisted to the main store -
|
|
17
|
+
* and it will be replaced by the actual data when the given `url` is resolved.
|
|
18
|
+
* ANIP-288: Expose this prop to the public API
|
|
19
|
+
*/
|
|
20
|
+
placeholderData?: CardState;
|
|
21
|
+
}) => React.JSX.Element;
|
|
10
22
|
export default FlexibleCard;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { LinkUrlProps } from '../types';
|
|
3
3
|
export declare const HyperlinkWithSmartLinkResolver: React.ForwardRefExoticComponent<LinkUrlProps & React.RefAttributes<any>>;
|
|
4
|
-
export interface HyperlinkResolverProps {
|
|
5
|
-
href: string;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: (props: HyperlinkResolverProps) => React.JSX.Element;
|
|
8
|
-
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "42.3.
|
|
3
|
+
"version": "42.3.5",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@atlaskit/textarea": "^8.0.0",
|
|
71
71
|
"@atlaskit/textfield": "^8.0.0",
|
|
72
72
|
"@atlaskit/theme": "^21.0.0",
|
|
73
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
73
|
+
"@atlaskit/tmp-editor-statsig": "^13.2.0",
|
|
74
74
|
"@atlaskit/tokens": "^6.4.0",
|
|
75
75
|
"@atlaskit/tooltip": "^20.5.0",
|
|
76
76
|
"@atlaskit/ufo": "^0.4.0",
|
|
@@ -220,9 +220,6 @@
|
|
|
220
220
|
"platform_deprecate_lp_cc_embed": {
|
|
221
221
|
"type": "boolean"
|
|
222
222
|
},
|
|
223
|
-
"navx-1834-refactor-resolved-hyperlink": {
|
|
224
|
-
"type": "boolean"
|
|
225
|
-
},
|
|
226
223
|
"platform_linking_plain_hyperlink_connect_button": {
|
|
227
224
|
"type": "boolean"
|
|
228
225
|
},
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _reactErrorBoundary = require("react-error-boundary");
|
|
10
|
-
// Remove on navx-1834-refactor-resolved-hyperlink cleanup
|
|
11
|
-
var withErrorBoundary = function withErrorBoundary(Component) {
|
|
12
|
-
return function (props) {
|
|
13
|
-
return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
14
|
-
fallback: null
|
|
15
|
-
}, /*#__PURE__*/_react.default.createElement(Component, props));
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
var _default = exports.default = withErrorBoundary;
|