@atlaskit/smart-card 25.4.4 → 25.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/extractors/flexible/extract-server-action.js +18 -0
- package/dist/cjs/extractors/flexible/extract-state.js +71 -0
- package/dist/cjs/extractors/flexible/index.js +10 -3
- package/dist/cjs/state/analytics/useDispatchAnalytics.js +31 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +4 -1
- package/dist/cjs/state/hooks/use-invoke/types.js +10 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/index.js +17 -8
- package/dist/cjs/view/FlexibleCard/utils.js +12 -8
- package/dist/es2019/extractors/flexible/extract-server-action.js +11 -0
- package/dist/es2019/extractors/flexible/extract-state.js +59 -0
- package/dist/es2019/extractors/flexible/index.js +10 -3
- package/dist/es2019/state/analytics/useDispatchAnalytics.js +25 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +5 -1
- package/dist/es2019/state/hooks/use-invoke/types.js +11 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/index.js +15 -6
- package/dist/es2019/view/FlexibleCard/utils.js +14 -9
- package/dist/esm/extractors/flexible/extract-server-action.js +11 -0
- package/dist/esm/extractors/flexible/extract-state.js +63 -0
- package/dist/esm/extractors/flexible/index.js +10 -3
- package/dist/esm/state/analytics/useDispatchAnalytics.js +24 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +4 -1
- package/dist/esm/state/hooks/use-invoke/types.js +11 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/index.js +17 -8
- package/dist/esm/view/FlexibleCard/utils.js +13 -9
- package/dist/types/extractors/common/lozenge/types.d.ts +2 -0
- package/dist/types/extractors/flexible/extract-server-action.d.ts +3 -0
- package/dist/types/extractors/flexible/extract-state.d.ts +4 -0
- package/dist/types/extractors/flexible/index.d.ts +2 -3
- package/dist/types/state/analytics/useDispatchAnalytics.d.ts +11 -0
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +1 -1
- package/dist/types/state/hooks/use-invoke/types.d.ts +23 -3
- package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +4 -1
- package/dist/types/state/hooks-external/useSmartLinkReload.d.ts +4 -1
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/types.d.ts +12 -2
- package/dist/types/view/FlexibleCard/utils.d.ts +3 -4
- package/package.json +2 -2
- package/report.api.md +1 -1
- package/tmp/api-report-tmp.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 25.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`bcc645691c5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bcc645691c5) - Add lozenge action feature flag and extract server action for state lozenge from JSON-LD response
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 25.5.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`5329942b8aa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5329942b8aa) - Deprecates analyticsHandler argument of useSmartLinkActions and useSmartLinkReload hooks.
|
|
15
|
+
|
|
3
16
|
## 25.4.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var extractServerAction = function extractServerAction(data) {
|
|
8
|
+
var actions = data === null || data === void 0 ? void 0 : data['atlassian:serverAction'];
|
|
9
|
+
if (!actions) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
if (actions && !Array.isArray(actions)) {
|
|
13
|
+
return [actions];
|
|
14
|
+
}
|
|
15
|
+
return actions;
|
|
16
|
+
};
|
|
17
|
+
var _default = extractServerAction;
|
|
18
|
+
exports.default = _default;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _lozenge = require("../common/lozenge");
|
|
10
|
+
var _helpers = require("../../state/helpers");
|
|
11
|
+
var _extractServerAction = _interopRequireDefault(require("./extract-server-action"));
|
|
12
|
+
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
var toInvokeRequest = function toInvokeRequest(extensionKey, resourceIdentifiers, actionType, details) {
|
|
16
|
+
if (!actionType) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
action: {
|
|
21
|
+
actionType: actionType,
|
|
22
|
+
resourceIdentifiers: resourceIdentifiers
|
|
23
|
+
},
|
|
24
|
+
providerKey: extensionKey,
|
|
25
|
+
details: details
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
var extractAction = function extractAction(response, id) {
|
|
29
|
+
var _action$dataRetrieval, _action$dataUpdateAct;
|
|
30
|
+
var extensionKey = (0, _helpers.getExtensionKey)(response);
|
|
31
|
+
var data = response === null || response === void 0 ? void 0 : response.data;
|
|
32
|
+
var actions = (0, _extractServerAction.default)(data);
|
|
33
|
+
if (!extensionKey || actions.length === 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var action = actions.find(function (item) {
|
|
37
|
+
return (item === null || item === void 0 ? void 0 : item.name) === 'UpdateAction' && (item === null || item === void 0 ? void 0 : item.refField) === 'tag';
|
|
38
|
+
});
|
|
39
|
+
if (!action || !action.resourceIdentifiers) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
var read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
|
|
43
|
+
var url = (0, _extractors.extractLink)(data);
|
|
44
|
+
var details = {
|
|
45
|
+
id: id,
|
|
46
|
+
url: url
|
|
47
|
+
};
|
|
48
|
+
var update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
|
|
49
|
+
return read || update ? {
|
|
50
|
+
read: read,
|
|
51
|
+
update: update
|
|
52
|
+
} : undefined;
|
|
53
|
+
};
|
|
54
|
+
var extractState = function extractState(response, showServerActions, id) {
|
|
55
|
+
if (!response || !response.data) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var lozenge = (0, _lozenge.extractLozenge)(response === null || response === void 0 ? void 0 : response.data);
|
|
59
|
+
if (!lozenge) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!showServerActions) {
|
|
63
|
+
return lozenge;
|
|
64
|
+
}
|
|
65
|
+
var action = extractAction(response, id);
|
|
66
|
+
return _objectSpread(_objectSpread({}, lozenge), {}, {
|
|
67
|
+
action: action
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var _default = extractState;
|
|
71
|
+
exports.default = _default;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _primitives = require("../common/primitives");
|
|
9
|
-
var _lozenge = require("../common/lozenge");
|
|
10
9
|
var _icon = require("./icon");
|
|
11
10
|
var _utils = require("./utils");
|
|
12
11
|
var _collaboratorGroup = require("./collaboratorGroup");
|
|
@@ -14,16 +13,24 @@ var _extractors = require("@atlaskit/linking-common/extractors");
|
|
|
14
13
|
var _extractPriority = _interopRequireDefault(require("./extract-priority"));
|
|
15
14
|
var _extractProviderIcon = _interopRequireDefault(require("./icon/extract-provider-icon"));
|
|
16
15
|
var _extractPreview = _interopRequireDefault(require("./extract-preview"));
|
|
16
|
+
var _extractState = _interopRequireDefault(require("./extract-state"));
|
|
17
17
|
var _latestCommit = require("./latest-commit");
|
|
18
18
|
var _extractPreviewAction = require("./actions/extract-preview-action");
|
|
19
19
|
var _extractDownloadAction = require("./actions/extract-download-action");
|
|
20
20
|
var _extractViewAction = require("./actions/extract-view-action");
|
|
21
|
-
var extractFlexibleUiContext = function extractFlexibleUiContext(
|
|
21
|
+
var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
22
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
23
|
+
featureFlags = _ref.featureFlags,
|
|
24
|
+
id = _ref.id,
|
|
25
|
+
renderers = _ref.renderers,
|
|
26
|
+
showServerActions = _ref.showServerActions,
|
|
27
|
+
response = _ref.response;
|
|
22
28
|
if (!response) {
|
|
23
29
|
return undefined;
|
|
24
30
|
}
|
|
25
31
|
var data = response.data;
|
|
26
32
|
var url = (0, _extractors.extractLink)(data);
|
|
33
|
+
var showLozengeAction = (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.useLozengeAction) === 'experiment';
|
|
27
34
|
return {
|
|
28
35
|
attachmentCount: (0, _utils.extractAttachmentCount)(data),
|
|
29
36
|
authorGroup: (0, _extractors.extractPersonCreatedBy)(data),
|
|
@@ -50,7 +57,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
|
|
|
50
57
|
snippet: (0, _primitives.extractSummary)(data) || undefined,
|
|
51
58
|
// Explicitly set here to remove an empty string
|
|
52
59
|
sourceBranch: (0, _utils.extractSourceBranch)(data),
|
|
53
|
-
state: (0,
|
|
60
|
+
state: (0, _extractState.default)(response, showLozengeAction && showServerActions, id),
|
|
54
61
|
subscriberCount: (0, _utils.extractSubscriberCount)(data),
|
|
55
62
|
targetBranch: (0, _utils.extractTargetBranch)(data),
|
|
56
63
|
title: (0, _extractors.extractTitle)(data) || url,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDispatchAnalytics = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
9
|
+
var _analytics = require("../../utils/analytics");
|
|
10
|
+
/**
|
|
11
|
+
* Hook designed to use a handler if provided (ideally not)
|
|
12
|
+
* Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
|
|
13
|
+
* but fallback to the dispatch provided by `useAnalyticsEvents`
|
|
14
|
+
*
|
|
15
|
+
* In future, potentially use this hook to feature flag the channel we are dispatching to
|
|
16
|
+
*/
|
|
17
|
+
var useDispatchAnalytics = function useDispatchAnalytics(handler) {
|
|
18
|
+
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
19
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
20
|
+
return {
|
|
21
|
+
dispatchAnalytics: (0, _react.useMemo)(function () {
|
|
22
|
+
if (handler) {
|
|
23
|
+
return handler;
|
|
24
|
+
}
|
|
25
|
+
return function (payload) {
|
|
26
|
+
createAnalyticsEvent(payload).fire(_analytics.ANALYTICS_CHANNEL);
|
|
27
|
+
};
|
|
28
|
+
}, [handler, createAnalyticsEvent])
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.useDispatchAnalytics = useDispatchAnalytics;
|
|
@@ -14,6 +14,7 @@ var _ufoExperiences = require("./ufoExperiences");
|
|
|
14
14
|
var _helpers = require("../helpers");
|
|
15
15
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
16
16
|
var _analytics2 = require("../../utils/analytics/analytics");
|
|
17
|
+
var _useDispatchAnalytics2 = require("./useDispatchAnalytics");
|
|
17
18
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
19
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
20
|
var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
|
|
@@ -44,7 +45,9 @@ var applyCommonAttributes = function applyCommonAttributes(event, commonAttribut
|
|
|
44
45
|
* @param defaultLocation location attribute to be used
|
|
45
46
|
* @returns
|
|
46
47
|
*/
|
|
47
|
-
var useSmartLinkAnalytics = function useSmartLinkAnalytics(url,
|
|
48
|
+
var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatchAnalytics, id, defaultLocation) {
|
|
49
|
+
var _useDispatchAnalytics = (0, _useDispatchAnalytics2.useDispatchAnalytics)(_dispatchAnalytics),
|
|
50
|
+
dispatchAnalytics = _useDispatchAnalytics.dispatchAnalytics;
|
|
48
51
|
var defaultId = id || 'NULL';
|
|
49
52
|
// We don't want to trigger a re-render by using useSmartCardState
|
|
50
53
|
var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
|
|
@@ -5,8 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.InvokeActionError = void 0;
|
|
7
7
|
var InvokeActionError;
|
|
8
|
+
/**
|
|
9
|
+
* Additional details for invoke function that may be required for component
|
|
10
|
+
*/
|
|
8
11
|
exports.InvokeActionError = InvokeActionError;
|
|
9
12
|
(function (InvokeActionError) {
|
|
10
13
|
InvokeActionError["NoData"] = "NoData";
|
|
11
14
|
InvokeActionError["Unknown"] = "Unknown";
|
|
12
|
-
})(InvokeActionError || (exports.InvokeActionError = InvokeActionError = {}));
|
|
15
|
+
})(InvokeActionError || (exports.InvokeActionError = InvokeActionError = {}));
|
|
16
|
+
/**
|
|
17
|
+
* Invoke request with additional details for the component
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* CRUD invoke requests for the component that support server actions
|
|
21
|
+
*/
|
package/dist/cjs/version.json
CHANGED
|
@@ -21,24 +21,33 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
21
|
* @see Container
|
|
22
22
|
*/
|
|
23
23
|
var FlexibleCard = function FlexibleCard(_ref) {
|
|
24
|
-
var
|
|
24
|
+
var analytics = _ref.analytics,
|
|
25
|
+
cardState = _ref.cardState,
|
|
25
26
|
children = _ref.children,
|
|
27
|
+
id = _ref.id,
|
|
26
28
|
onAuthorize = _ref.onAuthorize,
|
|
29
|
+
onClick = _ref.onClick,
|
|
27
30
|
onError = _ref.onError,
|
|
28
31
|
onResolve = _ref.onResolve,
|
|
29
32
|
renderers = _ref.renderers,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
onClick = _ref.onClick,
|
|
33
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
34
|
+
showServerActions = _ref.showServerActions,
|
|
33
35
|
testId = _ref.testId,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
ui = _ref.ui,
|
|
37
|
+
url = _ref.url;
|
|
36
38
|
var cardType = cardState.status,
|
|
37
39
|
details = cardState.details;
|
|
38
40
|
var status = cardType;
|
|
39
41
|
var context = (0, _react.useMemo)(function () {
|
|
40
|
-
return (0, _utils.getContextByStatus)(
|
|
41
|
-
|
|
42
|
+
return (0, _utils.getContextByStatus)({
|
|
43
|
+
response: details,
|
|
44
|
+
id: id,
|
|
45
|
+
renderers: renderers,
|
|
46
|
+
showServerActions: showServerActions,
|
|
47
|
+
status: status,
|
|
48
|
+
url: url
|
|
49
|
+
});
|
|
50
|
+
}, [details, id, renderers, showServerActions, status, url]);
|
|
42
51
|
var retry = (0, _utils.getRetryOptions)(url, status, details, onAuthorize);
|
|
43
52
|
var _ref2 = context || {},
|
|
44
53
|
title = _ref2.title;
|
|
@@ -14,7 +14,11 @@ var _icon = require("../../extractors/flexible/icon");
|
|
|
14
14
|
var _utils = require("../../utils");
|
|
15
15
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
16
16
|
var _extractProviderIcon = _interopRequireDefault(require("../../extractors/flexible/icon/extract-provider-icon"));
|
|
17
|
-
var getContextByStatus = function getContextByStatus(
|
|
17
|
+
var getContextByStatus = function getContextByStatus(params) {
|
|
18
|
+
var _ref = params !== null && params !== void 0 ? params : {},
|
|
19
|
+
response = _ref.response,
|
|
20
|
+
status = _ref.status,
|
|
21
|
+
url = _ref.url;
|
|
18
22
|
switch (status) {
|
|
19
23
|
case _constants.SmartLinkStatus.Pending:
|
|
20
24
|
case _constants.SmartLinkStatus.Resolving:
|
|
@@ -23,15 +27,15 @@ var getContextByStatus = function getContextByStatus(url, status, details, rende
|
|
|
23
27
|
url: url
|
|
24
28
|
};
|
|
25
29
|
case _constants.SmartLinkStatus.Resolved:
|
|
26
|
-
return (0, _flexible.default)(
|
|
30
|
+
return (0, _flexible.default)(params);
|
|
27
31
|
case _constants.SmartLinkStatus.Unauthorized:
|
|
28
32
|
case _constants.SmartLinkStatus.Forbidden:
|
|
29
33
|
case _constants.SmartLinkStatus.NotFound:
|
|
30
34
|
case _constants.SmartLinkStatus.Errored:
|
|
31
35
|
case _constants.SmartLinkStatus.Fallback:
|
|
32
36
|
default:
|
|
33
|
-
var linkIcon = (0, _icon.extractErrorIcon)(
|
|
34
|
-
var provider = (0, _extractProviderIcon.default)(
|
|
37
|
+
var linkIcon = (0, _icon.extractErrorIcon)(response, status);
|
|
38
|
+
var provider = (0, _extractProviderIcon.default)(response === null || response === void 0 ? void 0 : response.data);
|
|
35
39
|
return {
|
|
36
40
|
linkIcon: linkIcon,
|
|
37
41
|
title: url,
|
|
@@ -59,9 +63,9 @@ var getForbiddenMessageKey = function getForbiddenMessageKey(meta) {
|
|
|
59
63
|
return 'restricted_link';
|
|
60
64
|
}
|
|
61
65
|
};
|
|
62
|
-
var getRetryOptions = function getRetryOptions(url, status,
|
|
63
|
-
var
|
|
64
|
-
var data =
|
|
66
|
+
var getRetryOptions = function getRetryOptions(url, status, response, onAuthorize) {
|
|
67
|
+
var _response$meta, _access$action;
|
|
68
|
+
var data = response && response.data || (0, _jsonld.getEmptyJsonLd)();
|
|
65
69
|
var provider = (0, _extractors.extractProvider)(data);
|
|
66
70
|
var context = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
67
71
|
var values = context ? {
|
|
@@ -69,7 +73,7 @@ var getRetryOptions = function getRetryOptions(url, status, details, onAuthorize
|
|
|
69
73
|
} : undefined;
|
|
70
74
|
switch (status) {
|
|
71
75
|
case _constants.SmartLinkStatus.Forbidden:
|
|
72
|
-
var meta = (
|
|
76
|
+
var meta = (_response$meta = response === null || response === void 0 ? void 0 : response.meta) !== null && _response$meta !== void 0 ? _response$meta : (0, _jsonld.getForbiddenJsonLd)().meta;
|
|
73
77
|
var access = (0, _context.extractRequestAccessContext)({
|
|
74
78
|
jsonLd: meta,
|
|
75
79
|
url: url,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const extractServerAction = data => {
|
|
2
|
+
const actions = data === null || data === void 0 ? void 0 : data['atlassian:serverAction'];
|
|
3
|
+
if (!actions) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
if (actions && !Array.isArray(actions)) {
|
|
7
|
+
return [actions];
|
|
8
|
+
}
|
|
9
|
+
return actions;
|
|
10
|
+
};
|
|
11
|
+
export default extractServerAction;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { extractLozenge } from '../common/lozenge';
|
|
2
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
3
|
+
import extractServerAction from './extract-server-action';
|
|
4
|
+
import { extractLink } from '@atlaskit/linking-common/extractors';
|
|
5
|
+
const toInvokeRequest = (extensionKey, resourceIdentifiers, actionType, details) => {
|
|
6
|
+
if (!actionType) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
action: {
|
|
11
|
+
actionType,
|
|
12
|
+
resourceIdentifiers
|
|
13
|
+
},
|
|
14
|
+
providerKey: extensionKey,
|
|
15
|
+
details
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const extractAction = (response, id) => {
|
|
19
|
+
var _action$dataRetrieval, _action$dataUpdateAct;
|
|
20
|
+
const extensionKey = getExtensionKey(response);
|
|
21
|
+
const data = response === null || response === void 0 ? void 0 : response.data;
|
|
22
|
+
const actions = extractServerAction(data);
|
|
23
|
+
if (!extensionKey || actions.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const action = actions.find(item => (item === null || item === void 0 ? void 0 : item.name) === 'UpdateAction' && (item === null || item === void 0 ? void 0 : item.refField) === 'tag');
|
|
27
|
+
if (!action || !action.resourceIdentifiers) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
|
|
31
|
+
const url = extractLink(data);
|
|
32
|
+
const details = {
|
|
33
|
+
id,
|
|
34
|
+
url
|
|
35
|
+
};
|
|
36
|
+
const update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
|
|
37
|
+
return read || update ? {
|
|
38
|
+
read,
|
|
39
|
+
update
|
|
40
|
+
} : undefined;
|
|
41
|
+
};
|
|
42
|
+
const extractState = (response, showServerActions, id) => {
|
|
43
|
+
if (!response || !response.data) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const lozenge = extractLozenge(response === null || response === void 0 ? void 0 : response.data);
|
|
47
|
+
if (!lozenge) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!showServerActions) {
|
|
51
|
+
return lozenge;
|
|
52
|
+
}
|
|
53
|
+
const action = extractAction(response, id);
|
|
54
|
+
return {
|
|
55
|
+
...lozenge,
|
|
56
|
+
action
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export default extractState;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { extractSummary } from '../common/primitives';
|
|
2
|
-
import { extractLozenge } from '../common/lozenge';
|
|
3
2
|
import { extractLinkIcon } from './icon';
|
|
4
3
|
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn } from './utils';
|
|
5
4
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
@@ -7,16 +6,24 @@ import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCr
|
|
|
7
6
|
import extractPriority from './extract-priority';
|
|
8
7
|
import extractProviderIcon from './icon/extract-provider-icon';
|
|
9
8
|
import extractPreview from './extract-preview';
|
|
9
|
+
import extractState from './extract-state';
|
|
10
10
|
import { extractLatestCommit } from './latest-commit';
|
|
11
11
|
import { extractPreviewAction } from './actions/extract-preview-action';
|
|
12
12
|
import { extractDownloadAction } from './actions/extract-download-action';
|
|
13
13
|
import { extractViewAction } from './actions/extract-view-action';
|
|
14
|
-
const extractFlexibleUiContext = (
|
|
14
|
+
const extractFlexibleUiContext = ({
|
|
15
|
+
featureFlags,
|
|
16
|
+
id,
|
|
17
|
+
renderers,
|
|
18
|
+
showServerActions,
|
|
19
|
+
response
|
|
20
|
+
} = {}) => {
|
|
15
21
|
if (!response) {
|
|
16
22
|
return undefined;
|
|
17
23
|
}
|
|
18
24
|
const data = response.data;
|
|
19
25
|
const url = extractLink(data);
|
|
26
|
+
const showLozengeAction = (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.useLozengeAction) === 'experiment';
|
|
20
27
|
return {
|
|
21
28
|
attachmentCount: extractAttachmentCount(data),
|
|
22
29
|
authorGroup: extractPersonCreatedBy(data),
|
|
@@ -43,7 +50,7 @@ const extractFlexibleUiContext = (response, renderers) => {
|
|
|
43
50
|
snippet: extractSummary(data) || undefined,
|
|
44
51
|
// Explicitly set here to remove an empty string
|
|
45
52
|
sourceBranch: extractSourceBranch(data),
|
|
46
|
-
state:
|
|
53
|
+
state: extractState(response, showLozengeAction && showServerActions, id),
|
|
47
54
|
subscriberCount: extractSubscriberCount(data),
|
|
48
55
|
targetBranch: extractTargetBranch(data),
|
|
49
56
|
title: extractTitle(data) || url,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
|
+
import { ANALYTICS_CHANNEL } from '../../utils/analytics';
|
|
4
|
+
/**
|
|
5
|
+
* Hook designed to use a handler if provided (ideally not)
|
|
6
|
+
* Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
|
|
7
|
+
* but fallback to the dispatch provided by `useAnalyticsEvents`
|
|
8
|
+
*
|
|
9
|
+
* In future, potentially use this hook to feature flag the channel we are dispatching to
|
|
10
|
+
*/
|
|
11
|
+
export const useDispatchAnalytics = handler => {
|
|
12
|
+
const {
|
|
13
|
+
createAnalyticsEvent
|
|
14
|
+
} = useAnalyticsEvents();
|
|
15
|
+
return {
|
|
16
|
+
dispatchAnalytics: useMemo(() => {
|
|
17
|
+
if (handler) {
|
|
18
|
+
return handler;
|
|
19
|
+
}
|
|
20
|
+
return payload => {
|
|
21
|
+
createAnalyticsEvent(payload).fire(ANALYTICS_CHANNEL);
|
|
22
|
+
};
|
|
23
|
+
}, [handler, createAnalyticsEvent])
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -5,6 +5,7 @@ import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './u
|
|
|
5
5
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
7
|
import { trackLinkUpdated, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
8
|
+
import { useDispatchAnalytics } from './useDispatchAnalytics';
|
|
8
9
|
const applyCommonAttributes = (event, commonAttributes) => {
|
|
9
10
|
if (event && event.attributes) {
|
|
10
11
|
for (const [key, value] of Object.entries(commonAttributes)) {
|
|
@@ -30,7 +31,10 @@ const applyCommonAttributes = (event, commonAttributes) => {
|
|
|
30
31
|
* @param defaultLocation location attribute to be used
|
|
31
32
|
* @returns
|
|
32
33
|
*/
|
|
33
|
-
export const useSmartLinkAnalytics = (url,
|
|
34
|
+
export const useSmartLinkAnalytics = (url, _dispatchAnalytics, id, defaultLocation) => {
|
|
35
|
+
const {
|
|
36
|
+
dispatchAnalytics
|
|
37
|
+
} = useDispatchAnalytics(_dispatchAnalytics);
|
|
34
38
|
const defaultId = id || 'NULL';
|
|
35
39
|
// We don't want to trigger a re-render by using useSmartCardState
|
|
36
40
|
const {
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
export let InvokeActionError;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Additional details for invoke function that may be required for component
|
|
5
|
+
*/
|
|
2
6
|
(function (InvokeActionError) {
|
|
3
7
|
InvokeActionError["NoData"] = "NoData";
|
|
4
8
|
InvokeActionError["Unknown"] = "Unknown";
|
|
5
|
-
})(InvokeActionError || (InvokeActionError = {}));
|
|
9
|
+
})(InvokeActionError || (InvokeActionError = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Invoke request with additional details for the component
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* CRUD invoke requests for the component that support server actions
|
|
15
|
+
*/
|
package/dist/es2019/version.json
CHANGED
|
@@ -12,25 +12,34 @@ import { getContextByStatus, getRetryOptions } from './utils';
|
|
|
12
12
|
* @see Container
|
|
13
13
|
*/
|
|
14
14
|
const FlexibleCard = ({
|
|
15
|
+
analytics,
|
|
15
16
|
cardState,
|
|
16
17
|
children,
|
|
18
|
+
id,
|
|
17
19
|
onAuthorize,
|
|
20
|
+
onClick,
|
|
18
21
|
onError,
|
|
19
22
|
onResolve,
|
|
20
23
|
renderers,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
onClick,
|
|
24
|
+
showHoverPreview,
|
|
25
|
+
showServerActions,
|
|
24
26
|
testId,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
ui,
|
|
28
|
+
url
|
|
27
29
|
}) => {
|
|
28
30
|
const {
|
|
29
31
|
status: cardType,
|
|
30
32
|
details
|
|
31
33
|
} = cardState;
|
|
32
34
|
const status = cardType;
|
|
33
|
-
const context = useMemo(() => getContextByStatus(
|
|
35
|
+
const context = useMemo(() => getContextByStatus({
|
|
36
|
+
response: details,
|
|
37
|
+
id,
|
|
38
|
+
renderers,
|
|
39
|
+
showServerActions,
|
|
40
|
+
status,
|
|
41
|
+
url
|
|
42
|
+
}), [details, id, renderers, showServerActions, status, url]);
|
|
34
43
|
const retry = getRetryOptions(url, status, details, onAuthorize);
|
|
35
44
|
const {
|
|
36
45
|
title
|
|
@@ -2,12 +2,17 @@ import { SmartLinkStatus } from '../../constants';
|
|
|
2
2
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
3
3
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
4
4
|
import { messages } from '../../messages';
|
|
5
|
-
import
|
|
5
|
+
import extractFlexibleUiContext from '../../extractors/flexible';
|
|
6
6
|
import { extractErrorIcon } from '../../extractors/flexible/icon';
|
|
7
7
|
import { handleOnClick } from '../../utils';
|
|
8
8
|
import { extractProvider } from '@atlaskit/linking-common/extractors';
|
|
9
9
|
import extractProviderIcon from '../../extractors/flexible/icon/extract-provider-icon';
|
|
10
|
-
export const getContextByStatus =
|
|
10
|
+
export const getContextByStatus = params => {
|
|
11
|
+
const {
|
|
12
|
+
response,
|
|
13
|
+
status,
|
|
14
|
+
url
|
|
15
|
+
} = params !== null && params !== void 0 ? params : {};
|
|
11
16
|
switch (status) {
|
|
12
17
|
case SmartLinkStatus.Pending:
|
|
13
18
|
case SmartLinkStatus.Resolving:
|
|
@@ -16,15 +21,15 @@ export const getContextByStatus = (url, status, details, renderers) => {
|
|
|
16
21
|
url
|
|
17
22
|
};
|
|
18
23
|
case SmartLinkStatus.Resolved:
|
|
19
|
-
return
|
|
24
|
+
return extractFlexibleUiContext(params);
|
|
20
25
|
case SmartLinkStatus.Unauthorized:
|
|
21
26
|
case SmartLinkStatus.Forbidden:
|
|
22
27
|
case SmartLinkStatus.NotFound:
|
|
23
28
|
case SmartLinkStatus.Errored:
|
|
24
29
|
case SmartLinkStatus.Fallback:
|
|
25
30
|
default:
|
|
26
|
-
const linkIcon = extractErrorIcon(
|
|
27
|
-
const provider = extractProviderIcon(
|
|
31
|
+
const linkIcon = extractErrorIcon(response, status);
|
|
32
|
+
const provider = extractProviderIcon(response === null || response === void 0 ? void 0 : response.data);
|
|
28
33
|
return {
|
|
29
34
|
linkIcon,
|
|
30
35
|
title: url,
|
|
@@ -51,9 +56,9 @@ const getForbiddenMessageKey = meta => {
|
|
|
51
56
|
return 'restricted_link';
|
|
52
57
|
}
|
|
53
58
|
};
|
|
54
|
-
export const getRetryOptions = (url, status,
|
|
55
|
-
var
|
|
56
|
-
const data =
|
|
59
|
+
export const getRetryOptions = (url, status, response, onAuthorize) => {
|
|
60
|
+
var _response$meta, _access$action;
|
|
61
|
+
const data = response && response.data || getEmptyJsonLd();
|
|
57
62
|
const provider = extractProvider(data);
|
|
58
63
|
const context = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
59
64
|
const values = context ? {
|
|
@@ -61,7 +66,7 @@ export const getRetryOptions = (url, status, details, onAuthorize) => {
|
|
|
61
66
|
} : undefined;
|
|
62
67
|
switch (status) {
|
|
63
68
|
case SmartLinkStatus.Forbidden:
|
|
64
|
-
const meta = (
|
|
69
|
+
const meta = (_response$meta = response === null || response === void 0 ? void 0 : response.meta) !== null && _response$meta !== void 0 ? _response$meta : getForbiddenJsonLd().meta;
|
|
65
70
|
const access = extractRequestAccessContext({
|
|
66
71
|
jsonLd: meta,
|
|
67
72
|
url,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var extractServerAction = function extractServerAction(data) {
|
|
2
|
+
var actions = data === null || data === void 0 ? void 0 : data['atlassian:serverAction'];
|
|
3
|
+
if (!actions) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
if (actions && !Array.isArray(actions)) {
|
|
7
|
+
return [actions];
|
|
8
|
+
}
|
|
9
|
+
return actions;
|
|
10
|
+
};
|
|
11
|
+
export default extractServerAction;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { extractLozenge } from '../common/lozenge';
|
|
5
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
6
|
+
import extractServerAction from './extract-server-action';
|
|
7
|
+
import { extractLink } from '@atlaskit/linking-common/extractors';
|
|
8
|
+
var toInvokeRequest = function toInvokeRequest(extensionKey, resourceIdentifiers, actionType, details) {
|
|
9
|
+
if (!actionType) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
action: {
|
|
14
|
+
actionType: actionType,
|
|
15
|
+
resourceIdentifiers: resourceIdentifiers
|
|
16
|
+
},
|
|
17
|
+
providerKey: extensionKey,
|
|
18
|
+
details: details
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
var extractAction = function extractAction(response, id) {
|
|
22
|
+
var _action$dataRetrieval, _action$dataUpdateAct;
|
|
23
|
+
var extensionKey = getExtensionKey(response);
|
|
24
|
+
var data = response === null || response === void 0 ? void 0 : response.data;
|
|
25
|
+
var actions = extractServerAction(data);
|
|
26
|
+
if (!extensionKey || actions.length === 0) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var action = actions.find(function (item) {
|
|
30
|
+
return (item === null || item === void 0 ? void 0 : item.name) === 'UpdateAction' && (item === null || item === void 0 ? void 0 : item.refField) === 'tag';
|
|
31
|
+
});
|
|
32
|
+
if (!action || !action.resourceIdentifiers) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
var read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
|
|
36
|
+
var url = extractLink(data);
|
|
37
|
+
var details = {
|
|
38
|
+
id: id,
|
|
39
|
+
url: url
|
|
40
|
+
};
|
|
41
|
+
var update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
|
|
42
|
+
return read || update ? {
|
|
43
|
+
read: read,
|
|
44
|
+
update: update
|
|
45
|
+
} : undefined;
|
|
46
|
+
};
|
|
47
|
+
var extractState = function extractState(response, showServerActions, id) {
|
|
48
|
+
if (!response || !response.data) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
var lozenge = extractLozenge(response === null || response === void 0 ? void 0 : response.data);
|
|
52
|
+
if (!lozenge) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!showServerActions) {
|
|
56
|
+
return lozenge;
|
|
57
|
+
}
|
|
58
|
+
var action = extractAction(response, id);
|
|
59
|
+
return _objectSpread(_objectSpread({}, lozenge), {}, {
|
|
60
|
+
action: action
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export default extractState;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { extractSummary } from '../common/primitives';
|
|
2
|
-
import { extractLozenge } from '../common/lozenge';
|
|
3
2
|
import { extractLinkIcon } from './icon';
|
|
4
3
|
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn } from './utils';
|
|
5
4
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
@@ -7,16 +6,24 @@ import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCr
|
|
|
7
6
|
import extractPriority from './extract-priority';
|
|
8
7
|
import extractProviderIcon from './icon/extract-provider-icon';
|
|
9
8
|
import extractPreview from './extract-preview';
|
|
9
|
+
import extractState from './extract-state';
|
|
10
10
|
import { extractLatestCommit } from './latest-commit';
|
|
11
11
|
import { extractPreviewAction } from './actions/extract-preview-action';
|
|
12
12
|
import { extractDownloadAction } from './actions/extract-download-action';
|
|
13
13
|
import { extractViewAction } from './actions/extract-view-action';
|
|
14
|
-
var extractFlexibleUiContext = function extractFlexibleUiContext(
|
|
14
|
+
var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
15
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
16
|
+
featureFlags = _ref.featureFlags,
|
|
17
|
+
id = _ref.id,
|
|
18
|
+
renderers = _ref.renderers,
|
|
19
|
+
showServerActions = _ref.showServerActions,
|
|
20
|
+
response = _ref.response;
|
|
15
21
|
if (!response) {
|
|
16
22
|
return undefined;
|
|
17
23
|
}
|
|
18
24
|
var data = response.data;
|
|
19
25
|
var url = extractLink(data);
|
|
26
|
+
var showLozengeAction = (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.useLozengeAction) === 'experiment';
|
|
20
27
|
return {
|
|
21
28
|
attachmentCount: extractAttachmentCount(data),
|
|
22
29
|
authorGroup: extractPersonCreatedBy(data),
|
|
@@ -43,7 +50,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
|
|
|
43
50
|
snippet: extractSummary(data) || undefined,
|
|
44
51
|
// Explicitly set here to remove an empty string
|
|
45
52
|
sourceBranch: extractSourceBranch(data),
|
|
46
|
-
state:
|
|
53
|
+
state: extractState(response, showLozengeAction && showServerActions, id),
|
|
47
54
|
subscriberCount: extractSubscriberCount(data),
|
|
48
55
|
targetBranch: extractTargetBranch(data),
|
|
49
56
|
title: extractTitle(data) || url,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
|
+
import { ANALYTICS_CHANNEL } from '../../utils/analytics';
|
|
4
|
+
/**
|
|
5
|
+
* Hook designed to use a handler if provided (ideally not)
|
|
6
|
+
* Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
|
|
7
|
+
* but fallback to the dispatch provided by `useAnalyticsEvents`
|
|
8
|
+
*
|
|
9
|
+
* In future, potentially use this hook to feature flag the channel we are dispatching to
|
|
10
|
+
*/
|
|
11
|
+
export var useDispatchAnalytics = function useDispatchAnalytics(handler) {
|
|
12
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
13
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
14
|
+
return {
|
|
15
|
+
dispatchAnalytics: useMemo(function () {
|
|
16
|
+
if (handler) {
|
|
17
|
+
return handler;
|
|
18
|
+
}
|
|
19
|
+
return function (payload) {
|
|
20
|
+
createAnalyticsEvent(payload).fire(ANALYTICS_CHANNEL);
|
|
21
|
+
};
|
|
22
|
+
}, [handler, createAnalyticsEvent])
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -9,6 +9,7 @@ import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './u
|
|
|
9
9
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
|
|
10
10
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
11
11
|
import { trackLinkUpdated, uiIframeDwelledEvent, uiIframeFocusedEvent } from '../../utils/analytics/analytics';
|
|
12
|
+
import { useDispatchAnalytics } from './useDispatchAnalytics';
|
|
12
13
|
var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
|
|
13
14
|
if (event && event.attributes) {
|
|
14
15
|
for (var _i = 0, _Object$entries = Object.entries(commonAttributes); _i < _Object$entries.length; _i++) {
|
|
@@ -37,7 +38,9 @@ var applyCommonAttributes = function applyCommonAttributes(event, commonAttribut
|
|
|
37
38
|
* @param defaultLocation location attribute to be used
|
|
38
39
|
* @returns
|
|
39
40
|
*/
|
|
40
|
-
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url,
|
|
41
|
+
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, _dispatchAnalytics, id, defaultLocation) {
|
|
42
|
+
var _useDispatchAnalytics = useDispatchAnalytics(_dispatchAnalytics),
|
|
43
|
+
dispatchAnalytics = _useDispatchAnalytics.dispatchAnalytics;
|
|
41
44
|
var defaultId = id || 'NULL';
|
|
42
45
|
// We don't want to trigger a re-render by using useSmartCardState
|
|
43
46
|
var _useSmartLinkContext = useSmartLinkContext(),
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
export var InvokeActionError;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Additional details for invoke function that may be required for component
|
|
5
|
+
*/
|
|
2
6
|
(function (InvokeActionError) {
|
|
3
7
|
InvokeActionError["NoData"] = "NoData";
|
|
4
8
|
InvokeActionError["Unknown"] = "Unknown";
|
|
5
|
-
})(InvokeActionError || (InvokeActionError = {}));
|
|
9
|
+
})(InvokeActionError || (InvokeActionError = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Invoke request with additional details for the component
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* CRUD invoke requests for the component that support server actions
|
|
15
|
+
*/
|
package/dist/esm/version.json
CHANGED
|
@@ -12,24 +12,33 @@ import { getContextByStatus, getRetryOptions } from './utils';
|
|
|
12
12
|
* @see Container
|
|
13
13
|
*/
|
|
14
14
|
var FlexibleCard = function FlexibleCard(_ref) {
|
|
15
|
-
var
|
|
15
|
+
var analytics = _ref.analytics,
|
|
16
|
+
cardState = _ref.cardState,
|
|
16
17
|
children = _ref.children,
|
|
18
|
+
id = _ref.id,
|
|
17
19
|
onAuthorize = _ref.onAuthorize,
|
|
20
|
+
onClick = _ref.onClick,
|
|
18
21
|
onError = _ref.onError,
|
|
19
22
|
onResolve = _ref.onResolve,
|
|
20
23
|
renderers = _ref.renderers,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
onClick = _ref.onClick,
|
|
24
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
25
|
+
showServerActions = _ref.showServerActions,
|
|
24
26
|
testId = _ref.testId,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
ui = _ref.ui,
|
|
28
|
+
url = _ref.url;
|
|
27
29
|
var cardType = cardState.status,
|
|
28
30
|
details = cardState.details;
|
|
29
31
|
var status = cardType;
|
|
30
32
|
var context = useMemo(function () {
|
|
31
|
-
return getContextByStatus(
|
|
32
|
-
|
|
33
|
+
return getContextByStatus({
|
|
34
|
+
response: details,
|
|
35
|
+
id: id,
|
|
36
|
+
renderers: renderers,
|
|
37
|
+
showServerActions: showServerActions,
|
|
38
|
+
status: status,
|
|
39
|
+
url: url
|
|
40
|
+
});
|
|
41
|
+
}, [details, id, renderers, showServerActions, status, url]);
|
|
33
42
|
var retry = getRetryOptions(url, status, details, onAuthorize);
|
|
34
43
|
var _ref2 = context || {},
|
|
35
44
|
title = _ref2.title;
|
|
@@ -2,12 +2,16 @@ import { SmartLinkStatus } from '../../constants';
|
|
|
2
2
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
3
3
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
4
4
|
import { messages } from '../../messages';
|
|
5
|
-
import
|
|
5
|
+
import extractFlexibleUiContext from '../../extractors/flexible';
|
|
6
6
|
import { extractErrorIcon } from '../../extractors/flexible/icon';
|
|
7
7
|
import { handleOnClick } from '../../utils';
|
|
8
8
|
import { extractProvider } from '@atlaskit/linking-common/extractors';
|
|
9
9
|
import extractProviderIcon from '../../extractors/flexible/icon/extract-provider-icon';
|
|
10
|
-
export var getContextByStatus = function getContextByStatus(
|
|
10
|
+
export var getContextByStatus = function getContextByStatus(params) {
|
|
11
|
+
var _ref = params !== null && params !== void 0 ? params : {},
|
|
12
|
+
response = _ref.response,
|
|
13
|
+
status = _ref.status,
|
|
14
|
+
url = _ref.url;
|
|
11
15
|
switch (status) {
|
|
12
16
|
case SmartLinkStatus.Pending:
|
|
13
17
|
case SmartLinkStatus.Resolving:
|
|
@@ -16,15 +20,15 @@ export var getContextByStatus = function getContextByStatus(url, status, details
|
|
|
16
20
|
url: url
|
|
17
21
|
};
|
|
18
22
|
case SmartLinkStatus.Resolved:
|
|
19
|
-
return
|
|
23
|
+
return extractFlexibleUiContext(params);
|
|
20
24
|
case SmartLinkStatus.Unauthorized:
|
|
21
25
|
case SmartLinkStatus.Forbidden:
|
|
22
26
|
case SmartLinkStatus.NotFound:
|
|
23
27
|
case SmartLinkStatus.Errored:
|
|
24
28
|
case SmartLinkStatus.Fallback:
|
|
25
29
|
default:
|
|
26
|
-
var linkIcon = extractErrorIcon(
|
|
27
|
-
var provider = extractProviderIcon(
|
|
30
|
+
var linkIcon = extractErrorIcon(response, status);
|
|
31
|
+
var provider = extractProviderIcon(response === null || response === void 0 ? void 0 : response.data);
|
|
28
32
|
return {
|
|
29
33
|
linkIcon: linkIcon,
|
|
30
34
|
title: url,
|
|
@@ -51,9 +55,9 @@ var getForbiddenMessageKey = function getForbiddenMessageKey(meta) {
|
|
|
51
55
|
return 'restricted_link';
|
|
52
56
|
}
|
|
53
57
|
};
|
|
54
|
-
export var getRetryOptions = function getRetryOptions(url, status,
|
|
55
|
-
var
|
|
56
|
-
var data =
|
|
58
|
+
export var getRetryOptions = function getRetryOptions(url, status, response, onAuthorize) {
|
|
59
|
+
var _response$meta, _access$action;
|
|
60
|
+
var data = response && response.data || getEmptyJsonLd();
|
|
57
61
|
var provider = extractProvider(data);
|
|
58
62
|
var context = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
59
63
|
var values = context ? {
|
|
@@ -61,7 +65,7 @@ export var getRetryOptions = function getRetryOptions(url, status, details, onAu
|
|
|
61
65
|
} : undefined;
|
|
62
66
|
switch (status) {
|
|
63
67
|
case SmartLinkStatus.Forbidden:
|
|
64
|
-
var meta = (
|
|
68
|
+
var meta = (_response$meta = response === null || response === void 0 ? void 0 : response.meta) !== null && _response$meta !== void 0 ? _response$meta : getForbiddenJsonLd().meta;
|
|
65
69
|
var access = extractRequestAccessContext({
|
|
66
70
|
jsonLd: meta,
|
|
67
71
|
url: url,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { InvokeActions } from '../../../state/hooks/use-invoke/types';
|
|
1
2
|
export declare type LinkLozengeColor = 'default' | 'success' | 'removed' | 'inprogress' | 'new' | 'moved';
|
|
2
3
|
export interface LinkLozenge {
|
|
4
|
+
action?: InvokeActions;
|
|
3
5
|
text: string;
|
|
4
6
|
appearance?: LinkLozengeColor;
|
|
5
7
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JsonLd } from 'json-ld-types';
|
|
2
|
+
import type { LinkLozenge } from '../common/lozenge/types';
|
|
3
|
+
declare const extractState: (response?: JsonLd.Response<JsonLd.Data.BaseData> | undefined, showServerActions?: boolean | undefined, id?: string | undefined) => LinkLozenge | undefined;
|
|
4
|
+
export default extractState;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { JsonLd } from 'json-ld-types';
|
|
2
|
-
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
3
1
|
import { FlexibleUiDataContext } from '../../state/flexible-ui-context/types';
|
|
4
|
-
|
|
2
|
+
import { ExtractFlexibleUiDataContextParams } from '../../view/FlexibleCard/types';
|
|
3
|
+
declare const extractFlexibleUiContext: ({ featureFlags, id, renderers, showServerActions, response, }?: Partial<ExtractFlexibleUiDataContextParams>) => FlexibleUiDataContext | undefined;
|
|
5
4
|
export default extractFlexibleUiContext;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnalyticsHandler } from '../../';
|
|
2
|
+
/**
|
|
3
|
+
* Hook designed to use a handler if provided (ideally not)
|
|
4
|
+
* Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
|
|
5
|
+
* but fallback to the dispatch provided by `useAnalyticsEvents`
|
|
6
|
+
*
|
|
7
|
+
* In future, potentially use this hook to feature flag the channel we are dispatching to
|
|
8
|
+
*/
|
|
9
|
+
export declare const useDispatchAnalytics: (handler?: AnalyticsHandler | undefined) => {
|
|
10
|
+
dispatchAnalytics: AnalyticsHandler;
|
|
11
|
+
};
|
|
@@ -14,7 +14,7 @@ import { CommonEventProps, ConnectFailedEventProps, ConnectSucceededEventProps,
|
|
|
14
14
|
* @param defaultLocation location attribute to be used
|
|
15
15
|
* @returns
|
|
16
16
|
*/
|
|
17
|
-
export declare const useSmartLinkAnalytics: (url: string,
|
|
17
|
+
export declare const useSmartLinkAnalytics: (url: string, _dispatchAnalytics?: AnalyticsHandler | undefined, id?: string | undefined, defaultLocation?: string | undefined) => {
|
|
18
18
|
ui: {
|
|
19
19
|
/**
|
|
20
20
|
* This fires an event that represents when a user clicks on the authentication
|
|
@@ -3,11 +3,31 @@ export declare enum InvokeActionError {
|
|
|
3
3
|
NoData = "NoData",
|
|
4
4
|
Unknown = "Unknown"
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Additional details for invoke function that may be required for component
|
|
8
|
+
*/
|
|
9
|
+
export declare type CardDetails = {
|
|
10
|
+
/**
|
|
11
|
+
* An identifier for Smart Link analytics
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The URL of the Smart Link
|
|
16
|
+
*/
|
|
17
|
+
url?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Invoke request with additional details for the component
|
|
21
|
+
*/
|
|
22
|
+
export declare type InvokeRequestWithCardDetails = InvokeRequest & {
|
|
23
|
+
details?: CardDetails;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* CRUD invoke requests for the component that support server actions
|
|
27
|
+
*/
|
|
6
28
|
export declare type InvokeActions = {
|
|
7
29
|
create?: InvokeRequest;
|
|
8
30
|
read?: InvokeRequest;
|
|
9
|
-
update?:
|
|
10
|
-
details?: Record<string, any>;
|
|
11
|
-
};
|
|
31
|
+
update?: InvokeRequestWithCardDetails;
|
|
12
32
|
delete?: InvokeRequest;
|
|
13
33
|
};
|
|
@@ -37,8 +37,11 @@ export interface UseSmartLinkActionsOpts {
|
|
|
37
37
|
/**
|
|
38
38
|
* Callback for sending analytics events.
|
|
39
39
|
* @description Accepts an analytics payload and fires it to a system.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
|
|
42
|
+
* Overriding the analytics dispatch method is deprecated. Please omit this property.
|
|
40
43
|
*/
|
|
41
|
-
analyticsHandler
|
|
44
|
+
analyticsHandler?: AnalyticsHandler;
|
|
42
45
|
/**
|
|
43
46
|
* Platform on which actions are being invoked.
|
|
44
47
|
* @default 'web'
|
|
@@ -8,8 +8,11 @@ export interface UseSmartLinkReloadOpts {
|
|
|
8
8
|
/**
|
|
9
9
|
* Callback for sending analytics events.
|
|
10
10
|
* @description Accepts an analytics payload and fires it to a system.
|
|
11
|
+
*
|
|
12
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
|
|
13
|
+
* Overriding the analytics dispatch method is deprecated. Please omit this property.
|
|
11
14
|
*/
|
|
12
|
-
analyticsHandler
|
|
15
|
+
analyticsHandler?: AnalyticsHandler;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* Exposes a programmatic way to reload the data being used to render a Smart Link.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardAppearance, CardPlatform, CardProps } from './types';
|
|
3
3
|
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "
|
|
4
|
+
export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
|
|
5
5
|
export type { CardAppearance, CardProps, CardPlatform };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MessageDescriptor } from 'react-intl-next';
|
|
3
|
-
import {
|
|
3
|
+
import type { JsonLd } from 'json-ld-types';
|
|
4
|
+
import { CardState, LinkingPlatformFeatureFlags } from '@atlaskit/linking-common';
|
|
4
5
|
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
5
|
-
import { SmartLinkSize, SmartLinkTheme } from '../../constants';
|
|
6
|
+
import { SmartLinkSize, SmartLinkStatus, SmartLinkTheme } from '../../constants';
|
|
6
7
|
import { CardAppearance } from '../../view/Card';
|
|
7
8
|
import { OnResolveCallback } from '../Card/types';
|
|
8
9
|
import { OnErrorCallback } from '../types';
|
|
@@ -56,6 +57,10 @@ export declare type FlexibleCardProps = {
|
|
|
56
57
|
* to render Emoji.
|
|
57
58
|
*/
|
|
58
59
|
renderers?: CardProviderRenderers;
|
|
60
|
+
/**
|
|
61
|
+
* Determines whether to show available server actions.
|
|
62
|
+
*/
|
|
63
|
+
showServerActions?: boolean;
|
|
59
64
|
/**
|
|
60
65
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
61
66
|
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
@@ -127,3 +132,8 @@ export declare type RetryOptions = {
|
|
|
127
132
|
*/
|
|
128
133
|
values?: Record<string, string>;
|
|
129
134
|
};
|
|
135
|
+
export declare type ExtractFlexibleUiDataContextParams = Pick<FlexibleCardProps, 'id' | 'showServerActions' | 'renderers' | 'url'> & {
|
|
136
|
+
status?: SmartLinkStatus;
|
|
137
|
+
response?: JsonLd.Response;
|
|
138
|
+
featureFlags?: Partial<LinkingPlatformFeatureFlags>;
|
|
139
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { JsonLd } from 'json-ld-types';
|
|
2
|
-
import {
|
|
3
|
-
import { RetryOptions } from './types';
|
|
2
|
+
import { ExtractFlexibleUiDataContextParams, RetryOptions } from './types';
|
|
4
3
|
import { SmartLinkStatus } from '../../constants';
|
|
5
4
|
import { FlexibleUiDataContext } from '../../state/flexible-ui-context/types';
|
|
6
|
-
export declare const getContextByStatus: (
|
|
7
|
-
export declare const getRetryOptions: (url: string, status?: SmartLinkStatus | undefined,
|
|
5
|
+
export declare const getContextByStatus: (params: ExtractFlexibleUiDataContextParams) => FlexibleUiDataContext | undefined;
|
|
6
|
+
export declare const getRetryOptions: (url: string, status?: SmartLinkStatus | undefined, response?: JsonLd.Response<JsonLd.Data.BaseData> | undefined, onAuthorize?: (() => void) | undefined) => RetryOptions | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.5.1",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
35
35
|
"@atlaskit/in-product-testing": "^0.1.0",
|
|
36
36
|
"@atlaskit/link-client-extension": "^0.4.0",
|
|
37
|
-
"@atlaskit/linking-common": "^2.
|
|
37
|
+
"@atlaskit/linking-common": "^2.5.0",
|
|
38
38
|
"@atlaskit/linking-types": "^0.4.0",
|
|
39
39
|
"@atlaskit/logo": "^13.12.0",
|
|
40
40
|
"@atlaskit/lozenge": "^11.3.0",
|
package/report.api.md
CHANGED
|
@@ -955,7 +955,7 @@ type UiRenderSuccessEventProps = CommonEventProps & {
|
|
|
955
955
|
// @public @deprecated
|
|
956
956
|
export const useSmartLinkAnalytics: (
|
|
957
957
|
url: string,
|
|
958
|
-
|
|
958
|
+
_dispatchAnalytics?: AnalyticsHandler | undefined,
|
|
959
959
|
id?: string | undefined,
|
|
960
960
|
defaultLocation?: string | undefined,
|
|
961
961
|
) => {
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -816,7 +816,7 @@ type UiRenderSuccessEventProps = CommonEventProps & {
|
|
|
816
816
|
};
|
|
817
817
|
|
|
818
818
|
// @public @deprecated
|
|
819
|
-
export const useSmartLinkAnalytics: (url: string,
|
|
819
|
+
export const useSmartLinkAnalytics: (url: string, _dispatchAnalytics?: AnalyticsHandler | undefined, id?: string | undefined, defaultLocation?: string | undefined) => {
|
|
820
820
|
ui: {
|
|
821
821
|
authEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiAuthEventProps) => void;
|
|
822
822
|
authAlternateAccountEvent: ({ display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiAuthAlternateAccountEventProps) => void;
|