@atlaskit/smart-card 23.11.2 → 23.11.3

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,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 23.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`08ef315c46d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/08ef315c46d) - [ux] Add a copy url button to hover cards.
8
+
3
9
  ## 23.11.2
4
10
 
5
11
  ### Patch Changes
@@ -93,6 +93,11 @@ var messages = (0, _reactIntlNext.defineMessages)({
93
93
  defaultMessage: 'Connect to Atlassian to view more details from your work and collaboration from one place.',
94
94
  description: 'Shown when a user does not have access to a link, but can connect their external account to view the link on card view and we do not have the providers name.'
95
95
  },
96
+ copy_url_to_clipboard: {
97
+ id: 'fabric.linking.download',
98
+ defaultMessage: 'Copy link',
99
+ description: ''
100
+ },
96
101
  could_not_load_link: {
97
102
  id: 'fabric.linking.couldnt_load_link',
98
103
  defaultMessage: "We couldn't load this link for an unknown reason.",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.11.2",
3
+ "version": "23.11.3",
4
4
  "sideEffects": false
5
5
  }
@@ -7,12 +7,18 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.hoverCardClassName = exports.getOpenAction = exports.default = void 0;
10
+ exports.hoverCardClassName = exports.getOpenAction = exports.getCopyAction = exports.default = void 0;
11
+
12
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
15
 
12
16
  var _react = require("@emotion/react");
13
17
 
14
18
  var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
15
19
 
20
+ var _copy = _interopRequireDefault(require("@atlaskit/icon/glyph/copy"));
21
+
16
22
  var _extractors = require("@atlaskit/linking-common/extractors");
17
23
 
18
24
  var _react2 = _interopRequireWildcard(require("react"));
@@ -74,6 +80,47 @@ var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
74
80
 
75
81
  exports.getOpenAction = getOpenAction;
76
82
 
83
+ var getCopyAction = function getCopyAction(url) {
84
+ return {
85
+ name: _constants.ActionName.CustomAction,
86
+ icon: (0, _react.jsx)(_copy.default, {
87
+ label: "copy url",
88
+ size: "medium"
89
+ }),
90
+ iconPosition: 'before',
91
+ onClick: function () {
92
+ var _onClick = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
93
+ return _regenerator.default.wrap(function _callee$(_context) {
94
+ while (1) {
95
+ switch (_context.prev = _context.next) {
96
+ case 0:
97
+ _context.next = 2;
98
+ return navigator.clipboard.writeText(url);
99
+
100
+ case 2:
101
+ return _context.abrupt("return", _context.sent);
102
+
103
+ case 3:
104
+ case "end":
105
+ return _context.stop();
106
+ }
107
+ }
108
+ }, _callee);
109
+ }));
110
+
111
+ function onClick() {
112
+ return _onClick.apply(this, arguments);
113
+ }
114
+
115
+ return onClick;
116
+ }(),
117
+ tooltipMessage: (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.copy_url_to_clipboard),
118
+ testId: 'hover-card-copy-button'
119
+ };
120
+ };
121
+
122
+ exports.getCopyAction = getCopyAction;
123
+
77
124
  var HoverCardContent = function HoverCardContent(_ref) {
78
125
  var _cardState$details;
79
126
 
@@ -107,7 +154,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
107
154
  });
108
155
  }, [cardState.status, analytics.ui, id]);
109
156
  var titleActions = (0, _react2.useMemo)(function () {
110
- return [getOpenAction(url, analytics, onActionClick)];
157
+ return [getCopyAction(url), getOpenAction(url, analytics, onActionClick)];
111
158
  }, [url, analytics, onActionClick]);
112
159
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
113
160
  var types = data ? (0, _extractors.extractType)(data) : undefined;
@@ -85,6 +85,11 @@ export const messages = defineMessages({
85
85
  defaultMessage: 'Connect to Atlassian to view more details from your work and collaboration from one place.',
86
86
  description: 'Shown when a user does not have access to a link, but can connect their external account to view the link on card view and we do not have the providers name.'
87
87
  },
88
+ copy_url_to_clipboard: {
89
+ id: 'fabric.linking.download',
90
+ defaultMessage: 'Copy link',
91
+ description: ''
92
+ },
88
93
  could_not_load_link: {
89
94
  id: 'fabric.linking.couldnt_load_link',
90
95
  defaultMessage: "We couldn't load this link for an unknown reason.",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.11.2",
3
+ "version": "23.11.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
3
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
4
+ import CopyIcon from '@atlaskit/icon/glyph/copy';
4
5
  import { extractType } from '@atlaskit/linking-common/extractors';
5
6
  import React, { useCallback, useEffect, useMemo } from 'react';
6
7
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
@@ -36,6 +37,17 @@ export const getOpenAction = (url, analytics, onActionClick) => ({
36
37
  tooltipMessage: jsx(FormattedMessage, messages.open_link_in_a_new_tab),
37
38
  testId: 'hover-card-open-button'
38
39
  });
40
+ export const getCopyAction = url => ({
41
+ name: ActionName.CustomAction,
42
+ icon: jsx(CopyIcon, {
43
+ label: "copy url",
44
+ size: "medium"
45
+ }),
46
+ iconPosition: 'before',
47
+ onClick: async () => await navigator.clipboard.writeText(url),
48
+ tooltipMessage: jsx(FormattedMessage, messages.copy_url_to_clipboard),
49
+ testId: 'hover-card-copy-button'
50
+ });
39
51
 
40
52
  const HoverCardContent = ({
41
53
  id = '',
@@ -66,7 +78,7 @@ const HoverCardContent = ({
66
78
  actionSubjectId: 'titleGoToLink'
67
79
  });
68
80
  }, [cardState.status, analytics.ui, id]);
69
- const titleActions = useMemo(() => [getOpenAction(url, analytics, onActionClick)], [url, analytics, onActionClick]);
81
+ const titleActions = useMemo(() => [getCopyAction(url), getOpenAction(url, analytics, onActionClick)], [url, analytics, onActionClick]);
70
82
  const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
71
83
  const types = data ? extractType(data) : undefined;
72
84
  const {
@@ -85,6 +85,11 @@ export var messages = defineMessages({
85
85
  defaultMessage: 'Connect to Atlassian to view more details from your work and collaboration from one place.',
86
86
  description: 'Shown when a user does not have access to a link, but can connect their external account to view the link on card view and we do not have the providers name.'
87
87
  },
88
+ copy_url_to_clipboard: {
89
+ id: 'fabric.linking.download',
90
+ defaultMessage: 'Copy link',
91
+ description: ''
92
+ },
88
93
  could_not_load_link: {
89
94
  id: 'fabric.linking.couldnt_load_link',
90
95
  defaultMessage: "We couldn't load this link for an unknown reason.",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.11.2",
3
+ "version": "23.11.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,10 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+
1
4
  /** @jsx jsx */
2
5
  import { jsx } from '@emotion/react';
3
6
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
7
+ import CopyIcon from '@atlaskit/icon/glyph/copy';
4
8
  import { extractType } from '@atlaskit/linking-common/extractors';
5
9
  import React, { useCallback, useEffect, useMemo } from 'react';
6
10
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
@@ -38,6 +42,44 @@ export var getOpenAction = function getOpenAction(url, analytics, onActionClick)
38
42
  testId: 'hover-card-open-button'
39
43
  };
40
44
  };
45
+ export var getCopyAction = function getCopyAction(url) {
46
+ return {
47
+ name: ActionName.CustomAction,
48
+ icon: jsx(CopyIcon, {
49
+ label: "copy url",
50
+ size: "medium"
51
+ }),
52
+ iconPosition: 'before',
53
+ onClick: function () {
54
+ var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
55
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
56
+ while (1) {
57
+ switch (_context.prev = _context.next) {
58
+ case 0:
59
+ _context.next = 2;
60
+ return navigator.clipboard.writeText(url);
61
+
62
+ case 2:
63
+ return _context.abrupt("return", _context.sent);
64
+
65
+ case 3:
66
+ case "end":
67
+ return _context.stop();
68
+ }
69
+ }
70
+ }, _callee);
71
+ }));
72
+
73
+ function onClick() {
74
+ return _onClick.apply(this, arguments);
75
+ }
76
+
77
+ return onClick;
78
+ }(),
79
+ tooltipMessage: jsx(FormattedMessage, messages.copy_url_to_clipboard),
80
+ testId: 'hover-card-copy-button'
81
+ };
82
+ };
41
83
 
42
84
  var HoverCardContent = function HoverCardContent(_ref) {
43
85
  var _cardState$details;
@@ -72,7 +114,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
72
114
  });
73
115
  }, [cardState.status, analytics.ui, id]);
74
116
  var titleActions = useMemo(function () {
75
- return [getOpenAction(url, analytics, onActionClick)];
117
+ return [getCopyAction(url), getOpenAction(url, analytics, onActionClick)];
76
118
  }, [url, analytics, onActionClick]);
77
119
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
78
120
  var types = data ? extractType(data) : undefined;
@@ -1,6 +1,6 @@
1
1
  import { MessageDescriptor } from 'react-intl-next';
2
2
  export declare type RequestAccessMessageKey = 'click_to_join' | 'click_to_join_description' | 'forbidden_description' | 'request_access' | 'request_access_description' | 'request_access_pending' | 'request_access_pending_description' | 'request_denied_description';
3
- export declare type MessageKey = 'cannot_find_link' | 'connect_link_account_card' | 'connect_link_account_card_name' | 'connect_link_account_card_description' | 'connect_unauthorised_account_action' | 'connect_unauthorised_account_description' | 'connect_unauthorised_account_description_no_provider' | 'could_not_load_link' | 'download' | 'invalid_permissions' | 'invalid_permissions_description' | 'join_to_view' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'delete' | 'edit' | 'learn_more_about_smart_links' | 'loading' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'more_actions' | 'not_found_title' | 'not_found_description' | 'open_link_in_a_new_tab' | 'preview' | 'preview_close' | 'preview_max_size' | 'preview_min_size' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access_to_view' | 'request_denied' | 'try_again' | 'try_another_account' | 'view' | 'viewIn' | 'viewOriginal' | 'actions' | 'add_account' | 'cancel' | 'close' | 'connect_to' | 'connect_account_description' | 'retry' | 'save' | 'unlink_account' | RequestAccessMessageKey;
3
+ export declare type MessageKey = 'cannot_find_link' | 'connect_link_account_card' | 'connect_link_account_card_name' | 'connect_link_account_card_description' | 'connect_unauthorised_account_action' | 'connect_unauthorised_account_description' | 'connect_unauthorised_account_description_no_provider' | 'copy_url_to_clipboard' | 'could_not_load_link' | 'download' | 'invalid_permissions' | 'invalid_permissions_description' | 'join_to_view' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'delete' | 'edit' | 'learn_more_about_smart_links' | 'loading' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'more_actions' | 'not_found_title' | 'not_found_description' | 'open_link_in_a_new_tab' | 'preview' | 'preview_close' | 'preview_max_size' | 'preview_min_size' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access_to_view' | 'request_denied' | 'try_again' | 'try_another_account' | 'view' | 'viewIn' | 'viewOriginal' | 'actions' | 'add_account' | 'cancel' | 'close' | 'connect_to' | 'connect_account_description' | 'retry' | 'save' | 'unlink_account' | RequestAccessMessageKey;
4
4
  declare type Messages = {
5
5
  [K in MessageKey]: MessageDescriptor;
6
6
  };
@@ -4,5 +4,6 @@ import { ActionItem } from '../../FlexibleCard/components/blocks/types';
4
4
  import { HoverCardContentProps } from '../types';
5
5
  export declare const hoverCardClassName = "smart-links-hover-preview";
6
6
  export declare const getOpenAction: (url: string, analytics: AnalyticsFacade, onActionClick?: ((actionId: string) => void) | undefined) => ActionItem;
7
+ export declare const getCopyAction: (url: string) => ActionItem;
7
8
  declare const HoverCardContent: React.FC<HoverCardContentProps>;
8
9
  export default HoverCardContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.11.2",
3
+ "version": "23.11.3",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"