@atlaskit/profilecard 19.23.0 → 19.25.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.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/client/ProfileCardClient.js +12 -0
- package/dist/cjs/client/RovoAgentCardClient.js +131 -9
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/Actions.js +4 -3
- package/dist/cjs/components/Agent/AgentDeleteConfirmationModal.js +9 -9
- package/dist/cjs/components/Agent/AgentProfileCard.js +89 -39
- package/dist/cjs/components/Agent/AgentProfileCardResourced.js +3 -1
- package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +4 -2
- package/dist/cjs/components/Agent/messages.js +29 -0
- package/dist/cjs/components/User/ProfileCardTrigger.js +6 -3
- package/dist/cjs/components/common/ProfileCardTrigger.js +13 -25
- package/dist/cjs/util/analytics.js +3 -3
- package/dist/cjs/util/rovoAgentUtils.js +1 -15
- package/dist/es2019/client/ProfileCardClient.js +8 -0
- package/dist/es2019/client/RovoAgentCardClient.js +103 -6
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/Actions.js +4 -3
- package/dist/es2019/components/Agent/AgentDeleteConfirmationModal.js +9 -9
- package/dist/es2019/components/Agent/AgentProfileCard.js +50 -23
- package/dist/es2019/components/Agent/AgentProfileCardResourced.js +3 -1
- package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +4 -2
- package/dist/es2019/components/Agent/messages.js +23 -0
- package/dist/es2019/components/User/ProfileCardTrigger.js +6 -3
- package/dist/es2019/components/common/ProfileCardTrigger.js +2 -2
- package/dist/es2019/util/analytics.js +2 -2
- package/dist/es2019/util/rovoAgentUtils.js +0 -12
- package/dist/esm/client/ProfileCardClient.js +12 -0
- package/dist/esm/client/RovoAgentCardClient.js +131 -9
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/Actions.js +4 -3
- package/dist/esm/components/Agent/AgentDeleteConfirmationModal.js +9 -9
- package/dist/esm/components/Agent/AgentProfileCard.js +90 -40
- package/dist/esm/components/Agent/AgentProfileCardResourced.js +3 -1
- package/dist/esm/components/Agent/AgentProfileCardTrigger.js +4 -2
- package/dist/esm/components/Agent/messages.js +23 -0
- package/dist/esm/components/User/ProfileCardTrigger.js +6 -3
- package/dist/esm/components/common/ProfileCardTrigger.js +13 -25
- package/dist/esm/util/analytics.js +3 -3
- package/dist/esm/util/rovoAgentUtils.js +0 -13
- package/dist/types/client/ProfileCardClient.d.ts +2 -0
- package/dist/types/client/RovoAgentCardClient.d.ts +2 -0
- package/dist/types/components/Agent/Actions.d.ts +3 -1
- package/dist/types/components/Agent/AgentProfileCard.d.ts +2 -11
- package/dist/types/components/Agent/AgentProfileCardResourced.d.ts +2 -1
- package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +1 -9
- package/dist/types/components/Agent/messages.d.ts +22 -0
- package/dist/types/components/common/LoadingState.d.ts +2 -1
- package/dist/types/components/common/types.d.ts +2 -2
- package/dist/types/types.d.ts +31 -1
- package/dist/types/util/analytics.d.ts +6 -5
- package/dist/types/util/rovoAgentUtils.d.ts +0 -1
- package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -0
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +2 -0
- package/dist/types-ts4.5/components/Agent/Actions.d.ts +3 -1
- package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +2 -11
- package/dist/types-ts4.5/components/Agent/AgentProfileCardResourced.d.ts +2 -1
- package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +1 -9
- package/dist/types-ts4.5/components/Agent/messages.d.ts +22 -0
- package/dist/types-ts4.5/components/common/LoadingState.d.ts +2 -1
- package/dist/types-ts4.5/components/common/types.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +31 -1
- package/dist/types-ts4.5/util/analytics.d.ts +6 -5
- package/dist/types-ts4.5/util/rovoAgentUtils.d.ts +0 -1
- package/package.json +4 -8
- package/dist/cjs/client/getAgentInfo.js +0 -66
- package/dist/cjs/components/Agent/hooks/useDeleteAgent.js +0 -70
- package/dist/cjs/components/Agent/hooks/useSetFavouriteAgent.js +0 -91
- package/dist/es2019/client/getAgentInfo.js +0 -21
- package/dist/es2019/components/Agent/hooks/useDeleteAgent.js +0 -33
- package/dist/es2019/components/Agent/hooks/useSetFavouriteAgent.js +0 -48
- package/dist/esm/client/getAgentInfo.js +0 -58
- package/dist/esm/components/Agent/hooks/useDeleteAgent.js +0 -63
- package/dist/esm/components/Agent/hooks/useSetFavouriteAgent.js +0 -84
- package/dist/types/client/getAgentInfo.d.ts +0 -3
- package/dist/types/components/Agent/hooks/useDeleteAgent.d.ts +0 -8
- package/dist/types/components/Agent/hooks/useSetFavouriteAgent.d.ts +0 -10
- package/dist/types-ts4.5/client/getAgentInfo.d.ts +0 -3
- package/dist/types-ts4.5/components/Agent/hooks/useDeleteAgent.d.ts +0 -8
- package/dist/types-ts4.5/components/Agent/hooks/useSetFavouriteAgent.d.ts +0 -10
|
@@ -64,38 +64,26 @@ function ProfileCardTrigger(_ref) {
|
|
|
64
64
|
setVisible(false);
|
|
65
65
|
}, hideDelay);
|
|
66
66
|
}, [hideDelay]);
|
|
67
|
-
var showProfilecard = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
68
|
-
return _regenerator.default.wrap(function
|
|
69
|
-
while (1) switch (
|
|
67
|
+
var showProfilecard = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
68
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
69
|
+
while (1) switch (_context.prev = _context.next) {
|
|
70
70
|
case 0:
|
|
71
71
|
clearTimeout(hideTimer.current);
|
|
72
72
|
clearTimeout(showTimer.current);
|
|
73
|
-
showTimer.current = window.setTimeout(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
_context.next = 3;
|
|
82
|
-
return getProfileData === null || getProfileData === void 0 ? void 0 : getProfileData();
|
|
83
|
-
case 3:
|
|
84
|
-
setVisible(true);
|
|
85
|
-
if (fireAnalytics) {
|
|
86
|
-
fireAnalytics((0, _analytics.cardTriggered)(profileCardType, _trigger));
|
|
87
|
-
}
|
|
88
|
-
case 5:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context.stop();
|
|
73
|
+
showTimer.current = window.setTimeout(function () {
|
|
74
|
+
if (!visible) {
|
|
75
|
+
getProfileData === null || getProfileData === void 0 || getProfileData();
|
|
76
|
+
setVisible(true);
|
|
77
|
+
if (fireAnalytics) {
|
|
78
|
+
fireAnalytics((0, _analytics.cardTriggered)(profileCardType, _trigger));
|
|
91
79
|
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
80
|
+
}
|
|
81
|
+
}, showDelay);
|
|
94
82
|
case 3:
|
|
95
83
|
case "end":
|
|
96
|
-
return
|
|
84
|
+
return _context.stop();
|
|
97
85
|
}
|
|
98
|
-
},
|
|
86
|
+
}, _callee);
|
|
99
87
|
})), [showDelay, visible, getProfileData, fireAnalytics, profileCardType, _trigger]);
|
|
100
88
|
var onMouseEnter = (0, _react.useCallback)(function () {
|
|
101
89
|
showProfilecard();
|
|
@@ -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: "19.
|
|
48
|
+
packageVersion: "19.25.0"
|
|
49
49
|
}, attributes), {}, {
|
|
50
50
|
firedAt: Math.round((0, _performance.getPageTime)())
|
|
51
51
|
})
|
|
@@ -95,6 +95,6 @@ var moreMembersClicked = exports.moreMembersClicked = function moreMembersClicke
|
|
|
95
95
|
var errorRetryClicked = exports.errorRetryClicked = function errorRetryClicked(attributes) {
|
|
96
96
|
return createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
|
|
97
97
|
};
|
|
98
|
-
var agentRequestAnalytics = exports.agentRequestAnalytics = function agentRequestAnalytics(action, attributes) {
|
|
99
|
-
return createEvent('operational', action, AGENT_SUBJECT, 'request', attributes);
|
|
98
|
+
var agentRequestAnalytics = exports.agentRequestAnalytics = function agentRequestAnalytics(action, actionSubjectId, attributes) {
|
|
99
|
+
return createEvent('operational', action, AGENT_SUBJECT, actionSubjectId || 'request', attributes);
|
|
100
100
|
};
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.getAAIDFromARI = exports.
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
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; }
|
|
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) { (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; }
|
|
6
|
+
exports.getAAIDFromARI = exports.USER_ARI_PREFIX = void 0;
|
|
11
7
|
var USER_ARI_PREFIX = exports.USER_ARI_PREFIX = 'ari:cloud:identity::user/';
|
|
12
|
-
var createHeaders = exports.createHeaders = function createHeaders(product, cloudId) {
|
|
13
|
-
var config = {
|
|
14
|
-
headers: {
|
|
15
|
-
'X-Product': product,
|
|
16
|
-
'X-Experience-Id': 'profile-card',
|
|
17
|
-
'X-Cloudid': cloudId
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
return new Headers(_objectSpread({}, config.headers || {}));
|
|
21
|
-
};
|
|
22
8
|
var getAAIDFromARI = exports.getAAIDFromARI = function getAAIDFromARI(ari) {
|
|
23
9
|
return ari.replace(USER_ARI_PREFIX, '');
|
|
24
10
|
};
|
|
@@ -56,6 +56,14 @@ class ProfileCardClient {
|
|
|
56
56
|
var _this$rovoAgentClient2;
|
|
57
57
|
return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
|
|
58
58
|
}
|
|
59
|
+
deleteAgent(id, analytics) {
|
|
60
|
+
var _this$rovoAgentClient3;
|
|
61
|
+
return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.deleteAgent(id, analytics);
|
|
62
|
+
}
|
|
63
|
+
setFavouriteAgent(id, isFavourite, analytics) {
|
|
64
|
+
var _this$rovoAgentClient4;
|
|
65
|
+
return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.setFavouriteAgent(id, isFavourite, analytics);
|
|
66
|
+
}
|
|
59
67
|
}
|
|
60
68
|
function maybeCreateTeamCentralClient(config, clients) {
|
|
61
69
|
if (isFedRamp()) {
|
|
@@ -2,21 +2,44 @@ 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
|
-
|
|
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 || {})
|
|
15
|
+
});
|
|
16
|
+
};
|
|
6
17
|
export default class RovoAgentCardClient extends CachingClient {
|
|
7
18
|
constructor(options) {
|
|
8
19
|
super(options);
|
|
9
20
|
this.options = options;
|
|
10
21
|
}
|
|
11
22
|
makeRequest(id, cloudId) {
|
|
23
|
+
const product = this.options.productIdentifier || 'rovo';
|
|
24
|
+
const headers = createHeaders(product, this.options.cloudId);
|
|
12
25
|
if (id.type === 'identity') {
|
|
13
|
-
return
|
|
26
|
+
return fetch(new Request(`/gateway/api/assist/agents/v1/accountid/${id.value}`, {
|
|
27
|
+
method: 'GET',
|
|
28
|
+
credentials: 'include',
|
|
29
|
+
mode: 'cors',
|
|
30
|
+
headers
|
|
31
|
+
})).then(response => response.json());
|
|
14
32
|
}
|
|
15
|
-
return
|
|
33
|
+
return fetch(new Request(`/gateway/api/assist/agents/v1/${id.value}`, {
|
|
34
|
+
method: 'GET',
|
|
35
|
+
credentials: 'include',
|
|
36
|
+
mode: 'cors',
|
|
37
|
+
headers
|
|
38
|
+
})).then(response => response.json());
|
|
16
39
|
}
|
|
17
40
|
getProfile(id, analytics) {
|
|
18
41
|
if (!id.value) {
|
|
19
|
-
return Promise.reject(new Error('
|
|
42
|
+
return Promise.reject(new Error('Id is missing'));
|
|
20
43
|
}
|
|
21
44
|
if (!this.options.cloudId) {
|
|
22
45
|
return Promise.reject(new Error('cloudId is missing'));
|
|
@@ -35,7 +58,7 @@ export default class RovoAgentCardClient extends CachingClient {
|
|
|
35
58
|
this.setCachedProfile(id.value, data);
|
|
36
59
|
}
|
|
37
60
|
if (analytics) {
|
|
38
|
-
analytics(agentRequestAnalytics('succeeded', {
|
|
61
|
+
analytics(agentRequestAnalytics('succeeded', 'request', {
|
|
39
62
|
duration: getPageTime() - startTime,
|
|
40
63
|
gateway: true
|
|
41
64
|
}));
|
|
@@ -43,7 +66,81 @@ export default class RovoAgentCardClient extends CachingClient {
|
|
|
43
66
|
resolve(data);
|
|
44
67
|
}).catch(error => {
|
|
45
68
|
if (analytics) {
|
|
46
|
-
analytics(agentRequestAnalytics('failed', {
|
|
69
|
+
analytics(agentRequestAnalytics('failed', 'request', {
|
|
70
|
+
duration: getPageTime() - startTime,
|
|
71
|
+
...getErrorAttributes(error),
|
|
72
|
+
gateway: true
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
reject(error);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
deleteAgent(agentId, analytics) {
|
|
80
|
+
if (!this.options.cloudId) {
|
|
81
|
+
return Promise.reject(new Error('cloudId is missing'));
|
|
82
|
+
}
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const startTime = getPageTime();
|
|
85
|
+
const product = this.options.productIdentifier || 'rovo';
|
|
86
|
+
if (analytics) {
|
|
87
|
+
analytics(agentRequestAnalytics('triggered'));
|
|
88
|
+
}
|
|
89
|
+
const headers = createHeaders(product, this.options.cloudId);
|
|
90
|
+
fetch(new Request(`/gateway/api/assist/agents/v1/${agentId}`, {
|
|
91
|
+
method: 'DELETE',
|
|
92
|
+
credentials: 'include',
|
|
93
|
+
mode: 'cors',
|
|
94
|
+
headers
|
|
95
|
+
})).then(() => {
|
|
96
|
+
if (analytics) {
|
|
97
|
+
analytics(agentRequestAnalytics('succeeded', 'deleteAgent', {
|
|
98
|
+
duration: getPageTime() - startTime,
|
|
99
|
+
gateway: true
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
resolve();
|
|
103
|
+
}).catch(error => {
|
|
104
|
+
if (analytics) {
|
|
105
|
+
analytics(agentRequestAnalytics('failed', 'deleteAgent', {
|
|
106
|
+
duration: getPageTime() - startTime,
|
|
107
|
+
...getErrorAttributes(error),
|
|
108
|
+
gateway: true
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
reject(error);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
setFavouriteAgent(agentId, isFavourite, analytics) {
|
|
116
|
+
if (!this.options.cloudId) {
|
|
117
|
+
return Promise.reject(new Error('cloudId is missing'));
|
|
118
|
+
}
|
|
119
|
+
return new Promise(async (resolve, reject) => {
|
|
120
|
+
const startTime = getPageTime();
|
|
121
|
+
const product = this.options.productIdentifier || 'rovo';
|
|
122
|
+
const actionSubjectId = isFavourite ? 'favourite' : 'unfavourite';
|
|
123
|
+
const requestMethod = isFavourite ? 'POST' : 'DELETE';
|
|
124
|
+
if (analytics) {
|
|
125
|
+
analytics(agentRequestAnalytics('triggered', 'actionSubjectId'));
|
|
126
|
+
}
|
|
127
|
+
const headers = createHeaders(product, this.options.cloudId);
|
|
128
|
+
await fetch(new Request(`/gateway/api/assist/agents/v1/${agentId}/favourite`, {
|
|
129
|
+
method: requestMethod,
|
|
130
|
+
credentials: 'include',
|
|
131
|
+
mode: 'cors',
|
|
132
|
+
headers
|
|
133
|
+
})).then(() => {
|
|
134
|
+
if (analytics) {
|
|
135
|
+
analytics(agentRequestAnalytics('succeeded', actionSubjectId, {
|
|
136
|
+
duration: getPageTime() - startTime,
|
|
137
|
+
gateway: true
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
resolve();
|
|
141
|
+
}).catch(error => {
|
|
142
|
+
if (analytics) {
|
|
143
|
+
analytics(agentRequestAnalytics('failed', actionSubjectId, {
|
|
47
144
|
duration: getPageTime() - startTime,
|
|
48
145
|
...getErrorAttributes(error),
|
|
49
146
|
gateway: true
|
|
@@ -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', "19.
|
|
70
|
+
headers.append('atl-client-version', "19.25.0");
|
|
71
71
|
return headers;
|
|
72
72
|
};
|
|
73
73
|
export async function getTeamFromAGG(url, teamId, siteId) {
|
|
@@ -67,7 +67,8 @@ export const AgentActions = ({
|
|
|
67
67
|
onDeleteAgent,
|
|
68
68
|
onDuplicateAgent,
|
|
69
69
|
onCopyAgent,
|
|
70
|
-
onChatClick
|
|
70
|
+
onChatClick,
|
|
71
|
+
agent
|
|
71
72
|
}) => {
|
|
72
73
|
const {
|
|
73
74
|
formatMessage
|
|
@@ -148,8 +149,8 @@ export const AgentActions = ({
|
|
|
148
149
|
setIsDeleteModalOpen(false);
|
|
149
150
|
},
|
|
150
151
|
onSubmit: onDeleteAgent,
|
|
151
|
-
agentId:
|
|
152
|
-
agentName:
|
|
152
|
+
agentId: agent.id,
|
|
153
|
+
agentName: agent.name
|
|
153
154
|
}));
|
|
154
155
|
};
|
|
155
156
|
const messages = defineMessages({
|
|
@@ -37,45 +37,45 @@ export const AgentDeleteConfirmationModal = ({
|
|
|
37
37
|
};
|
|
38
38
|
const messages = defineMessages({
|
|
39
39
|
cancelText: {
|
|
40
|
-
id: '
|
|
40
|
+
id: 'profilecard.agent-profile.agent-delete-confirm.cancel-text',
|
|
41
41
|
defaultMessage: 'Cancel'
|
|
42
42
|
},
|
|
43
43
|
confirmText: {
|
|
44
|
-
id: '
|
|
44
|
+
id: 'profilecard.agent-profile.agent-delete-confirm.confirm-text',
|
|
45
45
|
defaultMessage: 'Delete'
|
|
46
46
|
},
|
|
47
47
|
title: {
|
|
48
|
-
id: '
|
|
48
|
+
id: 'profilecard.agent-profile.delete-agent-confirm-title',
|
|
49
49
|
defaultMessage: 'Delete "{agentName}"?',
|
|
50
50
|
description: 'Title text for the delete agent confirmation modal'
|
|
51
51
|
},
|
|
52
52
|
body: {
|
|
53
|
-
id: '
|
|
53
|
+
id: 'profilecard.agent-profile.delete-agent-confirm-body',
|
|
54
54
|
defaultMessage: `Are you sure you want to delete this agent? This action cannot be undone.`,
|
|
55
55
|
description: 'Body text for the delete agent confirmation modal'
|
|
56
56
|
},
|
|
57
57
|
error: {
|
|
58
|
-
id: '
|
|
58
|
+
id: 'profilecard.agent-profile.delete-agent-error',
|
|
59
59
|
defaultMessage: 'Could not delete agent',
|
|
60
60
|
description: 'Error message displayed when an agent cannot be deleted'
|
|
61
61
|
},
|
|
62
62
|
errorAgentNotFound: {
|
|
63
|
-
id: '
|
|
63
|
+
id: 'profilecard.agent-profile.delete-agent-error.agent-not-found',
|
|
64
64
|
defaultMessage: 'That agent could not be found.',
|
|
65
65
|
description: 'Error message displayed when an agent cannot be found'
|
|
66
66
|
},
|
|
67
67
|
errorAgentInUse: {
|
|
68
|
-
id: '
|
|
68
|
+
id: 'profilecard.agent-profile.delete-agent-error.agent-in-use',
|
|
69
69
|
defaultMessage: 'Agent is currently in use. Try again later.',
|
|
70
70
|
description: 'Error message displayed when an agent is in use'
|
|
71
71
|
},
|
|
72
72
|
errorIncorrectOwner: {
|
|
73
|
-
id: '
|
|
73
|
+
id: 'profilecard.agent-profile.delete-agent-error.incorrect-owner',
|
|
74
74
|
defaultMessage: 'You cannot delete agents you have not created yourself. Please contact the agent owner.',
|
|
75
75
|
description: 'Error message displayed when the agent owner is incorrect'
|
|
76
76
|
},
|
|
77
77
|
agentDeletedSuccess: {
|
|
78
|
-
id: '
|
|
78
|
+
id: 'profilecard.agent-profile.delete-agent-success',
|
|
79
79
|
defaultMessage: 'Agent has been deleted!',
|
|
80
80
|
description: 'Success message displayed when an agent is deleted'
|
|
81
81
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
2
3
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
4
|
import { Box, Stack, xcss } from '@atlaskit/primitives';
|
|
4
5
|
import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
|
|
@@ -9,8 +10,7 @@ import { AgentActions } from './Actions';
|
|
|
9
10
|
import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
|
|
10
11
|
import { ConversationStarters } from './ConversationStarters';
|
|
11
12
|
import { useAgentUrlActions } from './hooks/useAgentActions';
|
|
12
|
-
import {
|
|
13
|
-
import { useSetFavouriteAgent } from './hooks/useSetFavouriteAgent';
|
|
13
|
+
import { messages } from './messages';
|
|
14
14
|
const styles = xcss({
|
|
15
15
|
paddingBlockStart: 'space.400',
|
|
16
16
|
paddingInline: 'space.200'
|
|
@@ -34,7 +34,9 @@ const AgentProfileCard = ({
|
|
|
34
34
|
product = 'rovo',
|
|
35
35
|
hasError,
|
|
36
36
|
errorType,
|
|
37
|
-
onConversationStartersClick
|
|
37
|
+
onConversationStartersClick,
|
|
38
|
+
resourceClient,
|
|
39
|
+
addFlag
|
|
38
40
|
}) => {
|
|
39
41
|
var _agent$creatorInfo, _agent$creatorInfo2, _agent$creatorInfo3, _agent$creatorInfo4;
|
|
40
42
|
const {
|
|
@@ -46,21 +48,15 @@ const AgentProfileCard = ({
|
|
|
46
48
|
} = useAgentUrlActions({
|
|
47
49
|
cloudId: cloudId || ''
|
|
48
50
|
});
|
|
51
|
+
const [isStarred, setIsStarred] = useState(false);
|
|
52
|
+
const [starCount, setStarCount] = useState();
|
|
49
53
|
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
product
|
|
57
|
-
});
|
|
58
|
-
const {
|
|
59
|
-
deleteAgent
|
|
60
|
-
} = useDeleteAgent({
|
|
61
|
-
cloudId,
|
|
62
|
-
product
|
|
63
|
-
});
|
|
54
|
+
formatMessage
|
|
55
|
+
} = useIntl();
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setIsStarred(!!(agent !== null && agent !== void 0 && agent.favourite));
|
|
58
|
+
setStarCount(agent === null || agent === void 0 ? void 0 : agent.favourite_count);
|
|
59
|
+
}, [agent === null || agent === void 0 ? void 0 : agent.favourite, agent === null || agent === void 0 ? void 0 : agent.favourite_count]);
|
|
64
60
|
const {
|
|
65
61
|
createAnalyticsEvent
|
|
66
62
|
} = useAnalyticsEvents();
|
|
@@ -69,11 +65,41 @@ const AgentProfileCard = ({
|
|
|
69
65
|
fireEvent(createAnalyticsEvent, payload);
|
|
70
66
|
}
|
|
71
67
|
}, [createAnalyticsEvent]);
|
|
72
|
-
const
|
|
68
|
+
const handleSetFavourite = useCallback(async () => {
|
|
69
|
+
if (agent !== null && agent !== void 0 && agent.id) {
|
|
70
|
+
try {
|
|
71
|
+
await resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics);
|
|
72
|
+
if (isStarred) {
|
|
73
|
+
setStarCount(starCount ? starCount - 1 : 0);
|
|
74
|
+
} else {
|
|
75
|
+
setStarCount((starCount || 0) + 1);
|
|
76
|
+
}
|
|
77
|
+
setIsStarred(!isStarred);
|
|
78
|
+
} catch (error) {}
|
|
79
|
+
}
|
|
80
|
+
}, [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, isStarred, resourceClient, starCount]);
|
|
81
|
+
const handleOnDelete = useCallback(async () => {
|
|
73
82
|
if (agent) {
|
|
74
|
-
|
|
83
|
+
try {
|
|
84
|
+
await resourceClient.deleteAgent(agent.id, fireAnalytics);
|
|
85
|
+
addFlag === null || addFlag === void 0 ? void 0 : addFlag({
|
|
86
|
+
title: formatMessage(messages.agentDeletedSuccessFlagTitle),
|
|
87
|
+
description: formatMessage(messages.agentDeletedSuccessFlagDescription, {
|
|
88
|
+
agentName: agent.name
|
|
89
|
+
}),
|
|
90
|
+
type: 'success',
|
|
91
|
+
id: 'ptc-directory.agent-profile.delete-agent-success'
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
addFlag === null || addFlag === void 0 ? void 0 : addFlag({
|
|
95
|
+
title: formatMessage(messages.agentDeletedErrorFlagTitle),
|
|
96
|
+
description: formatMessage(messages.agentDeletedErrorFlagDescription),
|
|
97
|
+
type: 'error',
|
|
98
|
+
id: 'ptc-directory.agent-profile.delete-agent-error'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
75
101
|
}
|
|
76
|
-
};
|
|
102
|
+
}, [addFlag, agent, fireAnalytics, formatMessage, resourceClient]);
|
|
77
103
|
useEffect(() => {
|
|
78
104
|
if (!isLoading && agent) {
|
|
79
105
|
fireAnalytics(profileCardRendered('agent', 'content'));
|
|
@@ -109,7 +135,7 @@ const AgentProfileCard = ({
|
|
|
109
135
|
}, /*#__PURE__*/React.createElement(AgentProfileInfo, {
|
|
110
136
|
agentName: agent.name,
|
|
111
137
|
isStarred: isStarred,
|
|
112
|
-
onStarToggle:
|
|
138
|
+
onStarToggle: handleSetFavourite,
|
|
113
139
|
isHidden: agent.visibility === 'PRIVATE',
|
|
114
140
|
creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/React.createElement(AgentProfileCreator, {
|
|
115
141
|
creator: {
|
|
@@ -121,7 +147,7 @@ const AgentProfileCard = ({
|
|
|
121
147
|
onCreatorLinkClick: () => {}
|
|
122
148
|
}),
|
|
123
149
|
starCountRender: /*#__PURE__*/React.createElement(AgentStarCount, {
|
|
124
|
-
starCount:
|
|
150
|
+
starCount: starCount,
|
|
125
151
|
isLoading: false
|
|
126
152
|
}),
|
|
127
153
|
agentDescription: agent.description
|
|
@@ -135,6 +161,7 @@ const AgentProfileCard = ({
|
|
|
135
161
|
});
|
|
136
162
|
}
|
|
137
163
|
})), /*#__PURE__*/React.createElement(AgentActions, {
|
|
164
|
+
agent: agent,
|
|
138
165
|
isAgentCreatedByCurrentUser: isCreatedByViewingUser,
|
|
139
166
|
onEditAgent: () => onEditAgent(agent.id),
|
|
140
167
|
onCopyAgent: () => onCopyAgent(agent.id),
|
|
@@ -96,7 +96,9 @@ export const AgentProfileCardResourced = props => {
|
|
|
96
96
|
isCreatedByViewingUser: creatorUserId === props.viewingUserId,
|
|
97
97
|
product: props.product,
|
|
98
98
|
onConversationStartersClick: props.onConversationStartersClick,
|
|
99
|
-
onChatClick: props.onChatClick
|
|
99
|
+
onChatClick: props.onChatClick,
|
|
100
|
+
addFlag: props.addFlag,
|
|
101
|
+
resourceClient: props.resourceClient
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
return null;
|
|
@@ -79,12 +79,14 @@ export const AgentProfileCardTrigger = ({
|
|
|
79
79
|
}, /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
|
|
80
80
|
agent: profileData,
|
|
81
81
|
hasError: !!error,
|
|
82
|
-
isCreatedByViewingUser: (profileData === null || profileData === void 0 ? void 0 : (_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
|
|
82
|
+
isCreatedByViewingUser: (profileData === null || profileData === void 0 ? void 0 : profileData.creatorInfo) && (profileData === null || profileData === void 0 ? void 0 : (_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
|
|
83
83
|
cloudId: props.cloudId,
|
|
84
84
|
product: product,
|
|
85
85
|
errorType: error,
|
|
86
86
|
onChatClick: props.onChatClick,
|
|
87
|
-
onConversationStartersClick: props.onConversationStartersClick
|
|
87
|
+
onConversationStartersClick: props.onConversationStartersClick,
|
|
88
|
+
resourceClient: props.resourceClient,
|
|
89
|
+
addFlag: props.addFlag
|
|
88
90
|
}));
|
|
89
91
|
};
|
|
90
92
|
return /*#__PURE__*/React.createElement(ProfileCardTrigger, _extends({}, props, {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
agentDeletedSuccessFlagTitle: {
|
|
4
|
+
id: 'profilecard.agent-profile-card.delete-agent-success-flag-title',
|
|
5
|
+
defaultMessage: 'Agent deleted',
|
|
6
|
+
description: 'Flag message title displayed when an agent is deleted'
|
|
7
|
+
},
|
|
8
|
+
agentDeletedSuccessFlagDescription: {
|
|
9
|
+
id: 'profilecard.agent-profile-card.delete-agent-success-flag-description',
|
|
10
|
+
defaultMessage: 'You deleted {agentName}',
|
|
11
|
+
description: 'Flag message description displayed when an agent is deleted'
|
|
12
|
+
},
|
|
13
|
+
agentDeletedErrorFlagTitle: {
|
|
14
|
+
id: 'profilecard.agent-profile-card.delete-agent-error-flag-title',
|
|
15
|
+
defaultMessage: 'Failed to delete Agent',
|
|
16
|
+
description: 'Flag message title displayed when there is an error deleting agent'
|
|
17
|
+
},
|
|
18
|
+
agentDeletedErrorFlagDescription: {
|
|
19
|
+
id: 'profilecard.agent-profile-card.delete-agent-error-flag-description',
|
|
20
|
+
defaultMessage: 'Something went wrong while deleting the agent. Try again in a few moments.',
|
|
21
|
+
description: 'Flag message description displayed when there is an error deleting agent'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -26,7 +26,8 @@ function ProfileCardContent({
|
|
|
26
26
|
profileCardAction,
|
|
27
27
|
hasError,
|
|
28
28
|
errorType,
|
|
29
|
-
agentActions
|
|
29
|
+
agentActions,
|
|
30
|
+
addFlag
|
|
30
31
|
}) {
|
|
31
32
|
if (isAgent && fg('enable_agent_profile_card')) {
|
|
32
33
|
return /*#__PURE__*/React.createElement(AgentProfileCardResourced, {
|
|
@@ -37,7 +38,8 @@ function ProfileCardContent({
|
|
|
37
38
|
trigger: trigger,
|
|
38
39
|
product: product,
|
|
39
40
|
onChatClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onChatClick,
|
|
40
|
-
onConversationStartersClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onConversationStartersClick
|
|
41
|
+
onConversationStartersClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onConversationStartersClick,
|
|
42
|
+
addFlag: addFlag
|
|
41
43
|
});
|
|
42
44
|
} else {
|
|
43
45
|
return /*#__PURE__*/React.createElement(Suspense, {
|
|
@@ -278,7 +280,8 @@ export default function ProfilecardTriggerNext({
|
|
|
278
280
|
profileCardAction: filterActions(),
|
|
279
281
|
errorType: error,
|
|
280
282
|
hasError: hasError,
|
|
281
|
-
agentActions: agentActions
|
|
283
|
+
agentActions: agentActions,
|
|
284
|
+
addFlag: addFlag
|
|
282
285
|
})),
|
|
283
286
|
trigger: triggerProps => {
|
|
284
287
|
const {
|
|
@@ -50,9 +50,9 @@ function ProfileCardTrigger({
|
|
|
50
50
|
const showProfilecard = useCallback(async () => {
|
|
51
51
|
clearTimeout(hideTimer.current);
|
|
52
52
|
clearTimeout(showTimer.current);
|
|
53
|
-
showTimer.current = window.setTimeout(
|
|
53
|
+
showTimer.current = window.setTimeout(() => {
|
|
54
54
|
if (!visible) {
|
|
55
|
-
|
|
55
|
+
getProfileData === null || getProfileData === void 0 ? void 0 : getProfileData();
|
|
56
56
|
setVisible(true);
|
|
57
57
|
if (fireAnalytics) {
|
|
58
58
|
fireAnalytics(cardTriggered(profileCardType, trigger));
|
|
@@ -32,7 +32,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
32
32
|
actionSubjectId,
|
|
33
33
|
attributes: {
|
|
34
34
|
packageName: "@atlaskit/profilecard",
|
|
35
|
-
packageVersion: "19.
|
|
35
|
+
packageVersion: "19.25.0",
|
|
36
36
|
...attributes,
|
|
37
37
|
firedAt: Math.round(getPageTime())
|
|
38
38
|
}
|
|
@@ -63,4 +63,4 @@ export const moreActionsClicked = (type, attributes) => createEvent('ui', 'click
|
|
|
63
63
|
export const teamAvatarClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'avatar', attributes);
|
|
64
64
|
export const moreMembersClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'moreMembers', attributes);
|
|
65
65
|
export const errorRetryClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
|
|
66
|
-
export const agentRequestAnalytics = (action, attributes) => createEvent('operational', action, AGENT_SUBJECT, 'request', attributes);
|
|
66
|
+
export const agentRequestAnalytics = (action, actionSubjectId, attributes) => createEvent('operational', action, AGENT_SUBJECT, actionSubjectId || 'request', attributes);
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
export const USER_ARI_PREFIX = 'ari:cloud:identity::user/';
|
|
2
|
-
export const createHeaders = (product, cloudId) => {
|
|
3
|
-
const config = {
|
|
4
|
-
headers: {
|
|
5
|
-
'X-Product': product,
|
|
6
|
-
'X-Experience-Id': 'profile-card',
|
|
7
|
-
'X-Cloudid': cloudId
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
return new Headers({
|
|
11
|
-
...(config.headers || {})
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
2
|
export const getAAIDFromARI = ari => {
|
|
15
3
|
return ari.replace(USER_ARI_PREFIX, '');
|
|
16
4
|
};
|
|
@@ -72,6 +72,18 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
72
72
|
var _this$rovoAgentClient2;
|
|
73
73
|
return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
|
|
74
74
|
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "deleteAgent",
|
|
77
|
+
value: function deleteAgent(id, analytics) {
|
|
78
|
+
var _this$rovoAgentClient3;
|
|
79
|
+
return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.deleteAgent(id, analytics);
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "setFavouriteAgent",
|
|
83
|
+
value: function setFavouriteAgent(id, isFavourite, analytics) {
|
|
84
|
+
var _this$rovoAgentClient4;
|
|
85
|
+
return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.setFavouriteAgent(id, isFavourite, analytics);
|
|
86
|
+
}
|
|
75
87
|
}]);
|
|
76
88
|
return ProfileCardClient;
|
|
77
89
|
}();
|