@atlaskit/profilecard 19.17.7 → 19.18.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/client/RovoAgentCardClient.js +6 -3
  3. package/dist/cjs/client/getAgentInfo.js +7 -18
  4. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  5. package/dist/cjs/components/Agent/Actions.js +175 -0
  6. package/dist/cjs/components/Agent/AgentProfileCard.js +65 -7
  7. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +10 -4
  8. package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +27 -13
  9. package/dist/cjs/components/Agent/AgentProfileCardWrapper.js +1 -2
  10. package/dist/cjs/components/Agent/ConversationStarters.js +26 -0
  11. package/dist/cjs/components/Agent/useAgentActions.js +39 -0
  12. package/dist/cjs/components/Agent/useSetFavouriteAgent.js +85 -0
  13. package/dist/cjs/index.js +21 -0
  14. package/dist/cjs/util/analytics.js +1 -1
  15. package/dist/cjs/util/rovoAgentUtils.js +24 -0
  16. package/dist/cjs/util/url.js +20 -0
  17. package/dist/es2019/client/RovoAgentCardClient.js +6 -3
  18. package/dist/es2019/client/getAgentInfo.js +5 -15
  19. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  20. package/dist/es2019/components/Agent/Actions.js +168 -0
  21. package/dist/es2019/components/Agent/AgentProfileCard.js +59 -8
  22. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +9 -5
  23. package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +17 -6
  24. package/dist/es2019/components/Agent/AgentProfileCardWrapper.js +1 -2
  25. package/dist/es2019/components/Agent/ConversationStarters.js +20 -0
  26. package/dist/es2019/components/Agent/useAgentActions.js +34 -0
  27. package/dist/es2019/components/Agent/useSetFavouriteAgent.js +45 -0
  28. package/dist/es2019/index.js +4 -0
  29. package/dist/es2019/util/analytics.js +1 -1
  30. package/dist/es2019/util/rovoAgentUtils.js +16 -0
  31. package/dist/es2019/util/url.js +9 -0
  32. package/dist/esm/client/RovoAgentCardClient.js +6 -3
  33. package/dist/esm/client/getAgentInfo.js +7 -18
  34. package/dist/esm/client/getTeamFromAGG.js +1 -1
  35. package/dist/esm/components/Agent/Actions.js +165 -0
  36. package/dist/esm/components/Agent/AgentProfileCard.js +66 -8
  37. package/dist/esm/components/Agent/AgentProfileCardResourced.js +11 -5
  38. package/dist/esm/components/Agent/AgentProfileCardTrigger.js +24 -13
  39. package/dist/esm/components/Agent/AgentProfileCardWrapper.js +1 -2
  40. package/dist/esm/components/Agent/ConversationStarters.js +19 -0
  41. package/dist/esm/components/Agent/useAgentActions.js +33 -0
  42. package/dist/esm/components/Agent/useSetFavouriteAgent.js +78 -0
  43. package/dist/esm/index.js +4 -0
  44. package/dist/esm/util/analytics.js +1 -1
  45. package/dist/esm/util/rovoAgentUtils.js +17 -0
  46. package/dist/esm/util/url.js +13 -0
  47. package/dist/types/client/RovoAgentCardClient.d.ts +1 -1
  48. package/dist/types/client/getAgentInfo.d.ts +2 -2
  49. package/dist/types/components/Agent/Actions.d.ts +11 -0
  50. package/dist/types/components/Agent/AgentProfileCard.d.ts +5 -1
  51. package/dist/types/components/Agent/AgentProfileCardResourced.d.ts +2 -0
  52. package/dist/types/components/Agent/AgentProfileCardTrigger.d.ts +2 -2
  53. package/dist/types/components/Agent/ConversationStarters.d.ts +3 -0
  54. package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +5 -1
  55. package/dist/types/components/Agent/useAgentActions.d.ts +7 -0
  56. package/dist/types/components/Agent/useSetFavouriteAgent.d.ts +10 -0
  57. package/dist/types/index.d.ts +5 -1
  58. package/dist/types/types.d.ts +24 -3
  59. package/dist/types/util/rovoAgentUtils.d.ts +2 -0
  60. package/dist/types/util/url.d.ts +1 -0
  61. package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +1 -1
  62. package/dist/types-ts4.5/client/getAgentInfo.d.ts +2 -2
  63. package/dist/types-ts4.5/components/Agent/Actions.d.ts +11 -0
  64. package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +5 -1
  65. package/dist/types-ts4.5/components/Agent/AgentProfileCardResourced.d.ts +2 -0
  66. package/dist/types-ts4.5/components/Agent/AgentProfileCardTrigger.d.ts +2 -2
  67. package/dist/types-ts4.5/components/Agent/ConversationStarters.d.ts +3 -0
  68. package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +5 -1
  69. package/dist/types-ts4.5/components/Agent/useAgentActions.d.ts +7 -0
  70. package/dist/types-ts4.5/components/Agent/useSetFavouriteAgent.d.ts +10 -0
  71. package/dist/types-ts4.5/index.d.ts +5 -1
  72. package/dist/types-ts4.5/types.d.ts +27 -3
  73. package/dist/types-ts4.5/util/rovoAgentUtils.d.ts +2 -0
  74. package/dist/types-ts4.5/util/url.d.ts +1 -0
  75. package/package.json +3 -3
