@atlaskit/profilecard 25.0.3 → 25.1.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 (26) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  3. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  4. package/dist/cjs/components/Agent/AgentProfileCard.js +15 -4
  5. package/dist/cjs/components/Agent/hooks/duplicateFetch.js +174 -0
  6. package/dist/cjs/components/Agent/hooks/useAgentActions.js +71 -11
  7. package/dist/cjs/util/analytics.js +2 -2
  8. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  9. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  10. package/dist/es2019/components/Agent/AgentProfileCard.js +1 -1
  11. package/dist/es2019/components/Agent/hooks/duplicateFetch.js +121 -0
  12. package/dist/es2019/components/Agent/hooks/useAgentActions.js +38 -4
  13. package/dist/es2019/util/analytics.js +2 -2
  14. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  15. package/dist/esm/client/getTeamFromAGG.js +1 -1
  16. package/dist/esm/components/Agent/AgentProfileCard.js +15 -4
  17. package/dist/esm/components/Agent/hooks/duplicateFetch.js +167 -0
  18. package/dist/esm/components/Agent/hooks/useAgentActions.js +72 -12
  19. package/dist/esm/util/analytics.js +2 -2
  20. package/dist/types/components/Agent/Actions.d.ts +1 -1
  21. package/dist/types/components/Agent/hooks/duplicateFetch.d.ts +24 -0
  22. package/dist/types/components/Agent/hooks/useAgentActions.d.ts +1 -1
  23. package/dist/types-ts4.5/components/Agent/Actions.d.ts +1 -1
  24. package/dist/types-ts4.5/components/Agent/hooks/duplicateFetch.d.ts +24 -0
  25. package/dist/types-ts4.5/components/Agent/hooks/useAgentActions.d.ts +1 -1
  26. package/package.json +6 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 25.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`266566c8db777`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/266566c8db777) -
8
+ Duplicate agent via BE mutation when versioning is enabled Changing all duplicate touchpoints to
9
+ do useMutation and then redirect. So this requires chaging all the onDuplicate to return Promise
10
+ and handles the loading state.
11
+
12
+ 3 places where it changes:
13
+ - conversation-assistant-agent useAgentUrlActions - this is browse agent modal, view agent modal,
14
+ agent profile, chat sidebar, studio migration modal
15
+ - atlassian-studio AgentContextMenu - studio `...` buttons in side nav, agent title bar `...`
16
+ - profile-card useAgentUrlActions - Agent profile card (no relay)
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 25.0.3
4
23
 
5
24
  ### Patch Changes
@@ -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', "25.0.2");
14
+ headers.append('atl-client-version', "25.0.3");
15
15
  return headers;
16
16
  };
17
17
  function getOrgIdForCloudIdFromAGG(_x, _x2) {
@@ -66,7 +66,7 @@ var addHeaders = exports.addHeaders = function addHeaders(headers) {
66
66
  headers.append('X-ExperimentalApi', 'teams-beta');
67
67
  headers.append('X-ExperimentalApi', 'team-members-beta');
68
68
  headers.append('atl-client-name', "@atlaskit/profilecard");
69
- headers.append('atl-client-version', "25.0.2");
69
+ headers.append('atl-client-version', "25.0.3");
70
70
  return headers;
71
71
  };
72
72
  function getTeamFromAGG(_x, _x2, _x3) {
@@ -69,7 +69,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
69
69
  }),
70
70
  _onEditAgent = _useAgentUrlActions.onEditAgent,
71
71
  _onCopyAgent = _useAgentUrlActions.onCopyAgent,
72
- _onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
72
+ onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
73
73
  onOpenChatFullScreen = _useAgentUrlActions.onOpenChat,
74
74
  onConversationStarter = _useAgentUrlActions.onConversationStarter,
75
75
  onViewFullProfile = _useAgentUrlActions.onViewFullProfile;
@@ -274,9 +274,20 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
274
274
  onCopyAgent: function onCopyAgent() {
275
275
  return _onCopyAgent(agent.id);
276
276
  },
277
- onDuplicateAgent: function onDuplicateAgent() {
278
- return _onDuplicateAgent(agent.id);
279
- },
277
+ onDuplicateAgent: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
278
+ return _regenerator.default.wrap(function _callee3$(_context3) {
279
+ while (1) switch (_context3.prev = _context3.next) {
280
+ case 0:
281
+ _context3.next = 2;
282
+ return onDuplicateAgent(agent.id);
283
+ case 2:
284
+ return _context3.abrupt("return", _context3.sent);
285
+ case 3:
286
+ case "end":
287
+ return _context3.stop();
288
+ }
289
+ }, _callee3);
290
+ })),
280
291
  onDeleteAgent: handleOnDelete,
