@atlaskit/profilecard 20.9.0 → 20.10.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 (36) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/client/ProfileCardClient.js +10 -4
  3. package/dist/cjs/client/RovoAgentCardClient.js +57 -12
  4. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  5. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  6. package/dist/cjs/components/Agent/Actions.js +54 -11
  7. package/dist/cjs/components/Agent/AgentProfileCard.js +6 -1
  8. package/dist/cjs/components/Agent/hooks/useAgentActions.js +5 -1
  9. package/dist/cjs/util/analytics.js +1 -1
  10. package/dist/es2019/client/ProfileCardClient.js +8 -4
  11. package/dist/es2019/client/RovoAgentCardClient.js +48 -10
  12. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  13. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  14. package/dist/es2019/components/Agent/Actions.js +33 -4
  15. package/dist/es2019/components/Agent/AgentProfileCard.js +5 -2
  16. package/dist/es2019/components/Agent/hooks/useAgentActions.js +5 -1
  17. package/dist/es2019/util/analytics.js +1 -1
  18. package/dist/esm/client/ProfileCardClient.js +10 -4
  19. package/dist/esm/client/RovoAgentCardClient.js +57 -12
  20. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  21. package/dist/esm/client/getTeamFromAGG.js +1 -1
  22. package/dist/esm/components/Agent/Actions.js +56 -13
  23. package/dist/esm/components/Agent/AgentProfileCard.js +6 -1
  24. package/dist/esm/components/Agent/hooks/useAgentActions.js +5 -1
  25. package/dist/esm/util/analytics.js +1 -1
  26. package/dist/types/client/ProfileCardClient.d.ts +1 -0
  27. package/dist/types/client/RovoAgentCardClient.d.ts +2 -1
  28. package/dist/types/components/Agent/Actions.d.ts +4 -2
  29. package/dist/types/components/Agent/hooks/useAgentActions.d.ts +1 -0
  30. package/dist/types/types.d.ts +7 -0
  31. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +1 -0
  32. package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +2 -1
  33. package/dist/types-ts4.5/components/Agent/Actions.d.ts +4 -2
  34. package/dist/types-ts4.5/components/Agent/hooks/useAgentActions.d.ts +1 -0
  35. package/dist/types-ts4.5/types.d.ts +7 -0
  36. package/package.json +8 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 20.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#163699](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/163699)
8
+ [`f946e35c60150`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f946e35c60150) -
9
+ Refactor to use shared agent dropdown from @atlaskit/rovo-agent-components
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 20.9.0
4
16
 
5
17
  ### Minor Changes
@@ -165,17 +165,23 @@ var ProfileCardClient = /*#__PURE__*/function () {
165
165
  var _this$rovoAgentClient2;
166
166
  return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
167
167
  }
168
+ }, {
169
+ key: "getRovoAgentPermissions",
170
+ value: function getRovoAgentPermissions(id, fireAnalytics) {
171
+ var _this$rovoAgentClient3;
172
+ return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.getPermissions(id, fireAnalytics);
173
+ }
168
174
  }, {
169
175
  key: "deleteAgent",
170
176
  value: function deleteAgent(id, analytics) {
171
- var _this$rovoAgentClient3;
172
- return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.deleteAgent(id, analytics);
177
+ var _this$rovoAgentClient4;
178
+ return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.deleteAgent(id, analytics);
173
179
  }
174
180
  }, {
175
181
  key: "setFavouriteAgent",
176
182
  value: function setFavouriteAgent(id, isFavourite, analytics) {
177
- var _this$rovoAgentClient4;
178
- return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.setFavouriteAgent(id, isFavourite, analytics);
183
+ var _this$rovoAgentClient5;
184
+ return (_this$rovoAgentClient5 = this.rovoAgentClient) === null || _this$rovoAgentClient5 === void 0 ? void 0 : _this$rovoAgentClient5.setFavouriteAgent(id, isFavourite, analytics);
179
185
  }
180
186
  }]);
181
187
  return ProfileCardClient;
@@ -7,29 +7,30 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
16
  var _analytics = require("../util/analytics");
17
17
  var _performance = require("../util/performance");
18
18
  var _CachingClient2 = _interopRequireDefault(require("./CachingClient"));
19
19
  var _errorUtils = require("./errorUtils");
20
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
21
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
20
  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; }
23
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
- var createHeaders = function createHeaders(product, cloudId) {
25
- var config = {
26
- headers: {
27
- 'X-Product': product,
28
- 'X-Experience-Id': 'profile-card',
29
- 'X-Cloudid': cloudId || ''
30
- }
31
- };
32
- return new Headers(_objectSpread({}, config.headers || {}));
22
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
23
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
+ var createHeaders = function createHeaders(product, cloudId, isBodyJson) {
25
+ var headers = new Headers({
26
+ 'X-Product': product,
27
+ 'X-Experience-Id': 'profile-card',
28
+ 'X-Cloudid': cloudId || ''
29
+ });
30
+ if (isBodyJson) {
31
+ headers.set('Content-Type', 'application/json');
32
+ }
33
+ return headers;
33
34
  };
34
35
  var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClient) {
35
36
  (0, _inherits2.default)(RovoAgentCardClient, _CachingClient);
@@ -202,6 +203,50 @@ var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClien
202
203
  };
203
204
  }());
204
205
  }
206
+ }, {
207
+ key: "getPermissions",
208
+ value: function getPermissions(id, fireAnalytics) {
209
+ var _this5 = this;
210
+ if (!this.options.cloudId) {
211
+ return Promise.reject(new Error('cloudId is missing'));
212
+ }
213
+ return new Promise(function (resolve, reject) {
214
+ var startTime = (0, _performance.getPageTime)();
215
+ var product = _this5.options.productIdentifier || 'rovo';
216
+ if (fireAnalytics) {
217
+ fireAnalytics((0, _analytics.agentRequestAnalytics)('triggered'));
218
+ }
219
+ var headers = createHeaders(product, _this5.options.cloudId, true);
220
+ fetch(new Request("/gateway/api/assist/api/rovo/v2/permissions/agents/".concat(id), {
221
+ method: 'POST',
222
+ credentials: 'include',
223
+ mode: 'cors',
224
+ headers: headers,
225
+ body: JSON.stringify({
226
+ permission_ids: ['AGENT_CREATE', 'AGENT_UPDATE', 'AGENT_DELETE', 'AGENT_DEACTIVATE', 'AGENT_READ']
227
+ })
228
+ })).then(function (response) {
229
+ return response.json();
230
+ }).then(function (data) {
231
+ if (fireAnalytics) {
232
+ fireAnalytics((0, _analytics.agentRequestAnalytics)('succeeded', 'getAgentPermissions', {
233
+ duration: (0, _performance.getPageTime)() - startTime,
234
+ gateway: true
235
+ }));
236
+ }
237
+ resolve(data);
238
+ }).catch(function (error) {
239
+ if (fireAnalytics) {
240
+ fireAnalytics((0, _analytics.agentRequestAnalytics)('failed', 'getAgentPermissions', _objectSpread(_objectSpread({
241
+ duration: (0, _performance.getPageTime)() - startTime
242
+ }, (0, _errorUtils.getErrorAttributes)(error)), {}, {
243
+ gateway: true
244
+ })));
245
+ }
246
+ reject(error);
247
+ });
248
+ });
249
+ }
205
250
  }]);