@@ -0,0 +1,34 @@
1
+ import { useCallback } from 'react';
2
+ import { getATLContextUrl } from '@atlaskit/atlassian-context';
3
+ import { encodeParamsToUrl } from '../../util/url';
4
+ export const useAgentUrlActions = ({
5
+ cloudId
6
+ }) => {
7
+ const onEditAgent = useCallback(agentId => {
8
+ const url = `${getATLContextUrl('home')}/chat/agents/${agentId}/edit?cloudId=${cloudId}`;
9
+ window.open(url, '_blank', 'noopener, noreferrer');
10
+ }, [cloudId]);
11
+ const onCopyAgent = useCallback(agentId => {
12
+ const baseUrl = `${getATLContextUrl('home')}/chat`;
13
+ const urlWithParams = encodeParamsToUrl(baseUrl, {
14
+ cloudId,
15
+ pathway: 'chat',
16
+ agentId
17
+ });
18
+ navigator.clipboard.writeText(urlWithParams);
19
+ }, [cloudId]);
20
+ const onDuplicateAgent = useCallback(agentId => {
21
+ const baseUrl = `${getATLContextUrl('home')}/chat/agents/new`;
22
+ const urlWithParams = encodeParamsToUrl(baseUrl, {
23
+ cloudId,
24
+ pathway: 'agents-create',
25
+ agentId
26
+ });
27
+ window.open(urlWithParams, '_blank', 'noopener, noreferrer');
28
+ }, [cloudId]);
29
+ return {
30
+ onEditAgent,
31
+ onCopyAgent,
32
+ onDuplicateAgent
33
+ };
34
+ };
@@ -0,0 +1,45 @@
1
+ import { useState } from 'react';
2
+ import { createHeaders } from '../../util/rovoAgentUtils';
3
+ export const useSetFavouriteAgent = ({
4
+ agentId,
5
+ cloudId,
6
+ isStarred,
7
+ product
8
+ }) => {
9
+ const [isLoading, setIsLoading] = useState(false);
10
+ const [isFavourite, setIsFavourite] = useState(isStarred);
11
+ const setFavourite = async () => {
12
+ setIsLoading(true);
13
+ try {
14
+ const headers = createHeaders(product, cloudId);
15
+ if (isFavourite) {
16
+ await fetch(new Request(`/agents/v1/${agentId}/favourite`, {
17
+ method: 'POST',
18
+ credentials: 'include',
19
+ mode: 'cors',
20
+ headers
21
+ })).then(() => {
22
+ setIsFavourite(true);
23
+ });
24
+ } else {
25
+ await fetch(new Request(`/agents/v1/${agentId}/favourite`, {
26
+ method: 'DELETE',
27
+ credentials: 'include',
28
+ mode: 'cors',
29
+ headers
30
+ })).then(() => {
31
+ setIsFavourite(false);
32
+ });
33
+ }
34
+ setIsLoading(false);
35
+ } catch (error) {
36
+ setIsLoading(false);
37
+ }
38
+ };
39
+ return {
40
+ isLoading,
41
+ isStarred: isFavourite,
42
+ // hasError: Boolean(error) || cannotLoadUser,
43
+ setFavourite
44
+ };
45
+ };
@@ -5,6 +5,7 @@ import ProfileCardClient from './client/ProfileCardClient';
5
5
  import TeamProfileClient from './client/TeamProfileCardClient';
6
6
  // Note: when generating and updating Flow types in Jira, `UserProfileClient` and `UserProfileCardClient` are the same type
7
7
  import UserProfileClient, { modifyResponse } from './client/UserProfileCardClient';
