@atlaskit/profilecard 19.23.0 → 19.24.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 (80) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/client/ProfileCardClient.js +12 -0
  3. package/dist/cjs/client/RovoAgentCardClient.js +131 -9
  4. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  5. package/dist/cjs/components/Agent/Actions.js +4 -3
  6. package/dist/cjs/components/Agent/AgentDeleteConfirmationModal.js +9 -9
  7. package/dist/cjs/components/Agent/AgentProfileCard.js +78 -38
  8. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +3 -1
  9. package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +4 -2
  10. package/dist/cjs/components/Agent/messages.js +29 -0
  11. package/dist/cjs/components/User/ProfileCardTrigger.js +6 -3
  12. package/dist/cjs/components/common/ProfileCardTrigger.js +13 -25
  13. package/dist/cjs/util/analytics.js +3 -3
  14. package/dist/cjs/util/rovoAgentUtils.js +1 -15
  15. package/dist/es2019/client/ProfileCardClient.js +8 -0
  16. package/dist/es2019/client/RovoAgentCardClient.js +103 -6
  17. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  18. package/dist/es2019/components/Agent/Actions.js +4 -3
  19. package/dist/es2019/components/Agent/AgentDeleteConfirmationModal.js +9 -9
  20. package/dist/es2019/components/Agent/AgentProfileCard.js +42 -22
  21. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +3 -1
  22. package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +4 -2
  23. package/dist/es2019/components/Agent/messages.js +23 -0
  24. package/dist/es2019/components/User/ProfileCardTrigger.js +6 -3
  25. package/dist/es2019/components/common/ProfileCardTrigger.js +2 -2
  26. package/dist/es2019/util/analytics.js +2 -2
  27. package/dist/es2019/util/rovoAgentUtils.js +0 -12
  28. package/dist/esm/client/ProfileCardClient.js +12 -0
  29. package/dist/esm/client/RovoAgentCardClient.js +131 -9
  30. package/dist/esm/client/getTeamFromAGG.js +1 -1
  31. package/dist/esm/components/Agent/Actions.js +4 -3
  32. package/dist/esm/components/Agent/AgentDeleteConfirmationModal.js +9 -9
  33. package/dist/esm/components/Agent/AgentProfileCard.js +79 -39
  34. package/dist/esm/components/Agent/AgentProfileCardResourced.js +3 -1
  35. package/dist/esm/components/Agent/AgentProfileCardTrigger.js +4 -2
  36. package/dist/esm/components/Agent/messages.js +23 -0
  37. package/dist/esm/components/User/ProfileCardTrigger.js +6 -3
  38. package/dist/esm/components/common/ProfileCardTrigger.js +13 -25
  39. package/dist/esm/util/analytics.js +3 -3
  40. package/dist/esm/util/rovoAgentUtils.js +0 -13
  41. package/dist/types/client/ProfileCardClient.d.ts +2 -0
  42. package/dist/types/client/RovoAgentCardClient.d.ts +2 -0
  43. package/dist/types/components/Agent/Actions.d.ts +3 -1
  44. package/dist/types/components/Agent/AgentProfileCard.d.ts +2 -11
  45. package/dist/types/components/Agent/AgentProfileCardResourced.d.ts +2 -1
  46. package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +1 -9
  47. package/dist/types/components/Agent/messages.d.ts +22 -0
  48. package/dist/types/components/common/LoadingState.d.ts +2 -1
  49. package/dist/types/components/common/types.d.ts +2 -2
  50. package/dist/types/types.d.ts +31 -1
  51. package/dist/types/util/analytics.d.ts +6 -5
  52. package/dist/types/util/rovoAgentUtils.d.ts +0 -1
  53. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -0
  54. package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +2 -0
  55. package/dist/types-ts4.5/components/Agent/Actions.d.ts +3 -1
  56. package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +2 -11
  57. package/dist/types-ts4.5/components/Agent/AgentProfileCardResourced.d.ts +2 -1
  58. package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +1 -9
  59. package/dist/types-ts4.5/components/Agent/messages.d.ts +22 -0
  60. package/dist/types-ts4.5/components/common/LoadingState.d.ts +2 -1
  61. package/dist/types-ts4.5/components/common/types.d.ts +2 -2
  62. package/dist/types-ts4.5/types.d.ts +31 -1
  63. package/dist/types-ts4.5/util/analytics.d.ts +6 -5
  64. package/dist/types-ts4.5/util/rovoAgentUtils.d.ts +0 -1
  65. package/package.json +1 -1
  66. package/dist/cjs/client/getAgentInfo.js +0 -66
  67. package/dist/cjs/components/Agent/hooks/useDeleteAgent.js +0 -70
  68. package/dist/cjs/components/Agent/hooks/useSetFavouriteAgent.js +0 -91
  69. package/dist/es2019/client/getAgentInfo.js +0 -21
  70. package/dist/es2019/components/Agent/hooks/useDeleteAgent.js +0 -33
  71. package/dist/es2019/components/Agent/hooks/useSetFavouriteAgent.js +0 -48
  72. package/dist/esm/client/getAgentInfo.js +0 -58
  73. package/dist/esm/components/Agent/hooks/useDeleteAgent.js +0 -63
  74. package/dist/esm/components/Agent/hooks/useSetFavouriteAgent.js +0 -84
  75. package/dist/types/client/getAgentInfo.d.ts +0 -3
  76. package/dist/types/components/Agent/hooks/useDeleteAgent.d.ts +0 -8
  77. package/dist/types/components/Agent/hooks/useSetFavouriteAgent.d.ts +0 -10
  78. package/dist/types-ts4.5/client/getAgentInfo.d.ts +0 -3
  79. package/dist/types-ts4.5/components/Agent/hooks/useDeleteAgent.d.ts +0 -8
  80. package/dist/types-ts4.5/components/Agent/hooks/useSetFavouriteAgent.d.ts +0 -10
