@atlaskit/smart-card 26.51.0 → 26.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/extractors/flexible/actions/index.js +5 -2
- package/dist/cjs/extractors/flexible/index.js +1 -5
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
- package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +76 -0
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +8 -9
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +9 -8
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
- package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +41 -26
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +0 -8
- package/dist/cjs/view/HoverCard/components/ContentContainer.js +1 -0
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -0
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/flexible/actions/index.js +6 -2
- package/dist/es2019/extractors/flexible/index.js +1 -5
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
- package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +47 -0
- package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +7 -5
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -7
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
- package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +43 -22
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +0 -8
- package/dist/es2019/view/HoverCard/components/ContentContainer.js +1 -0
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +1 -0
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/flexible/actions/index.js +5 -2
- package/dist/esm/extractors/flexible/index.js +1 -5
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
- package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +66 -0
- package/dist/esm/view/FlexibleCard/components/actions/download-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +9 -7
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -7
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
- package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +41 -26
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +0 -8
- package/dist/esm/view/HoverCard/components/ContentContainer.js +1 -0
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +1 -0
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/__fixtures__/dropbox-file.d.ts +3 -0
- package/dist/types/extractors/flexible/actions/index.d.ts +1 -1
- package/dist/types/state/flexible-ui-context/types.d.ts +2 -12
- package/dist/types/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
- package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
- package/dist/types-ts4.5/__fixtures__/dropbox-file.d.ts +3 -0
- package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +1 -1
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +2 -12
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
- package/package.json +4 -4
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +0 -72
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +0 -47
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +0 -65
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
- /package/dist/cjs/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
- /package/dist/es2019/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
- /package/dist/{esm/view/FlexibleCard/components/actions/action/download-action → es2019/view/FlexibleCard/components/actions/follow-action}/types.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.52.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#87468](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87468) [`c93de2e39c73`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c93de2e39c73) - [ux] Removes image for 'not found' links in Flexible Block Card
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#87862](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87862) [`f47cde6d6abd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f47cde6d6abd) - Refactoring FollowAction to context.action
|
|
12
|
+
- [#87097](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87097) [`5d81dab96f45`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d81dab96f45) - Refactor FelibleCard's DownloadAction creation
|
|
13
|
+
- [#87006](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87006) [`9b1883e717d2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9b1883e717d2) - Refactor AISummaryBlockResolvedView to support VR testing
|
|
14
|
+
|
|
3
15
|
## 26.51.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -7,9 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _constants = require("../../../constants");
|
|
10
|
+
var _extractDownloadAction = require("./extract-download-action");
|
|
10
11
|
var _extractPreviewAction = require("./extract-preview-action");
|
|
11
|
-
var
|
|
12
|
-
|
|
12
|
+
var _extractFollowAction = _interopRequireDefault(require("./extract-follow-action"));
|
|
13
|
+
var extractActions = function extractActions(response, data, actionOptions, id) {
|
|
14
|
+
var _action;
|
|
15
|
+
var action = (_action = {}, (0, _defineProperty2.default)(_action, _constants.ActionName.PreviewAction, (0, _extractPreviewAction.extractPreviewAction)(response, actionOptions)), (0, _defineProperty2.default)(_action, _constants.ActionName.DownloadAction, (0, _extractDownloadAction.extractDownloadAction)(data, actionOptions)), (0, _defineProperty2.default)(_action, _constants.ActionName.FollowAction, (0, _extractFollowAction.default)(response, actionOptions, id)), _action);
|
|
13
16
|
return Object.values(action).some(function (value) {
|
|
14
17
|
return Boolean(value);
|
|
15
18
|
}) ? action : undefined;
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _primitives = require("../common/primitives");
|
|
9
9
|
var _actions = _interopRequireDefault(require("./actions"));
|
|
10
|
-
var _extractFollowAction = _interopRequireDefault(require("./actions/extract-follow-action"));
|
|
11
10
|
var _icon = require("./icon");
|
|
12
11
|
var _utils = require("./utils");
|
|
13
12
|
var _collaboratorGroup = require("./collaboratorGroup");
|
|
@@ -17,7 +16,6 @@ var _extractProviderIcon = _interopRequireDefault(require("./icon/extract-provid
|
|
|
17
16
|
var _extractPreview = _interopRequireDefault(require("./extract-preview"));
|
|
18
17
|
var _extractState = _interopRequireDefault(require("./extract-state"));
|
|
19
18
|
var _latestCommit = require("./latest-commit");
|
|
20
|
-
var _extractDownloadAction = require("./actions/extract-download-action");
|
|
21
19
|
var _extractViewAction = require("./actions/extract-view-action");
|
|
22
20
|
var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
23
21
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -31,7 +29,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
|
31
29
|
var data = response.data;
|
|
32
30
|
var url = (0, _linkExtractors.extractLink)(data);
|
|
33
31
|
return {
|
|
34
|
-
actions: (0, _actions.default)(response, actionOptions),
|
|
32
|
+
actions: (0, _actions.default)(response, data, actionOptions, id),
|
|
35
33
|
assignedToGroup: (0, _utils.extractPersonAssignedToAsArray)(data),
|
|
36
34
|
attachmentCount: (0, _utils.extractAttachmentCount)(data),
|
|
37
35
|
authorGroup: (0, _linkExtractors.extractPersonCreatedBy)(data),
|
|
@@ -47,9 +45,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
|
47
45
|
assignedTo: (0, _utils.extractAssignedTo)(data),
|
|
48
46
|
createdOn: (0, _linkExtractors.extractDateCreated)(data),
|
|
49
47
|
dueOn: (0, _utils.extractDueOn)(data),
|
|
50
|
-
followAction: (0, _extractFollowAction.default)(response, actionOptions, id),
|
|
51
48
|
viewAction: (0, _extractViewAction.extractViewAction)(data, actionOptions),
|
|
52
|
-
downloadAction: (0, _extractDownloadAction.extractDownloadAction)(data, actionOptions),
|
|
53
49
|
latestCommit: (0, _latestCommit.extractLatestCommit)(data),
|
|
54
50
|
linkIcon: (0, _icon.extractLinkIcon)(response, renderers),
|
|
55
51
|
location: (0, _utils.extractLocation)(data),
|
|
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
22
22
|
var context = exports.context = {
|
|
23
23
|
componentName: 'smart-cards',
|
|
24
24
|
packageName: "@atlaskit/smart-card",
|
|
25
|
-
packageVersion: "26.
|
|
25
|
+
packageVersion: "26.52.0"
|
|
26
26
|
};
|
|
27
27
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
28
28
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -49,7 +49,6 @@ var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
|
|
|
49
49
|
};
|
|
50
50
|
}, []);
|
|
51
51
|
return /*#__PURE__*/_react.default.createElement(_unresolvedView.default, (0, _extends2.default)({}, props, {
|
|
52
|
-
showPreview: true,
|
|
53
52
|
testId: testId,
|
|
54
53
|
title: title
|
|
55
54
|
}), /*#__PURE__*/_react.default.createElement(_lock.default, {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _utils = require("../../../../../utils");
|
|
15
|
+
var _reactIntlNext = require("react-intl-next");
|
|
16
|
+
var _constants = require("../../../../../constants");
|
|
17
|
+
var _messages = require("../../../../../messages");
|
|
18
|
+
var _action = _interopRequireDefault(require("../action"));
|
|
19
|
+
var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
|
|
20
|
+
var _useInvokeClientAction = _interopRequireDefault(require("../../../../../state/hooks/use-invoke-client-action"));
|
|
21
|
+
var _download = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
|
|
22
|
+
var _excluded = ["onClick"];
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
|
+
var DownloadAction = function DownloadAction(_ref) {
|
|
26
|
+
var _context$actions;
|
|
27
|
+
var onClickCallback = _ref.onClick,
|
|
28
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
29
|
+
var context = (0, _flexibleUiContext.useFlexibleUiContext)();
|
|
30
|
+
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)();
|
|
31
|
+
var invoke = (0, _useInvokeClientAction.default)({
|
|
32
|
+
analytics: analytics
|
|
33
|
+
});
|
|
34
|
+
var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[_constants.ActionName.DownloadAction];
|
|
35
|
+
var onClick = (0, _react.useCallback)(function () {
|
|
36
|
+
if (data !== null && data !== void 0 && data.downloadUrl) {
|
|
37
|
+
invoke({
|
|
38
|
+
actionType: _constants.ActionName.DownloadAction,
|
|
39
|
+
actionFn: function () {
|
|
40
|
+
var _actionFn = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
41
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
return _context.abrupt("return", (0, _utils.downloadUrl)(data === null || data === void 0 ? void 0 : data.downloadUrl));
|
|
45
|
+
case 1:
|
|
46
|
+
case "end":
|
|
47
|
+
return _context.stop();
|
|
48
|
+
}
|
|
49
|
+
}, _callee);
|
|
50
|
+
}));
|
|
51
|
+
function actionFn() {
|
|
52
|
+
return _actionFn.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
return actionFn;
|
|
55
|
+
}(),
|
|
56
|
+
// These values have already been set in analytics context.
|
|
57
|
+
// We only pass these here for ufo experience.
|
|
58
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
59
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
60
|
+
});
|
|
61
|
+
if (onClickCallback) {
|
|
62
|
+
onClickCallback();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, [analytics, data === null || data === void 0 ? void 0 : data.downloadUrl, invoke, onClickCallback]);
|
|
66
|
+
return data ? /*#__PURE__*/_react.default.createElement(_action.default, (0, _extends2.default)({
|
|
67
|
+
content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.download),
|
|
68
|
+
icon: /*#__PURE__*/_react.default.createElement(_download.default, {
|
|
69
|
+
label: "Download"
|
|
70
|
+
}),
|
|
71
|
+
onClick: onClick,
|
|
72
|
+
testId: "smart-action-download-action",
|
|
73
|
+
tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.download)
|
|
74
|
+
}, data, props)) : null;
|
|
75
|
+
};
|
|
76
|
+
var _default = exports.default = DownloadAction;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,23 +8,23 @@ exports.default = void 0;
|
|
|
9
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
10
|
var _inviteTeam = _interopRequireDefault(require("@atlaskit/icon/glyph/invite-team"));
|
|
12
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
12
|
var _reactIntlNext = require("react-intl-next");
|
|
13
|
+
var _constants = require("../../../../../constants");
|
|
14
14
|
var _messages = require("../../../../../messages");
|
|
15
15
|
var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
|
|
16
16
|
var _serverAction = _interopRequireDefault(require("../action/server-action"));
|
|
17
17
|
var _unfollowIcon = _interopRequireDefault(require("./unfollow-icon"));
|
|
18
18
|
var _excluded = ["value"];
|
|
19
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
19
|
var FollowAction = function FollowAction(props) {
|
|
22
|
-
var
|
|
23
|
-
|
|
20
|
+
var _context$actions, _context$actions2;
|
|
21
|
+
var context = (0, _flexibleUiContext.useFlexibleUiContext)();
|
|
22
|
+
if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[_constants.ActionName.FollowAction])) {
|
|
24
23
|
return null;
|
|
25
24
|
}
|
|
26
|
-
var _context$
|
|
27
|
-
value = _context$
|
|
28
|
-
data = (0, _objectWithoutProperties2.default)(_context$
|
|
25
|
+
var _context$actions$Acti = context === null || context === void 0 || (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[_constants.ActionName.FollowAction],
|
|
26
|
+
value = _context$actions$Acti.value,
|
|
27
|
+
data = (0, _objectWithoutProperties2.default)(_context$actions$Acti, _excluded);
|
|
29
28
|
var message = value ? _messages.messages.follow : _messages.messages.unfollow;
|
|
30
29
|
var icon = value ? /*#__PURE__*/_react.default.createElement(_inviteTeam.default, {
|
|
31
30
|
label: "Follow"
|
|
@@ -4,7 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.DeleteAction = exports.CustomAction = void 0;
|
|
8
|
+
Object.defineProperty(exports, "DownloadAction", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _downloadAction.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
exports.EditAction = void 0;
|
|
8
15
|
Object.defineProperty(exports, "FollowAction", {
|
|
9
16
|
enumerable: true,
|
|
10
17
|
get: function get() {
|
|
@@ -22,6 +29,7 @@ var _constants = require("../../../../constants");
|
|
|
22
29
|
var _utils = require("./utils");
|
|
23
30
|
var _followAction = _interopRequireDefault(require("./follow-action"));
|
|
24
31
|
var _previewAction = _interopRequireDefault(require("./preview-action"));
|
|
32
|
+
var _downloadAction = _interopRequireDefault(require("./download-action"));
|
|
25
33
|
/**
|
|
26
34
|
* Creates a DeleteAction component. Accepts default ActionProps, but defaults
|
|
27
35
|
* the icon to a cross icon.
|
|
@@ -42,13 +50,6 @@ var EditAction = exports.EditAction = (0, _utils.createUIAction)(_constants.Acti
|
|
|
42
50
|
*/
|
|
43
51
|
var ViewAction = exports.ViewAction = (0, _utils.createDataAction)(_constants.ActionName.ViewAction);
|
|
44
52
|
|
|
45
|
-
/**
|
|
46
|
-
* Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
|
|
47
|
-
* to the text 'Download' inside the button.
|
|
48
|
-
* @see Action
|
|
49
|
-
*/
|
|
50
|
-
var DownloadAction = exports.DownloadAction = (0, _utils.createDataAction)(_constants.ActionName.DownloadAction);
|
|
51
|
-
|
|
52
53
|
/**
|
|
53
54
|
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
54
55
|
* your own icon or text.
|
|
@@ -19,8 +19,6 @@ var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
|
|
|
19
19
|
var _edit = _interopRequireDefault(require("@atlaskit/icon/glyph/edit"));
|
|
20
20
|
var _viewAction = _interopRequireDefault(require("./action/view-action"));
|
|
21
21
|
var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
|
|
22
|
-
var _downloadAction = _interopRequireDefault(require("./action/download-action"));
|
|
23
|
-
var _download = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
|
|
24
22
|
var _actionMappings;
|
|
25
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
26
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -59,16 +57,6 @@ var actionMappings = (_actionMappings = {}, (0, _defineProperty2.default)(_actio
|
|
|
59
57
|
}),
|
|
60
58
|
tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.view)
|
|
61
59
|
}
|
|
62
|
-
}), (0, _defineProperty2.default)(_actionMappings, _constants.ActionName.DownloadAction, {
|
|
63
|
-
component: _downloadAction.default,
|
|
64
|
-
props: {
|
|
65
|
-
testId: 'smart-action-download-action',
|
|
66
|
-
content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.download),
|
|
67
|
-
icon: /*#__PURE__*/_react.default.createElement(_download.default, {
|
|
68
|
-
label: "Download"
|
|
69
|
-
}),
|
|
70
|
-
tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.download)
|
|
71
|
-
}
|
|
72
60
|
}), _actionMappings);
|
|
73
61
|
var getContextKey = function getContextKey(name) {
|
|
74
62
|
// Attempt to predict context prop name in advance to reduce the amount of
|
|
@@ -82,7 +70,6 @@ var getActionData = function getActionData(actionName, contextKey, context) {
|
|
|
82
70
|
var data = context[contextKey];
|
|
83
71
|
switch (actionName) {
|
|
84
72
|
case _constants.ActionName.ViewAction:
|
|
85
|
-
case _constants.ActionName.DownloadAction:
|
|
86
73
|
return data;
|
|
87
74
|
default:
|
|
88
75
|
return undefined;
|
|
@@ -5,10 +5,9 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.AISummaryBlockStatusIndicator = exports.AISummaryBlockErrorIndicator = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
12
|
var _reactIntlNext = require("react-intl-next");
|
|
14
13
|
var _primitives = require("@atlaskit/primitives");
|
|
@@ -26,18 +25,46 @@ var _aiSummary = _interopRequireDefault(require("../../../../../common/ai-summar
|
|
|
26
25
|
var _useAnalyticsEvents2 = require("../../../../../../common/analytics/generated/use-analytics-events");
|
|
27
26
|
var _aiEventSummaryViewed = _interopRequireDefault(require("../ai-event-summary-viewed"));
|
|
28
27
|
var _aiEventErrorViewed = _interopRequireDefault(require("../ai-event-error-viewed"));
|
|
28
|
+
var _reactMagneticDi = require("react-magnetic-di");
|
|
29
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
30
30
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
31
|
+
var AISummaryBlockErrorIndicator = exports.AISummaryBlockErrorIndicator = function AISummaryBlockErrorIndicator(_ref) {
|
|
32
|
+
var showErrorIndicator = _ref.showErrorIndicator,
|
|
33
|
+
error = _ref.error,
|
|
34
|
+
testId = _ref.testId;
|
|
35
|
+
return showErrorIndicator ? /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
36
|
+
grow: "fill"
|
|
37
|
+
}, /*#__PURE__*/_react.default.createElement(_aiEventErrorViewed.default, {
|
|
38
|
+
reason: error
|
|
39
|
+
}), /*#__PURE__*/_react.default.createElement(_aiStateIndicator.default, {
|
|
40
|
+
error: error,
|
|
41
|
+
state: 'error',
|
|
42
|
+
testId: testId
|
|
43
|
+
})) : null;
|
|
44
|
+
};
|
|
45
|
+
var AISummaryBlockStatusIndicator = exports.AISummaryBlockStatusIndicator = function AISummaryBlockStatusIndicator(_ref2) {
|
|
46
|
+
var showStatusIndicator = _ref2.showStatusIndicator,
|
|
47
|
+
metadata = _ref2.metadata,
|
|
48
|
+
status = _ref2.status,
|
|
49
|
+
testId = _ref2.testId;
|
|
50
|
+
var metadataElements = (0, _utils.renderElementItems)(metadata);
|
|
51
|
+
return showStatusIndicator ? /*#__PURE__*/_react.default.createElement(_aiStateIndicator.default, {
|
|
52
|
+
state: status,
|
|
53
|
+
testId: "".concat(testId, "-state-indicator")
|
|
54
|
+
}) : /*#__PURE__*/_react.default.createElement(_elementGroup.default, {
|
|
55
|
+
width: _constants.SmartLinkWidth.FitToContent,
|
|
56
|
+
testId: "".concat(testId, "-metadata-group")
|
|
57
|
+
}, metadataElements);
|
|
58
|
+
};
|
|
31
59
|
var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
32
60
|
var _props$actions = props.actions,
|
|
33
61
|
actions = _props$actions === void 0 ? [] : _props$actions,
|
|
34
|
-
metadata = props.metadata,
|
|
35
62
|
onActionMenuOpenChange = props.onActionMenuOpenChange,
|
|
36
63
|
_props$size = props.size,
|
|
37
64
|
size = _props$size === void 0 ? _constants.SmartLinkSize.Medium : _props$size,
|
|
38
65
|
testId = props.testId,
|
|
39
|
-
aiSummaryMinHeight = props.aiSummaryMinHeight
|
|
40
|
-
|
|
66
|
+
aiSummaryMinHeight = props.aiSummaryMinHeight,
|
|
67
|
+
metadata = props.metadata;
|
|
41
68
|
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
|
|
42
69
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
43
70
|
var context = (0, _flexibleUiContext.useFlexibleUiContext)();
|
|
@@ -57,18 +84,11 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
|
57
84
|
status === 'loading' && !!content;
|
|
58
85
|
var isSummarisedOnMountRef = (0, _react.useRef)(status === 'done');
|
|
59
86
|
var isErroredOnMountRef = (0, _react.useRef)(status === 'error');
|
|
60
|
-
var _useState = (0, _react.useState)(false),
|
|
61
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
62
|
-
showAISummaryErrorMessage = _useState2[0],
|
|
63
|
-
setShowAISummaryErrorMessage = _useState2[1];
|
|
64
87
|
(0, _react.useEffect)(function () {
|
|
65
88
|
// if the error was apparent on mount and the status is changed to loading we can
|
|
66
89
|
// clear the initial error on mount state
|
|
67
90
|
if (isErroredOnMountRef.current && status === 'loading') {
|
|
68
91
|
isErroredOnMountRef.current = false;
|
|
69
|
-
} else {
|
|
70
|
-
// if a new error occurs and it was not an apparent error on mount, we can show the error message
|
|
71
|
-
setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
|
|
72
92
|
}
|
|
73
93
|
}, [status]);
|
|
74
94
|
var combinedActions = (0, _react.useMemo)(function () {
|
|
@@ -111,25 +131,20 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
|
111
131
|
alignInline: "end",
|
|
112
132
|
grow: "fill",
|
|
113
133
|
spread: "space-between"
|
|
114
|
-
}, /*#__PURE__*/_react.default.createElement(_primitives.Box, null,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}, metadataElements)), /*#__PURE__*/_react.default.createElement(_primitives.Box, null, /*#__PURE__*/_react.default.createElement(_actionGroup.default, {
|
|
134
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Box, null, /*#__PURE__*/_react.default.createElement(AISummaryBlockStatusIndicator, {
|
|
135
|
+
metadata: metadata,
|
|
136
|
+
showStatusIndicator: !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done'),
|
|
137
|
+
status: status,
|
|
138
|
+
testId: testId
|
|
139
|
+
})), /*#__PURE__*/_react.default.createElement(_primitives.Box, null, /*#__PURE__*/_react.default.createElement(_actionGroup.default, {
|
|
121
140
|
onDropdownOpenChange: onDropdownOpenChange,
|
|
122
141
|
items: combinedActions,
|
|
123
142
|
appearance: "default",
|
|
124
143
|
size: size
|
|
125
|
-
}))),
|
|
126
|
-
|
|
127
|
-
}, /*#__PURE__*/_react.default.createElement(_aiEventErrorViewed.default, {
|
|
128
|
-
reason: error
|
|
129
|
-
}), /*#__PURE__*/_react.default.createElement(_aiStateIndicator.default, {
|
|
144
|
+
}))), /*#__PURE__*/_react.default.createElement(AISummaryBlockErrorIndicator, {
|
|
145
|
+
showErrorIndicator: !isErroredOnMountRef.current && status === 'error',
|
|
130
146
|
error: error,
|
|
131
|
-
state: status,
|
|
132
147
|
testId: testId
|
|
133
|
-
}))
|
|
148
|
+
}));
|
|
134
149
|
};
|
|
135
150
|
var _default = exports.default = AISummaryBlockResolvedView;
|
|
@@ -108,14 +108,6 @@ var filterActionItems = exports.filterActionItems = function filterActionItems()
|
|
|
108
108
|
case _constants.ActionName.CustomAction:
|
|
109
109
|
// Named and custom actions that user defines.
|
|
110
110
|
return Boolean(_constants.ActionName[item.name]);
|
|
111
|
-
case _constants.ActionName.DownloadAction:
|
|
112
|
-
// Remove once DownloadAction is refactored to context.action
|
|
113
|
-
// https://product-fabric.atlassian.net/browse/EDM-9545
|
|
114
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
|
|
115
|
-
// Remove once FollowAction is refactored to context.action
|
|
116
|
-
// https://product-fabric.atlassian.net/browse/EDM-9559
|
|
117
|
-
case _constants.ActionName.FollowAction:
|
|
118
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
|
|
119
111
|
// Remove once ViewAction is retired
|
|
120
112
|
// https://product-fabric.atlassian.net/browse/EDM-9547
|
|
121
113
|
case _constants.ActionName.ViewAction:
|
|
@@ -17,6 +17,7 @@ var _HoverCardContent = require("./HoverCardContent");
|
|
|
17
17
|
var _useAiSummary = require("../../../state/hooks/use-ai-summary");
|
|
18
18
|
var _store = require("../../../state/store");
|
|
19
19
|
var _linkExtractors = require("@atlaskit/link-extractors");
|
|
20
|
+
var _reactMagneticDi = require("react-magnetic-di");
|
|
20
21
|
var _excluded = ["children", "isAIEnabled", "testId", "url"],
|
|
21
22
|
_excluded2 = ["children", "isAIEnabled", "testId", "url"];
|
|
22
23
|
/** @jsx jsx */
|
|
@@ -22,6 +22,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
22
22
|
var _helpers = require("../../../../../state/helpers");
|
|
23
23
|
var _useAiSummary = require("../../../../../state/hooks/use-ai-summary");
|
|
24
24
|
var _linkExtractors = require("@atlaskit/link-extractors");
|
|
25
|
+
var _reactMagneticDi = require("react-magnetic-di");
|
|
25
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
26
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
28
|
var toFooterActions = exports.toFooterActions = function toFooterActions(cardActions, onActionClick) {
|
|
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
|
|
|
17
17
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
18
18
|
var PACKAGE_DATA = {
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "26.
|
|
20
|
+
packageVersion: "26.52.0",
|
|
21
21
|
componentName: 'linkUrl'
|
|
22
22
|
};
|
|
23
23
|
var Link = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { ActionName } from '../../../constants';
|
|
2
|
+
import { extractDownloadAction } from './extract-download-action';
|
|
2
3
|
import { extractPreviewAction } from './extract-preview-action';
|
|
3
|
-
|
|
4
|
+
import extractFollowAction from './extract-follow-action';
|
|
5
|
+
const extractActions = (response, data, actionOptions, id) => {
|
|
4
6
|
const action = {
|
|
5
|
-
[ActionName.PreviewAction]: extractPreviewAction(response, actionOptions)
|
|
7
|
+
[ActionName.PreviewAction]: extractPreviewAction(response, actionOptions),
|
|
8
|
+
[ActionName.DownloadAction]: extractDownloadAction(data, actionOptions),
|
|
9
|
+
[ActionName.FollowAction]: extractFollowAction(response, actionOptions, id)
|
|
6
10
|
};
|
|
7
11
|
return Object.values(action).some(value => Boolean(value)) ? action : undefined;
|
|
8
12
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { extractSummary } from '../common/primitives';
|
|
2
2
|
import extractActions from './actions';
|
|
3
|
-
import extractFollowAction from './actions/extract-follow-action';
|
|
4
3
|
import { extractLinkIcon } from './icon';
|
|
5
4
|
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
|
|
6
5
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
@@ -10,7 +9,6 @@ import extractProviderIcon from './icon/extract-provider-icon';
|
|
|
10
9
|
import extractPreview from './extract-preview';
|
|
11
10
|
import extractState from './extract-state';
|
|
12
11
|
import { extractLatestCommit } from './latest-commit';
|
|
13
|
-
import { extractDownloadAction } from './actions/extract-download-action';
|
|
14
12
|
import { extractViewAction } from './actions/extract-view-action';
|
|
15
13
|
const extractFlexibleUiContext = ({
|
|
16
14
|
id,
|
|
@@ -24,7 +22,7 @@ const extractFlexibleUiContext = ({
|
|
|
24
22
|
const data = response.data;
|
|
25
23
|
const url = extractLink(data);
|
|
26
24
|
return {
|
|
27
|
-
actions: extractActions(response, actionOptions),
|
|
25
|
+
actions: extractActions(response, data, actionOptions, id),
|
|
28
26
|
assignedToGroup: extractPersonAssignedToAsArray(data),
|
|
29
27
|
attachmentCount: extractAttachmentCount(data),
|
|
30
28
|
authorGroup: extractPersonCreatedBy(data),
|
|
@@ -40,9 +38,7 @@ const extractFlexibleUiContext = ({
|
|
|
40
38
|
assignedTo: extractAssignedTo(data),
|
|
41
39
|
createdOn: extractDateCreated(data),
|
|
42
40
|
dueOn: extractDueOn(data),
|
|
43
|
-
followAction: extractFollowAction(response, actionOptions, id),
|
|
44
41
|
viewAction: extractViewAction(data, actionOptions),
|
|
45
|
-
downloadAction: extractDownloadAction(data, actionOptions),
|
|
46
42
|
latestCommit: extractLatestCommit(data),
|
|
47
43
|
linkIcon: extractLinkIcon(response, renderers),
|
|
48
44
|
location: extractLocation(data),
|
|
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export const context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "26.
|
|
7
|
+
packageVersion: "26.52.0"
|
|
8
8
|
};
|
|
9
9
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -36,7 +36,6 @@ const FlexibleNotFoundView = ({
|
|
|
36
36
|
descriptor: messages.not_found_description
|
|
37
37
|
}), []);
|
|
38
38
|
return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
|
|
39
|
-
showPreview: true,
|
|
40
39
|
testId: testId,
|
|
41
40
|
title: title
|
|
42
41
|
}), /*#__PURE__*/React.createElement(LockIcon, {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { downloadUrl as download } from '../../../../../utils';
|
|
4
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { ActionName } from '../../../../../constants';
|
|
6
|
+
import { messages } from '../../../../../messages';
|
|
7
|
+
import Action from '../action';
|
|
8
|
+
import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
9
|
+
import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
|
|
10
|
+
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
11
|
+
const DownloadAction = ({
|
|
12
|
+
onClick: onClickCallback,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
var _context$actions;
|
|
16
|
+
const context = useFlexibleUiContext();
|
|
17
|
+
const analytics = useFlexibleUiAnalyticsContext();
|
|
18
|
+
const invoke = useInvokeClientAction({
|
|
19
|
+
analytics
|
|
20
|
+
});
|
|
21
|
+
const data = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
|
|
22
|
+
const onClick = useCallback(() => {
|
|
23
|
+
if (data !== null && data !== void 0 && data.downloadUrl) {
|
|
24
|
+
invoke({
|
|
25
|
+
actionType: ActionName.DownloadAction,
|
|
26
|
+
actionFn: async () => download(data === null || data === void 0 ? void 0 : data.downloadUrl),
|
|
27
|
+
// These values have already been set in analytics context.
|
|
28
|
+
// We only pass these here for ufo experience.
|
|
29
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
30
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
31
|
+
});
|
|
32
|
+
if (onClickCallback) {
|
|
33
|
+
onClickCallback();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [analytics, data === null || data === void 0 ? void 0 : data.downloadUrl, invoke, onClickCallback]);
|
|
37
|
+
return data ? /*#__PURE__*/React.createElement(Action, _extends({
|
|
38
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
|
|
39
|
+
icon: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
40
|
+
label: "Download"
|
|
41
|
+
}),
|
|
42
|
+
onClick: onClick,
|
|
43
|
+
testId: "smart-action-download-action",
|
|
44
|
+
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
|
|
45
|
+
}, data, props)) : null;
|
|
46
|
+
};
|
|
47
|
+
export default DownloadAction;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
|
|
3
|
-
import React
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { ActionName } from '../../../../../constants';
|
|
5
6
|
import { messages } from '../../../../../messages';
|
|
6
|
-
import {
|
|
7
|
+
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
7
8
|
import ServerAction from '../action/server-action';
|
|
8
9
|
import UnfollowIcon from './unfollow-icon';
|
|
9
10
|
const FollowAction = props => {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var _context$actions, _context$actions2;
|
|
12
|
+
const context = useFlexibleUiContext();
|
|
13
|
+
if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
|
|
12
14
|
return null;
|
|
13
15
|
}
|
|
14
16
|
const {
|
|
15
17
|
value,
|
|
16
18
|
...data
|
|
17
|
-
} = context.
|
|
19
|
+
} = context === null || context === void 0 ? void 0 : (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction];
|
|
18
20
|
const message = value ? messages.follow : messages.unfollow;
|
|
19
21
|
const icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
|
|
20
22
|
label: "Follow"
|
|
@@ -2,6 +2,7 @@ import { ActionName } from '../../../../constants';
|
|
|
2
2
|
import { createDataAction, createUIAction } from './utils';
|
|
3
3
|
export { default as FollowAction } from './follow-action';
|
|
4
4
|
export { default as PreviewAction } from './preview-action';
|
|
5
|
+
export { default as DownloadAction } from './download-action';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a DeleteAction component. Accepts default ActionProps, but defaults
|
|
@@ -23,13 +24,6 @@ export const EditAction = createUIAction(ActionName.EditAction);
|
|
|
23
24
|
*/
|
|
24
25
|
export const ViewAction = createDataAction(ActionName.ViewAction);
|
|
25
26
|
|
|
26
|
-
/**
|
|
27
|
-
* Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
|
|
28
|
-
* to the text 'Download' inside the button.
|
|
29
|
-
* @see Action
|
|
30
|
-
*/
|
|
31
|
-
export const DownloadAction = createDataAction(ActionName.DownloadAction);
|
|
32
|
-
|
|
33
27
|
/**
|
|
34
28
|
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
35
29
|
* your own icon or text.
|