8
+ import AgentProfileCard from './components/Agent/AgentProfileCard';
8
9
  import TeamProfileCardTrigger from './components/Team/TeamProfileCardTrigger';
9
10
  import ProfileCard from './components/User/ProfileCard';
10
11
  import ProfileCardResourced from './components/User/ProfileCardResourced';
@@ -19,6 +20,9 @@ export { default as TeamProfileCard } from './components/Team/TeamProfileCard';
19
20
  export { ProfileCard };
20
21
  export { ProfileCardTrigger };
21
22
  export { TeamProfileCardTrigger };
23
+ export { AgentProfileCard };
22
24
  export { ProfileCardClient as ProfileClient, TeamProfileClient, UserProfileClient, modifyResponse };
23
25
  export { DELAY_MS_SHOW, DELAY_MS_HIDE };
26
+ export { AgentProfileCardTrigger } from './components/Agent/AgentProfileCardTrigger';
27
+ export { AgentProfileCardResourced } from './components/Agent/AgentProfileCardResourced';
24
28
  export default ProfileCardResourced;
@@ -32,7 +32,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
32
32
  actionSubjectId,
33
33
  attributes: {
34
34
  packageName: "@atlaskit/profilecard",
35
- packageVersion: "19.17.7",
35
+ packageVersion: "19.18.0",
36
36
  ...attributes,
37
37
  firedAt: Math.round(getPageTime())
38
38
  }
@@ -0,0 +1,16 @@
1
+ export const createHeaders = (product, cloudId) => {
2
+ const config = {
3
+ headers: {
4
+ 'X-Product': product,
5
+ 'X-Experience-Id': 'profile-card',
6
+ 'X-Cloudid': cloudId
7
+ }
8
+ };
9
+ return new Headers({
10
+ ...(config.headers || {})
11
+ });
12
+ };
13
+ export const getAAIDFromARI = ari => {
14
+ const matched = ari.match(/\/([a-zA-Z0-9_\|\-\:]{1,128})$/);
15
+ return matched ? matched[1] : undefined;
16
+ };
@@ -0,0 +1,9 @@
1
+ export const encodeParamsToUrl = (baseUrl, params) => {
2
+ const url = new URL(baseUrl);
3
+ const searchParams = new URLSearchParams();
4
+ for (const [key, value] of Object.entries(params)) {
5
+ searchParams.append(key, String(value));
6
+ }
7
+ url.search = searchParams.toString();
8
+ return url.toString();
9
+ };
@@ -25,11 +25,11 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
25
25
  }
