@atlaskit/smart-card 42.3.4 → 43.0.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 +19 -0
- package/analytics.spec.yaml +63 -7
- 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 +5 -32
- package/dist/cjs/view/LinkUrl/HyperlinkResolver/unauthorize-view.js +11 -15
- 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 +5 -32
- package/dist/es2019/view/LinkUrl/HyperlinkResolver/unauthorize-view.js +4 -4
- 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 +5 -32
- package/dist/esm/view/LinkUrl/HyperlinkResolver/unauthorize-view.js +11 -13
- package/dist/esm/view/LinkUrl/index.js +23 -28
- package/dist/types/common/analytics/generated/analytics.types.d.ts +29 -29
- 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/Card/types.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/view/LinkUrl/HyperlinkResolver/unauthorize-view.d.ts +2 -1
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +29 -29
- 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/Card/types.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/dist/types-ts4.5/view/LinkUrl/HyperlinkResolver/unauthorize-view.d.ts +2 -1
- package/package.json +4 -7
- 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,14 +4,14 @@ import { useSmartCardActions as useSmartLinkActions } from '../actions';
|
|
|
4
4
|
import { useSmartLinkConfig } from '../config';
|
|
5
5
|
import { useSmartLinkRenderers } from '../renderers';
|
|
6
6
|
import { useSmartCardState as useSmartLinkState } from '../store';
|
|
7
|
-
export function useSmartLink(id, url
|
|
8
|
-
const state = useSmartLinkState(url
|
|
7
|
+
export function useSmartLink(id, url) {
|
|
8
|
+
const state = useSmartLinkState(url);
|
|
9
9
|
const {
|
|
10
10
|
store,
|
|
11
11
|
isPreviewPanelAvailable,
|
|
12
12
|
openPreviewPanel
|
|
13
13
|
} = useSmartLinkContext();
|
|
14
|
-
const actions = useSmartLinkActions(id, url
|
|
14
|
+
const actions = useSmartLinkActions(id, url);
|
|
15
15
|
const config = useSmartLinkConfig();
|
|
16
16
|
const renderers = useSmartLinkRenderers();
|
|
17
17
|
|
|
@@ -1,16 +1,12 @@
|
|
|
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
|
const PENDING_STATE = {
|
|
5
4
|
status: 'pending'
|
|
6
5
|
};
|
|
7
|
-
export function useSmartCardState(url
|
|
6
|
+
export function useSmartCardState(url) {
|
|
8
7
|
const {
|
|
9
8
|
store
|
|
10
9
|
} = useSmartLinkContext();
|
|
11
10
|
const cardState = useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, state => state[url]);
|
|
12
|
-
if (fg('platform_initial_data_for_smart_cards')) {
|
|
13
|
-
return (cardState === null || cardState === void 0 ? void 0 : cardState.status) !== 'resolved' && placeholderData ? placeholderData : cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
14
|
-
}
|
|
15
11
|
return cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
16
12
|
}
|
|
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
2
2
|
export const context = {
|
|
3
3
|
componentName: 'smart-cards',
|
|
4
4
|
packageName: "@atlaskit/smart-card",
|
|
5
|
-
packageVersion: "
|
|
5
|
+
packageVersion: "42.3.5"
|
|
6
6
|
};
|
|
7
7
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
8
8
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -57,19 +57,6 @@ function Component({
|
|
|
57
57
|
fireEvent
|
|
58
58
|
} = useAnalyticsEvents();
|
|
59
59
|
let isFlexibleUi = useMemo(() => isFlexibleUiCard(children, ui), [children, ui]);
|
|
60
|
-
const structuredPlaceholderData = fg('platform_initial_data_for_smart_cards') ?
|
|
61
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
62
|
-
useMemo(() => {
|
|
63
|
-
// execute some basic validation logic to ensure we should consider using placeholder data
|
|
64
|
-
if (appearance === 'inline' && isValidPlaceholderData(placeholderData)) {
|
|
65
|
-
const data = {
|
|
66
|
-
status: 'resolved',
|
|
67
|
-
metadataStatus: undefined,
|
|
68
|
-
details: placeholderData
|
|
69
|
-
};
|
|
70
|
-
return data;
|
|
71
|
-
}
|
|
72
|
-
}, [appearance, placeholderData]) : undefined;
|
|
73
60
|
|
|
74
61
|
// Get state, actions for this card.
|
|
75
62
|
const {
|
|
@@ -80,7 +67,7 @@ function Component({
|
|
|
80
67
|
error,
|
|
81
68
|
isPreviewPanelAvailable,
|
|
82
69
|
openPreviewPanel
|
|
83
|
-
} = useSmartLink(id, url
|
|
70
|
+
} = useSmartLink(id, url);
|
|
84
71
|
const ari = getObjectAri(state.details);
|
|
85
72
|
const name = getObjectName(state.details);
|
|
86
73
|
const definitionId = getDefinitionId(state.details);
|
|
@@ -229,6 +216,19 @@ function Component({
|
|
|
229
216
|
display: isFlexibleUi ? 'flexible' : appearance
|
|
230
217
|
});
|
|
231
218
|
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
219
|
+
const structuredPlaceholderData = fg('platform_initial_data_for_smart_cards') ?
|
|
220
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
221
|
+
useMemo(() => {
|
|
222
|
+
// execute some basic validation logic to ensure we should consider using placeholder data
|
|
223
|
+
if (isFlexibleUi && isValidPlaceholderData(placeholderData)) {
|
|
224
|
+
const data = {
|
|
225
|
+
status: 'resolved',
|
|
226
|
+
metadataStatus: undefined,
|
|
227
|
+
details: placeholderData
|
|
228
|
+
};
|
|
229
|
+
return data;
|
|
230
|
+
}
|
|
231
|
+
}, [isFlexibleUi, placeholderData]) : undefined;
|
|
232
232
|
if (isFlexibleUi) {
|
|
233
233
|
let cardState = state;
|
|
234
234
|
if (error) {
|
|
@@ -243,6 +243,7 @@ function Component({
|
|
|
243
243
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
244
244
|
id: id,
|
|
245
245
|
cardState: cardState,
|
|
246
|
+
placeholderData: fg('platform_initial_data_for_smart_cards') ? structuredPlaceholderData : undefined,
|
|
246
247
|
onAuthorize: services.length && handleAuthorize || undefined,
|
|
247
248
|
onClick: handleClickWrapper,
|
|
248
249
|
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
|
+
const 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.
|
|
@@ -18,6 +20,7 @@ import { getContextByStatus } from './utils';
|
|
|
18
20
|
const FlexibleCard = ({
|
|
19
21
|
appearance = 'flexible',
|
|
20
22
|
cardState,
|
|
23
|
+
placeholderData,
|
|
21
24
|
children,
|
|
22
25
|
id,
|
|
23
26
|
onAuthorize,
|
|
@@ -48,11 +51,15 @@ const FlexibleCard = ({
|
|
|
48
51
|
details
|
|
49
52
|
} = cardState;
|
|
50
53
|
const status = cardType;
|
|
54
|
+
const shouldUsePlaceholderData = PENDING_LINK_STATUSES.includes(status) && placeholderData && fg('platform_initial_data_for_smart_cards');
|
|
55
|
+
// if we have placeholder data it means we can internally use it
|
|
56
|
+
// as resolved data until the actual data comes back as one of the final statuses
|
|
57
|
+
const contextStatus = shouldUsePlaceholderData ? SmartLinkStatus.Resolved : status;
|
|
51
58
|
const context = useMemo(() => getContextByStatus({
|
|
52
59
|
aiSummaryConfig,
|
|
53
60
|
appearance,
|
|
54
61
|
fireEvent,
|
|
55
|
-
response: details,
|
|
62
|
+
response: shouldUsePlaceholderData ? placeholderData.details : details,
|
|
56
63
|
id,
|
|
57
64
|
onAuthorize,
|
|
58
65
|
onClick,
|
|
@@ -60,16 +67,16 @@ const FlexibleCard = ({
|
|
|
60
67
|
renderers,
|
|
61
68
|
resolve,
|
|
62
69
|
actionOptions,
|
|
63
|
-
status,
|
|
70
|
+
status: shouldUsePlaceholderData ? contextStatus : status,
|
|
64
71
|
url,
|
|
65
72
|
isPreviewPanelAvailable,
|
|
66
73
|
openPreviewPanel
|
|
67
|
-
}), [aiSummaryConfig, appearance, fireEvent, details, id, onAuthorize, onClick, origin, renderers, resolve, actionOptions, status, url, isPreviewPanelAvailable, openPreviewPanel]);
|
|
74
|
+
}), [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]);
|
|
68
75
|
const flexibleCardContext = useMemo(() => ({
|
|
69
76
|
data: context,
|
|
70
|
-
status,
|
|
77
|
+
status: fg('platform_initial_data_for_smart_cards') ? contextStatus : status,
|
|
71
78
|
ui
|
|
72
|
-
}), [context, status, ui]);
|
|
79
|
+
}), [context, contextStatus, status, ui]);
|
|
73
80
|
const {
|
|
74
81
|
linkTitle
|
|
75
82
|
} = context || {};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useCallback
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
3
|
import { withErrorBoundary as withReactErrorBoundary } from 'react-error-boundary';
|
|
4
4
|
import { injectIntl } from 'react-intl-next';
|
|
5
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
6
5
|
import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
|
|
7
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import { SmartCardContext } from '../../../state';
|
|
9
7
|
import { getFirstPartyIdentifier, getServices, getThirdPartyARI } from '../../../state/helpers';
|
|
10
8
|
import useResolveHyperlink from '../../../state/hooks/use-resolve-hyperlink';
|
|
11
|
-
import useResolveHyperlinkValidator
|
|
9
|
+
import useResolveHyperlinkValidator from '../../../state/hooks/use-resolve-hyperlink/useResolveHyperlinkValidator';
|
|
12
10
|
import withIntlProvider from '../../common/intl-provider';
|
|
13
11
|
import { useFire3PWorkflowsClickEvent } from '../../SmartLinkEvents/useSmartLinkEvents';
|
|
14
12
|
import Hyperlink from '../Hyperlink';
|
|
15
|
-
import withErrorBoundary from './error-boundary';
|
|
16
|
-
import { ResolveHyperlink } from './resolve-hyperlink';
|
|
17
13
|
import HyperlinkUnauthorizedView from './unauthorize-view';
|
|
18
14
|
const HyperlinkFallbackComponent = () => null;
|
|
19
15
|
const withValidator = (Component, DefaultComponent) => props => {
|
|
@@ -45,13 +41,9 @@ const HyperlinkWithSmartLinkResolverInner = ({
|
|
|
45
41
|
}
|
|
46
42
|
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback(e);
|
|
47
43
|
}, [onClickCallback, fire3PClickEvent, state === null || state === void 0 ? void 0 : state.status]);
|
|
48
|
-
|
|
49
|
-
// TODO: AI3W-1113: Show auth button
|
|
50
44
|
const onAuthorize = fg('platform_linking_plain_hyperlink_connect_button') ?
|
|
51
45
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
52
|
-
useCallback(() =>
|
|
53
|
-
// TODO: Need to add hyperlink type
|
|
54
|
-
actions.authorize('inline'), [actions]) : undefined;
|
|
46
|
+
useCallback(() => actions.authorize('hyperlink'), [actions]) : undefined;
|
|
55
47
|
if (fg('platform_linking_plain_hyperlink_connect_button')) {
|
|
56
48
|
switch (state === null || state === void 0 ? void 0 : state.status) {
|
|
57
49
|
case 'unauthorized':
|
|
@@ -59,6 +51,7 @@ const HyperlinkWithSmartLinkResolverInner = ({
|
|
|
59
51
|
return /*#__PURE__*/React.createElement(HyperlinkUnauthorizedView, _extends({}, props, {
|
|
60
52
|
onAuthorize: services !== null && services !== void 0 && services.length ? onAuthorize : undefined,
|
|
61
53
|
onClick: onClick,
|
|
54
|
+
showConnectBtn: (services === null || services === void 0 ? void 0 : services.length) > 0,
|
|
62
55
|
provider: provider
|
|
63
56
|
}));
|
|
64
57
|
default:
|
|
@@ -75,24 +68,4 @@ export const HyperlinkWithSmartLinkResolver = withReactErrorBoundary(withValidat
|
|
|
75
68
|
enforceContext: false
|
|
76
69
|
}), Hyperlink), {
|
|
77
70
|
FallbackComponent: HyperlinkFallbackComponent
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// Remove on navx-1834-refactor-resolved-hyperlink cleanup
|
|
81
|
-
|
|
82
|
-
const HyperlinkResolver = ({
|
|
83
|
-
href
|
|
84
|
-
}) => {
|
|
85
|
-
const hasSmartCardProvider = !!useContext(SmartCardContext);
|
|
86
|
-
const isSharePointResolveEnabled = FeatureGates.getExperimentValue('platform_editor_resolve_hyperlinks_confluence', 'isEnabled', false) || FeatureGates.getExperimentValue('platform_editor_resolve_hyperlinks_jira', 'isEnabled', false);
|
|
87
|
-
const isGoogleResolveEnabled = FeatureGates.getExperimentValue('platform_editor_resolve_google_hyperlinks', 'isEnabled', false);
|
|
88
|
-
const shouldResolveSharePoint = isSharePointDomain(href) && isSharePointResolveEnabled;
|
|
89
|
-
const shouldResolveGoogle = isGoogleDomain(href) && isGoogleResolveEnabled;
|
|
90
|
-
const shouldResolveHyperlink = hasSmartCardProvider && (shouldResolveSharePoint || shouldResolveGoogle);
|
|
91
|
-
if (!shouldResolveHyperlink) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
return /*#__PURE__*/React.createElement(ResolveHyperlink, {
|
|
95
|
-
href: href
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
export default withErrorBoundary(HyperlinkResolver);
|
|
71
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
4
|
import { messages } from '../../../messages';
|
|
5
5
|
import { ActionButton } from '../../InlineCard/common/action-button';
|
|
@@ -7,16 +7,16 @@ import Hyperlink from '../Hyperlink';
|
|
|
7
7
|
const HyperlinkUnauthorizedView = ({
|
|
8
8
|
onAuthorize,
|
|
9
9
|
provider,
|
|
10
|
+
showConnectBtn,
|
|
10
11
|
...props
|
|
11
12
|
}) => {
|
|
12
|
-
|
|
13
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Hyperlink, props), showConnectBtn && /*#__PURE__*/React.createElement(React.Fragment, null, ' ', /*#__PURE__*/React.createElement(ActionButton, {
|
|
13
14
|
onClick: onAuthorize,
|
|
14
15
|
testId: "button-connect-account"
|
|
15
16
|
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_link_account_card_name, {
|
|
16
17
|
values: {
|
|
17
18
|
context: provider === null || provider === void 0 ? void 0 : provider.text
|
|
18
19
|
}
|
|
19
|
-
})))
|
|
20
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Hyperlink, props), actionButton);
|
|
20
|
+
})))));
|
|
21
21
|
};
|
|
22
22
|
export default HyperlinkUnauthorizedView;
|
|
@@ -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.5",
|
|
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.5"
|
|
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;
|
|
@@ -49,15 +45,10 @@ var HyperlinkWithSmartLinkResolverInner = function HyperlinkWithSmartLinkResolve
|
|
|
49
45
|
}
|
|
50
46
|
onClickCallback === null || onClickCallback === void 0 || onClickCallback(e);
|
|
51
47
|
}, [onClickCallback, fire3PClickEvent, state === null || state === void 0 ? void 0 : state.status]);
|
|
52
|
-
|
|
53
|
-
// TODO: AI3W-1113: Show auth button
|
|
54
48
|
var onAuthorize = fg('platform_linking_plain_hyperlink_connect_button') ?
|
|
55
49
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
56
50
|
useCallback(function () {
|
|
57
|
-
return (
|
|
58
|
-
// TODO: Need to add hyperlink type
|
|
59
|
-
actions.authorize('inline')
|
|
60
|
-
);
|
|
51
|
+
return actions.authorize('hyperlink');
|
|
61
52
|
}, [actions]) : undefined;
|
|
62
53
|
if (fg('platform_linking_plain_hyperlink_connect_button')) {
|
|
63
54
|
switch (state === null || state === void 0 ? void 0 : state.status) {
|
|
@@ -66,6 +57,7 @@ var HyperlinkWithSmartLinkResolverInner = function HyperlinkWithSmartLinkResolve
|
|
|
66
57
|
return /*#__PURE__*/React.createElement(HyperlinkUnauthorizedView, _extends({}, props, {
|
|
67
58
|
onAuthorize: services !== null && services !== void 0 && services.length ? onAuthorize : undefined,
|
|
68
59
|
onClick: onClick,
|
|
60
|
+
showConnectBtn: (services === null || services === void 0 ? void 0 : services.length) > 0,
|
|
69
61
|
provider: provider
|
|
70
62
|
}));
|
|
71
63
|
default:
|
|
@@ -82,23 +74,4 @@ export var HyperlinkWithSmartLinkResolver = withReactErrorBoundary(withValidator
|
|
|
82
74
|
enforceContext: false
|
|
83
75
|
}), Hyperlink), {
|
|
84
76
|
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);
|
|
77
|
+
});
|