206
251
  return RovoAgentCardClient;
207
252
  }(_CachingClient2.default);
@@ -11,7 +11,7 @@ var _graphqlUtils = require("./graphqlUtils");
11
11
  var ORG_ID_FROM_CLOUD_ID_QUERY = "query OrgIdFromCloudId($cloudId: ID!) {\n\ttenantContexts(cloudIds: [$cloudId]) {\n\t\torgId\n\t}\n}";
12
12
  var addHeaders = function addHeaders(headers) {
13
13
  headers.append('atl-client-name', "@atlaskit/profilecard");
14
- headers.append('atl-client-version', "20.9.0");
14
+ headers.append('atl-client-version', "20.10.0");
15
15
  return headers;
16
16
  };
17
17
  function getOrgIdForCloudIdFromAGG(_x, _x2) {
@@ -57,7 +57,7 @@ var addHeaders = exports.addHeaders = function addHeaders(headers) {
57
57
  headers.append('X-ExperimentalApi', 'teams-beta');
58
58
  headers.append('X-ExperimentalApi', 'team-members-beta');
59
59
  headers.append('atl-client-name', "@atlaskit/profilecard");
60
- headers.append('atl-client-version', "20.9.0");
60
+ headers.append('atl-client-version', "20.10.0");
61
61
  return headers;
62
62
  };
63
63
  function getTeamFromAGG(_x, _x2, _x3) {
@@ -8,12 +8,15 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.AgentActions = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
13
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
14
  var _react = _interopRequireWildcard(require("react"));
13
15
  var _reactIntlNext = require("react-intl-next");
14
16
  var _new = _interopRequireWildcard(require("@atlaskit/button/new"));
15
17
  var _dropdownMenu = _interopRequireWildcard(require("@atlaskit/dropdown-menu"));
16
18
  var _showMoreHorizontalMore = _interopRequireDefault(require("@atlaskit/icon/core/migration/show-more-horizontal--more"));
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
20
  var _primitives = require("@atlaskit/primitives");
18
21
  var _rovoAgentComponents = require("@atlaskit/rovo-agent-components");
19
22
  var _AgentDeleteConfirmationModal = require("./AgentDeleteConfirmationModal");
@@ -82,13 +85,38 @@ var AgentActions = exports.AgentActions = function AgentActions(_ref3) {
82
85
  onDuplicateAgent = _ref3.onDuplicateAgent,
83
86
  onCopyAgent = _ref3.onCopyAgent,
84
87
  onChatClick = _ref3.onChatClick,
85
- agent = _ref3.agent;
88
+ onViewFullProfileClick = _ref3.onViewFullProfileClick,
89
+ agent = _ref3.agent,
90
+ resourceClient = _ref3.resourceClient;
86
91
  var _useIntl = (0, _reactIntlNext.useIntl)(),
87
92
  formatMessage = _useIntl.formatMessage;
88
93
  var _useState = (0, _react.useState)(false),
89
94
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
90
95
  isDeleteModalOpen = _useState2[0],
91
96
  setIsDeleteModalOpen = _useState2[1];
97
+ var isForgeAgent = agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY';
98
+ var loadAgentPermissions = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
99
+ var _yield$resourceClient, _yield$resourceClient2, AGENT_UPDATE, AGENT_DEACTIVATE;
100
+ return _regenerator.default.wrap(function _callee$(_context) {
101
+ while (1) switch (_context.prev = _context.next) {
102
+ case 0:
103
+ _context.next = 2;
104
+ return resourceClient.getRovoAgentPermissions(agent.id);
105
+ case 2:
106
+ _yield$resourceClient = _context.sent;
107
+ _yield$resourceClient2 = _yield$resourceClient.permissions;
108
+ AGENT_UPDATE = _yield$resourceClient2.AGENT_UPDATE;
109
+ AGENT_DEACTIVATE = _yield$resourceClient2.AGENT_DEACTIVATE;
110
+ return _context.abrupt("return", {
111
+ isEditEnabled: AGENT_UPDATE.permitted,
112
+ isDeleteEnabled: AGENT_DEACTIVATE.permitted
113
+ });
114
+ case 7:
115
+ case "end":
116
+ return _context.stop();
117
+ }
118
+ }, _callee);
119
+ })), [agent.id, resourceClient]);
92
120
  var agentActions = buildAgentActions({
93
121
  onDuplicateAgent: onDuplicateAgent,
94
122
  onCopyAgent: onCopyAgent,
@@ -120,10 +148,25 @@ var AgentActions = exports.AgentActions = function AgentActions(_ref3) {
120
148
  xcss: chatPillIconWrapper
121
149
  }, /*#__PURE__*/_react.default.createElement(_rovoAgentComponents.ChatPillIcon, null)), /*#__PURE__*/_react.default.createElement(_primitives.Box, {
122
150
  xcss: chatPillTextStyles
123
- }, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
124
- trigger: function trigger(_ref4) {
125
- var triggerRef = _ref4.triggerRef,
126
- props = (0, _objectWithoutProperties2.default)(_ref4, _excluded);
151
+ }, formatMessage(messages.actionChatToAgent)))))), (0, _platformFeatureFlags.fg)('rovo_use_agent_permissions') ? /*#__PURE__*/_react.default.createElement(_rovoAgentComponents.AgentDropdownMenu, {
152
+ agentId: agent.id,
153
+ isAgentCreatedByUser: isAgentCreatedByCurrentUser !== null && isAgentCreatedByCurrentUser !== void 0 ? isAgentCreatedByCurrentUser : false,
154
+ onDeleteAgent: function onDeleteAgent() {
155
+ return setIsDeleteModalOpen(true);
156
+ },
157
+ onEditAgent: onEditAgent,
158
+ onDuplicateAgent: onDuplicateAgent,
159
+ onCopyAgent: onCopyAgent,
160
+ isForgeAgent: isForgeAgent,
161
+ loadAgentPermissions: loadAgentPermissions,
162
+ loadPermissionsOnMount: true,
163
+ onViewAgentFullProfileClick: onViewFullProfileClick,
164
+ doesAgentHaveIdentityAccountId: !!agent.identity_account_id,
165
+ shouldTriggerStopPropagation: true
166
+ }) : /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
167
+ trigger: function trigger(_ref5) {
168
+ var triggerRef = _ref5.triggerRef,
169
+ props = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
127
170
  return /*#__PURE__*/_react.default.createElement(_primitives.Box, null, /*#__PURE__*/_react.default.createElement(_new.IconButton, (0, _extends2.default)({}, props, {
128
171
  icon: _showMoreHorizontalMore.default,
129
172
  label: "more",
@@ -136,9 +179,9 @@ var AgentActions = exports.AgentActions = function AgentActions(_ref3) {
136
179
  })));
137
180
  },
138
181
  placement: "bottom-end"
139
- }, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItemGroup, null, agentActions.map(function (_ref5, idx) {
140
- var text = _ref5.text,
141
- _onClick = _ref5.onClick;
182
+ }, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItemGroup, null, agentActions.map(function (_ref6, idx) {
183
+ var text = _ref6.text,
184
+ _onClick = _ref6.onClick;
142
185
  return /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
143
186
  key: idx,
144
187
  onClick: function onClick(e) {
@@ -148,9 +191,9 @@ var AgentActions = exports.AgentActions = function AgentActions(_ref3) {
148
191
  }, text);
149
192
  })), isAgentCreatedByCurrentUser && /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItemGroup, {
150
193
  hasSeparator: true
151
- }, agentSetting.map(function (_ref6, idx) {
152
- var text = _ref6.text,
153
- _onClick2 = _ref6.onClick;
194
+ }, agentSetting.map(function (_ref7, idx) {
195
+ var text = _ref7.text,
196
+ _onClick2 = _ref7.onClick;
154
197
  return /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
155
198
  key: idx,
156
199
  onClick: function onClick(e) {
@@ -59,7 +59,8 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
59
59
  _onCopyAgent = _useAgentUrlActions.onCopyAgent,
60
60
  _onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
61
61
  onOpenChatFullScreen = _useAgentUrlActions.onOpenChat,
62
- onConversationStarter = _useAgentUrlActions.onConversationStarter;
62
+ onConversationStarter = _useAgentUrlActions.onConversationStarter,
63
+ onViewFullProfile = _useAgentUrlActions.onViewFullProfile;
63
64
  var _useState = (0, _react.useState)(false),
64
65
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
65
66
  isStarred = _useState2[0],
@@ -232,6 +233,10 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
232
233
  onDeleteAgent: handleOnDelete,
233
234
  onChatClick: function onChatClick() {
234
235
  return _onChatClick ? _onChatClick() : onOpenChatFullScreen(agent.id);
236
+ },
237
+ resourceClient: resourceClient,
238
+ onViewFullProfileClick: function onViewFullProfileClick() {
239
+ return onViewFullProfile(agent.id);
235
240
  }
236
241
  })));