281
292
  onChatClick: onChatClick ? function (event) {
282
293
  return onChatClick(event);
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.fetchHasVersionCapability = exports.fetchDuplicateAgentMutation = exports.fetchActivationId = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
11
+
12
+ /**
13
+ * Fetches version capability for a site via raw GraphQL fetch.
14
+ * Returns true only if versioning migration has completed.
15
+ *
16
+ * TODO remove after versioning rollout complete
17
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
18
+ */
19
+ var fetchHasVersionCapability = exports.fetchHasVersionCapability = /*#__PURE__*/function () {
20
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(cloudId) {
21
+ var _json$data, response, json, result;
22
+ return _regenerator.default.wrap(function _callee$(_context) {
23
+ while (1) switch (_context.prev = _context.next) {
24
+ case 0:
25
+ _context.prev = 0;
26
+ _context.next = 3;
27
+ return fetch(GRAPHQL_ENDPOINT, {
28
+ method: 'POST',
29
+ credentials: 'include',
30
+ headers: {
31
+ 'Content-Type': 'application/json'
32
+ },
33
+ body: JSON.stringify({
34
+ query: "query profilecardHasVersionCapabilityQuery($cloudId: String!) {\n\t\t\t\t\tagentStudio_hasVersionCapability(cloudId: $cloudId) @optIn(to: \"AgentStudio\") {\n\t\t\t\t\t\t__typename\n\t\t\t\t\t\t... on AgentStudioHasVersionCapability {\n\t\t\t\t\t\t\thasVersionCapability\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
35
+ variables: {
36
+ cloudId: cloudId
37
+ }
38
+ })
39
+ });
40
+ case 3:
41
+ response = _context.sent;
42
+ _context.next = 6;
43
+ return response.json();
44
+ case 6:
45
+ json = _context.sent;
46
+ result = json === null || json === void 0 || (_json$data = json.data) === null || _json$data === void 0 ? void 0 : _json$data.agentStudio_hasVersionCapability;
47
+ return _context.abrupt("return", (result === null || result === void 0 ? void 0 : result.__typename) === 'AgentStudioHasVersionCapability' ? Boolean(result.hasVersionCapability) : false);
48
+ case 11:
49
+ _context.prev = 11;
50
+ _context.t0 = _context["catch"](0);
51
+ return _context.abrupt("return", false);
52
+ case 14:
53
+ case "end":
54
+ return _context.stop();
55
+ }
56
+ }, _callee, null, [[0, 11]]);
57
+ }));
58
+ return function fetchHasVersionCapability(_x) {
59
+ return _ref.apply(this, arguments);
60
+ };
61
+ }();
62
+
63
+ /**
64
+ * Fetches the Rovo activation ID for a given cloud ID.
65
+ * Used to construct the agent ARI when not available.
66
+ */
67
+ var fetchActivationId = exports.fetchActivationId = /*#__PURE__*/function () {
68
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(cloudId) {
69
+ var _json$data$tenantCont, _json$data2, response, json;
70
+ return _regenerator.default.wrap(function _callee2$(_context2) {
71
+ while (1) switch (_context2.prev = _context2.next) {
72
+ case 0:
73
+ _context2.prev = 0;
74
+ _context2.next = 3;
75
+ return fetch(GRAPHQL_ENDPOINT, {
76
+ method: 'POST',
77
+ credentials: 'include',
78
+ headers: {
79
+ 'Content-Type': 'application/json'
80
+ },
81
+ body: JSON.stringify({
82
+ query: "query profilecardActivationQuery($cloudId: ID!, $product: String!) {\n\t\t\t\t\ttenantContexts(cloudIds: [$cloudId]) {\n\t\t\t\t\t\tactivationIdByProduct(product: $product) {\n\t\t\t\t\t\t\tactive\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
83
+ variables: {
84
+ cloudId: cloudId,
85
+ product: 'rovo'
86
+ }
87
+ })
88
+ });
89
+ case 3:
90
+ response = _context2.sent;
91
+ _context2.next = 6;
92
+ return response.json();
93
+ case 6:
94
+ json = _context2.sent;
95
+ return _context2.abrupt("return", (_json$data$tenantCont = json === null || json === void 0 || (_json$data2 = json.data) === null || _json$data2 === void 0 || (_json$data2 = _json$data2.tenantContexts) === null || _json$data2 === void 0 || (_json$data2 = _json$data2[0]) === null || _json$data2 === void 0 || (_json$data2 = _json$data2.activationIdByProduct) === null || _json$data2 === void 0 ? void 0 : _json$data2.active) !== null && _json$data$tenantCont !== void 0 ? _json$data$tenantCont : null);
96
+ case 10:
97
+ _context2.prev = 10;
98
+ _context2.t0 = _context2["catch"](0);
99
+ return _context2.abrupt("return", null);
100
+ case 13:
101
+ case "end":
102
+ return _context2.stop();
103
+ }
104
+ }, _callee2, null, [[0, 10]]);
105
+ }));
106
+ return function fetchActivationId(_x2) {
107
+ return _ref2.apply(this, arguments);
108
+ };
109
+ }();
110
+
111
+ /**
112
+ * Calls the agentStudio_duplicateAgent mutation via raw GraphQL fetch.
113
+ *
114
+ * TODO: Add SLO tracking and Sentry error reporting.
115
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
116
+ */
117
+ var fetchDuplicateAgentMutation = exports.fetchDuplicateAgentMutation = /*#__PURE__*/function () {
118
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(agentAri) {
119
+ var _json$data3, _result$agent, _result$errors$0$mess, _result$errors, response, json, result;
120
+ return _regenerator.default.wrap(function _callee3$(_context3) {
121
+ while (1) switch (_context3.prev = _context3.next) {
122
+ case 0:
123
+ _context3.prev = 0;
124
+ _context3.next = 3;
125
+ return fetch(GRAPHQL_ENDPOINT, {
126
+ method: 'POST',
127
+ credentials: 'include',
128
+ headers: {
129
+ 'Content-Type': 'application/json'
130
+ },
131
+ body: JSON.stringify({
132
+ query: "mutation profilecardDuplicateAgentMutation($agentId: ID!) {\n\t\t\t\t\tagentStudio_duplicateAgent(id: $agentId) @optIn(to: \"AgentStudio\") {\n\t\t\t\t\t\tagent { id }\n\t\t\t\t\t\tsuccess\n\t\t\t\t\t\terrors { message }\n\t\t\t\t\t}\n\t\t\t\t}",
133
+ variables: {
134
+ agentId: agentAri
135
+ }
136
+ })
137
+ });
138
+ case 3:
139
+ response = _context3.sent;
140
+ _context3.next = 6;
141
+ return response.json();
142
+ case 6:
143
+ json = _context3.sent;
144
+ result = json === null || json === void 0 || (_json$data3 = json.data) === null || _json$data3 === void 0 ? void 0 : _json$data3.agentStudio_duplicateAgent;
145
+ if (!(result !== null && result !== void 0 && result.success && result !== null && result !== void 0 && (_result$agent = result.agent) !== null && _result$agent !== void 0 && _result$agent.id)) {
146
+ _context3.next = 10;
147
+ break;
148
+ }
149
+ return _context3.abrupt("return", {
150
+ success: true,
151
+ newAgentAri: result.agent.id
152
+ });
153
+ case 10:
154
+ return _context3.abrupt("return", {
155
+ success: false,
156
+ errorMessage: (_result$errors$0$mess = result === null || result === void 0 || (_result$errors = result.errors) === null || _result$errors === void 0 || (_result$errors = _result$errors[0]) === null || _result$errors === void 0 ? void 0 : _result$errors.message) !== null && _result$errors$0$mess !== void 0 ? _result$errors$0$mess : 'Duplicate agent mutation failed'
157
+ });
158
+ case 13:
159
+ _context3.prev = 13;
160
+ _context3.t0 = _context3["catch"](0);
161
+ return _context3.abrupt("return", {
162
+ success: false,
163
+ errorMessage: _context3.t0 instanceof Error ? _context3.t0.message : 'Network error during duplication'
164
+ });
165
+ case 16:
166
+ case "end":
167
+ return _context3.stop();
168
+ }
169
+ }, _callee3, null, [[0, 13]]);
170
+ }));
171
+ return function fetchDuplicateAgentMutation(_x3) {
172
+ return _ref3.apply(this, arguments);
173
+ };
174
+ }();
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useAgentUrlActions = exports.firstCharUpper = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
12
  var _react = require("react");