26
26
  _createClass(RovoAgentCardClient, [{
27
27
  key: "makeRequest",
28
- value: function makeRequest(agentId) {
28
+ value: function makeRequest(agentId, cloudId) {
29
29
  if (!this.options.productIdentifier) {
30
30
  throw new Error('Trying to fetch agents data with no specified config.productIdentifier');
31
31
  }
32
- return getAgentDetailsByAgentId(agentId, this.options.productIdentifier);
32
+ return getAgentDetailsByAgentId(agentId, this.options.productIdentifier, cloudId);
33
33
  }
34
34
  }, {
35
35
  key: "getProfile",
@@ -38,6 +38,9 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
38
38
  if (!agentId) {
39
39
  return Promise.reject(new Error('agentId is missing'));
40
40
  }
41
+ if (!this.options.cloudId) {
42
+ return Promise.reject(new Error('cloudId is missing'));
43
+ }
41
44
  var cache = this.getCachedProfile(agentId);
42
45
  if (cache) {
43
46
  return Promise.resolve(cache);
@@ -47,7 +50,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
47
50
  if (analytics) {
48
51
  analytics(agentRequestAnalytics('triggered'));
49
52
  }
50
- _this2.makeRequest(agentId).then(function (data) {
53
+ _this2.makeRequest(agentId, _this2.options.cloudId || '').then(function (data) {
51
54
  if (_this2.cache) {
52
55
  _this2.setCachedProfile(agentId, data);
53
56
  }
@@ -1,27 +1,16 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- 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; }
5
- 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; }
6
- var createHeaders = function createHeaders(product) {
7
- var config = {
8
- headers: {
9
- 'x-product': product,
10
- 'x-experience-id': 'profile-card'
11
- }
12
- };
13
- return new Headers(_objectSpread({}, config.headers || {}));
14
- };
15
- export function getAgentDetailsByAgentId(_x, _x2) {
3
+ import { createHeaders } from '../util/rovoAgentUtils';
4
+ export function getAgentDetailsByAgentId(_x, _x2, _x3) {
16
5
  return _getAgentDetailsByAgentId.apply(this, arguments);
17
6
  }
18
7
  function _getAgentDetailsByAgentId() {
19
- _getAgentDetailsByAgentId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(agentId, product) {
8
+ _getAgentDetailsByAgentId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(agentId, product, cloudId) {
20
9
  var headers;
21
10
  return _regeneratorRuntime.wrap(function _callee$(_context) {
22
11
  while (1) switch (_context.prev = _context.next) {
23
12
  case 0:
24
- headers = createHeaders(product);
13
+ headers = createHeaders(product, cloudId);
25
14
  _context.next = 3;
26
15
  return fetch(new Request("assist/agents/v1/".concat(agentId), {
27
16
  method: 'GET',
@@ -41,16 +30,16 @@ function _getAgentDetailsByAgentId() {
41
30
  }));
42
31
  return _getAgentDetailsByAgentId.apply(this, arguments);
43
32
  }
44
- export function getAgentDetailsByUserId(_x3, _x4) {
33
+ export function getAgentDetailsByUserId(_x4, _x5, _x6) {
45
34
  return _getAgentDetailsByUserId.apply(this, arguments);
46
35
  }
47
36
  function _getAgentDetailsByUserId() {
48
- _getAgentDetailsByUserId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(userId, product) {
37
+ _getAgentDetailsByUserId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(userId, product, cloudId) {
49
38
  var headers;
50
39
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
51
40
  while (1) switch (_context2.prev = _context2.next) {
52
41
  case 0:
53
- headers = createHeaders(product);
42
+ headers = createHeaders(product, cloudId);
54
43
  _context2.next = 3;
55
44
  return fetch(new Request("assist/agents/v1/accountid/".concat(userId), {
56
45
  method: 'GET',
@@ -48,7 +48,7 @@ export var addHeaders = function addHeaders(headers) {
48
48
  headers.append('X-ExperimentalApi', 'teams-beta');
49
49
  headers.append('X-ExperimentalApi', 'team-members-beta');
50
50
  headers.append('atl-client-name', "@atlaskit/profilecard");
51
- headers.append('atl-client-version', "19.17.7");
51
+ headers.append('atl-client-version', "19.18.0");
52
52
  return headers;
53
53
  };
54
54
  export function getTeamFromAGG(_x, _x2, _x3) {
@@ -0,0 +1,165 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["triggerRef"];
4
+ import React from 'react';
5
+ import { defineMessages, FormattedMessage, useIntl } from 'react-intl-next';
6
+ import Button, { IconButton } from '@atlaskit/button/new';
7
+ import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
8
+ import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
9
+ import { Box, Inline, xcss } from '@atlaskit/primitives';
10
+ import { ChatPillIcon } from '@atlaskit/rovo-agent-components';
11
+ var chatToAgentButtonContainer = xcss({
12
+ width: '100%'
13
+ });
14
+ var buttonStyles = xcss({
15
+ borderRadius: '3px',
16
+ color: 'color.text',
17
+ backgroundColor: 'color.background.neutral',
18
+ ':hover': {
19
+ backgroundColor: 'color.background.neutral.hovered'
20
+ },
21
+ ':active': {
22
+ backgroundColor: 'color.background.neutral.pressed'
23
+ }
24
+ });
25
+ var chatToAgentButtonWrapper = xcss({
26
+ display: 'flex',
27
+ justifyContent: 'center',
28
+ lineHeight: '20px',
29
+ padding: 'space.075',
30
+ fontWeight: '500'
31
+ });
32
+ var chatPillButtonInlineStyles = xcss({
33
+ paddingInline: 'space.025'
34
+ });
35
+ var chatPillTextStyles = xcss({
36
+ wordBreak: 'break-word',
37
+ textAlign: 'left',
38
+ whiteSpace: 'pre-wrap'
39
+ });
40
+ var chatPillIconWrapper = xcss({
41
+ minWidth: '20px',
42
+ height: '20px'
43
+ });
44
+ var actopnsWrapperStyles = xcss({
45
+ borderTop: '1px',
46
+ borderTopStyle: 'solid',
47
+ borderColor: 'color.border',
48
+ padding: 'space.200',
49
+ marginBlockStart: 'space.200',
50
+ color: 'color.text'
51
+ });
52
+ var buildAgentActions = function buildAgentActions(_ref) {
53
+ var onDuplicateAgent = _ref.onDuplicateAgent,
54
+ onCopyAgent = _ref.onCopyAgent;
55
+ return [{
56
+ text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionDuplicate),
57
+ onClick: onDuplicateAgent
58
+ }, {
59
+ text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionCopyLink),
60
+ onClick: onCopyAgent
61
+ }];
62
+ };
63
+ var buildAgentSettings = function buildAgentSettings(_ref2) {
64
+ var onEditAgent = _ref2.onEditAgent,
65
+ onDeleteAgent = _ref2.onDeleteAgent;
66
+ return [{
67
+ text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionEdit),
68
+ onClick: onEditAgent
69
+ }, {
70
+ text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionDelete),
71
+ onClick: onDeleteAgent
72
+ }];
73
+ };
74
+ export var AgentActions = function AgentActions(_ref3) {
75
+ var isAgentCreatedByCurrentUser = _ref3.isAgentCreatedByCurrentUser,
76
+ onEditAgent = _ref3.onEditAgent,
77
+ onDeleteAgent = _ref3.onDeleteAgent,
78
+ onDuplicateAgent = _ref3.onDuplicateAgent,
79
+ onCopyAgent = _ref3.onCopyAgent,
80
+ onChatClick = _ref3.onChatClick;
81
+ var _useIntl = useIntl(),
82
+ formatMessage = _useIntl.formatMessage;
83
+ var agentActions = buildAgentActions({
84
+ onDuplicateAgent: onDuplicateAgent,
85
+ onCopyAgent: onCopyAgent
86
+ });
87
+ var agentSetting = buildAgentSettings({
88
+ onEditAgent: onEditAgent,
89
+ onDeleteAgent: onDeleteAgent
90
+ });
91
+ return /*#__PURE__*/React.createElement(Inline, {
92
+ space: "space.100",
93
+ xcss: actopnsWrapperStyles
94
+ }, /*#__PURE__*/React.createElement(Box, {
95
+ xcss: [chatToAgentButtonContainer, buttonStyles]
96
+ }, /*#__PURE__*/React.createElement(Button, {
97
+ shouldFitContainer: true,
98
+ onClick: onChatClick
99
+ }, /*#__PURE__*/React.createElement(Box, {
100
+ xcss: chatToAgentButtonWrapper
101
+ }, /*#__PURE__*/React.createElement(Inline, {
102
+ space: "space.050",
103
+ xcss: chatPillButtonInlineStyles
104
+ }, /*#__PURE__*/React.createElement(Box, {
105
+ xcss: chatPillIconWrapper
106
+ }, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
107
+ xcss: chatPillTextStyles
108
+ }, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/React.createElement(DropdownMenu, {
109
+ trigger: function trigger(_ref4) {
110
+ var triggerRef = _ref4.triggerRef,
111
+ props = _objectWithoutProperties(_ref4, _excluded);
112
+ return /*#__PURE__*/React.createElement(Box, {
113
+ xcss: buttonStyles
114
+ }, /*#__PURE__*/React.createElement(IconButton, _extends({}, props, {
115
+ icon: MoreIcon,
116
+ label: "more",
117
+ ref: triggerRef
118
+ })));
119
+ },
120
+ placement: "bottom-end"
121
+ }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, agentActions.map(function (_ref5, idx) {
122
+ var text = _ref5.text,
123
+ onClick = _ref5.onClick;
124
+ return /*#__PURE__*/React.createElement(DropdownItem, {
125
+ key: idx,
126
+ onClick: onClick
127
+ }, text);
128
+ })), isAgentCreatedByCurrentUser && /*#__PURE__*/React.createElement(DropdownItemGroup, {
129
+ hasSeparator: true
130
+ }, agentSetting.map(function (_ref6, idx) {
131
+ var text = _ref6.text,
132
+ onClick = _ref6.onClick;
133
+ return /*#__PURE__*/React.createElement(DropdownItem, {
134
+ key: idx,
135
+ onClick: onClick
136
+ }, text);
137
+ }))));
138
+ };
139
+ var messages = defineMessages({
140
+ actionChatToAgent: {
141
+ id: 'ptc-directory.agent-profile.action.dropdown.chat-to-agent.nonfinal',
142
+ defaultMessage: 'Chat to Agent',
143
+ description: 'Text for the "chat to agent" action to chat to the agent'
144
+ },
145
+ actionDelete: {
146
+ id: 'ptc-directory.agent-profile.action.dropdown.delete.nonfinal',
147
+ defaultMessage: 'Delete Agent',
148
+ description: 'Text for the "Delete" action to delete an agent'
149
+ },
150
+ actionEdit: {
151
+ id: 'ptc-directory.agent-profile.action.dropdown.edit.nonfinal',
152
+ defaultMessage: 'Edit Agent',
153
+ description: 'Text for the "Edit" action to edit an agent'
154
+ },
155
+ actionCopyLink: {
156
+ id: 'ptc-directory.agent-profile.action.dropdown.copy-link.nonfinal',
157
+ defaultMessage: 'Copy link',
158
+ description: 'Text for the Copy link of an agent'
159
+ },
160
+ actionDuplicate: {
161
+ id: 'ptc-directory.agent-profile.action.dropdown.duplicate.nonfinal',
162
+ defaultMessage: 'Duplicate Agent',
163
+ description: 'Text for the Duplicate Agent action to create a duplicate'
164
+ }
165
+ });
@@ -1,20 +1,49 @@
1
1
  import React from 'react';
2
2
  import { Box, Stack, xcss } from '@atlaskit/primitives';
3
- import { AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
3
+ import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
4
4
  import LoadingState from '../common/LoadingState';
5
+ import { AgentActions } from './Actions';
5
6
  import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
7
+ import { ConversationStarters } from './ConversationStarters';
8
+ import { useAgentUrlActions } from './useAgentActions';
9
+ import { useSetFavouriteAgent } from './useSetFavouriteAgent';
6
10
  var styles = xcss({
7
- paddingBlock: 'space.0',
11
+ paddingBlockStart: 'space.400',
8
12
  paddingInline: 'space.200'
9
13
  });
14
+ var avatarStyles = xcss({
15
+ position: 'absolute',
16
+ top: 'space.300',
17
+ left: 'space.200'
18
+ });
10
19
  var cardContainerStyles = xcss({
11
20
  borderRadius: 'border.radius.200',
12
- boxShadow: 'elevation.shadow.overlay'
21
+ boxShadow: 'elevation.shadow.overlay',
22
+ position: 'relative'
13
23
  });
14
24
  var AgentProfileCard = function AgentProfileCard(_ref) {
15
25
  var _agent$creatorInfo, _agent$creatorInfo2, _agent$creatorInfo3, _agent$creatorInfo4;
16
26
  var agent = _ref.agent,
17
- isLoading = _ref.isLoading;
27
+ isLoading = _ref.isLoading,
28
+ isCreatedByViewingUser = _ref.isCreatedByViewingUser,
29
+ cloudId = _ref.cloudId,
30
+ onOpenChat = _ref.onOpenChat,
31
+ _ref$product = _ref.product,
32
+ product = _ref$product === void 0 ? 'rovo' : _ref$product;
33
+ var _useAgentUrlActions = useAgentUrlActions({
34
+ cloudId: cloudId || ''
35
+ }),
36
+ _onEditAgent = _useAgentUrlActions.onEditAgent,
37
+ _onCopyAgent = _useAgentUrlActions.onCopyAgent,
38
+ _onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent;
39
+ var _useSetFavouriteAgent = useSetFavouriteAgent({
40
+ agentId: agent.id,
41
+ cloudId: cloudId || '',
42
+ isStarred: agent.favourite,
43
+ product: product
44
+ }),
45
+ isStarred = _useSetFavouriteAgent.isStarred,
46
+ setFavourite = _useSetFavouriteAgent.setFavourite;
18
47
  if (isLoading) {
19
48
  return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(LoadingState, {
20
49
  profileType: "agent"
@@ -22,13 +51,19 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
22
51
  }
23
52
  return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
24
53
  xcss: cardContainerStyles
25
- }, /*#__PURE__*/React.createElement(Stack, {
54
+ }, /*#__PURE__*/React.createElement(AgentBanner, {
55
+ height: 96
56
+ }), /*#__PURE__*/React.createElement(Box, {
57
+ xcss: avatarStyles
58
+ }, /*#__PURE__*/React.createElement(AgentAvatar, {
59
+ size: "xlarge"
60
+ })), /*#__PURE__*/React.createElement(Stack, {
26
61
  space: "space.100",
27
62
  xcss: styles
28
63
  }, /*#__PURE__*/React.createElement(AgentProfileInfo, {
29
64
  agentName: agent.name,
30
- isStarred: agent.favourite,
31
- onStarToggle: function onStarToggle() {},
65
+ isStarred: isStarred,
66
+ onStarToggle: setFavourite,
32
67
  creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/React.createElement(AgentProfileCreator, {
33
68
  creator: {
34
69
  type: (_agent$creatorInfo2 = agent.creatorInfo) === null || _agent$creatorInfo2 === void 0 ? void 0 : _agent$creatorInfo2.type,
@@ -43,6 +78,29 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
43
78
  isLoading: false
44
79
  }),
45
80
  agentDescription: agent.description
46
- }))));
81
+ }), /*#__PURE__*/React.createElement(ConversationStarters, {
82
+ isAgentDefault: agent.is_default,
83
+ userDefinedConversationStarters: agent.user_defined_conversation_starters,
84
+ onConversationStarterClick: function onConversationStarterClick(conversationStarter) {
85
+ throw new Error('Function not implemented.');
86
+ }
87
+ })), /*#__PURE__*/React.createElement(AgentActions, {
88
+ isAgentCreatedByCurrentUser: isCreatedByViewingUser,
89
+ onEditAgent: function onEditAgent() {
90
+ return _onEditAgent(agent.id);
91
+ },
92
+ onCopyAgent: function onCopyAgent() {
93
+ return _onCopyAgent(agent.id);
94
+ },
95
+ onDuplicateAgent: function onDuplicateAgent() {
96
+ return _onDuplicateAgent(agent.id);
97
+ },
98
+ onDeleteAgent: function onDeleteAgent() {
99
+ throw new Error('Function not implemented.');
100
+ },
101
+ onChatClick: function onChatClick() {
102
+ return onOpenChat === null || onOpenChat === void 0 ? void 0 : onOpenChat(agent.id);
103
+ }
104
+ })));
47
105
  };
48
106
  export default AgentProfileCard;
@@ -4,7 +4,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  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; }
5
5
  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; }
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- import React, { useCallback, useEffect, useState } from 'react';
7
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
8
+ import { getAAIDFromARI } from '../../util/rovoAgentUtils';
8
9
  import ErrorMessage from '../Error/ErrorMessage';
9
10
  import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
10
11
  import { AgentProfileCardLazy } from './lazyAgentProfileCard';
@@ -21,6 +22,9 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
21
22
  _useState6 = _slicedToArray(_useState5, 2),
22
23
  error = _useState6[0],
23
24
  setError = _useState6[1];
25
+ var creatorUserId = useMemo(function () {
26
+ return (agentData === null || agentData === void 0 ? void 0 : agentData.creator_type) === 'CUSTOMER' && agentData.creator ? getAAIDFromARI(agentData.creator) : '';
27
+ }, [agentData === null || agentData === void 0 ? void 0 : agentData.creator_type, agentData === null || agentData === void 0 ? void 0 : agentData.creator]);
24
28
  var getCreator = useCallback( /*#__PURE__*/function () {
25
29
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(creator_type, creator) {
26
30
  var creatorInfo;
@@ -47,13 +51,13 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
47
51
  });
48
52
  case 7:
49
53
  _context.next = 9;
50
- return props.resourceClient.getProfile(creator, props.cloudId || '');
54
+ return props.resourceClient.getProfile(creatorUserId || '', props.cloudId || '');
51
55
  case 9:
52
56
  creatorInfo = _context.sent;
53
57
  return _context.abrupt("return", {
54
58
  type: 'CUSTOMER',
55
59
  name: creatorInfo.fullName,
56
- profileLink: "/people/".concat(creator)
60
+ profileLink: "/people/".concat(creatorUserId)
57
61
  });
58
62
  case 11:
59
63
  return _context.abrupt("return", undefined);
@@ -66,7 +70,7 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
66
70
  return function (_x, _x2) {
67
71
  return _ref.apply(this, arguments);
68
72
  };
69
- }(), [props.cloudId, props.resourceClient]);
73
+ }(), [creatorUserId, props.cloudId, props.resourceClient]);
70
74
  var getAgentInfo = useCallback(function () {
71
75
  return props.resourceClient.getRovoAgentProfile(props.agentId);
72
76
  }, [props.agentId, props.resourceClient]);
@@ -136,7 +140,9 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
136
140
  return /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
137
141
  agent: agentData,
138
142
  isLoading: isLoading,
139
- hasError: !!error
143
+ hasError: !!error,
144
+ isCreatedByViewingUser: creatorUserId === props.viewingUserId,
145
+ product: props.product
140
146
  });
141
147
  }
142
148
  return null;
@@ -2,23 +2,26 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["trigger"];
5
+ var _excluded = ["trigger", "viewingUserId", "product"];
6
6
  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; }
7
7
  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; }
8
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
- import React from 'react';
9
+ import React, { Suspense } from 'react';
10
+ import { getAAIDFromARI } from '../../util/rovoAgentUtils';
10
11
  import ProfileCardTrigger from '../common/ProfileCardTrigger';
11
12
  import { AgentProfileCardLazy } from './lazyAgentProfileCard';
12
13
  export var AgentProfileCardTrigger = function AgentProfileCardTrigger(_ref) {
13
14
  var _ref$trigger = _ref.trigger,
14
15
  trigger = _ref$trigger === void 0 ? 'hover' : _ref$trigger,
16
+ viewingUserId = _ref.viewingUserId,
17
+ product = _ref.product,
15
18
  props = _objectWithoutProperties(_ref, _excluded);
16
19
  var resourceClient = props.resourceClient,
17
20
  userId = props.userId,
18
21
  cloudId = props.cloudId;
19
22
  var getCreator = /*#__PURE__*/function () {
20
23
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(creator_type, creator) {
21
- var creatorInfo;
24
+ var _userId, creatorInfo;
22
25
  return _regeneratorRuntime.wrap(function _callee$(_context) {
23
26
  while (1) switch (_context.prev = _context.next) {
24
27
  case 0:
@@ -29,7 +32,7 @@ export var AgentProfileCardTrigger = function AgentProfileCardTrigger(_ref) {
29
32
  return _context.abrupt("return", undefined);
30
33
  case 2:
31
34
  _context.t0 = creator_type;
32
- _context.next = _context.t0 === 'SYSTEM' ? 5 : _context.t0 === 'THIRD_PARTY' ? 6 : _context.t0 === 'CUSTOMER' ? 7 : 11;
35
+ _context.next = _context.t0 === 'SYSTEM' ? 5 : _context.t0 === 'THIRD_PARTY' ? 6 : _context.t0 === 'CUSTOMER' ? 7 : 12;
33
36
  break;
34
37
  case 5:
35
38
  return _context.abrupt("return", {
@@ -41,18 +44,20 @@ export var AgentProfileCardTrigger = function AgentProfileCardTrigger(_ref) {
41
44
  name: creator !== null && creator !== void 0 ? creator : ''
42
45
  });
43
46
  case 7:
44
- _context.next = 9;
45
- return props.resourceClient.getProfile(creator, cloudId || '');
46
- case 9:
47
+ _userId = getAAIDFromARI(creator) || '';
48
+ _context.next = 10;
49
+ return props.resourceClient.getProfile(_userId, cloudId || '');
50
+ case 10:
47
51
  creatorInfo = _context.sent;
48
52
  return _context.abrupt("return", {
49
53
  type: 'CUSTOMER',
50
54
  name: creatorInfo.fullName,
51
- profileLink: "/people/".concat(creator)
55
+ profileLink: "/people/".concat(_userId),
56
+ id: _userId
52
57
  });
53
- case 11:
54
- return _context.abrupt("return", undefined);
55
58
  case 12:
59
+ return _context.abrupt("return", undefined);
60
+ case 13:
56
61
  case "end":
57
62
  return _context.stop();
58
63
  }
@@ -90,15 +95,21 @@ export var AgentProfileCardTrigger = function AgentProfileCardTrigger(_ref) {
90
95
  };
91
96
  }();
92
97
  var renderProfileCard = function renderProfileCard(_ref4) {
98
+ var _profileData$creatorI;
93
99
  var profileData = _ref4.profileData,
94
100
  isLoading = _ref4.isLoading;
95
101
  if (!profileData) {
96
102
  return /*#__PURE__*/React.createElement(React.Fragment, null);
97
103
  }
98
- return /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
104
+ return /*#__PURE__*/React.createElement(Suspense, {
105
+ fallback: null
106
+ }, /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
99
107
  agent: profileData,
100
- isLoading: isLoading
101
- });
108
+ isLoading: isLoading,
109
+ isCreatedByViewingUser: ((_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
110
+ cloudId: props.cloudId,
111
+ product: product
112
+ }));
102
113
  };
103
114
  return /*#__PURE__*/React.createElement(ProfileCardTrigger, _extends({}, props, {
104
115
  renderProfileCard: renderProfileCard,
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Box, xcss } from '@atlaskit/primitives';
3
3
  var styles = xcss({
4
- width: '360px',
5
- borderRadius: '6px'
4
+ width: '360px'
6
5
  });
7
6
  export var AgentProfileCardWrapper = function AgentProfileCardWrapper(_ref) {
8
7
  var children = _ref.children;