@@ -1,18 +1,29 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- 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; }
8
- 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 _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ 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; }
12
+ 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; }
11
13
  import { agentRequestAnalytics } from '../util/analytics';
12
14
  import { getPageTime } from '../util/performance';
13
15
  import CachingClient from './CachingClient';
14
16
  import { getErrorAttributes } from './errorUtils';
15
- import { getAgentDetailsByAgentId, getAgentDetailsByUserId } from './getAgentInfo';
17
+ var createHeaders = function createHeaders(product, cloudId) {
18
+ var config = {
19
+ headers: {
20
+ 'X-Product': product,
21
+ 'X-Experience-Id': 'profile-card',
22
+ 'X-Cloudid': cloudId || ''
23
+ }
24
+ };
25
+ return new Headers(_objectSpread({}, config.headers || {}));
26
+ };
16
27
  var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
17
28
  _inherits(RovoAgentCardClient, _CachingClient);
18
29
  var _super = _createSuper(RovoAgentCardClient);
@@ -26,17 +37,33 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
26
37
  _createClass(RovoAgentCardClient, [{
27
38
  key: "makeRequest",
28
39
  value: function makeRequest(id, cloudId) {
40
+ var product = this.options.productIdentifier || 'rovo';
41
+ var headers = createHeaders(product, this.options.cloudId);
29
42
  if (id.type === 'identity') {
30
- return getAgentDetailsByUserId(id.value, this.options.productIdentifier || 'rovo', cloudId);
43
+ return fetch(new Request("/gateway/api/assist/agents/v1/accountid/".concat(id.value), {
44
+ method: 'GET',
45
+ credentials: 'include',
46
+ mode: 'cors',
47
+ headers: headers
48
+ })).then(function (response) {
49
+ return response.json();
50
+ });
31
51
  }
32
- return getAgentDetailsByAgentId(id.value, this.options.productIdentifier || 'rovo', cloudId);
52
+ return fetch(new Request("/gateway/api/assist/agents/v1/".concat(id.value), {
53
+ method: 'GET',
54
+ credentials: 'include',
55
+ mode: 'cors',
56
+ headers: headers
57
+ })).then(function (response) {
58
+ return response.json();
59
+ });
33
60
  }
34
61
  }, {
35
62
  key: "getProfile",
36
63
  value: function getProfile(id, analytics) {
37
64
  var _this2 = this;
38
65
  if (!id.value) {
39
- return Promise.reject(new Error('IF is missing'));
66
+ return Promise.reject(new Error('Id is missing'));
40
67
  }
41
68
  if (!this.options.cloudId) {
42
69
  return Promise.reject(new Error('cloudId is missing'));
@@ -55,7 +82,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
55
82
  _this2.setCachedProfile(id.value, data);
56
83
  }
57
84
  if (analytics) {
58
- analytics(agentRequestAnalytics('succeeded', {
85
+ analytics(agentRequestAnalytics('succeeded', 'request', {
59
86
  duration: getPageTime() - startTime,
60
87
  gateway: true
61
88
  }));
@@ -63,7 +90,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
63
90
  resolve(data);
64
91
  }).catch(function (error) {
65
92
  if (analytics) {
66
- analytics(agentRequestAnalytics('failed', _objectSpread(_objectSpread({
93
+ analytics(agentRequestAnalytics('failed', 'request', _objectSpread(_objectSpread({
67
94
  duration: getPageTime() - startTime
68
95
  }, getErrorAttributes(error)), {}, {
69
96
  gateway: true
@@ -73,6 +100,101 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
73
100
  });
74
101
  });
75
102
  }
103
+ }, {
104
+ key: "deleteAgent",
105
+ value: function deleteAgent(agentId, analytics) {
106
+ var _this3 = this;
107
+ if (!this.options.cloudId) {
108
+ return Promise.reject(new Error('cloudId is missing'));
109
+ }
110
+ return new Promise(function (resolve, reject) {
111
+ var startTime = getPageTime();
112
+ var product = _this3.options.productIdentifier || 'rovo';
113
+ if (analytics) {
114
+ analytics(agentRequestAnalytics('triggered'));
115
+ }
116
+ var headers = createHeaders(product, _this3.options.cloudId);
117
+ fetch(new Request("/gateway/api/assist/agents/v1/".concat(agentId), {
118
+ method: 'DELETE',
119
+ credentials: 'include',
120
+ mode: 'cors',
121
+ headers: headers
122
+ })).then(function () {
123
+ if (analytics) {
124
+ analytics(agentRequestAnalytics('succeeded', 'deleteAgent', {
125
+ duration: getPageTime() - startTime,
126
+ gateway: true
127
+ }));
128
+ }
129
+ resolve();
130
+ }).catch(function (error) {
131
+ if (analytics) {
132
+ analytics(agentRequestAnalytics('failed', 'deleteAgent', _objectSpread(_objectSpread({
133
+ duration: getPageTime() - startTime
134
+ }, getErrorAttributes(error)), {}, {
135
+ gateway: true
136
+ })));
137
+ }
138
+ reject(error);
139
+ });
140
+ });
141
+ }
142
+ }, {
143
+ key: "setFavouriteAgent",
144
+ value: function setFavouriteAgent(agentId, isFavourite, analytics) {
145
+ var _this4 = this;
146
+ if (!this.options.cloudId) {
147
+ return Promise.reject(new Error('cloudId is missing'));
148
+ }
149
+ return new Promise( /*#__PURE__*/function () {
150
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
151
+ var startTime, product, actionSubjectId, requestMethod, headers;
152
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
153
+ while (1) switch (_context.prev = _context.next) {
154
+ case 0:
155
+ startTime = getPageTime();
156
+ product = _this4.options.productIdentifier || 'rovo';
157
+ actionSubjectId = isFavourite ? 'favourite' : 'unfavourite';
158
+ requestMethod = isFavourite ? 'POST' : 'DELETE';
159
+ if (analytics) {
160
+ analytics(agentRequestAnalytics('triggered', 'actionSubjectId'));
161
+ }
162
+ headers = createHeaders(product, _this4.options.cloudId);
163
+ _context.next = 8;
164
+ return fetch(new Request("/gateway/api/assist/agents/v1/".concat(agentId, "/favourite"), {
165
+ method: requestMethod,
166
+ credentials: 'include',
167
+ mode: 'cors',
168
+ headers: headers
169
+ })).then(function () {
170
+ if (analytics) {
171
+ analytics(agentRequestAnalytics('succeeded', actionSubjectId, {
172
+ duration: getPageTime() - startTime,
173
+ gateway: true
174
+ }));
175
+ }
176
+ resolve();
177
+ }).catch(function (error) {
178
+ if (analytics) {
179
+ analytics(agentRequestAnalytics('failed', actionSubjectId, _objectSpread(_objectSpread({
180
+ duration: getPageTime() - startTime
181
+ }, getErrorAttributes(error)), {}, {
182
+ gateway: true
183
+ })));
184
+ }
185
+ reject(error);
186
+ });
187
+ case 8:
188
+ case "end":
189
+ return _context.stop();
190
+ }
191
+ }, _callee);
192
+ }));
193
+ return function (_x, _x2) {
194
+ return _ref.apply(this, arguments);
195
+ };
196
+ }());
197
+ }
76
198
  }]);
77
199
  return RovoAgentCardClient;
78
200
  }(CachingClient);
@@ -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.23.0");
51
+ headers.append('atl-client-version', "19.24.0");
52
52
  return headers;
53
53
  };
54
54
  export function getTeamFromAGG(_x, _x2, _x3) {
@@ -68,7 +68,8 @@ export var AgentActions = function AgentActions(_ref3) {
68
68
  onDeleteAgent = _ref3.onDeleteAgent,
69
69
  onDuplicateAgent = _ref3.onDuplicateAgent,
70
70
  onCopyAgent = _ref3.onCopyAgent,
71
- onChatClick = _ref3.onChatClick;
71
+ onChatClick = _ref3.onChatClick,
72
+ agent = _ref3.agent;
72
73
  var _useIntl = useIntl(),
73
74
  formatMessage = _useIntl.formatMessage;
74
75
  var _useState = useState(false),
@@ -149,8 +150,8 @@ export var AgentActions = function AgentActions(_ref3) {
149
150
  setIsDeleteModalOpen(false);
150
151
  },
151
152
  onSubmit: onDeleteAgent,
152
- agentId: 'some Id',
153
- agentName: "agentName"
153
+ agentId: agent.id,
154
+ agentName: agent.name
154
155
  }));
155
156
  };
156
157
  var messages = defineMessages({
@@ -49,45 +49,45 @@ export var AgentDeleteConfirmationModal = function AgentDeleteConfirmationModal(
49
49
  };
50
50
  var messages = defineMessages({
51
51
  cancelText: {
52
- id: 'ai-mate.agent-modal.agent-delete-confirm.cancel-text',
52
+ id: 'profilecard.agent-profile.agent-delete-confirm.cancel-text',
53
53
  defaultMessage: 'Cancel'
54
54
  },
55
55
  confirmText: {
56
- id: 'ai-mate.agent-modal.agent-delete-confirm.confirm-text',
56
+ id: 'profilecard.agent-profile.agent-delete-confirm.confirm-text',
57
57
  defaultMessage: 'Delete'
58
58
  },
59
59
  title: {
60
- id: 'ai-mate.agent-list.delete-agent-confirm-title',
60
+ id: 'profilecard.agent-profile.delete-agent-confirm-title',
61
61
  defaultMessage: 'Delete "{agentName}"?',
62
62
  description: 'Title text for the delete agent confirmation modal'
63
63
  },
64
64
  body: {
65
- id: 'ai-mate.agent-list.delete-agent-confirm-body',
65
+ id: 'profilecard.agent-profile.delete-agent-confirm-body',
66
66
  defaultMessage: "Are you sure you want to delete this agent? This action cannot be undone.",
67
67
  description: 'Body text for the delete agent confirmation modal'
68
68
  },
69
69
  error: {
70
- id: 'ai-mate.agent-list.delete-agent-error',
70
+ id: 'profilecard.agent-profile.delete-agent-error',
71
71
  defaultMessage: 'Could not delete agent',
72
72
  description: 'Error message displayed when an agent cannot be deleted'
73
73
  },
74
74
  errorAgentNotFound: {
75
- id: 'ai-mate.agent-list.delete-agent-error.agent-not-found',
75
+ id: 'profilecard.agent-profile.delete-agent-error.agent-not-found',
76
76
  defaultMessage: 'That agent could not be found.',
77
77
  description: 'Error message displayed when an agent cannot be found'
78
78
  },
79
79
  errorAgentInUse: {
80
- id: 'ai-mate.agent-list.delete-agent-error.agent-in-use',
80
+ id: 'profilecard.agent-profile.delete-agent-error.agent-in-use',
81
81
  defaultMessage: 'Agent is currently in use. Try again later.',
82
82
  description: 'Error message displayed when an agent is in use'
83
83
  },
84
84
  errorIncorrectOwner: {
85
- id: 'ai-mate.agent-list.delete-agent-error.incorrect-owner',
85
+ id: 'profilecard.agent-profile.delete-agent-error.incorrect-owner',
86
86
  defaultMessage: 'You cannot delete agents you have not created yourself. Please contact the agent owner.',
87
87
  description: 'Error message displayed when the agent owner is incorrect'
88
88
  },
89
89
  agentDeletedSuccess: {
90
- id: 'ai-mate.agent-list.delete-agent-success',
90
+ id: 'profilecard.agent-profile.delete-agent-success',
91
91
  defaultMessage: 'Agent has been deleted!',
92
92
  description: 'Success message displayed when an agent is deleted'
93
93
  }
@@ -1,6 +1,8 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import React, { useCallback, useEffect } from 'react';
4
+ import React, { useCallback, useEffect, useState } from 'react';
5
+ import { useIntl } from 'react-intl-next';
4
6
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
5
7
  import { Box, Stack, xcss } from '@atlaskit/primitives';
6
8
  import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
@@ -11,8 +13,7 @@ import { AgentActions } from './Actions';
11
13
  import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
12
14
  import { ConversationStarters } from './ConversationStarters';
13
15
  import { useAgentUrlActions } from './hooks/useAgentActions';
14
- import { useDeleteAgent } from './hooks/useDeleteAgent';
15
- import { useSetFavouriteAgent } from './hooks/useSetFavouriteAgent';
16
+ import { messages } from './messages';
16
17
  var styles = xcss({
17
18
  paddingBlockStart: 'space.400',
18
19
  paddingInline: 'space.200'
@@ -38,7 +39,9 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
38
39
  product = _ref$product === void 0 ? 'rovo' : _ref$product,
39
40
  hasError = _ref.hasError,
40
41
  errorType = _ref.errorType,
41
- onConversationStartersClick = _ref.onConversationStartersClick;
42
+ onConversationStartersClick = _ref.onConversationStartersClick,
43
+ resourceClient = _ref.resourceClient,
44
+ addFlag = _ref.addFlag;
42
45
  var _useAgentUrlActions = useAgentUrlActions({
43
46
  cloudId: cloudId || ''
44
47
  }),
@@ -47,19 +50,15 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
47
50
  _onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
48
51
  onOpenChatFullScreecn = _useAgentUrlActions.onOpenChat,
49
52
  onConversationStarter = _useAgentUrlActions.onConversationStarter;
50
- var _useSetFavouriteAgent = useSetFavouriteAgent({
51
- agentId: agent === null || agent === void 0 ? void 0 : agent.id,
52
- cloudId: cloudId,
53
- isStarred: !!(agent !== null && agent !== void 0 && agent.favourite),
54
- product: product
55
- }),
56
- isStarred = _useSetFavouriteAgent.isStarred,
57
- setFavourite = _useSetFavouriteAgent.setFavourite;
58
- var _useDeleteAgent = useDeleteAgent({
59
- cloudId: cloudId,
60
- product: product
61
- }),
62
- deleteAgent = _useDeleteAgent.deleteAgent;
53
+ var _useState = useState(false),
54
+ _useState2 = _slicedToArray(_useState, 2),
55
+ isStarred = _useState2[0],
56
+ setIsStarred = _useState2[1];
57
+ var _useIntl = useIntl(),
58
+ formatMessage = _useIntl.formatMessage;
59
+ useEffect(function () {
60
+ setIsStarred(!!(agent !== null && agent !== void 0 && agent.favourite));
61
+ }, [agent === null || agent === void 0 ? void 0 : agent.favourite]);
63
62
  var _useAnalyticsEvents = useAnalyticsEvents(),
64
63
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
65
64
  var fireAnalytics = useCallback(function (payload) {
@@ -67,27 +66,67 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
67
66
  fireEvent(createAnalyticsEvent, payload);
68
67
  }
69
68
  }, [createAnalyticsEvent]);
70
- var handleOnDelete = /*#__PURE__*/function () {
71
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
72
- return _regeneratorRuntime.wrap(function _callee$(_context) {
73
- while (1) switch (_context.prev = _context.next) {
74
- case 0:
75
- if (!agent) {
76
- _context.next = 3;
77
- break;
78
- }
79
- _context.next = 3;
80
- return deleteAgent(agent.id);
81
- case 3:
82
- case "end":
83
- return _context.stop();
84
- }
85
- }, _callee);
86
- }));
87
- return function handleOnDelete() {
88
- return _ref2.apply(this, arguments);
89
- };
90
- }();
69
+ var handleSetFavourite = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
70
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ if (!(agent !== null && agent !== void 0 && agent.id)) {
74
+ _context.next = 9;
75
+ break;
76
+ }
77
+ _context.prev = 1;
78
+ _context.next = 4;
79
+ return resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics);
80
+ case 4:
81
+ setIsStarred(!isStarred);
82
+ _context.next = 9;
83
+ break;
84
+ case 7:
85
+ _context.prev = 7;
86
+ _context.t0 = _context["catch"](1);
87
+ case 9:
88
+ case "end":
89
+ return _context.stop();
90
+ }
91
+ }, _callee, null, [[1, 7]]);
92
+ })), [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, isStarred, resourceClient]);
93
+ var handleOnDelete = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
94
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
95
+ while (1) switch (_context2.prev = _context2.next) {
96
+ case 0:
97
+ if (!agent) {
98
+ _context2.next = 10;
99
+ break;
100
+ }
101
+ _context2.prev = 1;
102
+ _context2.next = 4;
103
+ return resourceClient.deleteAgent(agent.id, fireAnalytics);
104
+ case 4:
105
+ addFlag === null || addFlag === void 0 || addFlag({
106
+ title: formatMessage(messages.agentDeletedSuccessFlagTitle),
107
+ description: formatMessage(messages.agentDeletedSuccessFlagDescription, {
108
+ agentName: agent.name
109
+ }),
110
+ type: 'success',
111
+ id: 'ptc-directory.agent-profile.delete-agent-success'
112
+ });
113
+ _context2.next = 10;
114
+ break;
115
+ case 7:
116
+ _context2.prev = 7;
117
+ _context2.t0 = _context2["catch"](1);
118
+ addFlag === null || addFlag === void 0 || addFlag({
119
+ title: formatMessage(messages.agentDeletedErrorFlagTitle),
120
+ description: formatMessage(messages.agentDeletedErrorFlagDescription),
121
+ type: 'error',
122
+ id: 'ptc-directory.agent-profile.delete-agent-error'
123
+ });
124
+ case 10:
125
+ case "end":
126
+ return _context2.stop();
127
+ }
128
+ }, _callee2, null, [[1, 7]]);
129
+ })), [addFlag, agent, fireAnalytics, formatMessage, resourceClient]);
91
130
  useEffect(function () {
92
131
  if (!isLoading && agent) {
93
132
  fireAnalytics(profileCardRendered('agent', 'content'));
@@ -123,7 +162,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
123
162
  }, /*#__PURE__*/React.createElement(AgentProfileInfo, {
124
163
  agentName: agent.name,
125
164
  isStarred: isStarred,
126
- onStarToggle: setFavourite,
165
+ onStarToggle: handleSetFavourite,
127
166
  isHidden: agent.visibility === 'PRIVATE',
128
167
  creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/React.createElement(AgentProfileCreator, {
129
168
  creator: {
@@ -149,6 +188,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
149
188
  });
150
189
  }
151
190
  })), /*#__PURE__*/React.createElement(AgentActions, {
191
+ agent: agent,
152
192
  isAgentCreatedByCurrentUser: isCreatedByViewingUser,
153
193
  onEditAgent: function onEditAgent() {
154
194
  return _onEditAgent(agent.id);
@@ -168,7 +168,9 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
168
168
  isCreatedByViewingUser: creatorUserId === props.viewingUserId,
169
169
  product: props.product,
170
170
  onConversationStartersClick: props.onConversationStartersClick,
171
- onChatClick: props.onChatClick
171
+ onChatClick: props.onChatClick,
172
+ addFlag: props.addFlag,
173
+ resourceClient: props.resourceClient
172
174
  });
173
175
  }
174
176
  return null;
@@ -126,12 +126,14 @@ export var AgentProfileCardTrigger = function AgentProfileCardTrigger(_ref) {
126
126
  }, /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
127
127
  agent: profileData,
128
128
  hasError: !!error,
129
- isCreatedByViewingUser: (profileData === null || profileData === void 0 || (_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
129
+ isCreatedByViewingUser: (profileData === null || profileData === void 0 ? void 0 : profileData.creatorInfo) && (profileData === null || profileData === void 0 || (_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
130
130
  cloudId: props.cloudId,
131
131
  product: product,
132
132
  errorType: error,
133
133
  onChatClick: props.onChatClick,
134
- onConversationStartersClick: props.onConversationStartersClick
134
+ onConversationStartersClick: props.onConversationStartersClick,
135
+ resourceClient: props.resourceClient,
136
+ addFlag: props.addFlag
135
137
  }));
136
138
  };
137
139
  return /*#__PURE__*/React.createElement(ProfileCardTrigger, _extends({}, props, {
@@ -0,0 +1,23 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ agentDeletedSuccessFlagTitle: {
4
+ id: 'profilecard.agent-profile-card.delete-agent-success-flag-title',
5
+ defaultMessage: 'Agent deleted',
6
+ description: 'Flag message title displayed when an agent is deleted'
7
+ },
8
+ agentDeletedSuccessFlagDescription: {
9
+ id: 'profilecard.agent-profile-card.delete-agent-success-flag-description',
10
+ defaultMessage: 'You deleted {agentName}',
11
+ description: 'Flag message description displayed when an agent is deleted'
12
+ },
13
+ agentDeletedErrorFlagTitle: {
14
+ id: 'profilecard.agent-profile-card.delete-agent-error-flag-title',
15
+ defaultMessage: 'Failed to delete Agent',
16
+ description: 'Flag message title displayed when there is an error deleting agent'
17
+ },
18
+ agentDeletedErrorFlagDescription: {
19
+ id: 'profilecard.agent-profile-card.delete-agent-error-flag-description',
20
+ defaultMessage: 'Something went wrong while deleting the agent. Try again in a few moments.',
21
+ description: 'Flag message description displayed when there is an error deleting agent'
22
+ }
23
+ });
@@ -36,7 +36,8 @@ function ProfileCardContent(_ref) {
36
36
  profileCardAction = _ref.profileCardAction,
37
37
  hasError = _ref.hasError,
38
38
  errorType = _ref.errorType,
39
- agentActions = _ref.agentActions;
39
+ agentActions = _ref.agentActions,
40
+ addFlag = _ref.addFlag;
40
41
  if (isAgent && fg('enable_agent_profile_card')) {
41
42
  return /*#__PURE__*/React.createElement(AgentProfileCardResourced, {
42
43
  accountId: userId,
@@ -46,7 +47,8 @@ function ProfileCardContent(_ref) {
46
47
  trigger: trigger,
47
48
  product: product,
48
49
  onChatClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onChatClick,
49
- onConversationStartersClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onConversationStartersClick
50
+ onConversationStartersClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onConversationStartersClick,
51
+ addFlag: addFlag
50
52
  });
51
53
  } else {
52
54
  return /*#__PURE__*/React.createElement(Suspense, {
@@ -339,7 +341,8 @@ export default function ProfilecardTriggerNext(_ref2) {
339
341
  profileCardAction: filterActions(),
340
342
  errorType: error,
341
343
  hasError: hasError,
342
- agentActions: agentActions
344
+ agentActions: agentActions,
345
+ addFlag: addFlag
343
346
  }));
344
347
  },
345
348
  trigger: function trigger(triggerProps) {
@@ -54,38 +54,26 @@ function ProfileCardTrigger(_ref) {
54
54
  setVisible(false);
55
55
  }, hideDelay);
56
56
  }, [hideDelay]);
57
- var showProfilecard = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
58
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
59
- while (1) switch (_context2.prev = _context2.next) {
57
+ var showProfilecard = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
58
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
59
+ while (1) switch (_context.prev = _context.next) {
60
60
  case 0:
61
61
  clearTimeout(hideTimer.current);
62
62
  clearTimeout(showTimer.current);
63
- showTimer.current = window.setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
64
- return _regeneratorRuntime.wrap(function _callee$(_context) {
65
- while (1) switch (_context.prev = _context.next) {
66
- case 0:
67
- if (visible) {
68
- _context.next = 5;
69
- break;
70
- }
71
- _context.next = 3;
72
- return getProfileData === null || getProfileData === void 0 ? void 0 : getProfileData();
73
- case 3:
74
- setVisible(true);
75
- if (fireAnalytics) {
76
- fireAnalytics(cardTriggered(profileCardType, _trigger));
77
- }
78
- case 5:
79
- case "end":
80
- return _context.stop();
63
+ showTimer.current = window.setTimeout(function () {
64
+ if (!visible) {
65
+ getProfileData === null || getProfileData === void 0 || getProfileData();
66
+ setVisible(true);
67
+ if (fireAnalytics) {
68
+ fireAnalytics(cardTriggered(profileCardType, _trigger));
81
69
  }
82
- }, _callee);
83
- })), showDelay);
70
+ }
71
+ }, showDelay);
84
72
  case 3:
85
73
  case "end":
86
- return _context2.stop();
74
+ return _context.stop();
87
75
  }
