@atlaskit/smart-card 26.53.0 → 26.55.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/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/index.js +16 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +0 -3
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +4 -3
- package/dist/cjs/view/EmbedModal/index.js +3 -3
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +1 -10
- package/dist/cjs/view/FlexibleCard/components/blocks/action-block/index.js +2 -10
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +2 -10
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +4 -6
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/index.js +15 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +0 -3
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +4 -4
- package/dist/es2019/view/EmbedModal/index.js +4 -5
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -10
- package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +2 -10
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +2 -10
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +4 -6
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/index.js +15 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +0 -3
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +4 -3
- package/dist/esm/view/EmbedModal/index.js +4 -4
- package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -10
- package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +2 -10
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +2 -10
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +4 -6
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +0 -8
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +7 -1
- package/dist/types-ts4.5/constants.d.ts +3 -0
- package/dist/types-ts4.5/utils/index.d.ts +7 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +0 -8
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +7 -1
- package/package.json +4 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +0 -72
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/types.js +0 -5
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -64
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +0 -47
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/types.js +0 -1
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -55
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +0 -65
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/types.js +0 -1
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -54
- package/dist/types/view/FlexibleCard/components/actions/action/view-action/index.d.ts +0 -4
- package/dist/types/view/FlexibleCard/components/actions/action/view-action/types.d.ts +0 -5
- package/dist/types/view/FlexibleCard/components/actions/utils.d.ts +0 -3
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/view-action/index.d.ts +0 -4
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/view-action/types.d.ts +0 -5
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/utils.d.ts +0 -3
|
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
|
|
|
10
10
|
import LinkWarningModal from './LinkWarningModal';
|
|
11
11
|
var PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "26.
|
|
13
|
+
packageVersion: "26.55.0",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -131,6 +131,9 @@ export declare enum ActionName {
|
|
|
131
131
|
EditAction = "EditAction",
|
|
132
132
|
FollowAction = "FollowAction",
|
|
133
133
|
PreviewAction = "PreviewAction",
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-8954 Internal documentation for deprecation (no external access)}
|
|
136
|
+
*/
|
|
134
137
|
ViewAction = "ViewAction",
|
|
135
138
|
DownloadAction = "DownloadAction",
|
|
136
139
|
CustomAction = "CustomAction"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CardProps } from '../view/Card';
|
|
3
3
|
import { FrameStyle } from '../view/EmbedCard/types';
|
|
4
|
+
import { ActiveThemeState } from '@atlaskit/tokens/src/theme-config';
|
|
4
5
|
export declare const isCardWithData: (props: CardProps) => boolean;
|
|
5
6
|
export declare const isSpecialEvent: (evt: React.MouseEvent | React.KeyboardEvent) => boolean;
|
|
6
7
|
export declare const isIframe: () => boolean;
|
|
@@ -29,3 +30,9 @@ export declare const openUrl: (url?: string) => Promise<void>;
|
|
|
29
30
|
* This function is to be removed on deprecation of isFrameVisible.
|
|
30
31
|
*/
|
|
31
32
|
export declare const combineFrameStyle: (frameStyle?: CardProps['frameStyle'], isFrameVisible?: CardProps['isFrameVisible']) => FrameStyle | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Append a theme to the URL if it exists
|
|
35
|
+
* @param previewUrl
|
|
36
|
+
* @param themeState
|
|
37
|
+
*/
|
|
38
|
+
export declare const getPreviewUrlWithTheme: (previewUrl: string, themeState: Partial<ActiveThemeState>) => string;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ViewActionProps } from './action/view-action/types';
|
|
3
1
|
export { default as CustomAction } from './action';
|
|
4
2
|
export { default as DeleteAction } from './delete-action';
|
|
5
3
|
export { default as EditAction } from './edit-action';
|
|
6
4
|
export { default as DownloadAction } from './download-action';
|
|
7
5
|
export { default as FollowAction } from './follow-action';
|
|
8
6
|
export { default as PreviewAction } from './preview-action';
|
|
9
|
-
/**
|
|
10
|
-
* Creates a ViewAction component. Accepts default ViewActionProps, and defaults
|
|
11
|
-
* to the text 'View' inside the button.
|
|
12
|
-
* @see Action
|
|
13
|
-
*/
|
|
14
|
-
export declare const ViewAction: import("react").FC<ViewActionProps>;
|
|
@@ -161,7 +161,13 @@ export type BaseDataActionItem = {
|
|
|
161
161
|
* renders a preview modal when clicked.
|
|
162
162
|
*/
|
|
163
163
|
export type NamedDataActionItem = BaseDataActionItem & {
|
|
164
|
-
name: ActionName.FollowAction | ActionName.PreviewAction | ActionName.DownloadAction
|
|
164
|
+
name: ActionName.FollowAction | ActionName.PreviewAction | ActionName.DownloadAction
|
|
165
|
+
/**
|
|
166
|
+
* To be removed once ActionName.ViewAction is retired
|
|
167
|
+
* Currently left in to maintain backwards compatibility with public API
|
|
168
|
+
* https://product-fabric.atlassian.net/browse/EDM-9665
|
|
169
|
+
*/
|
|
170
|
+
| ActionName.ViewAction;
|
|
165
171
|
};
|
|
166
172
|
/**
|
|
167
173
|
* This represents an action that does not fetch data where Icon and Content are provided implicitly.
|
|
@@ -131,6 +131,9 @@ export declare enum ActionName {
|
|
|
131
131
|
EditAction = "EditAction",
|
|
132
132
|
FollowAction = "FollowAction",
|
|
133
133
|
PreviewAction = "PreviewAction",
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-8954 Internal documentation for deprecation (no external access)}
|
|
136
|
+
*/
|
|
134
137
|
ViewAction = "ViewAction",
|
|
135
138
|
DownloadAction = "DownloadAction",
|
|
136
139
|
CustomAction = "CustomAction"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CardProps } from '../view/Card';
|
|
3
3
|
import { FrameStyle } from '../view/EmbedCard/types';
|
|
4
|
+
import { ActiveThemeState } from '@atlaskit/tokens/src/theme-config';
|
|
4
5
|
export declare const isCardWithData: (props: CardProps) => boolean;
|
|
5
6
|
export declare const isSpecialEvent: (evt: React.MouseEvent | React.KeyboardEvent) => boolean;
|
|
6
7
|
export declare const isIframe: () => boolean;
|
|
@@ -29,3 +30,9 @@ export declare const openUrl: (url?: string) => Promise<void>;
|
|
|
29
30
|
* This function is to be removed on deprecation of isFrameVisible.
|
|
30
31
|
*/
|
|
31
32
|
export declare const combineFrameStyle: (frameStyle?: CardProps['frameStyle'], isFrameVisible?: CardProps['isFrameVisible']) => FrameStyle | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Append a theme to the URL if it exists
|
|
35
|
+
* @param previewUrl
|
|
36
|
+
* @param themeState
|
|
37
|
+
*/
|
|
38
|
+
export declare const getPreviewUrlWithTheme: (previewUrl: string, themeState: Partial<ActiveThemeState>) => string;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ViewActionProps } from './action/view-action/types';
|
|
3
1
|
export { default as CustomAction } from './action';
|
|
4
2
|
export { default as DeleteAction } from './delete-action';
|
|
5
3
|
export { default as EditAction } from './edit-action';
|
|
6
4
|
export { default as DownloadAction } from './download-action';
|
|
7
5
|
export { default as FollowAction } from './follow-action';
|
|
8
6
|
export { default as PreviewAction } from './preview-action';
|
|
9
|
-
/**
|
|
10
|
-
* Creates a ViewAction component. Accepts default ViewActionProps, and defaults
|
|
11
|
-
* to the text 'View' inside the button.
|
|
12
|
-
* @see Action
|
|
13
|
-
*/
|
|
14
|
-
export declare const ViewAction: import("react").FC<ViewActionProps>;
|
|
@@ -161,7 +161,13 @@ export type BaseDataActionItem = {
|
|
|
161
161
|
* renders a preview modal when clicked.
|
|
162
162
|
*/
|
|
163
163
|
export type NamedDataActionItem = BaseDataActionItem & {
|
|
164
|
-
name: ActionName.FollowAction | ActionName.PreviewAction | ActionName.DownloadAction
|
|
164
|
+
name: ActionName.FollowAction | ActionName.PreviewAction | ActionName.DownloadAction
|
|
165
|
+
/**
|
|
166
|
+
* To be removed once ActionName.ViewAction is retired
|
|
167
|
+
* Currently left in to maintain backwards compatibility with public API
|
|
168
|
+
* https://product-fabric.atlassian.net/browse/EDM-9665
|
|
169
|
+
*/
|
|
170
|
+
| ActionName.ViewAction;
|
|
165
171
|
};
|
|
166
172
|
/**
|
|
167
173
|
* This represents an action that does not fetch data where Icon and Content are provided implicitly.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.55.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -169,6 +169,9 @@
|
|
|
169
169
|
},
|
|
170
170
|
"platform.linking-platform.smart-card.hover-card-action-redesign": {
|
|
171
171
|
"type": "boolean"
|
|
172
|
+
},
|
|
173
|
+
"platform.linking-platform.smart-card.enable-theme-state-url": {
|
|
174
|
+
"type": "boolean"
|
|
172
175
|
}
|
|
173
176
|
},
|
|
174
177
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
var _index = _interopRequireDefault(require("../index"));
|
|
14
|
-
var _utils = require("../../../../../../utils");
|
|
15
|
-
var _constants = require("../../../../../../constants");
|
|
16
|
-
var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
|
|
17
|
-
var _useInvokeClientAction = _interopRequireDefault(require("../../../../../../state/hooks/use-invoke-client-action"));
|
|
18
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
var ViewAction = function ViewAction(props) {
|
|
21
|
-
var appearance = props.appearance,
|
|
22
|
-
asDropDownItem = props.asDropDownItem,
|
|
23
|
-
testId = props.testId,
|
|
24
|
-
_onClick = props.onClick,
|
|
25
|
-
viewUrl = props.viewUrl,
|
|
26
|
-
url = props.url;
|
|
27
|
-
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)();
|
|
28
|
-
var invoke = (0, _useInvokeClientAction.default)({
|
|
29
|
-
analytics: analytics
|
|
30
|
-
});
|
|
31
|
-
if (viewUrl && url) {
|
|
32
|
-
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
33
|
-
onClick: function onClick() {
|
|
34
|
-
invoke({
|
|
35
|
-
actionType: _constants.ActionName.ViewAction,
|
|
36
|
-
actionFn: function () {
|
|
37
|
-
var _actionFn = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
38
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
39
|
-
while (1) switch (_context.prev = _context.next) {
|
|
40
|
-
case 0:
|
|
41
|
-
return _context.abrupt("return", (0, _utils.openUrl)(viewUrl));
|
|
42
|
-
case 1:
|
|
43
|
-
case "end":
|
|
44
|
-
return _context.stop();
|
|
45
|
-
}
|
|
46
|
-
}, _callee);
|
|
47
|
-
}));
|
|
48
|
-
function actionFn() {
|
|
49
|
-
return _actionFn.apply(this, arguments);
|
|
50
|
-
}
|
|
51
|
-
return actionFn;
|
|
52
|
-
}(),
|
|
53
|
-
// These values have already been set in analytics context.
|
|
54
|
-
// We only pass these here for ufo experience.
|
|
55
|
-
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
56
|
-
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
57
|
-
});
|
|
58
|
-
if (_onClick) {
|
|
59
|
-
_onClick();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement(_index.default, (0, _extends2.default)({}, action, {
|
|
64
|
-
appearance: appearance,
|
|
65
|
-
asDropDownItem: asDropDownItem,
|
|
66
|
-
testId: testId
|
|
67
|
-
}));
|
|
68
|
-
} else {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var _default = exports.default = ViewAction;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createDataAction = void 0;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _constants = require("../../../../constants");
|
|
13
|
-
var _flexibleUiContext = require("../../../../state/flexible-ui-context");
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
var _reactIntlNext = require("react-intl-next");
|
|
16
|
-
var _messages = require("../../../../messages");
|
|
17
|
-
var _viewAction = _interopRequireDefault(require("./action/view-action"));
|
|
18
|
-
var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
|
|
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" != _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; }
|
|
21
|
-
var actionMappings = (0, _defineProperty2.default)({}, _constants.ActionName.ViewAction, {
|
|
22
|
-
component: _viewAction.default,
|
|
23
|
-
props: {
|
|
24
|
-
testId: 'smart-action-view-action',
|
|
25
|
-
content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.view),
|
|
26
|
-
icon: /*#__PURE__*/_react.default.createElement(_shortcut.default, {
|
|
27
|
-
label: "View"
|
|
28
|
-
}),
|
|
29
|
-
tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.view)
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
var getContextKey = function getContextKey(name) {
|
|
33
|
-
// Attempt to predict context prop name in advance to reduce the amount of
|
|
34
|
-
// code run during runtime
|
|
35
|
-
return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
|
|
36
|
-
};
|
|
37
|
-
var getActionData = function getActionData(actionName, contextKey, context) {
|
|
38
|
-
if (!context) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
var data = context[contextKey];
|
|
42
|
-
switch (actionName) {
|
|
43
|
-
case _constants.ActionName.ViewAction:
|
|
44
|
-
return data;
|
|
45
|
-
default:
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var createDataAction = exports.createDataAction = function createDataAction(name) {
|
|
50
|
-
var _ref = actionMappings[name] || {},
|
|
51
|
-
BaseAction = _ref.component,
|
|
52
|
-
props = _ref.props;
|
|
53
|
-
var contextKey = getContextKey(name);
|
|
54
|
-
if (!BaseAction) {
|
|
55
|
-
throw Error("Action ".concat(name, " does not exist."));
|
|
56
|
-
}
|
|
57
|
-
return function (overrides) {
|
|
58
|
-
var context = (0, _react.useContext)(_flexibleUiContext.FlexibleUiContext);
|
|
59
|
-
var data = getActionData(name, contextKey, context);
|
|
60
|
-
return data && (0, _typeof2.default)(data) === 'object' ? /*#__PURE__*/_react.default.createElement(BaseAction, (0, _extends2.default)({}, props, data, overrides, {
|
|
61
|
-
url: context === null || context === void 0 ? void 0 : context.url
|
|
62
|
-
})) : null;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Action from '../index';
|
|
4
|
-
import { openUrl } from '../../../../../../utils';
|
|
5
|
-
import { ActionName } from '../../../../../../constants';
|
|
6
|
-
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
7
|
-
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
8
|
-
const ViewAction = props => {
|
|
9
|
-
const {
|
|
10
|
-
appearance,
|
|
11
|
-
asDropDownItem,
|
|
12
|
-
testId,
|
|
13
|
-
onClick,
|
|
14
|
-
viewUrl,
|
|
15
|
-
url
|
|
16
|
-
} = props;
|
|
17
|
-
const analytics = useFlexibleUiAnalyticsContext();
|
|
18
|
-
const invoke = useInvokeClientAction({
|
|
19
|
-
analytics
|
|
20
|
-
});
|
|
21
|
-
if (viewUrl && url) {
|
|
22
|
-
const action = {
|
|
23
|
-
...props,
|
|
24
|
-
onClick: () => {
|
|
25
|
-
invoke({
|
|
26
|
-
actionType: ActionName.ViewAction,
|
|
27
|
-
actionFn: async () => openUrl(viewUrl),
|
|
28
|
-
// These values have already been set in analytics context.
|
|
29
|
-
// We only pass these here for ufo experience.
|
|
30
|
-
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
31
|
-
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
32
|
-
});
|
|
33
|
-
if (onClick) {
|
|
34
|
-
onClick();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
|
|
39
|
-
appearance: appearance,
|
|
40
|
-
asDropDownItem: asDropDownItem,
|
|
41
|
-
testId: testId
|
|
42
|
-
}));
|
|
43
|
-
} else {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
export default ViewAction;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { ActionName } from '../../../../constants';
|
|
3
|
-
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
4
|
-
import React, { useContext } from 'react';
|
|
5
|
-
import { FormattedMessage } from 'react-intl-next';
|
|
6
|
-
import { messages } from '../../../../messages';
|
|
7
|
-
import ViewAction from './action/view-action';
|
|
8
|
-
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
9
|
-
const actionMappings = {
|
|
10
|
-
[ActionName.ViewAction]: {
|
|
11
|
-
component: ViewAction,
|
|
12
|
-
props: {
|
|
13
|
-
testId: 'smart-action-view-action',
|
|
14
|
-
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.view),
|
|
15
|
-
icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
16
|
-
label: "View"
|
|
17
|
-
}),
|
|
18
|
-
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const getContextKey = name => {
|
|
23
|
-
// Attempt to predict context prop name in advance to reduce the amount of
|
|
24
|
-
// code run during runtime
|
|
25
|
-
return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
|
|
26
|
-
};
|
|
27
|
-
const getActionData = (actionName, contextKey, context) => {
|
|
28
|
-
if (!context) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
const data = context[contextKey];
|
|
32
|
-
switch (actionName) {
|
|
33
|
-
case ActionName.ViewAction:
|
|
34
|
-
return data;
|
|
35
|
-
default:
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
export const createDataAction = name => {
|
|
40
|
-
const {
|
|
41
|
-
component: BaseAction,
|
|
42
|
-
props
|
|
43
|
-
} = actionMappings[name] || {};
|
|
44
|
-
const contextKey = getContextKey(name);
|
|
45
|
-
if (!BaseAction) {
|
|
46
|
-
throw Error(`Action ${name} does not exist.`);
|
|
47
|
-
}
|
|
48
|
-
return overrides => {
|
|
49
|
-
const context = useContext(FlexibleUiContext);
|
|
50
|
-
const data = getActionData(name, contextKey, context);
|
|
51
|
-
return data && typeof data === 'object' ? /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides, {
|
|
52
|
-
url: context === null || context === void 0 ? void 0 : context.url
|
|
53
|
-
})) : null;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import Action from '../index';
|
|
9
|
-
import { openUrl } from '../../../../../../utils';
|
|
10
|
-
import { ActionName } from '../../../../../../constants';
|
|
11
|
-
import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
|
|
12
|
-
import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
|
|
13
|
-
var ViewAction = function ViewAction(props) {
|
|
14
|
-
var appearance = props.appearance,
|
|
15
|
-
asDropDownItem = props.asDropDownItem,
|
|
16
|
-
testId = props.testId,
|
|
17
|
-
_onClick = props.onClick,
|
|
18
|
-
viewUrl = props.viewUrl,
|
|
19
|
-
url = props.url;
|
|
20
|
-
var analytics = useFlexibleUiAnalyticsContext();
|
|
21
|
-
var invoke = useInvokeClientAction({
|
|
22
|
-
analytics: analytics
|
|
23
|
-
});
|
|
24
|
-
if (viewUrl && url) {
|
|
25
|
-
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
26
|
-
onClick: function onClick() {
|
|
27
|
-
invoke({
|
|
28
|
-
actionType: ActionName.ViewAction,
|
|
29
|
-
actionFn: function () {
|
|
30
|
-
var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
31
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
|
-
while (1) switch (_context.prev = _context.next) {
|
|
33
|
-
case 0:
|
|
34
|
-
return _context.abrupt("return", openUrl(viewUrl));
|
|
35
|
-
case 1:
|
|
36
|
-
case "end":
|
|
37
|
-
return _context.stop();
|
|
38
|
-
}
|
|
39
|
-
}, _callee);
|
|
40
|
-
}));
|
|
41
|
-
function actionFn() {
|
|
42
|
-
return _actionFn.apply(this, arguments);
|
|
43
|
-
}
|
|
44
|
-
return actionFn;
|
|
45
|
-
}(),
|
|
46
|
-
// These values have already been set in analytics context.
|
|
47
|
-
// We only pass these here for ufo experience.
|
|
48
|
-
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
49
|
-
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
50
|
-
});
|
|
51
|
-
if (_onClick) {
|
|
52
|
-
_onClick();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
|
|
57
|
-
appearance: appearance,
|
|
58
|
-
asDropDownItem: asDropDownItem,
|
|
59
|
-
testId: testId
|
|
60
|
-
}));
|
|
61
|
-
} else {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
export default ViewAction;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import { ActionName } from '../../../../constants';
|
|
5
|
-
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
6
|
-
import React, { useContext } from 'react';
|
|
7
|
-
import { FormattedMessage } from 'react-intl-next';
|
|
8
|
-
import { messages } from '../../../../messages';
|
|
9
|
-
import ViewAction from './action/view-action';
|
|
10
|
-
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
11
|
-
var actionMappings = _defineProperty({}, ActionName.ViewAction, {
|
|
12
|
-
component: ViewAction,
|
|
13
|
-
props: {
|
|
14
|
-
testId: 'smart-action-view-action',
|
|
15
|
-
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.view),
|
|
16
|
-
icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
17
|
-
label: "View"
|
|
18
|
-
}),
|
|
19
|
-
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
var getContextKey = function getContextKey(name) {
|
|
23
|
-
// Attempt to predict context prop name in advance to reduce the amount of
|
|
24
|
-
// code run during runtime
|
|
25
|
-
return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
|
|
26
|
-
};
|
|
27
|
-
var getActionData = function getActionData(actionName, contextKey, context) {
|
|
28
|
-
if (!context) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
var data = context[contextKey];
|
|
32
|
-
switch (actionName) {
|
|
33
|
-
case ActionName.ViewAction:
|
|
34
|
-
return data;
|
|
35
|
-
default:
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
export var createDataAction = function createDataAction(name) {
|
|
40
|
-
var _ref = actionMappings[name] || {},
|
|
41
|
-
BaseAction = _ref.component,
|
|
42
|
-
props = _ref.props;
|
|
43
|
-
var contextKey = getContextKey(name);
|
|
44
|
-
if (!BaseAction) {
|
|
45
|
-
throw Error("Action ".concat(name, " does not exist."));
|
|
46
|
-
}
|
|
47
|
-
return function (overrides) {
|
|
48
|
-
var context = useContext(FlexibleUiContext);
|
|
49
|
-
var data = getActionData(name, contextKey, context);
|
|
50
|
-
return data && _typeof(data) === 'object' ? /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides, {
|
|
51
|
-
url: context === null || context === void 0 ? void 0 : context.url
|
|
52
|
-
})) : null;
|
|
53
|
-
};
|
|
54
|
-
};
|