@atlaskit/smart-card 23.6.5 → 23.6.7

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 23.6.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9110a0daf0e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9110a0daf0e) - [ux] Added support of different forbidden views for Block Card with Flexible UI
8
+
9
+ ## 23.6.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [`b86cebed4a3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b86cebed4a3) - Hover Preview: Update actionable element hover state
14
+
3
15
  ## 23.6.5
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.5",
3
+ "version": "23.6.7",
4
4
  "sideEffects": false
5
5
  }
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.ForbiddenAction = void 0;
9
9
 
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
10
12
  var _react = _interopRequireDefault(require("react"));
11
13
 
12
14
  var _reactIntlNext = require("react-intl-next");
@@ -19,13 +21,19 @@ var _messages = require("../../../../messages");
19
21
  * Returns a CustomActionItem with a "Try Another Account" default message
20
22
  *
21
23
  * @see CustomActionItem
22
- * @param onAuthorize a function that will be called on the click of the button
24
+ * @param onClick a function that will be called on the click of the button
25
+ * @param content is a message key for a message to be displayed in the action
26
+ * @param context is a variable for a message in case a message contains a placeholder
23
27
  */
24
- var ForbiddenAction = function ForbiddenAction(onAuthorize) {
28
+ var ForbiddenAction = function ForbiddenAction(onClick, content, context) {
25
29
  return {
26
30
  name: _constants.ActionName.CustomAction,
27
- content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.try_another_account),
28
- onClick: onAuthorize
31
+ content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.messages[content], {
32
+ values: {
33
+ context: context
34
+ }
35
+ })),
36
+ onClick: onClick
29
37
  };
30
38
  };
31
39
 
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports.default = void 0;
11
11
 
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
12
14
  var _react = _interopRequireWildcard(require("react"));
13
15
 
14
16
  var _FlexibleCard = _interopRequireDefault(require("../../../FlexibleCard"));
@@ -31,6 +33,12 @@ var _ForbiddenAction = require("../../actions/flexible/ForbiddenAction");
31
33
 
32
34
  var _text = _interopRequireDefault(require("../../../FlexibleCard/components/elements/text"));
33
35
 
36
+ var _jsonld = require("../../../../utils/jsonld");
37
+
38
+ var _extractors = require("@atlaskit/linking-common/extractors");
39
+
40
+ var _context = require("../../../../extractors/common/context");
41
+
34
42
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
43
 
36
44
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -43,6 +51,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
43
51
  * @see FlexibleCardProps
44
52
  */
45
53
  var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
54
+ var _details$meta;
55
+
46
56
  var cardState = _ref.cardState,
47
57
  onAuthorize = _ref.onAuthorize,
48
58
  onClick = _ref.onClick,
@@ -52,9 +62,28 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
52
62
  ui = _ref.ui,
53
63
  url = _ref.url;
54
64
  var status = cardState.status;
65
+ var details = cardState === null || cardState === void 0 ? void 0 : cardState.details;
66
+ var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : (0, _jsonld.getForbiddenJsonLd)().meta;
67
+ var provider = (0, _extractors.extractProvider)(details === null || details === void 0 ? void 0 : details.data);
68
+ var providerName = (provider === null || provider === void 0 ? void 0 : provider.text) || '';
69
+ var requestAccessContext = (0, _context.extractRequestAccessContext)({
70
+ jsonLd: cardMetadata,
71
+ url: url,
72
+ context: providerName
73
+ });
74
+ var descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
55
75
  var actions = (0, _react.useMemo)(function () {
56
- return onAuthorize ? [(0, _ForbiddenAction.ForbiddenAction)(onAuthorize)] : [];
57
- }, [onAuthorize]);
76
+ var actionFromAccessContext = [];
77
+ var tryAnotherAccountAction = onAuthorize ? [(0, _ForbiddenAction.ForbiddenAction)(onAuthorize, 'try_another_account')] : [];
78
+
79
+ if (requestAccessContext) {
80
+ var action = requestAccessContext.action,
81
+ callToActionMessageKey = requestAccessContext.callToActionMessageKey;
82
+ actionFromAccessContext = action && callToActionMessageKey ? [(0, _ForbiddenAction.ForbiddenAction)(action.promise, callToActionMessageKey, providerName)] : [];
83
+ }
84
+
85
+ return [].concat(tryAnotherAccountAction, (0, _toConsumableArray2.default)(actionFromAccessContext));
86
+ }, [onAuthorize, requestAccessContext, providerName]);
58
87
  return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