88
- }, _callee2);
76
+ }, _callee);
89
77
  })), [showDelay, visible, getProfileData, fireAnalytics, profileCardType, _trigger]);
90
78
  var onMouseEnter = useCallback(function () {
91
79
  showProfilecard();
@@ -39,7 +39,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
39
39
  actionSubjectId: actionSubjectId,
40
40
  attributes: _objectSpread(_objectSpread({
41
41
  packageName: "@atlaskit/profilecard",
42
- packageVersion: "19.23.0"
42
+ packageVersion: "19.24.0"
43
43
  }, attributes), {}, {
44
44
  firedAt: Math.round(getPageTime())
45
45
  })
@@ -89,6 +89,6 @@ export var moreMembersClicked = function moreMembersClicked(attributes) {
89
89
  export var errorRetryClicked = function errorRetryClicked(attributes) {
90
90
  return createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
91
91
  };
92
- export var agentRequestAnalytics = function agentRequestAnalytics(action, attributes) {
93
- return createEvent('operational', action, AGENT_SUBJECT, 'request', attributes);
92
+ export var agentRequestAnalytics = function agentRequestAnalytics(action, actionSubjectId, attributes) {
93
+ return createEvent('operational', action, AGENT_SUBJECT, actionSubjectId || 'request', attributes);
94
94
  };
@@ -1,17 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- 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; }
3
- 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; }
4
1
  export var USER_ARI_PREFIX = 'ari:cloud:identity::user/';
5
- export var createHeaders = function createHeaders(product, cloudId) {
6
- var config = {
7
- headers: {
8
- 'X-Product': product,
9
- 'X-Experience-Id': 'profile-card',
10
- 'X-Cloudid': cloudId
11
- }
12
- };
13
- return new Headers(_objectSpread({}, config.headers || {}));
14
- };
15
2
  export var getAAIDFromARI = function getAAIDFromARI(ari) {
16
3
  return ari.replace(USER_ARI_PREFIX, '');
17
4
  };
@@ -17,5 +17,7 @@ declare class ProfileCardClient {
17
17
  getTeamCentralBaseUrl(): string | undefined;
18
18
  shouldShowGiveKudos(): Promise<boolean>;
19
19
  getRovoAgentProfile(id: AgentIdType, analytics?: (event: AnalyticsEventPayload) => void): Promise<import("../types").RovoAgent>;
20
+ deleteAgent(id: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
21
+ setFavouriteAgent(id: string, isFavourite: boolean, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
20
22
  }
21
23
  export default ProfileCardClient;
@@ -6,4 +6,6 @@ export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
6
6
  constructor(options: ProfileClientOptions);
7
7
  makeRequest(id: AgentIdType, cloudId: string): Promise<RovoAgent>;
8
8
  getProfile(id: AgentIdType, analytics?: (event: AnalyticsEventPayload) => void): Promise<RovoAgent>;
9
+ deleteAgent(agentId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
10
+ setFavouriteAgent(agentId: string, isFavourite: boolean, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
9
11
  }
@@ -1,5 +1,7 @@
1
1
  /// <reference types="react" />
2
+ import { type RovoAgentProfileCardInfo } from '../../types';
2
3
  type AgentActionsProps = {
4
+ agent: RovoAgentProfileCardInfo;
3
5
  isAgentCreatedByCurrentUser?: boolean;
4
6
  onEditAgent: () => void;
5
7
  onCopyAgent: () => void;
@@ -7,5 +9,5 @@ type AgentActionsProps = {
7
9
  onDeleteAgent: () => void;
8
10
  onChatClick: () => void;
9
11
  };
10
- export declare const AgentActions: ({ isAgentCreatedByCurrentUser, onEditAgent, onDeleteAgent, onDuplicateAgent, onCopyAgent, onChatClick, }: AgentActionsProps) => JSX.Element;
12
+ export declare const AgentActions: ({ isAgentCreatedByCurrentUser, onEditAgent, onDeleteAgent, onDuplicateAgent, onCopyAgent, onChatClick, agent, }: AgentActionsProps) => JSX.Element;
11
13
  export {};