@atlaskit/smart-card 42.2.1 → 42.2.2
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 +10 -0
- package/dist/cjs/state/actions/index.js +8 -6
- package/dist/cjs/state/hooks/useSmartLink.js +3 -3
- package/dist/cjs/state/store/index.js +5 -1
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +22 -5
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/state/actions/index.js +6 -4
- package/dist/es2019/state/hooks/useSmartLink.js +3 -3
- package/dist/es2019/state/store/index.js +5 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +18 -3
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/state/actions/index.js +8 -6
- package/dist/esm/state/hooks/useSmartLink.js +3 -3
- package/dist/esm/state/store/index.js +5 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +22 -5
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/state/actions/index.d.ts +2 -1
- package/dist/types/state/hooks/useSmartLink.d.ts +3 -2
- package/dist/types/state/store/index.d.ts +1 -1
- package/dist/types-ts4.5/state/actions/index.d.ts +2 -1
- package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +3 -2
- package/dist/types-ts4.5/state/store/index.d.ts +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 42.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`28644626ba801`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/28644626ba801) -
|
|
8
|
+
Start implementation of future `placeholderData` prop to `CardSSR` - which will be used to supply
|
|
9
|
+
data exclusively for initial render. The regular request to ORS is still performed and its data
|
|
10
|
+
will be used once available.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 42.2.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -11,13 +11,14 @@ var _react = require("react");
|
|
|
11
11
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
12
12
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
13
13
|
var _outboundAuthFlowClient = require("@atlaskit/outbound-auth-flow-client");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
|
|
15
16
|
var _constants = require("../../constants");
|
|
16
17
|
var _analytics = require("../analytics");
|
|
17
18
|
var _helpers = require("../helpers");
|
|
18
19
|
var _useInvokeClientAction = _interopRequireDefault(require("../hooks/use-invoke-client-action"));
|
|
19
20
|
var _useResolve = _interopRequireDefault(require("../hooks/use-resolve"));
|
|
20
|
-
var useSmartCardActions = exports.useSmartCardActions = function useSmartCardActions(id, url) {
|
|
21
|
+
var useSmartCardActions = exports.useSmartCardActions = function useSmartCardActions(id, url, placeholderData) {
|
|
21
22
|
var resolveUrl = (0, _useResolve.default)();
|
|
22
23
|
var invokeClientAction = (0, _useInvokeClientAction.default)({});
|
|
23
24
|
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
|
|
@@ -27,8 +28,9 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
|
|
|
27
28
|
var getState = store.getState,
|
|
28
29
|
dispatch = store.dispatch;
|
|
29
30
|
var getSmartLinkState = (0, _react.useCallback)(function () {
|
|
30
|
-
var _getState$url;
|
|
31
|
-
var
|
|
31
|
+
var _ref2, _getState$url;
|
|
32
|
+
var placeholderObject = (0, _platformFeatureFlags.fg)('platform_initial_data_for_smart_cards') ? placeholderData : undefined;
|
|
33
|
+
var _ref = (_ref2 = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : placeholderObject) !== null && _ref2 !== void 0 ? _ref2 : {
|
|
32
34
|
status: _constants.SmartLinkStatus.Pending
|
|
33
35
|
},
|
|
34
36
|
details = _ref.details,
|
|
@@ -39,7 +41,7 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
|
|
|
39
41
|
status: status,
|
|
40
42
|
metadataStatus: metadataStatus
|
|
41
43
|
};
|
|
42
|
-
}, [getState, url]);
|
|
44
|
+
}, [getState, url, placeholderData]);
|
|
43
45
|
var setMetadataStatus = (0, _react.useCallback)(function (metadataStatus) {
|
|
44
46
|
dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_UPDATE_METADATA_STATUS, {
|
|
45
47
|
url: url
|
|
@@ -152,7 +154,7 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
|
|
|
152
154
|
}
|
|
153
155
|
}, [getSmartLinkState, id, reload, fireEvent]);
|
|
154
156
|
var invoke = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
155
|
-
var
|
|
157
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(opts, appearance) {
|
|
156
158
|
var key, action, source;
|
|
157
159
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
158
160
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -179,7 +181,7 @@ var useSmartCardActions = exports.useSmartCardActions = function useSmartCardAct
|
|
|
179
181
|
}, _callee2);
|
|
180
182
|
}));
|
|
181
183
|
return function (_x, _x2) {
|
|
182
|
-
return
|
|
184
|
+
return _ref4.apply(this, arguments);
|
|
183
185
|
};
|
|
184
186
|
}(), [invokeClientAction]);
|
|
185
187
|
return (0, _react.useMemo)(function () {
|
|
@@ -12,13 +12,13 @@ var _actions = require("../actions");
|
|
|
12
12
|
var _config = require("../config");
|
|
13
13
|
var _renderers = require("../renderers");
|
|
14
14
|
var _store = require("../store");
|
|
15
|
-
function useSmartLink(id, url) {
|
|
16
|
-
var state = (0, _store.useSmartCardState)(url);
|
|
15
|
+
function useSmartLink(id, url, placeholderData) {
|
|
16
|
+
var state = (0, _store.useSmartCardState)(url, placeholderData);
|
|
17
17
|
var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
|
|
18
18
|
store = _useSmartLinkContext.store,
|
|
19
19
|
isPreviewPanelAvailable = _useSmartLinkContext.isPreviewPanelAvailable,
|
|
20
20
|
openPreviewPanel = _useSmartLinkContext.openPreviewPanel;
|
|
21
|
-
var actions = (0, _actions.useSmartCardActions)(id, url);
|
|
21
|
+
var actions = (0, _actions.useSmartCardActions)(id, url, placeholderData);
|
|
22
22
|
var config = (0, _config.useSmartLinkConfig)();
|
|
23
23
|
var renderers = (0, _renderers.useSmartLinkRenderers)();
|
|
24
24
|
|
|
@@ -6,14 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useSmartCardState = useSmartCardState;
|
|
7
7
|
var _withSelector = require("use-sync-external-store/shim/with-selector");
|
|
8
8
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
var PENDING_STATE = {
|
|
10
11
|
status: 'pending'
|
|
11
12
|
};
|
|
12
|
-
function useSmartCardState(url) {
|
|
13
|
+
function useSmartCardState(url, placeholderData) {
|
|
13
14
|
var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
|
|
14
15
|
store = _useSmartLinkContext.store;
|
|
15
16
|
var cardState = (0, _withSelector.useSyncExternalStoreWithSelector)(store.subscribe, store.getState, store.getState, function (state) {
|
|
16
17
|
return state[url];
|
|
17
18
|
});
|
|
19
|
+
if ((0, _platformFeatureFlags.fg)('platform_initial_data_for_smart_cards')) {
|
|
20
|
+
return (cardState === null || cardState === void 0 ? void 0 : cardState.status) !== 'resolved' && placeholderData ? placeholderData : cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
21
|
+
}
|
|
18
22
|
return cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
19
23
|
}
|
|
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
11
11
|
var context = exports.context = {
|
|
12
12
|
componentName: 'smart-cards',
|
|
13
13
|
packageName: "@atlaskit/smart-card",
|
|
14
|
-
packageVersion: "
|
|
14
|
+
packageVersion: "42.2.1"
|
|
15
15
|
};
|
|
16
16
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
17
17
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -29,6 +29,9 @@ var _InlineCard = require("../InlineCard");
|
|
|
29
29
|
var _useSmartLinkEvents = require("../SmartLinkEvents/useSmartLinkEvents");
|
|
30
30
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
31
31
|
var thirdPartyARIPrefix = 'ari:third-party';
|
|
32
|
+
var isValidPlaceholderData = function isValidPlaceholderData(placeholderData) {
|
|
33
|
+
return (placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.data) && 'url' in placeholderData.data && 'name' in placeholderData.data;
|
|
34
|
+
};
|
|
32
35
|
function Component(_ref) {
|
|
33
36
|
var id = _ref.id,
|
|
34
37
|
url = _ref.url,
|
|
@@ -55,14 +58,31 @@ function Component(_ref) {
|
|
|
55
58
|
truncateInline = _ref.truncateInline,
|
|
56
59
|
CompetitorPrompt = _ref.CompetitorPrompt,
|
|
57
60
|
hideIconLoadingSkeleton = _ref.hideIconLoadingSkeleton,
|
|
58
|
-
disablePreviewPanel = _ref.disablePreviewPanel
|
|
61
|
+
disablePreviewPanel = _ref.disablePreviewPanel,
|
|
62
|
+
placeholderData = _ref.placeholderData;
|
|
59
63
|
var _useAnalyticsEventsNe = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
60
64
|
createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
|
|
61
65
|
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
|
|
62
66
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
67
|
+
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
68
|
+
return (0, _flexible.isFlexibleUiCard)(children, ui);
|
|
69
|
+
}, [children, ui]);
|
|
70
|
+
var structuredPlaceholderData = (0, _platformFeatureFlags.fg)('platform_initial_data_for_smart_cards') ?
|
|
71
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
72
|
+
(0, _react.useMemo)(function () {
|
|
73
|
+
// execute some basic validation logic to ensure we should consider using placeholder data
|
|
74
|
+
if (appearance === 'inline' && !isFlexibleUi && isValidPlaceholderData(placeholderData)) {
|
|
75
|
+
var data = {
|
|
76
|
+
status: 'resolved',
|
|
77
|
+
metadataStatus: undefined,
|
|
78
|
+
details: placeholderData
|
|
79
|
+
};
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
}, [appearance, isFlexibleUi, placeholderData]) : undefined;
|
|
63
83
|
|
|
64
84
|
// Get state, actions for this card.
|
|
65
|
-
var _useSmartLink = (0, _state.useSmartLink)(id, url),
|
|
85
|
+
var _useSmartLink = (0, _state.useSmartLink)(id, url, (0, _platformFeatureFlags.fg)('platform_initial_data_for_smart_cards') ? structuredPlaceholderData : undefined),
|
|
66
86
|
state = _useSmartLink.state,
|
|
67
87
|
actions = _useSmartLink.actions,
|
|
68
88
|
config = _useSmartLink.config,
|
|
@@ -78,9 +98,6 @@ function Component(_ref) {
|
|
|
78
98
|
var services = (0, _helpers.getServices)(state.details);
|
|
79
99
|
var thirdPartyARI = (0, _helpers.getThirdPartyARI)(state.details);
|
|
80
100
|
var firstPartyIdentifier = (0, _helpers.getFirstPartyIdentifier)();
|
|
81
|
-
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
82
|
-
return (0, _flexible.isFlexibleUiCard)(children, ui);
|
|
83
|
-
}, [children, ui]);
|
|
84
101
|
var actionOptions = (0, _combineActionOptions.combineActionOptions)({
|
|
85
102
|
actionOptions: actionOptionsProp,
|
|
86
103
|
platform: platform
|
|
@@ -25,7 +25,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
25
25
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
26
26
|
var PACKAGE_DATA = {
|
|
27
27
|
packageName: "@atlaskit/smart-card",
|
|
28
|
-
packageVersion: "
|
|
28
|
+
packageVersion: "42.2.1",
|
|
29
29
|
componentName: 'linkUrl'
|
|
30
30
|
};
|
|
31
31
|
var Anchor = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -2,13 +2,14 @@ import { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
3
3
|
import { ACTION_RESOLVING, ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
|
|
4
4
|
import { auth } from '@atlaskit/outbound-auth-flow-client';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
6
7
|
import { SmartLinkStatus } from '../../constants';
|
|
7
8
|
import { startUfoExperience } from '../analytics';
|
|
8
9
|
import { getByDefinitionId, getDefinitionId, getExtensionKey, getServices } from '../helpers';
|
|
9
10
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
10
11
|
import useResolve from '../hooks/use-resolve';
|
|
11
|
-
export const useSmartCardActions = (id, url) => {
|
|
12
|
+
export const useSmartCardActions = (id, url, placeholderData) => {
|
|
12
13
|
const resolveUrl = useResolve();
|
|
13
14
|
const invokeClientAction = useInvokeClientAction({});
|
|
14
15
|
const {
|
|
@@ -22,12 +23,13 @@ export const useSmartCardActions = (id, url) => {
|
|
|
22
23
|
dispatch
|
|
23
24
|
} = store;
|
|
24
25
|
const getSmartLinkState = useCallback(() => {
|
|
25
|
-
var _getState$url;
|
|
26
|
+
var _ref, _getState$url;
|
|
27
|
+
const placeholderObject = fg('platform_initial_data_for_smart_cards') ? placeholderData : undefined;
|
|
26
28
|
const {
|
|
27
29
|
details,
|
|
28
30
|
status,
|
|
29
31
|
metadataStatus
|
|
30
|
-
} = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : {
|
|
32
|
+
} = (_ref = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : placeholderObject) !== null && _ref !== void 0 ? _ref : {
|
|
31
33
|
status: SmartLinkStatus.Pending
|
|
32
34
|
};
|
|
33
35
|
return {
|
|
@@ -35,7 +37,7 @@ export const useSmartCardActions = (id, url) => {
|
|
|
35
37
|
status,
|
|
36
38
|
metadataStatus
|
|
37
39
|
};
|
|
38
|
-
}, [getState, url]);
|
|
40
|
+
}, [getState, url, placeholderData]);
|
|
39
41
|
const setMetadataStatus = useCallback(metadataStatus => {
|
|
40
42
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
41
43
|
url
|
|
@@ -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, placeholderData) {
|
|
8
|
+
const state = useSmartLinkState(url, placeholderData);
|
|
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, placeholderData);
|
|
15
15
|
const config = useSmartLinkConfig();
|
|
16
16
|
const renderers = useSmartLinkRenderers();
|
|
17
17
|
|
|
@@ -1,12 +1,16 @@
|
|
|
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';
|
|
3
4
|
const PENDING_STATE = {
|
|
4
5
|
status: 'pending'
|
|
5
6
|
};
|
|
6
|
-
export function useSmartCardState(url) {
|
|
7
|
+
export function useSmartCardState(url, placeholderData) {
|
|
7
8
|
const {
|
|
8
9
|
store
|
|
9
10
|
} = useSmartLinkContext();
|
|
10
11
|
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
|
+
}
|
|
11
15
|
return cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
12
16
|
}
|
|
@@ -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.2.1"
|
|
6
6
|
};
|
|
7
7
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
8
8
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -20,6 +20,7 @@ import FlexibleCard from '../FlexibleCard';
|
|
|
20
20
|
import { InlineCard } from '../InlineCard';
|
|
21
21
|
import { useFire3PWorkflowsClickEvent } from '../SmartLinkEvents/useSmartLinkEvents';
|
|
22
22
|
const thirdPartyARIPrefix = 'ari:third-party';
|
|
23
|
+
const isValidPlaceholderData = placeholderData => (placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.data) && 'url' in placeholderData.data && 'name' in placeholderData.data;
|
|
23
24
|
function Component({
|
|
24
25
|
id,
|
|
25
26
|
url,
|
|
@@ -46,7 +47,8 @@ function Component({
|
|
|
46
47
|
truncateInline,
|
|
47
48
|
CompetitorPrompt,
|
|
48
49
|
hideIconLoadingSkeleton,
|
|
49
|
-
disablePreviewPanel
|
|
50
|
+
disablePreviewPanel,
|
|
51
|
+
placeholderData
|
|
50
52
|
}) {
|
|
51
53
|
const {
|
|
52
54
|
createAnalyticsEvent
|
|
@@ -54,6 +56,20 @@ function Component({
|
|
|
54
56
|
const {
|
|
55
57
|
fireEvent
|
|
56
58
|
} = useAnalyticsEvents();
|
|
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' && !isFlexibleUi && isValidPlaceholderData(placeholderData)) {
|
|
65
|
+
const data = {
|
|
66
|
+
status: 'resolved',
|
|
67
|
+
metadataStatus: undefined,
|
|
68
|
+
details: placeholderData
|
|
69
|
+
};
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
}, [appearance, isFlexibleUi, placeholderData]) : undefined;
|
|
57
73
|
|
|
58
74
|
// Get state, actions for this card.
|
|
59
75
|
const {
|
|
@@ -64,7 +80,7 @@ function Component({
|
|
|
64
80
|
error,
|
|
65
81
|
isPreviewPanelAvailable,
|
|
66
82
|
openPreviewPanel
|
|
67
|
-
} = useSmartLink(id, url);
|
|
83
|
+
} = useSmartLink(id, url, fg('platform_initial_data_for_smart_cards') ? structuredPlaceholderData : undefined);
|
|
68
84
|
const ari = getObjectAri(state.details);
|
|
69
85
|
const name = getObjectName(state.details);
|
|
70
86
|
const definitionId = getDefinitionId(state.details);
|
|
@@ -73,7 +89,6 @@ function Component({
|
|
|
73
89
|
const services = getServices(state.details);
|
|
74
90
|
const thirdPartyARI = getThirdPartyARI(state.details);
|
|
75
91
|
const firstPartyIdentifier = getFirstPartyIdentifier();
|
|
76
|
-
let isFlexibleUi = useMemo(() => isFlexibleUiCard(children, ui), [children, ui]);
|
|
77
92
|
const actionOptions = combineActionOptions({
|
|
78
93
|
actionOptions: actionOptionsProp,
|
|
79
94
|
platform
|
|
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
13
13
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
14
14
|
const PACKAGE_DATA = {
|
|
15
15
|
packageName: "@atlaskit/smart-card",
|
|
16
|
-
packageVersion: "
|
|
16
|
+
packageVersion: "42.2.1",
|
|
17
17
|
componentName: 'linkUrl'
|
|
18
18
|
};
|
|
19
19
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -4,13 +4,14 @@ 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';
|
|
7
8
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
8
9
|
import { SmartLinkStatus } from '../../constants';
|
|
9
10
|
import { startUfoExperience } from '../analytics';
|
|
10
11
|
import { getByDefinitionId, getDefinitionId, getExtensionKey, getServices } from '../helpers';
|
|
11
12
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
12
13
|
import useResolve from '../hooks/use-resolve';
|
|
13
|
-
export var useSmartCardActions = function useSmartCardActions(id, url) {
|
|
14
|
+
export var useSmartCardActions = function useSmartCardActions(id, url, placeholderData) {
|
|
14
15
|
var resolveUrl = useResolve();
|
|
15
16
|
var invokeClientAction = useInvokeClientAction({});
|
|
16
17
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
@@ -20,8 +21,9 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
|
|
|
20
21
|
var getState = store.getState,
|
|
21
22
|
dispatch = store.dispatch;
|
|
22
23
|
var getSmartLinkState = useCallback(function () {
|
|
23
|
-
var _getState$url;
|
|
24
|
-
var
|
|
24
|
+
var _ref2, _getState$url;
|
|
25
|
+
var placeholderObject = fg('platform_initial_data_for_smart_cards') ? placeholderData : undefined;
|
|
26
|
+
var _ref = (_ref2 = (_getState$url = getState()[url]) !== null && _getState$url !== void 0 ? _getState$url : placeholderObject) !== null && _ref2 !== void 0 ? _ref2 : {
|
|
25
27
|
status: SmartLinkStatus.Pending
|
|
26
28
|
},
|
|
27
29
|
details = _ref.details,
|
|
@@ -32,7 +34,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
|
|
|
32
34
|
status: status,
|
|
33
35
|
metadataStatus: metadataStatus
|
|
34
36
|
};
|
|
35
|
-
}, [getState, url]);
|
|
37
|
+
}, [getState, url, placeholderData]);
|
|
36
38
|
var setMetadataStatus = useCallback(function (metadataStatus) {
|
|
37
39
|
dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
|
|
38
40
|
url: url
|
|
@@ -145,7 +147,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
|
|
|
145
147
|
}
|
|
146
148
|
}, [getSmartLinkState, id, reload, fireEvent]);
|
|
147
149
|
var invoke = useCallback( /*#__PURE__*/function () {
|
|
148
|
-
var
|
|
150
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(opts, appearance) {
|
|
149
151
|
var key, action, source;
|
|
150
152
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
151
153
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -172,7 +174,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url) {
|
|
|
172
174
|
}, _callee2);
|
|
173
175
|
}));
|
|
174
176
|
return function (_x, _x2) {
|
|
175
|
-
return
|
|
177
|
+
return _ref4.apply(this, arguments);
|
|
176
178
|
};
|
|
177
179
|
}(), [invokeClientAction]);
|
|
178
180
|
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, placeholderData) {
|
|
9
|
+
var state = useSmartLinkState(url, placeholderData);
|
|
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, placeholderData);
|
|
15
15
|
var config = useSmartLinkConfig();
|
|
16
16
|
var renderers = useSmartLinkRenderers();
|
|
17
17
|
|
|
@@ -1,13 +1,17 @@
|
|
|
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';
|
|
3
4
|
var PENDING_STATE = {
|
|
4
5
|
status: 'pending'
|
|
5
6
|
};
|
|
6
|
-
export function useSmartCardState(url) {
|
|
7
|
+
export function useSmartCardState(url, placeholderData) {
|
|
7
8
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
8
9
|
store = _useSmartLinkContext.store;
|
|
9
10
|
var cardState = useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, function (state) {
|
|
10
11
|
return state[url];
|
|
11
12
|
});
|
|
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
|
+
}
|
|
12
16
|
return cardState !== null && cardState !== void 0 ? cardState : PENDING_STATE;
|
|
13
17
|
}
|
|
@@ -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.2.1"
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -20,6 +20,9 @@ import FlexibleCard from '../FlexibleCard';
|
|
|
20
20
|
import { InlineCard } from '../InlineCard';
|
|
21
21
|
import { useFire3PWorkflowsClickEvent } from '../SmartLinkEvents/useSmartLinkEvents';
|
|
22
22
|
var thirdPartyARIPrefix = 'ari:third-party';
|
|
23
|
+
var isValidPlaceholderData = function isValidPlaceholderData(placeholderData) {
|
|
24
|
+
return (placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.data) && 'url' in placeholderData.data && 'name' in placeholderData.data;
|
|
25
|
+
};
|
|
23
26
|
function Component(_ref) {
|
|
24
27
|
var id = _ref.id,
|
|
25
28
|
url = _ref.url,
|
|
@@ -46,14 +49,31 @@ function Component(_ref) {
|
|
|
46
49
|
truncateInline = _ref.truncateInline,
|
|
47
50
|
CompetitorPrompt = _ref.CompetitorPrompt,
|
|
48
51
|
hideIconLoadingSkeleton = _ref.hideIconLoadingSkeleton,
|
|
49
|
-
disablePreviewPanel = _ref.disablePreviewPanel
|
|
52
|
+
disablePreviewPanel = _ref.disablePreviewPanel,
|
|
53
|
+
placeholderData = _ref.placeholderData;
|
|
50
54
|
var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
|
|
51
55
|
createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
|
|
52
56
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
53
57
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
58
|
+
var isFlexibleUi = useMemo(function () {
|
|
59
|
+
return isFlexibleUiCard(children, ui);
|
|
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' && !isFlexibleUi && isValidPlaceholderData(placeholderData)) {
|
|
66
|
+
var data = {
|
|
67
|
+
status: 'resolved',
|
|
68
|
+
metadataStatus: undefined,
|
|
69
|
+
details: placeholderData
|
|
70
|
+
};
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
}, [appearance, isFlexibleUi, placeholderData]) : undefined;
|
|
54
74
|
|
|
55
75
|
// Get state, actions for this card.
|
|
56
|
-
var _useSmartLink = useSmartLink(id, url),
|
|
76
|
+
var _useSmartLink = useSmartLink(id, url, fg('platform_initial_data_for_smart_cards') ? structuredPlaceholderData : undefined),
|
|
57
77
|
state = _useSmartLink.state,
|
|
58
78
|
actions = _useSmartLink.actions,
|
|
59
79
|
config = _useSmartLink.config,
|
|
@@ -69,9 +89,6 @@ function Component(_ref) {
|
|
|
69
89
|
var services = getServices(state.details);
|
|
70
90
|
var thirdPartyARI = getThirdPartyARI(state.details);
|
|
71
91
|
var firstPartyIdentifier = getFirstPartyIdentifier();
|
|
72
|
-
var isFlexibleUi = useMemo(function () {
|
|
73
|
-
return isFlexibleUiCard(children, ui);
|
|
74
|
-
}, [children, ui]);
|
|
75
92
|
var actionOptions = combineActionOptions({
|
|
76
93
|
actionOptions: actionOptionsProp,
|
|
77
94
|
platform: platform
|
|
@@ -16,7 +16,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
16
16
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
17
17
|
var PACKAGE_DATA = {
|
|
18
18
|
packageName: "@atlaskit/smart-card",
|
|
19
|
-
packageVersion: "
|
|
19
|
+
packageVersion: "42.2.1",
|
|
20
20
|
componentName: 'linkUrl'
|
|
21
21
|
};
|
|
22
22
|
var Anchor = withLinkClickedEvent('a');
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type JsonLd } from '@atlaskit/json-ld-types';
|
|
2
|
+
import { type CardState } from '@atlaskit/linking-common';
|
|
2
3
|
import { type InvokeClientOpts, type InvokeServerOpts } from '../../model/invoke-opts';
|
|
3
4
|
import { type CardInnerAppearance } from '../../view/Card/types';
|
|
4
|
-
export declare const useSmartCardActions: (id: string, url: string) => {
|
|
5
|
+
export declare const useSmartCardActions: (id: string, url: string, placeholderData?: CardState) => {
|
|
5
6
|
register: () => Promise<void>;
|
|
6
7
|
reload: () => void;
|
|
7
8
|
authorize: (appearance: CardInnerAppearance) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { CardState } from '@atlaskit/linking-common';
|
|
2
|
+
export declare function useSmartLink(id: string, url: string, placeholderData?: CardState): {
|
|
3
|
+
state: CardState;
|
|
3
4
|
actions: {
|
|
4
5
|
register: () => Promise<void>;
|
|
5
6
|
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): CardState;
|
|
3
|
+
export declare function useSmartCardState(url: string, placeholderData?: CardState): CardState;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type JsonLd } from '@atlaskit/json-ld-types';
|
|
2
|
+
import { type CardState } from '@atlaskit/linking-common';
|
|
2
3
|
import { type InvokeClientOpts, type InvokeServerOpts } from '../../model/invoke-opts';
|
|
3
4
|
import { type CardInnerAppearance } from '../../view/Card/types';
|
|
4
|
-
export declare const useSmartCardActions: (id: string, url: string) => {
|
|
5
|
+
export declare const useSmartCardActions: (id: string, url: string, placeholderData?: CardState) => {
|
|
5
6
|
register: () => Promise<void>;
|
|
6
7
|
reload: () => void;
|
|
7
8
|
authorize: (appearance: CardInnerAppearance) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { CardState } from '@atlaskit/linking-common';
|
|
2
|
+
export declare function useSmartLink(id: string, url: string, placeholderData?: CardState): {
|
|
3
|
+
state: CardState;
|
|
3
4
|
actions: {
|
|
4
5
|
register: () => Promise<void>;
|
|
5
6
|
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): CardState;
|
|
3
|
+
export declare function useSmartCardState(url: string, placeholderData?: CardState): CardState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "42.2.
|
|
3
|
+
"version": "42.2.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@atlaskit/afm-i18n-platform-linking-platform-smart-card": "2.6.0",
|
|
30
30
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
31
31
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
32
|
-
"@atlaskit/avatar": "^25.
|
|
32
|
+
"@atlaskit/avatar": "^25.2.0",
|
|
33
33
|
"@atlaskit/avatar-group": "^12.2.0",
|
|
34
34
|
"@atlaskit/badge": "^18.1.0",
|
|
35
35
|
"@atlaskit/button": "^23.4.0",
|
|
@@ -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": "^12.
|
|
73
|
+
"@atlaskit/tmp-editor-statsig": "^12.30.0",
|
|
74
74
|
"@atlaskit/tokens": "^6.3.0",
|
|
75
75
|
"@atlaskit/tooltip": "^20.4.0",
|
|
76
76
|
"@atlaskit/ufo": "^0.4.0",
|
|
@@ -238,6 +238,9 @@
|
|
|
238
238
|
"navx-1895-a11y-close-button-in-preview-modal": {
|
|
239
239
|
"type": "boolean"
|
|
240
240
|
},
|
|
241
|
+
"platform_initial_data_for_smart_cards": {
|
|
242
|
+
"type": "boolean"
|
|
243
|
+
},
|
|
241
244
|
"jfp-magma-platform-lozenge-jump-fix": {
|
|
242
245
|
"type": "boolean"
|
|
243
246
|
}
|