11
13
  var _atlassianContext = require("@atlaskit/atlassian-context");
@@ -15,6 +17,7 @@ var _navigation = require("@atlaskit/teams-app-config/navigation");
15
17
  var _teamsAppInternalAnalytics = require("@atlaskit/teams-app-internal-analytics");
16
18
  var _url = require("../../../util/url");
17
19
  var _utils = require("../utils");
20
+ var _duplicateFetch = require("./duplicateFetch");
18
21
  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; }
19
22
  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; }
20
23
  var firstCharUpper = exports.firstCharUpper = function firstCharUpper(str) {
@@ -57,17 +60,74 @@ var useAgentUrlActions = exports.useAgentUrlActions = function useAgentUrlAction
57
60
  source: source
58
61
  });
59
62
  };
60
- var onDuplicateAgent = (0, _react.useCallback)(function (agentId) {
61
- var url = (0, _utils.getAtlassianStudioAgentDuplicateUrl)(cloudId, agentId);
62
- window.open(url, '_blank', 'noopener, noreferrer');
63
- fireEvent('ui.button.clicked.duplicateAgentButton', {
64
- agentId: agentId,
65
- source: source
66
- });
67
- }, [cloudId, fireEvent, source]);
68
- var onConversationStarter = function onConversationStarter(_ref4) {
69
- var agentId = _ref4.agentId,
70
- prompt = _ref4.prompt;
63
+ var onDuplicateAgent = (0, _react.useCallback)( /*#__PURE__*/function () {
64
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(agentId) {
65
+ var legacyDuplicateUrl, hasVersionCapability, activationId, agentAri, result;
66
+ return _regenerator.default.wrap(function _callee$(_context) {
67
+ while (1) switch (_context.prev = _context.next) {
68
+ case 0:
69
+ fireEvent('ui.button.clicked.duplicateAgentButton', {
70
+ agentId: agentId,
71
+ source: source
72
+ });
73
+ legacyDuplicateUrl = (0, _utils.getAtlassianStudioAgentDuplicateUrl)(cloudId, agentId); // When versioning FG is off, use legacy duplicate flow
74
+ if ((0, _platformFeatureFlags.fg)('rovo_agent_versioning_enabled')) {
75
+ _context.next = 5;
76
+ break;
77
+ }
78
+ window.open(legacyDuplicateUrl, '_blank', 'noopener, noreferrer');
79
+ return _context.abrupt("return");
80
+ case 5:
81
+ _context.next = 7;
82
+ return (0, _duplicateFetch.fetchHasVersionCapability)(cloudId);
83
+ case 7:
84
+ hasVersionCapability = _context.sent;
85
+ if (hasVersionCapability) {
86
+ _context.next = 11;
87
+ break;
88
+ }
89
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
90
+ window.location.assign(legacyDuplicateUrl);
91
+ return _context.abrupt("return");
92
+ case 11:
93
+ _context.next = 13;
94
+ return (0, _duplicateFetch.fetchActivationId)(cloudId);
95
+ case 13:
96
+ activationId = _context.sent;
97
+ if (activationId) {
98
+ _context.next = 17;
99
+ break;
100
+ }
101
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
102
+ window.location.assign(legacyDuplicateUrl);
103
+ return _context.abrupt("return");
104
+ case 17:
105
+ agentAri = "ari:cloud:rovo::agent/activation/".concat(activationId, "/").concat(agentId); // Call BE mutation to duplicate the agent
106
+ _context.next = 20;
107
+ return (0, _duplicateFetch.fetchDuplicateAgentMutation)(agentAri);
108
+ case 20:
109
+ result = _context.sent;
110
+ if (result.success && result.newAgentAri) {
111
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
112
+ window.location.assign((0, _utils.getStudioPath)("/s/".concat(cloudId, "/agents/").concat(encodeURIComponent(result.newAgentAri), "/v/draft/details")));
113
+ } else {
114
+ // Fallback to legacy on error
115
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
116
+ window.location.assign(legacyDuplicateUrl);
117
+ }
118
+ case 22:
119
+ case "end":
120
+ return _context.stop();
121
+ }
122
+ }, _callee);
123
+ }));
124
+ return function (_x) {
125
+ return _ref4.apply(this, arguments);
126
+ };
127
+ }(), [cloudId, fireEvent, source]);
128
+ var onConversationStarter = function onConversationStarter(_ref5) {
129
+ var agentId = _ref5.agentId,
130
+ prompt = _ref5.prompt;
71
131
  var startConversationInNewTab = function startConversationInNewTab() {
72
132
  var baseUrl = "".concat((0, _atlassianContext.getATLContextUrl)('home'), "/chat");
73
133
  var urlWithParams = (0, _url.encodeParamsToUrl)(baseUrl, _objectSpread({
@@ -12,7 +12,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
12
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) { (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; }
13
13
  var PACKAGE_META_DATA = exports.PACKAGE_META_DATA = {
14
14
  packageName: (_process$env$_PACKAGE = "@atlaskit/profilecard") !== null && _process$env$_PACKAGE !== void 0 ? _process$env$_PACKAGE : '',
15
- packageVersion: (_process$env$_PACKAGE2 = "25.0.2") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
15
+ packageVersion: (_process$env$_PACKAGE2 = "25.0.3") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
16
16
  };
17
17
  var TEAM_SUBJECT = 'teamProfileCard';
18
18
  var USER_SUBJECT = 'profilecard';
@@ -31,7 +31,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
31
31
  actionSubjectId: actionSubjectId,
32
32
  attributes: _objectSpread(_objectSpread({
33
33
  packageName: "@atlaskit/profilecard",
34
- packageVersion: "25.0.2"
34
+ packageVersion: "25.0.3"
35
35
  }, attributes), {}, {
36
36
  firedAt: Math.round((0, _performance.getPageTime)())
37
37
  })
@@ -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', "25.0.2");
9
+ headers.append('atl-client-version', "25.0.3");
10
10
  return headers;
11
11
  };
12
12
  export async function getOrgIdForCloudIdFromAGG(url, cloudId) {
@@ -78,7 +78,7 @@ export const addHeaders = headers => {
78
78
  headers.append('X-ExperimentalApi', 'teams-beta');
79
79
  headers.append('X-ExperimentalApi', 'team-members-beta');
80
80
  headers.append('atl-client-name', "@atlaskit/profilecard");
81
- headers.append('atl-client-version', "25.0.2");
81
+ headers.append('atl-client-version', "25.0.3");
82
82
  return headers;
83
83
  };
84
84
  export async function getTeamFromAGG(url, teamId, siteId) {
@@ -222,7 +222,7 @@ const AgentProfileCard = ({
222
222
  agent: agent,
223
223
  onEditAgent: () => onEditAgent(agent.id),
224
224
  onCopyAgent: () => onCopyAgent(agent.id),
225
- onDuplicateAgent: () => onDuplicateAgent(agent.id),
225
+ onDuplicateAgent: async () => await onDuplicateAgent(agent.id),
226
226
  onDeleteAgent: handleOnDelete,
227
227
  onChatClick: onChatClick ? event => onChatClick(event) : () => onOpenChatFullScreen(agent.id, agent.name),
228
228
  resourceClient: resourceClient,
@@ -0,0 +1,121 @@
1
+ const GRAPHQL_ENDPOINT = '/gateway/api/graphql';
2
+
3
+ /**
4
+ * Fetches version capability for a site via raw GraphQL fetch.
5
+ * Returns true only if versioning migration has completed.
6
+ *
7
+ * TODO remove after versioning rollout complete
8
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
9
+ */
10
+ export const fetchHasVersionCapability = async cloudId => {
11
+ try {
12
+ var _json$data;
13
+ const response = await fetch(GRAPHQL_ENDPOINT, {
14
+ method: 'POST',
15
+ credentials: 'include',
16
+ headers: {
17
+ 'Content-Type': 'application/json'
18
+ },
19
+ body: JSON.stringify({
20
+ query: `query profilecardHasVersionCapabilityQuery($cloudId: String!) {
21
+ agentStudio_hasVersionCapability(cloudId: $cloudId) @optIn(to: "AgentStudio") {
22
+ __typename
23
+ ... on AgentStudioHasVersionCapability {
24
+ hasVersionCapability
25
+ }
26
+ }
27
+ }`,
28
+ variables: {
29
+ cloudId
30
+ }
31
+ })
32
+ });
33
+ const json = await response.json();
34
+ const result = json === null || json === void 0 ? void 0 : (_json$data = json.data) === null || _json$data === void 0 ? void 0 : _json$data.agentStudio_hasVersionCapability;
35
+ return (result === null || result === void 0 ? void 0 : result.__typename) === 'AgentStudioHasVersionCapability' ? Boolean(result.hasVersionCapability) : false;
36
+ } catch {
37
+ return false;
38
+ }
39
+ };
40
+
41
+ /**
42
+ * Fetches the Rovo activation ID for a given cloud ID.
43
+ * Used to construct the agent ARI when not available.
44
+ */
45
+ export const fetchActivationId = async cloudId => {
46
+ try {
47
+ var _json$data$tenantCont, _json$data2, _json$data2$tenantCon, _json$data2$tenantCon2, _json$data2$tenantCon3;
48
+ const response = await fetch(GRAPHQL_ENDPOINT, {
49
+ method: 'POST',
50
+ credentials: 'include',
51
+ headers: {
52
+ 'Content-Type': 'application/json'
53
+ },
54
+ body: JSON.stringify({
55
+ query: `query profilecardActivationQuery($cloudId: ID!, $product: String!) {
56
+ tenantContexts(cloudIds: [$cloudId]) {
57
+ activationIdByProduct(product: $product) {
58
+ active
59
+ }
60
+ }
61
+ }`,
62
+ variables: {
63
+ cloudId,
64
+ product: 'rovo'
65
+ }
66
+ })
67
+ });
68
+ const json = await response.json();
69
+ return (_json$data$tenantCont = json === null || json === void 0 ? void 0 : (_json$data2 = json.data) === null || _json$data2 === void 0 ? void 0 : (_json$data2$tenantCon = _json$data2.tenantContexts) === null || _json$data2$tenantCon === void 0 ? void 0 : (_json$data2$tenantCon2 = _json$data2$tenantCon[0]) === null || _json$data2$tenantCon2 === void 0 ? void 0 : (_json$data2$tenantCon3 = _json$data2$tenantCon2.activationIdByProduct) === null || _json$data2$tenantCon3 === void 0 ? void 0 : _json$data2$tenantCon3.active) !== null && _json$data$tenantCont !== void 0 ? _json$data$tenantCont : null;
70
+ } catch {
71
+ return null;
72
+ }
73
+ };
74
+
75
+ /**
76
+ * Calls the agentStudio_duplicateAgent mutation via raw GraphQL fetch.
77
+ *
78
+ * TODO: Add SLO tracking and Sentry error reporting.
79
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
80
+ */
81
+ export const fetchDuplicateAgentMutation = async agentAri => {
82
+ try {
83
+ var _json$data3, _result$agent, _result$errors$0$mess, _result$errors, _result$errors$;
84
+ const response = await fetch(GRAPHQL_ENDPOINT, {
85
+ method: 'POST',
86
+ credentials: 'include',
87
+ headers: {
88
+ 'Content-Type': 'application/json'
89
+ },
90
+ body: JSON.stringify({
91
+ query: `mutation profilecardDuplicateAgentMutation($agentId: ID!) {
92
+ agentStudio_duplicateAgent(id: $agentId) @optIn(to: "AgentStudio") {
93
+ agent { id }
94
+ success
95
+ errors { message }
96
+ }
97
+ }`,
98
+ variables: {
99
+ agentId: agentAri
100
+ }
101
+ })
102
+ });
103
+ const json = await response.json();
104
+ const result = json === null || json === void 0 ? void 0 : (_json$data3 = json.data) === null || _json$data3 === void 0 ? void 0 : _json$data3.agentStudio_duplicateAgent;
105
+ if (result !== null && result !== void 0 && result.success && result !== null && result !== void 0 && (_result$agent = result.agent) !== null && _result$agent !== void 0 && _result$agent.id) {
106
+ return {
107
+ success: true,
108
+ newAgentAri: result.agent.id
109
+ };
110
+ }
111
+ return {
112
+ success: false,
113
+ errorMessage: (_result$errors$0$mess = result === null || result === void 0 ? void 0 : (_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : (_result$errors$ = _result$errors[0]) === null || _result$errors$ === void 0 ? void 0 : _result$errors$.message) !== null && _result$errors$0$mess !== void 0 ? _result$errors$0$mess : 'Duplicate agent mutation failed'
114
+ };
115
+ } catch (error) {
116
+ return {
117
+ success: false,
118
+ errorMessage: error instanceof Error ? error.message : 'Network error during duplication'
119
+ };
120
+ }
121
+ };
@@ -5,7 +5,8 @@ import { useRovoPostMessageToPubsub } from '@atlaskit/rovo-triggers/post-message
5
5
  import { navigateToTeamsApp } from '@atlaskit/teams-app-config/navigation';
6
6
  import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
7
7
  import { encodeParamsToUrl } from '../../../util/url';
8
- import { getAtlassianStudioAgentDuplicateUrl, getAtlassianStudioAgentEditUrl } from '../utils';
8
+ import { getAtlassianStudioAgentDuplicateUrl, getAtlassianStudioAgentEditUrl, getStudioPath } from '../utils';
9
+ import { fetchHasVersionCapability, fetchActivationId, fetchDuplicateAgentMutation } from './duplicateFetch';
9
10
  export const firstCharUpper = str => str.charAt(0).toUpperCase() + str.slice(1);
10
11
  const ROVO_PARAM_PREFIX = 'rovoChat';
11
12
  const createRovoParams = params => {
@@ -44,13 +45,46 @@ export const useAgentUrlActions = ({
44
45
  source
45
46
  });
46
47
  };
47
- const onDuplicateAgent = useCallback(agentId => {
48
- const url = getAtlassianStudioAgentDuplicateUrl(cloudId, agentId);
49
- window.open(url, '_blank', 'noopener, noreferrer');
48
+ const onDuplicateAgent = useCallback(async agentId => {
50
49
  fireEvent('ui.button.clicked.duplicateAgentButton', {
51
50
  agentId,
52
51
  source
53
52
  });
53
+ const legacyDuplicateUrl = getAtlassianStudioAgentDuplicateUrl(cloudId, agentId);
54
+
55
+ // When versioning FG is off, use legacy duplicate flow
56
+ if (!fg('rovo_agent_versioning_enabled')) {
57
+ window.open(legacyDuplicateUrl, '_blank', 'noopener, noreferrer');
58
+ return;
59
+ }
60
+
61
+ // Check if versioning migration has completed for this site
62
+ const hasVersionCapability = await fetchHasVersionCapability(cloudId);
63
+ if (!hasVersionCapability) {
64
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
65
+ window.location.assign(legacyDuplicateUrl);
66
+ return;
67
+ }
68
+
69
+ // Resolve agent ARI (profilecard doesn't have agentAri, so fetch activationId)
70
+ const activationId = await fetchActivationId(cloudId);
71
+ if (!activationId) {
72
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
73
+ window.location.assign(legacyDuplicateUrl);
74
+ return;
75
+ }
76
+ const agentAri = `ari:cloud:rovo::agent/activation/${activationId}/${agentId}`;
77
+
78
+ // Call BE mutation to duplicate the agent
79
+ const result = await fetchDuplicateAgentMutation(agentAri);
80
+ if (result.success && result.newAgentAri) {
81
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
82
+ window.location.assign(getStudioPath(`/s/${cloudId}/agents/${encodeURIComponent(result.newAgentAri)}/v/draft/details`));
83
+ } else {
84
+ // Fallback to legacy on error
85
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
86
+ window.location.assign(legacyDuplicateUrl);
87
+ }
54
88
  }, [cloudId, fireEvent, source]);
55
89
  const onConversationStarter = ({
56
90
  agentId,
@@ -2,7 +2,7 @@ var _process$env$_PACKAGE, _process$env$_PACKAGE2;
2
2
  import { getPageTime } from './performance';
3
3
  export const PACKAGE_META_DATA = {
4
4
  packageName: (_process$env$_PACKAGE = "@atlaskit/profilecard") !== null && _process$env$_PACKAGE !== void 0 ? _process$env$_PACKAGE : '',
5
- packageVersion: (_process$env$_PACKAGE2 = "25.0.2") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
5
+ packageVersion: (_process$env$_PACKAGE2 = "25.0.3") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
6
6
  };
7
7
  const TEAM_SUBJECT = 'teamProfileCard';
8
8
  const USER_SUBJECT = 'profilecard';
@@ -19,7 +19,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
19
19
  actionSubjectId,
20
20
  attributes: {
21
21
  packageName: "@atlaskit/profilecard",
22
- packageVersion: "25.0.2",
22
+ packageVersion: "25.0.3",
23
23
  ...attributes,
24
24
  firedAt: Math.round(getPageTime())
25
25
  }
@@ -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', "25.0.2");
7
+ headers.append('atl-client-version', "25.0.3");
8
8
  return headers;
9
9
  };
10
10
  export function getOrgIdForCloudIdFromAGG(_x, _x2) {
@@ -59,7 +59,7 @@ export var addHeaders = function addHeaders(headers) {
59
59
  headers.append('X-ExperimentalApi', 'teams-beta');
60
60
  headers.append('X-ExperimentalApi', 'team-members-beta');
61
61
  headers.append('atl-client-name', "@atlaskit/profilecard");
62
- headers.append('atl-client-version', "25.0.2");
62
+ headers.append('atl-client-version', "25.0.3");
63
63
  return headers;
64
64
  };
65
65
  export function getTeamFromAGG(_x, _x2, _x3) {
@@ -60,7 +60,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
60
60
  }),
61
61
  _onEditAgent = _useAgentUrlActions.onEditAgent,
62
62
  _onCopyAgent = _useAgentUrlActions.onCopyAgent,
63
- _onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
63
+ onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
64
64
  onOpenChatFullScreen = _useAgentUrlActions.onOpenChat,
65
65
  onConversationStarter = _useAgentUrlActions.onConversationStarter,
66
66
  onViewFullProfile = _useAgentUrlActions.onViewFullProfile;
@@ -265,9 +265,20 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
265
265
  onCopyAgent: function onCopyAgent() {
266
266
  return _onCopyAgent(agent.id);
267
267
  },
268
- onDuplicateAgent: function onDuplicateAgent() {
269
- return _onDuplicateAgent(agent.id);
270
- },
268
+ onDuplicateAgent: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
269
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
270
+ while (1) switch (_context3.prev = _context3.next) {
271
+ case 0:
272
+ _context3.next = 2;
273
+ return onDuplicateAgent(agent.id);
274
+ case 2:
275
+ return _context3.abrupt("return", _context3.sent);
276
+ case 3:
277
+ case "end":
278
+ return _context3.stop();
279
+ }
280
+ }, _callee3);
281
+ })),
271
282
  onDeleteAgent: handleOnDelete,
272
283
  onChatClick: onChatClick ? function (event) {
273
284
  return onChatClick(event);
@@ -0,0 +1,167 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
4
+
5
+ /**
6
+ * Fetches version capability for a site via raw GraphQL fetch.
7
+ * Returns true only if versioning migration has completed.
8
+ *
9
+ * TODO remove after versioning rollout complete
10
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
11
+ */
12
+ export var fetchHasVersionCapability = /*#__PURE__*/function () {
13
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(cloudId) {
14
+ var _json$data, response, json, result;
15
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
16
+ while (1) switch (_context.prev = _context.next) {
17
+ case 0:
18
+ _context.prev = 0;
19
+ _context.next = 3;
20
+ return fetch(GRAPHQL_ENDPOINT, {
21
+ method: 'POST',
22
+ credentials: 'include',
23
+ headers: {
24
+ 'Content-Type': 'application/json'
25
+ },
26
+ body: JSON.stringify({
27
+ query: "query profilecardHasVersionCapabilityQuery($cloudId: String!) {\n\t\t\t\t\tagentStudio_hasVersionCapability(cloudId: $cloudId) @optIn(to: \"AgentStudio\") {\n\t\t\t\t\t\t__typename\n\t\t\t\t\t\t... on AgentStudioHasVersionCapability {\n\t\t\t\t\t\t\thasVersionCapability\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
28
+ variables: {
29
+ cloudId: cloudId
30
+ }
31
+ })
32
+ });
33
+ case 3:
34
+ response = _context.sent;
35
+ _context.next = 6;
36
+ return response.json();
37
+ case 6:
38
+ json = _context.sent;
39
+ result = json === null || json === void 0 || (_json$data = json.data) === null || _json$data === void 0 ? void 0 : _json$data.agentStudio_hasVersionCapability;
40
+ return _context.abrupt("return", (result === null || result === void 0 ? void 0 : result.__typename) === 'AgentStudioHasVersionCapability' ? Boolean(result.hasVersionCapability) : false);
41
+ case 11:
42
+ _context.prev = 11;
43
+ _context.t0 = _context["catch"](0);
44
+ return _context.abrupt("return", false);
45
+ case 14:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }, _callee, null, [[0, 11]]);
50
+ }));
51
+ return function fetchHasVersionCapability(_x) {
52
+ return _ref.apply(this, arguments);
53
+ };
54
+ }();
55
+
56
+ /**
57
+ * Fetches the Rovo activation ID for a given cloud ID.
58
+ * Used to construct the agent ARI when not available.
59
+ */
60
+ export var fetchActivationId = /*#__PURE__*/function () {
61
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(cloudId) {
62
+ var _json$data$tenantCont, _json$data2, response, json;
63
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
64
+ while (1) switch (_context2.prev = _context2.next) {
65
+ case 0:
66
+ _context2.prev = 0;
67
+ _context2.next = 3;
68
+ return fetch(GRAPHQL_ENDPOINT, {
69
+ method: 'POST',
70
+ credentials: 'include',
71
+ headers: {
72
+ 'Content-Type': 'application/json'
73
+ },
74
+ body: JSON.stringify({
75
+ query: "query profilecardActivationQuery($cloudId: ID!, $product: String!) {\n\t\t\t\t\ttenantContexts(cloudIds: [$cloudId]) {\n\t\t\t\t\t\tactivationIdByProduct(product: $product) {\n\t\t\t\t\t\t\tactive\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
76
+ variables: {
77
+ cloudId: cloudId,
78
+ product: 'rovo'
79
+ }
80
+ })
81
+ });
82
+ case 3:
83
+ response = _context2.sent;
84
+ _context2.next = 6;
85
+ return response.json();
86
+ case 6:
87
+ json = _context2.sent;
88
+ return _context2.abrupt("return", (_json$data$tenantCont = json === null || json === void 0 || (_json$data2 = json.data) === null || _json$data2 === void 0 || (_json$data2 = _json$data2.tenantContexts) === null || _json$data2 === void 0 || (_json$data2 = _json$data2[0]) === null || _json$data2 === void 0 || (_json$data2 = _json$data2.activationIdByProduct) === null || _json$data2 === void 0 ? void 0 : _json$data2.active) !== null && _json$data$tenantCont !== void 0 ? _json$data$tenantCont : null);
89
+ case 10:
90
+ _context2.prev = 10;
91
+ _context2.t0 = _context2["catch"](0);
92
+ return _context2.abrupt("return", null);
93
+ case 13:
94
+ case "end":
95
+ return _context2.stop();
96
+ }
97
+ }, _callee2, null, [[0, 10]]);
98
+ }));
99
+ return function fetchActivationId(_x2) {
100
+ return _ref2.apply(this, arguments);
101
+ };
102
+ }();
103
+
104
+ /**
105
+ * Calls the agentStudio_duplicateAgent mutation via raw GraphQL fetch.
106
+ *
107
+ * TODO: Add SLO tracking and Sentry error reporting.
108
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
109
+ */
110
+ export var fetchDuplicateAgentMutation = /*#__PURE__*/function () {
111
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(agentAri) {
112
+ var _json$data3, _result$agent, _result$errors$0$mess, _result$errors, response, json, result;
113
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
114
+ while (1) switch (_context3.prev = _context3.next) {
115
+ case 0:
116
+ _context3.prev = 0;
117
+ _context3.next = 3;
118
+ return fetch(GRAPHQL_ENDPOINT, {
119
+ method: 'POST',
120
+ credentials: 'include',
121
+ headers: {
122
+ 'Content-Type': 'application/json'
123
+ },
124
+ body: JSON.stringify({
125
+ query: "mutation profilecardDuplicateAgentMutation($agentId: ID!) {\n\t\t\t\t\tagentStudio_duplicateAgent(id: $agentId) @optIn(to: \"AgentStudio\") {\n\t\t\t\t\t\tagent { id }\n\t\t\t\t\t\tsuccess\n\t\t\t\t\t\terrors { message }\n\t\t\t\t\t}\n\t\t\t\t}",
126
+ variables: {
127
+ agentId: agentAri
128
+ }
129
+ })
130
+ });
131
+ case 3:
132
+ response = _context3.sent;
133
+ _context3.next = 6;
134
+ return response.json();
135
+ case 6:
136
+ json = _context3.sent;
137
+ result = json === null || json === void 0 || (_json$data3 = json.data) === null || _json$data3 === void 0 ? void 0 : _json$data3.agentStudio_duplicateAgent;
138
+ if (!(result !== null && result !== void 0 && result.success && result !== null && result !== void 0 && (_result$agent = result.agent) !== null && _result$agent !== void 0 && _result$agent.id)) {
139
+ _context3.next = 10;
140
+ break;
141
+ }
142
+ return _context3.abrupt("return", {
143
+ success: true,
144
+ newAgentAri: result.agent.id
145
+ });
146
+ case 10:
147
+ return _context3.abrupt("return", {
148
+ success: false,
149
+ errorMessage: (_result$errors$0$mess = result === null || result === void 0 || (_result$errors = result.errors) === null || _result$errors === void 0 || (_result$errors = _result$errors[0]) === null || _result$errors === void 0 ? void 0 : _result$errors.message) !== null && _result$errors$0$mess !== void 0 ? _result$errors$0$mess : 'Duplicate agent mutation failed'
150
+ });
151
+ case 13:
152
+ _context3.prev = 13;
153
+ _context3.t0 = _context3["catch"](0);
154
+ return _context3.abrupt("return", {
155
+ success: false,
156
+ errorMessage: _context3.t0 instanceof Error ? _context3.t0.message : 'Network error during duplication'
157
+ });
158
+ case 16:
159
+ case "end":
160
+ return _context3.stop();
161
+ }
162
+ }, _callee3, null, [[0, 13]]);
163
+ }));
164
+ return function fetchDuplicateAgentMutation(_x3) {
165
+ return _ref3.apply(this, arguments);
166
+ };
167
+ }();
@@ -1,7 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
7
  import { useCallback } from 'react';