237
242
  };
@@ -75,11 +75,15 @@ var useAgentUrlActions = exports.useAgentUrlActions = function useAgentUrlAction
75
75
  })));
76
76
  window.open(urlWithParams, '_blank', 'noopener, noreferrer');
77
77
  };
78
+ var onViewFullProfile = function onViewFullProfile(agentId) {
79
+ window.open("".concat(window.location.origin, "/people/agent/").concat(agentId), '_blank', 'noopener, noreferrer');
80
+ };
78
81
  return {
79
82
  onEditAgent: onEditAgent,
80
83
  onCopyAgent: onCopyAgent,
81
84
  onDuplicateAgent: onDuplicateAgent,
82
85
  onOpenChat: onOpenChat,
83
- onConversationStarter: onConversationStarter
86
+ onConversationStarter: onConversationStarter,
87
+ onViewFullProfile: onViewFullProfile
84
88
  };
85
89
  };
@@ -45,7 +45,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
45
45
  actionSubjectId: actionSubjectId,
46
46
  attributes: _objectSpread(_objectSpread({
47
47
  packageName: "@atlaskit/profilecard",
48
- packageVersion: "20.9.0"
48
+ packageVersion: "20.10.0"
49
49
  }, attributes), {}, {
50
50
  firedAt: Math.round((0, _performance.getPageTime)())
51
51
  })
@@ -78,13 +78,17 @@ class ProfileCardClient {
78
78
  var _this$rovoAgentClient2;
79
79
  return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
80
80
  }