59
88
  appearance: "block",
60
89
  cardState: cardState,
@@ -73,7 +102,10 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
73
102
  testId: "".concat(testId, "-lock-icon")
74
103
  }), /*#__PURE__*/_react.default.createElement(_text.default, {
75
104
  message: {
76
- descriptor: _messages.messages.invalid_permissions_description
105
+ descriptor: _messages.messages[descriptiveMessageKey],
106
+ values: {
107
+ context: providerName
108
+ }
77
109
  }
78
110
  })), /*#__PURE__*/_react.default.createElement(_blocks.CustomBlock, null, /*#__PURE__*/_react.default.createElement(_footer.default, {
79
111
  actions: actions,
@@ -2,14 +2,18 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.default = void 0;
9
11
 
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
10
14
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
15
 
12
- var _react = _interopRequireDefault(require("react"));
16
+ var _react = _interopRequireWildcard(require("react"));
13
17
 
14
18
  var _react2 = require("@emotion/react");
15
19
 
@@ -19,8 +23,12 @@ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-
19
23
 
20
24
  var _templateObject, _templateObject2;
21
25
 
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
22
30
  var styles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height: inherit;\n"])));
23
- var actionStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n"])));
31
+ var actionStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n\n :hover {\n cursor: pointer;\n }\n"])));
24
32
  /**
25
33
  * A base element that displays a Lozenge.
26
34
  * @internal
@@ -38,6 +46,23 @@ var Lozenge = function Lozenge(_ref) {
38
46
  _ref$testId = _ref.testId,
39
47
  testId = _ref$testId === void 0 ? 'smart-element-lozenge' : _ref$testId;
40
48
 
49
+ var _useState = (0, _react.useState)(false),
50
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
51
+ isBold = _useState2[0],
52
+ setIsBold = _useState2[1];
53
+
54
+ var onHover = (0, _react.useCallback)(function (isHover) {
55
+ if (onClick) {
56
+ setIsBold(isHover);
57
+ }
58
+ }, [onClick]);
59
+ var onMouseEnter = (0, _react.useCallback)(function () {
60
+ return onHover(true);
61
+ }, [onHover]);
62
+ var onMouseLeave = (0, _react.useCallback)(function () {
63
+ return onHover(false);
64
+ }, [onHover]);
65
+
41
66
  if (!text) {
42
67
  return null;
43
68
  }
@@ -48,9 +73,13 @@ var Lozenge = function Lozenge(_ref) {
48
73
  "data-smart-element": name,
49
74
  "data-smart-element-lozenge": true,
50
75
  "data-testid": testId,
51
- onClick: onClick
76
+ onClick: onClick,
77
+ onMouseEnter: onMouseEnter,
78
+ onMouseLeave: onMouseLeave,
79
+ tabIndex: onClick ? 0 : -1
52
80
  }, (0, _react2.jsx)(_lozenge.default, {
53
81
  appearance: appearance,
82
+ isBold: isBold,
54
83
  testId: "".concat(testId, "-lozenge")
55
84
  }, text, onClick && (0, _react2.jsx)(_chevronDown.default, {
56
85
  label: "action",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.5",
3
+ "version": "23.6.7",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React from 'react';
2
3
  import { FormattedMessage } from 'react-intl-next';
3
4
  import { ActionName } from '../../../../constants';
@@ -6,11 +7,17 @@ import { messages } from '../../../../messages';
6
7
  * Returns a CustomActionItem with a "Try Another Account" default message
7
8
  *
8
9
  * @see CustomActionItem
9
- * @param onAuthorize a function that will be called on the click of the button
10
+ * @param onClick a function that will be called on the click of the button
11
+ * @param content is a message key for a message to be displayed in the action
12
+ * @param context is a variable for a message in case a message contains a placeholder
10
13
  */
11
14
 
12
- export const ForbiddenAction = onAuthorize => ({
15
+ export const ForbiddenAction = (onClick, content, context) => ({
13
16
  name: ActionName.CustomAction,
14
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.try_another_account),
15
- onClick: onAuthorize
17
+ content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[content], {
18
+ values: {
19
+ context
20
+ }
21
+ })),
22
+ onClick: onClick
16
23
  });
@@ -9,7 +9,9 @@ import LockIcon from '@atlaskit/icon/glyph/lock-filled';
9
9
  import BlockCardFooter from '../../components/flexible/footer';
10
10
  import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
11
11
  import Text from '../../../FlexibleCard/components/elements/text';
12
-
12
+ import { getForbiddenJsonLd } from '../../../../utils/jsonld';
13
+ import { extractProvider } from '@atlaskit/linking-common/extractors';
14
+ import { extractRequestAccessContext } from '../../../../extractors/common/context';
13
15
  /**
14
16
  * This view represent a Block Card with the 'Forbidden' status.
15
17
  * It should have a "Try another account" button that will allow a user to connect another account and view the block card.
@@ -17,6 +19,7 @@ import Text from '../../../FlexibleCard/components/elements/text';
17
19
  * @see SmartLinkStatus
18
20
  * @see FlexibleCardProps
19
21
  */
22
+
20
23
  const FlexibleForbiddenView = ({
21
24
  cardState,
22
25
  onAuthorize,
@@ -26,8 +29,33 @@ const FlexibleForbiddenView = ({
26
29
  ui,
27
30
  url
28
31
  }) => {
32
+ var _details$meta;
33
+
29
34
  const status = cardState.status;
30
- const actions = useMemo(() => onAuthorize ? [ForbiddenAction(onAuthorize)] : [], [onAuthorize]);
35
+ const details = cardState === null || cardState === void 0 ? void 0 : cardState.details;
36
+ const cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
37
+ const provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
38
+ const providerName = (provider === null || provider === void 0 ? void 0 : provider.text) || '';
39
+ const requestAccessContext = extractRequestAccessContext({
40
+ jsonLd: cardMetadata,
41
+ url,
42
+ context: providerName
43
+ });
44
+ const descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
45
+ const actions = useMemo(() => {
46
+ let actionFromAccessContext = [];
47
+ const tryAnotherAccountAction = onAuthorize ? [ForbiddenAction(onAuthorize, 'try_another_account')] : [];
48
+
49
+ if (requestAccessContext) {
50
+ const {
51
+ action,
52
+ callToActionMessageKey
53
+ } = requestAccessContext;
54
+ actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, providerName)] : [];
55
+ }
56
+
57
+ return [...tryAnotherAccountAction, ...actionFromAccessContext];
58
+ }, [onAuthorize, requestAccessContext, providerName]);
31
59
  return /*#__PURE__*/React.createElement(FlexibleCard, {
32
60
  appearance: "block",
33
61
  cardState: cardState,
@@ -46,7 +74,10 @@ const FlexibleForbiddenView = ({
46
74
  testId: `${testId}-lock-icon`
47
75
  }), /*#__PURE__*/React.createElement(Text, {
48
76
  message: {
49
- descriptor: messages.invalid_permissions_description
77
+ descriptor: messages[descriptiveMessageKey],
78
+ values: {
79
+ context: providerName
80
+ }
50
81
  }
51
82
  })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
52
83
  actions: actions,
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
2
+ import React, { useCallback, useState } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import AtlaskitLozenge from '@atlaskit/lozenge';
5
5
  import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
@@ -19,6 +19,10 @@ const actionStyles = css`
19
19
  height: unset;
20
20
  margin: -4px 0;
21
21
  }
22
+
23
+ :hover {
24
+ cursor: pointer;
25
+ }
22
26
  `;
23
27
  /**
24
28
  * A base element that displays a Lozenge.
@@ -35,6 +39,15 @@ const Lozenge = ({
35
39
  text,
36
40
  testId = 'smart-element-lozenge'
37
41
  }) => {
42
+ const [isBold, setIsBold] = useState(false);
43
+ const onHover = useCallback(isHover => {
44
+ if (onClick) {
45
+ setIsBold(isHover);
46
+ }
47
+ }, [onClick]);
48
+ const onMouseEnter = useCallback(() => onHover(true), [onHover]);
49
+ const onMouseLeave = useCallback(() => onHover(false), [onHover]);
50
+
38
51
  if (!text) {
39
52
  return null;
40
53
  }
@@ -45,9 +58,13 @@ const Lozenge = ({
45
58
  "data-smart-element": name,
46
59
  "data-smart-element-lozenge": true,
47
60
  "data-testid": testId,
48
- onClick: onClick
61
+ onClick: onClick,
62
+ onMouseEnter: onMouseEnter,
63
+ onMouseLeave: onMouseLeave,
64
+ tabIndex: onClick ? 0 : -1
49
65
  }, jsx(AtlaskitLozenge, {
50
66
  appearance: appearance,
67
+ isBold: isBold,
51
68
  testId: `${testId}-lozenge`
52
69
  }, text, onClick && jsx(ChevronDownIcon, {
53
70
  label: "action",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.5",
3
+ "version": "23.6.7",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React from 'react';
2
3
  import { FormattedMessage } from 'react-intl-next';
3
4
  import { ActionName } from '../../../../constants';
@@ -6,13 +7,19 @@ import { messages } from '../../../../messages';
6
7
  * Returns a CustomActionItem with a "Try Another Account" default message
7
8
  *
8
9
  * @see CustomActionItem
9
- * @param onAuthorize a function that will be called on the click of the button
10
+ * @param onClick a function that will be called on the click of the button
11
+ * @param content is a message key for a message to be displayed in the action
12
+ * @param context is a variable for a message in case a message contains a placeholder
10
13
  */
11
14
 
12
- export var ForbiddenAction = function ForbiddenAction(onAuthorize) {
15
+ export var ForbiddenAction = function ForbiddenAction(onClick, content, context) {
13
16
  return {
14
17
  name: ActionName.CustomAction,
15
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.try_another_account),
16
- onClick: onAuthorize
18
+ content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[content], {
19
+ values: {
20
+ context: context
21
+ }
22
+ })),
23
+ onClick: onClick
17
24
  };
18
25
  };
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import React, { useMemo } from 'react';
2
3
  import FlexibleCard from '../../../FlexibleCard';
3
4
  import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
@@ -9,7 +10,9 @@ import LockIcon from '@atlaskit/icon/glyph/lock-filled';
9
10
  import BlockCardFooter from '../../components/flexible/footer';
10
11
  import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
11
12
  import Text from '../../../FlexibleCard/components/elements/text';
12
-
13
+ import { getForbiddenJsonLd } from '../../../../utils/jsonld';
14
+ import { extractProvider } from '@atlaskit/linking-common/extractors';
15
+ import { extractRequestAccessContext } from '../../../../extractors/common/context';
13
16
  /**
14
17
  * This view represent a Block Card with the 'Forbidden' status.
15
18
  * It should have a "Try another account" button that will allow a user to connect another account and view the block card.
@@ -17,7 +20,10 @@ import Text from '../../../FlexibleCard/components/elements/text';
17
20
  * @see SmartLinkStatus
18
21
  * @see FlexibleCardProps
19
22
  */
23
+
20
24
  var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
25
+ var _details$meta;
26
+
21
27
  var cardState = _ref.cardState,
22
28
  onAuthorize = _ref.onAuthorize,
23
29
  onClick = _ref.onClick,
@@ -27,9 +33,28 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
27
33
  ui = _ref.ui,
28
34
  url = _ref.url;
29
35
  var status = cardState.status;
36
+ var details = cardState === null || cardState === void 0 ? void 0 : cardState.details;
37
+ var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
38
+ var provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
39
+ var providerName = (provider === null || provider === void 0 ? void 0 : provider.text) || '';
40
+ var requestAccessContext = extractRequestAccessContext({
41
+ jsonLd: cardMetadata,
42
+ url: url,
43
+ context: providerName
44
+ });
45
+ var descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
30
46
  var actions = useMemo(function () {
31
- return onAuthorize ? [ForbiddenAction(onAuthorize)] : [];
32
- }, [onAuthorize]);
47
+ var actionFromAccessContext = [];
48
+ var tryAnotherAccountAction = onAuthorize ? [ForbiddenAction(onAuthorize, 'try_another_account')] : [];
49
+
50
+ if (requestAccessContext) {
51
+ var action = requestAccessContext.action,
52
+ callToActionMessageKey = requestAccessContext.callToActionMessageKey;
53
+ actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, providerName)] : [];
54
+ }
55
+
56
+ return [].concat(tryAnotherAccountAction, _toConsumableArray(actionFromAccessContext));
57
+ }, [onAuthorize, requestAccessContext, providerName]);
33
58
  return /*#__PURE__*/React.createElement(FlexibleCard, {
34
59
  appearance: "block",
35
60
  cardState: cardState,
@@ -48,7 +73,10 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
48
73
  testId: "".concat(testId, "-lock-icon")
49
74
  }), /*#__PURE__*/React.createElement(Text, {
50
75
  message: {
51
- descriptor: messages.invalid_permissions_description
76
+ descriptor: messages[descriptiveMessageKey],
77
+ values: {
78
+ context: providerName
79
+ }
52
80
  }
53
81
  })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