6
8
  import { getATLContextUrl } from '@atlaskit/atlassian-context';
7
9
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -9,7 +11,8 @@ import { useRovoPostMessageToPubsub } from '@atlaskit/rovo-triggers/post-message
9
11
  import { navigateToTeamsApp } from '@atlaskit/teams-app-config/navigation';
10
12
  import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
11
13
  import { encodeParamsToUrl } from '../../../util/url';
12
- import { getAtlassianStudioAgentDuplicateUrl, getAtlassianStudioAgentEditUrl } from '../utils';
14
+ import { getAtlassianStudioAgentDuplicateUrl, getAtlassianStudioAgentEditUrl, getStudioPath } from '../utils';
15
+ import { fetchHasVersionCapability, fetchActivationId, fetchDuplicateAgentMutation } from './duplicateFetch';
13
16
  export var firstCharUpper = function firstCharUpper(str) {
14
17
  return str.charAt(0).toUpperCase() + str.slice(1);
15
18
  };
@@ -50,17 +53,74 @@ export var useAgentUrlActions = function useAgentUrlActions(_ref3) {
50
53
  source: source
51
54
  });
52
55
  };
53
- var onDuplicateAgent = useCallback(function (agentId) {
54
- var url = getAtlassianStudioAgentDuplicateUrl(cloudId, agentId);
55
- window.open(url, '_blank', 'noopener, noreferrer');
56
- fireEvent('ui.button.clicked.duplicateAgentButton', {
57
- agentId: agentId,
58
- source: source
59
- });
60
- }, [cloudId, fireEvent, source]);
61
- var onConversationStarter = function onConversationStarter(_ref4) {
62
- var agentId = _ref4.agentId,
63
- prompt = _ref4.prompt;
56
+ var onDuplicateAgent = useCallback( /*#__PURE__*/function () {
57
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(agentId) {
58
+ var legacyDuplicateUrl, hasVersionCapability, activationId, agentAri, result;
59
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
60
+ while (1) switch (_context.prev = _context.next) {
61
+ case 0:
62
+ fireEvent('ui.button.clicked.duplicateAgentButton', {
63
+ agentId: agentId,
64
+ source: source
65
+ });
66
+ legacyDuplicateUrl = getAtlassianStudioAgentDuplicateUrl(cloudId, agentId); // When versioning FG is off, use legacy duplicate flow
67
+ if (fg('rovo_agent_versioning_enabled')) {
68
+ _context.next = 5;
69
+ break;
70
+ }
71
+ window.open(legacyDuplicateUrl, '_blank', 'noopener, noreferrer');
72
+ return _context.abrupt("return");
73
+ case 5:
74
+ _context.next = 7;
75
+ return fetchHasVersionCapability(cloudId);
76
+ case 7:
77
+ hasVersionCapability = _context.sent;
78
+ if (hasVersionCapability) {
79
+ _context.next = 11;
80
+ break;
81
+ }
82
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
83
+ window.location.assign(legacyDuplicateUrl);
84
+ return _context.abrupt("return");
85
+ case 11:
86
+ _context.next = 13;
87
+ return fetchActivationId(cloudId);
88
+ case 13:
89
+ activationId = _context.sent;
90
+ if (activationId) {
91
+ _context.next = 17;
92
+ break;
93
+ }
94
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
95
+ window.location.assign(legacyDuplicateUrl);
96
+ return _context.abrupt("return");
97
+ case 17:
98
+ agentAri = "ari:cloud:rovo::agent/activation/".concat(activationId, "/").concat(agentId); // Call BE mutation to duplicate the agent
99
+ _context.next = 20;
100
+ return fetchDuplicateAgentMutation(agentAri);
101
+ case 20:
102
+ result = _context.sent;
103
+ if (result.success && result.newAgentAri) {
104
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
105
+ window.location.assign(getStudioPath("/s/".concat(cloudId, "/agents/").concat(encodeURIComponent(result.newAgentAri), "/v/draft/details")));
106
+ } else {
107
+ // Fallback to legacy on error
108
+ // Opening in same tab because, we cannot open in new tab after async operation, because browsers prevent `.open` after certain duration
109
+ window.location.assign(legacyDuplicateUrl);
110
+ }
111
+ case 22:
112
+ case "end":
113
+ return _context.stop();
114
+ }
115
+ }, _callee);
116
+ }));
117
+ return function (_x) {
118
+ return _ref4.apply(this, arguments);
119
+ };
120
+ }(), [cloudId, fireEvent, source]);
121
+ var onConversationStarter = function onConversationStarter(_ref5) {
122
+ var agentId = _ref5.agentId,
123
+ prompt = _ref5.prompt;
64
124
  var startConversationInNewTab = function startConversationInNewTab() {
65
125
  var baseUrl = "".concat(getATLContextUrl('home'), "/chat");
66
126
  var urlWithParams = encodeParamsToUrl(baseUrl, _objectSpread({
@@ -5,7 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import { getPageTime } from './performance';
6
6
  export var PACKAGE_META_DATA = {
7
7
  packageName: (_process$env$_PACKAGE = "@atlaskit/profilecard") !== null && _process$env$_PACKAGE !== void 0 ? _process$env$_PACKAGE : '',
8
- packageVersion: (_process$env$_PACKAGE2 = "25.0.2") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
8
+ packageVersion: (_process$env$_PACKAGE2 = "25.0.3") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
9
9
  };
10
10
  var TEAM_SUBJECT = 'teamProfileCard';
11
11
  var USER_SUBJECT = 'profilecard';
@@ -24,7 +24,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
24
24
  actionSubjectId: actionSubjectId,
25
25
  attributes: _objectSpread(_objectSpread({
26
26
  packageName: "@atlaskit/profilecard",
27
- packageVersion: "25.0.2"
27
+ packageVersion: "25.0.3"
28
28
  }, attributes), {}, {
29
29
  firedAt: Math.round(getPageTime())
30
30
  })
@@ -4,7 +4,7 @@ type AgentActionsProps = {
4
4
  agent: RovoAgentProfileCardInfo;
5
5
  onEditAgent: () => void;
6
6
  onCopyAgent: () => void;
7
- onDuplicateAgent: () => void;
7
+ onDuplicateAgent: () => Promise<void>;
8
8
  onDeleteAgent: () => void;
9
9
  onChatClick: (event: React.MouseEvent) => void;
10
10
  onViewFullProfileClick: () => void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Fetches version capability for a site via raw GraphQL fetch.
3
+ * Returns true only if versioning migration has completed.
4
+ *
5
+ * TODO remove after versioning rollout complete
6
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
7
+ */
8
+ export declare const fetchHasVersionCapability: (cloudId: string) => Promise<boolean>;
9
+ /**
10
+ * Fetches the Rovo activation ID for a given cloud ID.
11
+ * Used to construct the agent ARI when not available.
12
+ */
13
+ export declare const fetchActivationId: (cloudId: string) => Promise<string | null>;
14
+ /**
15
+ * Calls the agentStudio_duplicateAgent mutation via raw GraphQL fetch.
16
+ *
17
+ * TODO: Add SLO tracking and Sentry error reporting.
18
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
19
+ */
20
+ export declare const fetchDuplicateAgentMutation: (agentAri: string) => Promise<{
21
+ success: boolean;
22
+ newAgentAri?: string;
23
+ errorMessage?: string;
24
+ }>;
@@ -5,7 +5,7 @@ export declare const useAgentUrlActions: ({ cloudId, source, }: {
5
5
  }) => {
6
6
  onEditAgent: (agentId: string) => void;
7
7
  onCopyAgent: (agentId: string) => void;
8
- onDuplicateAgent: (agentId: string) => void;
8
+ onDuplicateAgent: (agentId: string) => Promise<void>;
9
9
  onOpenChat: (agentId: string, agentName: string) => void;
10
10
  onConversationStarter: ({ agentId, prompt }: {
11
11
  agentId: string;
@@ -4,7 +4,7 @@ type AgentActionsProps = {
4
4
  agent: RovoAgentProfileCardInfo;
5
5
  onEditAgent: () => void;
6
6
  onCopyAgent: () => void;
7
- onDuplicateAgent: () => void;
7
+ onDuplicateAgent: () => Promise<void>;
8
8
  onDeleteAgent: () => void;
9
9
  onChatClick: (event: React.MouseEvent) => void;
10
10
  onViewFullProfileClick: () => void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Fetches version capability for a site via raw GraphQL fetch.
3
+ * Returns true only if versioning migration has completed.
4
+ *
5
+ * TODO remove after versioning rollout complete
6
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
7
+ */
8
+ export declare const fetchHasVersionCapability: (cloudId: string) => Promise<boolean>;
9
+ /**
10
+ * Fetches the Rovo activation ID for a given cloud ID.
11
+ * Used to construct the agent ARI when not available.
12
+ */
13
+ export declare const fetchActivationId: (cloudId: string) => Promise<string | null>;
14
+ /**
15
+ * Calls the agentStudio_duplicateAgent mutation via raw GraphQL fetch.
16
+ *
17
+ * TODO: Add SLO tracking and Sentry error reporting.
18
+ * See: https://product-fabric.atlassian.net/browse/RAGE-2822
19
+ */
20
+ export declare const fetchDuplicateAgentMutation: (agentAri: string) => Promise<{
21
+ success: boolean;
22
+ newAgentAri?: string;
23
+ errorMessage?: string;
24
+ }>;
@@ -5,7 +5,7 @@ export declare const useAgentUrlActions: ({ cloudId, source, }: {
5
5
  }) => {
6
6
  onEditAgent: (agentId: string) => void;
7
7
  onCopyAgent: (agentId: string) => void;
8
- onDuplicateAgent: (agentId: string) => void;
8
+ onDuplicateAgent: (agentId: string) => Promise<void>;
9
9
  onOpenChat: (agentId: string, agentName: string) => void;
10
10
  onConversationStarter: ({ agentId, prompt }: {
11
11
  agentId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "25.0.3",
3
+ "version": "25.1.0",
4
4
  "description": "A React component to display a card with user information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -65,7 +65,7 @@
65
65
  "@atlaskit/platform-feature-flags": "^1.1.0",
66
66
  "@atlaskit/popup": "^4.16.0",
67
67
  "@atlaskit/primitives": "^19.0.0",
68
- "@atlaskit/rovo-agent-components": "^4.1.0",
68
+ "@atlaskit/rovo-agent-components": "^4.2.0",
69
69
  "@atlaskit/rovo-triggers": "^5.41.0",
70
70
  "@atlaskit/spinner": "^19.1.0",
71
71
  "@atlaskit/teams-app-config": "^1.12.0",
@@ -74,7 +74,7 @@
74
74
  "@atlaskit/teams-avatar": "^2.6.0",
75
75
  "@atlaskit/teams-public": "^1.1.0",
76
76
  "@atlaskit/theme": "^23.1.0",
77
- "@atlaskit/tmp-editor-statsig": "^62.7.0",
77
+ "@atlaskit/tmp-editor-statsig": "^62.8.0",
78
78
  "@atlaskit/tokens": "^13.0.0",
79
79
  "@atlaskit/tooltip": "^21.1.0",
80
80
  "@babel/runtime": "^7.0.0",
@@ -174,6 +174,9 @@
174
174
  "rovo_display_ai_disclaimer_on_agent_profile_card": {
175
175
  "type": "boolean"
176
176
  },
177
+ "rovo_agent_versioning_enabled": {
178
+ "type": "boolean"
179
+ },
177
180
  "rovo_agent_support_a2a_avatar": {
178
181
  "type": "boolean"
179
182
  },