81
- deleteAgent(id, analytics) {
81
+ getRovoAgentPermissions(id, fireAnalytics) {
82
82
  var _this$rovoAgentClient3;
83
- return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.deleteAgent(id, analytics);
83
+ return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.getPermissions(id, fireAnalytics);
84
84
  }
85
- setFavouriteAgent(id, isFavourite, analytics) {
85
+ deleteAgent(id, analytics) {
86
86
  var _this$rovoAgentClient4;
87
- return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.setFavouriteAgent(id, isFavourite, analytics);
87
+ return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.deleteAgent(id, analytics);
88
+ }
89
+ setFavouriteAgent(id, isFavourite, analytics) {
90
+ var _this$rovoAgentClient5;
91
+ return (_this$rovoAgentClient5 = this.rovoAgentClient) === null || _this$rovoAgentClient5 === void 0 ? void 0 : _this$rovoAgentClient5.setFavouriteAgent(id, isFavourite, analytics);
88
92
  }
89
93
  }
90
94
  function maybeCreateTeamCentralClient(config, clients) {
@@ -2,17 +2,16 @@ import { agentRequestAnalytics } from '../util/analytics';
2
2
  import { getPageTime } from '../util/performance';
3
3
  import CachingClient from './CachingClient';
4
4
  import { getErrorAttributes } from './errorUtils';
5
- const createHeaders = (product, cloudId) => {
6
- const config = {
7
- headers: {
8
- 'X-Product': product,
9
- 'X-Experience-Id': 'profile-card',
10
- 'X-Cloudid': cloudId || ''
11
- }
12
- };
13
- return new Headers({
14
- ...(config.headers || {})
5
+ const createHeaders = (product, cloudId, isBodyJson) => {
6
+ const headers = new Headers({
7
+ 'X-Product': product,
8
+ 'X-Experience-Id': 'profile-card',
9
+ 'X-Cloudid': cloudId || ''
15
10
  });
11
+ if (isBodyJson) {
12
+ headers.set('Content-Type', 'application/json');
13
+ }
14
+ return headers;
16
15
  };
17
16
  export default class RovoAgentCardClient extends CachingClient {
18
17
  constructor(options) {
@@ -150,4 +149,43 @@ export default class RovoAgentCardClient extends CachingClient {
150
149
  });
151
150
  });
152
151
  }
152
+ getPermissions(id, fireAnalytics) {
153
+ if (!this.options.cloudId) {
154
+ return Promise.reject(new Error('cloudId is missing'));
155
+ }
156
+ return new Promise((resolve, reject) => {
157
+ const startTime = getPageTime();
158
+ const product = this.options.productIdentifier || 'rovo';
159
+ if (fireAnalytics) {
160
+ fireAnalytics(agentRequestAnalytics('triggered'));
161
+ }
162
+ const headers = createHeaders(product, this.options.cloudId, true);
163
+ fetch(new Request(`/gateway/api/assist/api/rovo/v2/permissions/agents/${id}`, {
164
+ method: 'POST',
165
+ credentials: 'include',
166
+ mode: 'cors',
167
+ headers,
168
+ body: JSON.stringify({
169
+ permission_ids: ['AGENT_CREATE', 'AGENT_UPDATE', 'AGENT_DELETE', 'AGENT_DEACTIVATE', 'AGENT_READ']
170
+ })
171
+ })).then(response => response.json()).then(data => {
172
+ if (fireAnalytics) {
173
+ fireAnalytics(agentRequestAnalytics('succeeded', 'getAgentPermissions', {
174
+ duration: getPageTime() - startTime,
175
+ gateway: true
176
+ }));
177
+ }
178
+ resolve(data);
179
+ }).catch(error => {
180
+ if (fireAnalytics) {
181
+ fireAnalytics(agentRequestAnalytics('failed', 'getAgentPermissions', {
182
+ duration: getPageTime() - startTime,
183
+ ...getErrorAttributes(error),
184
+ gateway: true
185
+ }));
186
+ }
187
+ reject(error);
188
+ });
189
+ });
190
+ }
153
191
  }
@@ -6,7 +6,7 @@ const ORG_ID_FROM_CLOUD_ID_QUERY = `query OrgIdFromCloudId($cloudId: ID!) {
6
6
  }`;
7
7
  const addHeaders = headers => {
8
8
  headers.append('atl-client-name', "@atlaskit/profilecard");
9
- headers.append('atl-client-version', "20.9.0");
9
+ headers.append('atl-client-version', "20.10.0");
10
10
  return headers;
11
11
  };
12
12
  export async function getOrgIdForCloudIdFromAGG(url, cloudId) {
@@ -67,7 +67,7 @@ export const addHeaders = headers => {
67
67
  headers.append('X-ExperimentalApi', 'teams-beta');
68
68
  headers.append('X-ExperimentalApi', 'team-members-beta');
69
69
  headers.append('atl-client-name', "@atlaskit/profilecard");
70
- headers.append('atl-client-version', "20.9.0");
70
+ headers.append('atl-client-version', "20.10.0");
71
71
  return headers;
72
72
  };
73
73
  export async function getTeamFromAGG(url, teamId, siteId) {
@@ -1,11 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useState } from 'react';
2
+ import React, { useCallback, useState } from 'react';
3
3
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl-next';
4
4
  import Button, { IconButton } from '@atlaskit/button/new';
5
5
  import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
6
6
  import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { Box, Inline, xcss } from '@atlaskit/primitives';
8
- import { ChatPillIcon } from '@atlaskit/rovo-agent-components';
9
+ import { AgentDropdownMenu, ChatPillIcon } from '@atlaskit/rovo-agent-components';
9
10
  import { AgentDeleteConfirmationModal } from './AgentDeleteConfirmationModal';
10
11
  const chatToAgentButtonContainer = xcss({
11
12
  width: '100%'
@@ -71,12 +72,27 @@ export const AgentActions = ({
71
72
  onDuplicateAgent,
72
73
  onCopyAgent,
73
74
  onChatClick,
74
- agent
75
+ onViewFullProfileClick,
76
+ agent,
77
+ resourceClient
75
78
  }) => {
76
79
  const {
77
80
  formatMessage
78
81
  } = useIntl();
79
82
  const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
83
+ const isForgeAgent = agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY';
84
+ const loadAgentPermissions = useCallback(async () => {
85
+ const {
86
+ permissions: {
87
+ AGENT_UPDATE,
88
+ AGENT_DEACTIVATE
89
+ }
90
+ } = await resourceClient.getRovoAgentPermissions(agent.id);
91
+ return {
92
+ isEditEnabled: AGENT_UPDATE.permitted,
93
+ isDeleteEnabled: AGENT_DEACTIVATE.permitted
94
+ };
95
+ }, [agent.id, resourceClient]);
80
96
  const agentActions = buildAgentActions({
81
97
  onDuplicateAgent,
82
98
  onCopyAgent,
@@ -108,7 +124,20 @@ export const AgentActions = ({
108
124
  xcss: chatPillIconWrapper
109
125
  }, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
110
126
  xcss: chatPillTextStyles
111
- }, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/React.createElement(DropdownMenu, {
127
+ }, formatMessage(messages.actionChatToAgent)))))), fg('rovo_use_agent_permissions') ? /*#__PURE__*/React.createElement(AgentDropdownMenu, {
128
+ agentId: agent.id,
129
+ isAgentCreatedByUser: isAgentCreatedByCurrentUser !== null && isAgentCreatedByCurrentUser !== void 0 ? isAgentCreatedByCurrentUser : false,
130
+ onDeleteAgent: () => setIsDeleteModalOpen(true),
131
+ onEditAgent: onEditAgent,
132
+ onDuplicateAgent: onDuplicateAgent,
133
+ onCopyAgent: onCopyAgent,
134
+ isForgeAgent: isForgeAgent,
135
+ loadAgentPermissions: loadAgentPermissions,
136
+ loadPermissionsOnMount: true,
137
+ onViewAgentFullProfileClick: onViewFullProfileClick,
138
+ doesAgentHaveIdentityAccountId: !!agent.identity_account_id,
139
+ shouldTriggerStopPropagation: true
140
+ }) : /*#__PURE__*/React.createElement(DropdownMenu, {
112
141
  trigger: ({
113
142
  triggerRef,
114
143
  ...props
@@ -44,7 +44,8 @@ const AgentProfileCard = ({
44
44
  onCopyAgent,
45
45
  onDuplicateAgent,
46
46
  onOpenChat: onOpenChatFullScreen,
47
- onConversationStarter
47
+ onConversationStarter,
48
+ onViewFullProfile
48
49
  } = useAgentUrlActions({
49
50
  cloudId: cloudId || ''
50
51
  });
@@ -177,7 +178,9 @@ const AgentProfileCard = ({
177
178
  onCopyAgent: () => onCopyAgent(agent.id),
178
179
  onDuplicateAgent: () => onDuplicateAgent(agent.id),
179
180
  onDeleteAgent: handleOnDelete,
180
- onChatClick: () => onChatClick ? onChatClick() : onOpenChatFullScreen(agent.id)
181
+ onChatClick: () => onChatClick ? onChatClick() : onOpenChatFullScreen(agent.id),
182
+ resourceClient: resourceClient,
183
+ onViewFullProfileClick: () => onViewFullProfile(agent.id)
181
184
  })));
182
185
  };
183
186
  export default AgentProfileCard;
@@ -65,11 +65,15 @@ export const useAgentUrlActions = ({
65
65
  });
66
66
  window.open(urlWithParams, '_blank', 'noopener, noreferrer');
67
67
  };
68
+ const onViewFullProfile = agentId => {
69
+ window.open(`${window.location.origin}/people/agent/${agentId}`, '_blank', 'noopener, noreferrer');
70
+ };
68
71
  return {
69
72
  onEditAgent,
70
73
  onCopyAgent,
71
74
  onDuplicateAgent,
72
75
  onOpenChat,
73
- onConversationStarter
76
+ onConversationStarter,
77
+ onViewFullProfile
74
78
  };
75
79
  };
@@ -32,7 +32,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
32
32
  actionSubjectId,
33
33
  attributes: {
34
34
  packageName: "@atlaskit/profilecard",
35
- packageVersion: "20.9.0",
35
+ packageVersion: "20.10.0",
36
36
  ...attributes,
37
37
  firedAt: Math.round(getPageTime())
38
38
  }
@@ -158,17 +158,23 @@ var ProfileCardClient = /*#__PURE__*/function () {
158
158
  var _this$rovoAgentClient2;
159
159
  return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
160
160
  }
161
+ }, {
162
+ key: "getRovoAgentPermissions",
163
+ value: function getRovoAgentPermissions(id, fireAnalytics) {
164
+ var _this$rovoAgentClient3;
165
+ return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.getPermissions(id, fireAnalytics);
166
+ }
161
167
  }, {
162
168
  key: "deleteAgent",
163
169
  value: function deleteAgent(id, analytics) {
164
- var _this$rovoAgentClient3;
165
- return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.deleteAgent(id, analytics);
170
+ var _this$rovoAgentClient4;
171
+ return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.deleteAgent(id, analytics);
166
172
  }
167
173
  }, {
168
174
  key: "setFavouriteAgent",
169
175
  value: function setFavouriteAgent(id, isFavourite, analytics) {
170
- var _this$rovoAgentClient4;
171
- return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.setFavouriteAgent(id, isFavourite, analytics);
176
+ var _this$rovoAgentClient5;
177
+ return (_this$rovoAgentClient5 = this.rovoAgentClient) === null || _this$rovoAgentClient5 === void 0 ? void 0 : _this$rovoAgentClient5.setFavouriteAgent(id, isFavourite, analytics);
172
178
  }
173
179
  }]);
174
180
  return ProfileCardClient;
@@ -1,28 +1,29 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
4
5
  import _inherits from "@babel/runtime/helpers/inherits";
5
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
10
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
9
  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
10
  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
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  import { agentRequestAnalytics } from '../util/analytics';
14
14
  import { getPageTime } from '../util/performance';
15
15
  import CachingClient from './CachingClient';
16
16
  import { getErrorAttributes } from './errorUtils';
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 || {}));
17
+ var createHeaders = function createHeaders(product, cloudId, isBodyJson) {
18
+ var headers = new Headers({
19
+ 'X-Product': product,
20
+ 'X-Experience-Id': 'profile-card',
21
+ 'X-Cloudid': cloudId || ''
22
+ });
23
+ if (isBodyJson) {
24
+ headers.set('Content-Type', 'application/json');
25
+ }
26
+ return headers;
26
27
  };
