@atlaskit/profilecard 20.9.0 → 20.11.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 +20 -0
- package/afm-post-office/tsconfig.json +1 -1
- package/dist/cjs/client/ProfileCardClient.js +10 -4
- package/dist/cjs/client/RovoAgentCardClient.js +57 -12
- package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/Actions.js +54 -11
- package/dist/cjs/components/Agent/AgentProfileCard.js +6 -1
- package/dist/cjs/components/Agent/AgentProfileCardResourced.js +47 -67
- package/dist/cjs/components/Agent/hooks/useAgentActions.js +5 -1
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/client/ProfileCardClient.js +8 -4
- package/dist/es2019/client/RovoAgentCardClient.js +48 -10
- package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/Actions.js +33 -4
- package/dist/es2019/components/Agent/AgentProfileCard.js +5 -2
- package/dist/es2019/components/Agent/AgentProfileCardResourced.js +29 -37
- package/dist/es2019/components/Agent/hooks/useAgentActions.js +5 -1
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/client/ProfileCardClient.js +10 -4
- package/dist/esm/client/RovoAgentCardClient.js +57 -12
- package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/Actions.js +56 -13
- package/dist/esm/components/Agent/AgentProfileCard.js +6 -1
- package/dist/esm/components/Agent/AgentProfileCardResourced.js +48 -68
- package/dist/esm/components/Agent/hooks/useAgentActions.js +5 -1
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/client/ProfileCardClient.d.ts +1 -0
- package/dist/types/client/RovoAgentCardClient.d.ts +2 -1
- package/dist/types/components/Agent/Actions.d.ts +4 -2
- package/dist/types/components/Agent/AgentProfileCardResourced.d.ts +1 -1
- package/dist/types/components/Agent/hooks/useAgentActions.d.ts +1 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types-ts4.5/client/ProfileCardClient.d.ts +1 -0
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +2 -1
- package/dist/types-ts4.5/components/Agent/Actions.d.ts +4 -2
- package/dist/types-ts4.5/components/Agent/AgentProfileCardResourced.d.ts +1 -1
- package/dist/types-ts4.5/components/Agent/hooks/useAgentActions.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +7 -0
- package/package.json +8 -5
|
@@ -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
|
-
|
|
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(
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
3
|
import { fireEvent } from '../../util/analytics';
|
|
4
4
|
import { getAAIDFromARI } from '../../util/rovoAgentUtils';
|
|
@@ -51,34 +51,27 @@ export const AgentProfileCardResourced = props => {
|
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
53
|
}, [creatorUserId, fireAnalytics, props.cloudId, props.resourceClient]);
|
|
54
|
-
const getAgentInfo = useCallback(() => {
|
|
55
|
-
return props.resourceClient.getRovoAgentProfile({
|
|
56
|
-
type: 'identity',
|
|
57
|
-
value: props.accountId
|
|
58
|
-
}, fireAnalytics);
|
|
59
|
-
}, [fireAnalytics, props.accountId, props.resourceClient]);
|
|
60
54
|
const fetchData = useCallback(async () => {
|
|
61
55
|
setIsLoading(true);
|
|
62
|
-
|
|
63
|
-
const profileData = await
|
|
56
|
+
try {
|
|
57
|
+
const profileData = await props.resourceClient.getRovoAgentProfile({
|
|
58
|
+
type: 'identity',
|
|
59
|
+
value: props.accountId
|
|
60
|
+
}, fireAnalytics);
|
|
64
61
|
const agentCreatorInfo = await getCreator(profileData === null || profileData === void 0 ? void 0 : profileData.creator_type, (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined);
|
|
65
|
-
|
|
62
|
+
setAgentData({
|
|
66
63
|
...profileData,
|
|
67
64
|
creatorInfo: agentCreatorInfo
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
setIsLoading(false);
|
|
73
|
-
}, [getAgentInfo, getCreator]);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
try {
|
|
76
|
-
fetchData();
|
|
77
|
-
} catch (error) {
|
|
65
|
+
});
|
|
66
|
+
} catch (err) {
|
|
67
|
+
setError(err);
|
|
68
|
+
} finally {
|
|
78
69
|
setIsLoading(false);
|
|
79
|
-
setError(error);
|
|
80
70
|
}
|
|
81
|
-
}, [
|
|
71
|
+
}, [fireAnalytics, getCreator, props.accountId, props.resourceClient]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
fetchData();
|
|
74
|
+
}, [fetchData]);
|
|
82
75
|
if (error || !isLoading && !agentData) {
|
|
83
76
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
84
77
|
reload: () => {
|
|
@@ -88,19 +81,18 @@ export const AgentProfileCardResourced = props => {
|
|
|
88
81
|
fireAnalytics: () => {}
|
|
89
82
|
}));
|
|
90
83
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
return null;
|
|
84
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
85
|
+
fallback: null
|
|
86
|
+
}, /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
|
|
87
|
+
agent: agentData,
|
|
88
|
+
isLoading: isLoading,
|
|
89
|
+
hasError: !!error,
|
|
90
|
+
isCreatedByViewingUser: creatorUserId === props.viewingUserId,
|
|
91
|
+
product: props.product,
|
|
92
|
+
onConversationStartersClick: props.onConversationStartersClick,
|
|
93
|
+
onChatClick: props.onChatClick,
|
|
94
|
+
addFlag: props.addFlag,
|
|
95
|
+
resourceClient: props.resourceClient,
|
|
96
|
+
cloudId: props.cloudId
|
|
97
|
+
}));
|
|
106
98
|
};
|
|
@@ -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.
|
|
35
|
+
packageVersion: "20.11.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$
|
|
165
|
-
return (_this$
|
|
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$
|
|
171
|
-
return (_this$
|
|
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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
7
|
+
headers.append('atl-client-version', "20.11.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.
|
|
51
|
+
headers.append('atl-client-version', "20.11.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
|
|
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
|
-
|
|
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(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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 (
|
|
130
|
-
var text =
|
|
131
|
-
_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 (
|
|
142
|
-
var text =
|
|
143
|
-
_onClick2 =
|
|
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
|
};
|
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
|
+
import React, { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
9
|
import { fireEvent } from '../../util/analytics';
|
|
10
10
|
import { getAAIDFromARI } from '../../util/rovoAgentUtils';
|
|
@@ -92,65 +92,46 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
|
|
|
92
92
|
return _ref.apply(this, arguments);
|
|
93
93
|
};
|
|
94
94
|
}(), [creatorUserId, fireAnalytics, props.cloudId, props.resourceClient]);
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}, fireAnalytics);
|
|
100
|
-
}, [fireAnalytics, props.accountId, props.resourceClient]);
|
|
101
|
-
var fetchData = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
102
|
-
var getAgentData, agentData;
|
|
103
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
104
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
95
|
+
var fetchData = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
96
|
+
var profileData, agentCreatorInfo;
|
|
97
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
98
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
105
99
|
case 0:
|
|
106
100
|
setIsLoading(true);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
_context2.next = 2;
|
|
114
|
-
return getAgentInfo();
|
|
115
|
-
case 2:
|
|
116
|
-
profileData = _context2.sent;
|
|
117
|
-
_context2.next = 5;
|
|
118
|
-
return getCreator(profileData === null || profileData === void 0 ? void 0 : profileData.creator_type, (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined);
|
|
119
|
-
case 5:
|
|
120
|
-
agentCreatorInfo = _context2.sent;
|
|
121
|
-
return _context2.abrupt("return", _objectSpread(_objectSpread({}, profileData), {}, {
|
|
122
|
-
creatorInfo: agentCreatorInfo
|
|
123
|
-
}));
|
|
124
|
-
case 7:
|
|
125
|
-
case "end":
|
|
126
|
-
return _context2.stop();
|
|
127
|
-
}
|
|
128
|
-
}, _callee2);
|
|
129
|
-
}));
|
|
130
|
-
return function getAgentData() {
|
|
131
|
-
return _ref3.apply(this, arguments);
|
|
132
|
-
};
|
|
133
|
-
}();
|
|
134
|
-
_context3.next = 4;
|
|
135
|
-
return getAgentData();
|
|
101
|
+
_context2.prev = 1;
|
|
102
|
+
_context2.next = 4;
|
|
103
|
+
return props.resourceClient.getRovoAgentProfile({
|
|
104
|
+
type: 'identity',
|
|
105
|
+
value: props.accountId
|
|
106
|
+
}, fireAnalytics);
|
|
136
107
|
case 4:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
108
|
+
profileData = _context2.sent;
|
|
109
|
+
_context2.next = 7;
|
|
110
|
+
return getCreator(profileData === null || profileData === void 0 ? void 0 : profileData.creator_type, (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined);
|
|
140
111
|
case 7:
|
|
112
|
+
agentCreatorInfo = _context2.sent;
|
|
113
|
+
setAgentData(_objectSpread(_objectSpread({}, profileData), {}, {
|
|
114
|
+
creatorInfo: agentCreatorInfo
|
|
115
|
+
}));
|
|
116
|
+
_context2.next = 14;
|
|
117
|
+
break;
|
|
118
|
+
case 11:
|
|
119
|
+
_context2.prev = 11;
|
|
120
|
+
_context2.t0 = _context2["catch"](1);
|
|
121
|
+
setError(_context2.t0);
|
|
122
|
+
case 14:
|
|
123
|
+
_context2.prev = 14;
|
|
124
|
+
setIsLoading(false);
|
|
125
|
+
return _context2.finish(14);
|
|
126
|
+
case 17:
|
|
141
127
|
case "end":
|
|
142
|
-
return
|
|
128
|
+
return _context2.stop();
|
|
143
129
|
}
|
|
144
|
-
},
|
|
145
|
-
})), [
|
|
130
|
+
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
131
|
+
})), [fireAnalytics, getCreator, props.accountId, props.resourceClient]);
|
|
146
132
|
useEffect(function () {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} catch (error) {
|
|
150
|
-
setIsLoading(false);
|
|
151
|
-
setError(error);
|
|
152
|
-
}
|
|
153
|
-
}, [fetchData, getAgentInfo, getCreator, props.accountId, props.cloudId, props.resourceClient]);
|
|
133
|
+
fetchData();
|
|
134
|
+
}, [fetchData]);
|
|
154
135
|
if (error || !isLoading && !agentData) {
|
|
155
136
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
156
137
|
reload: function reload() {
|
|
@@ -160,19 +141,18 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
|
|
|
160
141
|
fireAnalytics: function fireAnalytics() {}
|
|
161
142
|
}));
|
|
162
143
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
return null;
|
|
144
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
145
|
+
fallback: null
|
|
146
|
+
}, /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
|
|
147
|
+
agent: agentData,
|
|
148
|
+
isLoading: isLoading,
|
|
149
|
+
hasError: !!error,
|
|
150
|
+
isCreatedByViewingUser: creatorUserId === props.viewingUserId,
|
|
151
|
+
product: props.product,
|
|
152
|
+
onConversationStartersClick: props.onConversationStartersClick,
|
|
153
|
+
onChatClick: props.onChatClick,
|
|
154
|
+
addFlag: props.addFlag,
|
|
155
|
+
resourceClient: props.resourceClient,
|
|
156
|
+
cloudId: props.cloudId
|
|
157
|
+
}));
|
|
178
158
|
};
|
|
@@ -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.
|
|
42
|
+
packageVersion: "20.11.0"
|
|
43
43
|
}, attributes), {}, {
|
|
44
44
|
firedAt: Math.round(getPageTime())
|
|
45
45
|
})
|