54
82
  actions: actions,
@@ -1,14 +1,15 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
3
 
3
4
  var _templateObject, _templateObject2;
4
5
 
5
6
  /** @jsx jsx */
6
- import React from 'react';
7
+ import React, { useCallback, useState } from 'react';
7
8
  import { css, jsx } from '@emotion/react';
8
9
  import AtlaskitLozenge from '@atlaskit/lozenge';
9
10
  import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
10
11
  var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: inherit;\n"])));
11
- var actionStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n"])));
12
+ var actionStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n\n :hover {\n cursor: pointer;\n }\n"])));
12
13
  /**
13
14
  * A base element that displays a Lozenge.
14
15
  * @internal
@@ -26,6 +27,23 @@ var Lozenge = function Lozenge(_ref) {
26
27
  _ref$testId = _ref.testId,
27
28
  testId = _ref$testId === void 0 ? 'smart-element-lozenge' : _ref$testId;
28
29
 
30
+ var _useState = useState(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ isBold = _useState2[0],
33
+ setIsBold = _useState2[1];
34
+
35
+ var onHover = useCallback(function (isHover) {
36
+ if (onClick) {
37
+ setIsBold(isHover);
38
+ }
39
+ }, [onClick]);
40
+ var onMouseEnter = useCallback(function () {
41
+ return onHover(true);
42
+ }, [onHover]);
43
+ var onMouseLeave = useCallback(function () {
44
+ return onHover(false);
45
+ }, [onHover]);
46
+
29
47
  if (!text) {
30
48
  return null;
31
49
  }
@@ -36,9 +54,13 @@ var Lozenge = function Lozenge(_ref) {
36
54
  "data-smart-element": name,
37
55
  "data-smart-element-lozenge": true,
38
56
  "data-testid": testId,
39
- onClick: onClick
57
+ onClick: onClick,
58
+ onMouseEnter: onMouseEnter,
59
+ onMouseLeave: onMouseLeave,
60
+ tabIndex: onClick ? 0 : -1
40
61
  }, jsx(AtlaskitLozenge, {
41
62
  appearance: appearance,
63
+ isBold: isBold,
42
64
  testId: "".concat(testId, "-lozenge")
43
65
  }, text, onClick && jsx(ChevronDownIcon, {
44
66
  label: "action",
@@ -1,8 +1,11 @@
1
1
  import { CustomActionItem } from '../../../FlexibleCard/components/blocks/types';
2
+ import { MessageKey, RequestAccessMessageKey } from '../../../../messages';
2
3
  /**
3
4
  * Returns a CustomActionItem with a "Try Another Account" default message
4
5
  *
5
6
  * @see CustomActionItem
6
- * @param onAuthorize a function that will be called on the click of the button
7
+ * @param onClick a function that will be called on the click of the button
8
+ * @param content is a message key for a message to be displayed in the action
9
+ * @param context is a variable for a message in case a message contains a placeholder
7
10
  */
8
- export declare const ForbiddenAction: (onAuthorize: () => void) => CustomActionItem;
11
+ export declare const ForbiddenAction: (onClick: () => void, content: RequestAccessMessageKey | MessageKey, context?: string | undefined) => CustomActionItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.5",
3
+ "version": "23.6.7",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/icon-object": "^6.2.0",
34
34
  "@atlaskit/icon-priority": "^6.3.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
- "@atlaskit/linking-common": "^1.15.0",
36
+ "@atlaskit/linking-common": "^1.16.0",
37
37
  "@atlaskit/logo": "^13.10.0",
38
38
  "@atlaskit/lozenge": "^11.3.0",
39
39
  "@atlaskit/media-common": "^2.17.0",