27
28
  var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
28
29
  _inherits(RovoAgentCardClient, _CachingClient);
@@ -195,6 +196,50 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
195
196
  };
196
197
  }());
197
198
  }
199
+ }, {
200
+ key: "getPermissions",
201
+ value: function getPermissions(id, fireAnalytics) {
202
+ var _this5 = this;
203
+ if (!this.options.cloudId) {
204
+ return Promise.reject(new Error('cloudId is missing'));
205
+ }
206
+ return new Promise(function (resolve, reject) {
207
+ var startTime = getPageTime();
208
+ var product = _this5.options.productIdentifier || 'rovo';
209
+ if (fireAnalytics) {
210
+ fireAnalytics(agentRequestAnalytics('triggered'));
211
+ }
212
+ var headers = createHeaders(product, _this5.options.cloudId, true);
213
+ fetch(new Request("/gateway/api/assist/api/rovo/v2/permissions/agents/".concat(id), {
214
+ method: 'POST',
215
+ credentials: 'include',
216
+ mode: 'cors',
217
+ headers: headers,
218
+ body: JSON.stringify({
219
+ permission_ids: ['AGENT_CREATE', 'AGENT_UPDATE', 'AGENT_DELETE', 'AGENT_DEACTIVATE', 'AGENT_READ']
220
+ })
221
+ })).then(function (response) {
222
+ return response.json();
223
+ }).then(function (data) {
224
+ if (fireAnalytics) {
225
+ fireAnalytics(agentRequestAnalytics('succeeded', 'getAgentPermissions', {
226
+ duration: getPageTime() - startTime,
227
+ gateway: true
228
+ }));
229
+ }
230
+ resolve(data);
231
+ }).catch(function (error) {
232
+ if (fireAnalytics) {
233
+ fireAnalytics(agentRequestAnalytics('failed', 'getAgentPermissions', _objectSpread(_objectSpread({
234
+ duration: getPageTime() - startTime
235
+ }, getErrorAttributes(error)), {}, {
236
+ gateway: true
237
+ })));
238
+ }
239
+ reject(error);
240
+ });
241
+ });
242
+ }
198
243
  }]);
199
244
  return RovoAgentCardClient;
200
245
  }(CachingClient);
@@ -4,7 +4,7 @@ import { AGGQuery } from './graphqlUtils';
4
4
  var ORG_ID_FROM_CLOUD_ID_QUERY = "query OrgIdFromCloudId($cloudId: ID!) {\n\ttenantContexts(cloudIds: [$cloudId]) {\n\t\torgId\n\t}\n}";
5
5
  var addHeaders = function addHeaders(headers) {
6
6
  headers.append('atl-client-name', "@atlaskit/profilecard");
7
- headers.append('atl-client-version', "20.9.0");
7
+ headers.append('atl-client-version', "20.10.0");
8
8
  return headers;
9
9
  };
10
10
  export function getOrgIdForCloudIdFromAGG(_x, _x2) {
@@ -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', "20.9.0");
51
+ headers.append('atl-client-version', "20.10.0");
52
52
  return headers;
53
53
  };
54
54
  export function getTeamFromAGG(_x, _x2, _x3) {
@@ -1,14 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  var _excluded = ["triggerRef"];
5
- import React, { useState } from 'react';
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
+ import React, { useCallback, useState } from 'react';
6
8
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl-next';
7
9
  import Button, { IconButton } from '@atlaskit/button/new';
8
10
  import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
9
11
  import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
10
13
  import { Box, Inline, xcss } from '@atlaskit/primitives';
11
- import { ChatPillIcon } from '@atlaskit/rovo-agent-components';
14
+ import { AgentDropdownMenu, ChatPillIcon } from '@atlaskit/rovo-agent-components';
12
15
  import { AgentDeleteConfirmationModal } from './AgentDeleteConfirmationModal';
13
16
  var chatToAgentButtonContainer = xcss({
14
17
  width: '100%'
@@ -72,13 +75,38 @@ export var AgentActions = function AgentActions(_ref3) {
72
75
  onDuplicateAgent = _ref3.onDuplicateAgent,
73
76
  onCopyAgent = _ref3.onCopyAgent,
74
77
  onChatClick = _ref3.onChatClick,
75
- agent = _ref3.agent;
78
+ onViewFullProfileClick = _ref3.onViewFullProfileClick,
79
+ agent = _ref3.agent,
80
+ resourceClient = _ref3.resourceClient;
76
81
  var _useIntl = useIntl(),
77
82
  formatMessage = _useIntl.formatMessage;
78
83
  var _useState = useState(false),
79
84
  _useState2 = _slicedToArray(_useState, 2),
80
85
  isDeleteModalOpen = _useState2[0],
81
86
  setIsDeleteModalOpen = _useState2[1];
87
+ var isForgeAgent = agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY';
88
+ var loadAgentPermissions = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
89
+ var _yield$resourceClient, _yield$resourceClient2, AGENT_UPDATE, AGENT_DEACTIVATE;
90
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
91
+ while (1) switch (_context.prev = _context.next) {
92
+ case 0:
93
+ _context.next = 2;
94
+ return resourceClient.getRovoAgentPermissions(agent.id);
95
+ case 2:
96
+ _yield$resourceClient = _context.sent;
97
+ _yield$resourceClient2 = _yield$resourceClient.permissions;
98
+ AGENT_UPDATE = _yield$resourceClient2.AGENT_UPDATE;
99
+ AGENT_DEACTIVATE = _yield$resourceClient2.AGENT_DEACTIVATE;
100
+ return _context.abrupt("return", {
101
+ isEditEnabled: AGENT_UPDATE.permitted,
102
+ isDeleteEnabled: AGENT_DEACTIVATE.permitted
103
+ });
104
+ case 7:
105
+ case "end":
106
+ return _context.stop();
107
+ }
108
+ }, _callee);
109
+ })), [agent.id, resourceClient]);
82
110
  var agentActions = buildAgentActions({
83
111
  onDuplicateAgent: onDuplicateAgent,
84
112
  onCopyAgent: onCopyAgent,
@@ -110,10 +138,25 @@ export var AgentActions = function AgentActions(_ref3) {
110
138
  xcss: chatPillIconWrapper
111
139
  }, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
112
140
  xcss: chatPillTextStyles
113
- }, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/React.createElement(DropdownMenu, {
114
- trigger: function trigger(_ref4) {
115
- var triggerRef = _ref4.triggerRef,
116
- props = _objectWithoutProperties(_ref4, _excluded);
141
+ }, formatMessage(messages.actionChatToAgent)))))), fg('rovo_use_agent_permissions') ? /*#__PURE__*/React.createElement(AgentDropdownMenu, {
142
+ agentId: agent.id,
143
+ isAgentCreatedByUser: isAgentCreatedByCurrentUser !== null && isAgentCreatedByCurrentUser !== void 0 ? isAgentCreatedByCurrentUser : false,
144
+ onDeleteAgent: function onDeleteAgent() {
145
+ return setIsDeleteModalOpen(true);
146
+ },
147
+ onEditAgent: onEditAgent,
148
+ onDuplicateAgent: onDuplicateAgent,
149
+ onCopyAgent: onCopyAgent,
150
+ isForgeAgent: isForgeAgent,
151
+ loadAgentPermissions: loadAgentPermissions,
152
+ loadPermissionsOnMount: true,
153
+ onViewAgentFullProfileClick: onViewFullProfileClick,
154
+ doesAgentHaveIdentityAccountId: !!agent.identity_account_id,
155
+ shouldTriggerStopPropagation: true
156
+ }) : /*#__PURE__*/React.createElement(DropdownMenu, {
157
+ trigger: function trigger(_ref5) {
158
+ var triggerRef = _ref5.triggerRef,
159
+ props = _objectWithoutProperties(_ref5, _excluded);
117
160
  return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(IconButton, _extends({}, props, {
118
161
  icon: MoreIcon,
119
162
  label: "more",
@@ -126,9 +169,9 @@ export var AgentActions = function AgentActions(_ref3) {
126
169
  })));
127
170
  },
128
171
  placement: "bottom-end"
129
- }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, agentActions.map(function (_ref5, idx) {
130
- var text = _ref5.text,
131
- _onClick = _ref5.onClick;
172
+ }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, agentActions.map(function (_ref6, idx) {
173
+ var text = _ref6.text,
174
+ _onClick = _ref6.onClick;
132
175
  return /*#__PURE__*/React.createElement(DropdownItem, {
133
176
  key: idx,
134
177
  onClick: function onClick(e) {
@@ -138,9 +181,9 @@ export var AgentActions = function AgentActions(_ref3) {
138
181
  }, text);
139
182
  })), isAgentCreatedByCurrentUser && /*#__PURE__*/React.createElement(DropdownItemGroup, {
140
183
  hasSeparator: true
141
- }, agentSetting.map(function (_ref6, idx) {
142
- var text = _ref6.text,
143
- _onClick2 = _ref6.onClick;
184
+ }, agentSetting.map(function (_ref7, idx) {
185
+ var text = _ref7.text,
186
+ _onClick2 = _ref7.onClick;
144
187
  return /*#__PURE__*/React.createElement(DropdownItem, {
145
188
  key: idx,
146
189
  onClick: function onClick(e) {
@@ -49,7 +49,8 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
49
49
  _onCopyAgent = _useAgentUrlActions.onCopyAgent,
50
50
  _onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
51
51
  onOpenChatFullScreen = _useAgentUrlActions.onOpenChat,
52
- onConversationStarter = _useAgentUrlActions.onConversationStarter;
52
+ onConversationStarter = _useAgentUrlActions.onConversationStarter,
53
+ onViewFullProfile = _useAgentUrlActions.onViewFullProfile;
53
54
  var _useState = useState(false),
54
55
  _useState2 = _slicedToArray(_useState, 2),
55
56
  isStarred = _useState2[0],
@@ -222,6 +223,10 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
222
223
  onDeleteAgent: handleOnDelete,
223
224
  onChatClick: function onChatClick() {
224
225
  return _onChatClick ? _onChatClick() : onOpenChatFullScreen(agent.id);
226
+ },
227
+ resourceClient: resourceClient,
228
+ onViewFullProfileClick: function onViewFullProfileClick() {
229
+ return onViewFullProfile(agent.id);
225
230
  }
226
231
  })));
227
232
  };
@@ -68,11 +68,15 @@ export var useAgentUrlActions = function useAgentUrlActions(_ref3) {
68
68
  })));
69
69
  window.open(urlWithParams, '_blank', 'noopener, noreferrer');
70
70
  };
71
+ var onViewFullProfile = function onViewFullProfile(agentId) {
72
+ window.open("".concat(window.location.origin, "/people/agent/").concat(agentId), '_blank', 'noopener, noreferrer');
73
+ };
71
74
  return {
72
75
  onEditAgent: onEditAgent,
73
76
  onCopyAgent: onCopyAgent,
74
77
  onDuplicateAgent: onDuplicateAgent,
75
78
  onOpenChat: onOpenChat,
76
- onConversationStarter: onConversationStarter
79
+ onConversationStarter: onConversationStarter,
80
+ onViewFullProfile: onViewFullProfile
77
81
  };
78
82
  };
@@ -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: "20.9.0"
42
+ packageVersion: "20.10.0"
43
43
  }, attributes), {}, {
44
44
  firedAt: Math.round(getPageTime())
45
45
  })
@@ -21,6 +21,7 @@ declare class ProfileCardClient implements ProfileClient {
21
21
  getTeamCentralBaseUrl(teamCentralScopes?: TeamCentralScopes): Promise<string | undefined>;
22
22
  shouldShowGiveKudos(): Promise<boolean>;
23
23
  getRovoAgentProfile(id: AgentIdType, analytics?: (event: AnalyticsEventPayload) => void): Promise<import("../types").RovoAgent>;
24
+ getRovoAgentPermissions(id: string, fireAnalytics?: ((event: AnalyticsEventPayload) => void) | undefined): Promise<import("../types").AgentPermissions>;
24
25
  deleteAgent(id: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
25
26
  setFavouriteAgent(id: string, isFavourite: boolean, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
26
27
  }
@@ -1,5 +1,5 @@
1
1
  import { type AnalyticsEventPayload } from '@atlaskit/analytics-next';
2
- import type { AgentIdType, ProfileClientOptions, RovoAgent } from '../types';
2
+ import type { AgentIdType, AgentPermissions, ProfileClientOptions, RovoAgent } from '../types';
3
3
  import CachingClient from './CachingClient';
4
4
  export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
5
5
  options: ProfileClientOptions;
@@ -8,4 +8,5 @@ export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
8
8
  getProfile(id: AgentIdType, analytics?: (event: AnalyticsEventPayload) => void): Promise<RovoAgent>;
9
9
  deleteAgent(agentId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
10
10
  setFavouriteAgent(agentId: string, isFavourite: boolean, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
11
+ getPermissions(id: string, fireAnalytics?: (event: AnalyticsEventPayload) => void): Promise<AgentPermissions>;
11
12
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type RovoAgentProfileCardInfo } from '../../types';
2
+ import { type ProfileClient, type RovoAgentProfileCardInfo } from '../../types';
3
3
  type AgentActionsProps = {
4
4
  agent: RovoAgentProfileCardInfo;
5
5
  isAgentCreatedByCurrentUser?: boolean;
@@ -8,6 +8,8 @@ type AgentActionsProps = {
8
8
  onDuplicateAgent: () => void;
9
9
  onDeleteAgent: () => void;
10
10
  onChatClick: () => void;
11
+ onViewFullProfileClick: () => void;
12
+ resourceClient: ProfileClient;
11
13
  };
12
- export declare const AgentActions: ({ isAgentCreatedByCurrentUser, onEditAgent, onDeleteAgent, onDuplicateAgent, onCopyAgent, onChatClick, agent, }: AgentActionsProps) => JSX.Element;
14
+ export declare const AgentActions: ({ isAgentCreatedByCurrentUser, onEditAgent, onDeleteAgent, onDuplicateAgent, onCopyAgent, onChatClick, onViewFullProfileClick, agent, resourceClient, }: AgentActionsProps) => JSX.Element;
13
15
  export {};
@@ -10,4 +10,5 @@ export declare const useAgentUrlActions: ({ cloudId }: {
10
10
  agentId: string;
11
11
  prompt: string;
12
12
  }) => void;
13
+ onViewFullProfile: (agentId: string) => void;
13
14
  };
@@ -435,6 +435,12 @@ export type AgentIdType = {
435
435
  type: 'agent' | 'identity';
436
436
  value: string;
437
437
  };
438
+ type AgentPermissionName = 'AGENT_UPDATE' | 'AGENT_DEACTIVATE';
439
+ export type AgentPermissions = {
440
+ permissions: Record<AgentPermissionName, {
441
+ permitted: boolean;
442
+ }>;
443
+ };
438
444
  export interface ProfileClient {
439
445
  flushCache: () => void;
440
446
  getProfile: (cloudId: string, userId: string, analytics?: (event: AnalyticsEventPayload) => void) => Promise<ProfileCardClientData>;
@@ -443,6 +449,7 @@ export interface ProfileClient {
443
449
  shouldShowGiveKudos: () => Promise<boolean>;
444
450
  getTeamCentralBaseUrl: (teamCentralScopes?: TeamCentralScopes) => Promise<string | undefined>;
445
451
  getRovoAgentProfile: (id: AgentIdType, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<RovoAgent>;
452
+ getRovoAgentPermissions: (id: string, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<AgentPermissions>;
446
453
  deleteAgent: (id: string, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<void>;
447
454
  setFavouriteAgent: (id: string, isFavourite: boolean, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<void>;
448
455
  }
@@ -21,6 +21,7 @@ declare class ProfileCardClient implements ProfileClient {
21
21
  getTeamCentralBaseUrl(teamCentralScopes?: TeamCentralScopes): Promise<string | undefined>;
22
22
  shouldShowGiveKudos(): Promise<boolean>;
23
23
  getRovoAgentProfile(id: AgentIdType, analytics?: (event: AnalyticsEventPayload) => void): Promise<import("../types").RovoAgent>;
24
+ getRovoAgentPermissions(id: string, fireAnalytics?: ((event: AnalyticsEventPayload) => void) | undefined): Promise<import("../types").AgentPermissions>;
24
25
  deleteAgent(id: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
25
26
  setFavouriteAgent(id: string, isFavourite: boolean, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
26
27
  }
@@ -1,5 +1,5 @@
1
1
  import { type AnalyticsEventPayload } from '@atlaskit/analytics-next';
2
- import type { AgentIdType, ProfileClientOptions, RovoAgent } from '../types';
2
+ import type { AgentIdType, AgentPermissions, ProfileClientOptions, RovoAgent } from '../types';
3
3
  import CachingClient from './CachingClient';
4
4
  export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
5
5
  options: ProfileClientOptions;
@@ -8,4 +8,5 @@ export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
8
8
  getProfile(id: AgentIdType, analytics?: (event: AnalyticsEventPayload) => void): Promise<RovoAgent>;
9
9
  deleteAgent(agentId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
10
10
  setFavouriteAgent(agentId: string, isFavourite: boolean, analytics?: (event: AnalyticsEventPayload) => void): Promise<void>;
11
+ getPermissions(id: string, fireAnalytics?: (event: AnalyticsEventPayload) => void): Promise<AgentPermissions>;
11
12
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type RovoAgentProfileCardInfo } from '../../types';
2
+ import { type ProfileClient, type RovoAgentProfileCardInfo } from '../../types';
3
3
  type AgentActionsProps = {
4
4
  agent: RovoAgentProfileCardInfo;
5
5
  isAgentCreatedByCurrentUser?: boolean;
@@ -8,6 +8,8 @@ type AgentActionsProps = {
8
8
  onDuplicateAgent: () => void;
9
9
  onDeleteAgent: () => void;
10
10
  onChatClick: () => void;
11
+ onViewFullProfileClick: () => void;
12
+ resourceClient: ProfileClient;
11
13
  };
12
- export declare const AgentActions: ({ isAgentCreatedByCurrentUser, onEditAgent, onDeleteAgent, onDuplicateAgent, onCopyAgent, onChatClick, agent, }: AgentActionsProps) => JSX.Element;
14
+ export declare const AgentActions: ({ isAgentCreatedByCurrentUser, onEditAgent, onDeleteAgent, onDuplicateAgent, onCopyAgent, onChatClick, onViewFullProfileClick, agent, resourceClient, }: AgentActionsProps) => JSX.Element;
13
15
  export {};
@@ -10,4 +10,5 @@ export declare const useAgentUrlActions: ({ cloudId }: {
10
10
  agentId: string;
11
11
  prompt: string;
12
12
  }) => void;
13
+ onViewFullProfile: (agentId: string) => void;
13
14
  };
@@ -441,6 +441,12 @@ export type AgentIdType = {
441
441
  type: 'agent' | 'identity';
442
442
  value: string;
443
443
  };
444
+ type AgentPermissionName = 'AGENT_UPDATE' | 'AGENT_DEACTIVATE';
445
+ export type AgentPermissions = {
446
+ permissions: Record<AgentPermissionName, {
447
+ permitted: boolean;
448
+ }>;
449
+ };
444
450
  export interface ProfileClient {
445
451
  flushCache: () => void;
446
452
  getProfile: (cloudId: string, userId: string, analytics?: (event: AnalyticsEventPayload) => void) => Promise<ProfileCardClientData>;
@@ -449,6 +455,7 @@ export interface ProfileClient {
449
455
  shouldShowGiveKudos: () => Promise<boolean>;
450
456
  getTeamCentralBaseUrl: (teamCentralScopes?: TeamCentralScopes) => Promise<string | undefined>;
451
457
  getRovoAgentProfile: (id: AgentIdType, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<RovoAgent>;
458
+ getRovoAgentPermissions: (id: string, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<AgentPermissions>;
452
459
  deleteAgent: (id: string, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<void>;
453
460
  setFavouriteAgent: (id: string, isFavourite: boolean, fireAnalytics?: (event: AnalyticsEventPayload) => void) => Promise<void>;
454
461
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "20.9.0",
3
+ "version": "20.10.0",
4
4
  "description": "A React component to display a card with user information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -58,19 +58,19 @@
58
58
  "@atlaskit/dropdown-menu": "^12.22.0",
59
59
  "@atlaskit/empty-state": "^7.12.0",
60
60
  "@atlaskit/focus-ring": "^1.7.0",
61
- "@atlaskit/give-kudos": "^2.2.0",
61
+ "@atlaskit/give-kudos": "^2.3.0",
62
62
  "@atlaskit/icon": "^22.24.0",
63
63
  "@atlaskit/lozenge": "^11.12.0",
64
64
  "@atlaskit/menu": "^2.13.0",
65
65
  "@atlaskit/modal-dialog": "^12.17.0",
66
66
  "@atlaskit/platform-feature-flags": "^0.3.0",
67
67
  "@atlaskit/popup": "^1.29.0",
68
- "@atlaskit/primitives": "^13.0.0",
69
- "@atlaskit/rovo-agent-components": "^1.9.0",
68
+ "@atlaskit/primitives": "^13.1.0",
69
+ "@atlaskit/rovo-agent-components": "^1.12.0",
70
70
  "@atlaskit/spinner": "^16.3.0",
71
71
  "@atlaskit/theme": "^14.0.0",
72
72
  "@atlaskit/tokens": "^2.2.0",
73
- "@atlaskit/tooltip": "^18.8.0",
73
+ "@atlaskit/tooltip": "^18.9.0",
74
74
  "@babel/runtime": "^7.0.0",
75
75
  "@emotion/react": "^11.7.1",
76
76
  "@emotion/styled": "^11.0.0",
@@ -125,6 +125,9 @@
125
125
  "enable_agent_profile_card": {
126
126
  "type": "boolean"
127
127
  },
128
+ "rovo_use_agent_permissions": {
129
+ "type": "boolean"
130
+ },
128
131
  "platform_profile_card_css_refactor": {
129
132
  "type": "boolean"
130
133
  }