@atlaskit/profilecard 24.14.0 → 24.15.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 +21 -0
- package/__tests__/vr-tests/__snapshots__/user-profilecard/error-state--default.png +0 -0
- package/__tests__/vr-tests/agent-profilecard.vr.tsx +7 -1
- package/__tests__/vr-tests/user-profilecard.vr.tsx +42 -6
- package/dist/cjs/client/ProfileCardClient.js +10 -10
- package/dist/cjs/client/RovoAgentCardClient.js +172 -56
- package/dist/cjs/client/TeamProfileCardClient.js +44 -14
- package/dist/cjs/client/UserProfileCardClient.js +2 -9
- package/dist/cjs/client/errorUtils.js +83 -5
- package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/Actions.js +25 -11
- package/dist/cjs/components/Agent/ActionsCompiled.compiled.css +19 -0
- package/dist/cjs/components/Agent/ActionsCompiled.js +150 -0
- package/dist/cjs/components/Agent/AgentDeleteConfirmationModal.js +2 -4
- package/dist/cjs/components/Agent/AgentProfileCard.js +28 -14
- package/dist/cjs/components/Agent/AgentProfileCardCompiled.compiled.css +8 -0
- package/dist/cjs/components/Agent/AgentProfileCardCompiled.js +257 -0
- package/dist/cjs/components/Agent/AgentProfileCardResourced.js +8 -5
- package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +6 -2
- package/dist/cjs/components/Agent/AgentProfileCardWrapper.compiled.css +1 -0
- package/dist/cjs/components/Agent/AgentProfileCardWrapper.js +9 -8
- package/dist/cjs/components/Agent/ConversationStarters.js +2 -4
- package/dist/cjs/components/Agent/hooks/useAgentActions.js +61 -30
- package/dist/cjs/components/Error/ErrorMessage.js +3 -3
- package/dist/cjs/components/Team/TeamForbiddenErrorState.js +21 -6
- package/dist/cjs/components/Team/TeamLoadingState.js +21 -6
- package/dist/cjs/components/Team/TeamProfileCard.js +155 -60
- package/dist/cjs/components/Team/TeamProfileCardTrigger.js +107 -36
- package/dist/cjs/components/User/ProfileCardDetails.compiled.css +0 -1
- package/dist/cjs/components/User/ProfileCardDetails.js +2 -4
- package/dist/cjs/components/User/ReportingLinesDetails.js +4 -1
- package/dist/cjs/components/User/ReportingLinesDetailsCompiled.compiled.css +11 -0
- package/dist/cjs/components/User/ReportingLinesDetailsCompiled.js +109 -0
- package/dist/cjs/components/common/ProfileCardWrapper.compiled.css +1 -0
- package/dist/cjs/components/common/ProfileCardWrapper.js +9 -8
- package/dist/cjs/components/team-profile-card/main.js +18 -9
- package/dist/cjs/components/team-profile-card/team-actions/more-actions/index.js +2 -4
- package/dist/cjs/components/team-profile-card/team-connections/main.js +36 -17
- package/dist/cjs/styled/CoverImage.compiled.css +2 -0
- package/dist/cjs/styled/CoverImage.js +4 -2
- package/dist/cjs/styled/Error.compiled.css +0 -2
- package/dist/cjs/styled/Error.js +5 -3
- package/dist/cjs/util/analytics.js +57 -2
- package/dist/es2019/client/ProfileCardClient.js +10 -10
- package/dist/es2019/client/RovoAgentCardClient.js +186 -58
- package/dist/es2019/client/TeamProfileCardClient.js +49 -16
- package/dist/es2019/client/UserProfileCardClient.js +3 -10
- package/dist/es2019/client/errorUtils.js +84 -3
- package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/Actions.js +26 -11
- package/dist/es2019/components/Agent/ActionsCompiled.compiled.css +19 -0
- package/dist/es2019/components/Agent/ActionsCompiled.js +127 -0
- package/dist/es2019/components/Agent/AgentDeleteConfirmationModal.js +1 -2
- package/dist/es2019/components/Agent/AgentProfileCard.js +28 -13
- package/dist/es2019/components/Agent/AgentProfileCardCompiled.compiled.css +8 -0
- package/dist/es2019/components/Agent/AgentProfileCardCompiled.js +200 -0
- package/dist/es2019/components/Agent/AgentProfileCardResourced.js +9 -5
- package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +7 -2
- package/dist/es2019/components/Agent/AgentProfileCardWrapper.compiled.css +1 -0
- package/dist/es2019/components/Agent/AgentProfileCardWrapper.js +8 -7
- package/dist/es2019/components/Agent/ConversationStarters.js +1 -3
- package/dist/es2019/components/Agent/hooks/useAgentActions.js +62 -30
- package/dist/es2019/components/Error/ErrorMessage.js +1 -2
- package/dist/es2019/components/Team/TeamForbiddenErrorState.js +17 -6
- package/dist/es2019/components/Team/TeamLoadingState.js +17 -6
- package/dist/es2019/components/Team/TeamProfileCard.js +144 -54
- package/dist/es2019/components/Team/TeamProfileCardTrigger.js +75 -12
- package/dist/es2019/components/User/ProfileCardDetails.compiled.css +0 -1
- package/dist/es2019/components/User/ProfileCardDetails.js +1 -4
- package/dist/es2019/components/User/ReportingLinesDetails.js +4 -1
- package/dist/es2019/components/User/ReportingLinesDetailsCompiled.compiled.css +11 -0
- package/dist/es2019/components/User/ReportingLinesDetailsCompiled.js +96 -0
- package/dist/es2019/components/common/ProfileCardWrapper.compiled.css +1 -0
- package/dist/es2019/components/common/ProfileCardWrapper.js +8 -7
- package/dist/es2019/components/team-profile-card/main.js +19 -9
- package/dist/es2019/components/team-profile-card/team-actions/more-actions/index.js +1 -2
- package/dist/es2019/components/team-profile-card/team-connections/main.js +38 -17
- package/dist/es2019/styled/CoverImage.compiled.css +2 -0
- package/dist/es2019/styled/CoverImage.js +4 -2
- package/dist/es2019/styled/Error.compiled.css +0 -2
- package/dist/es2019/styled/Error.js +6 -4
- package/dist/es2019/util/analytics.js +57 -2
- package/dist/esm/client/ProfileCardClient.js +10 -10
- package/dist/esm/client/RovoAgentCardClient.js +174 -58
- package/dist/esm/client/TeamProfileCardClient.js +46 -16
- package/dist/esm/client/UserProfileCardClient.js +3 -10
- package/dist/esm/client/errorUtils.js +82 -4
- package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/Actions.js +25 -11
- package/dist/esm/components/Agent/ActionsCompiled.compiled.css +19 -0
- package/dist/esm/components/Agent/ActionsCompiled.js +141 -0
- package/dist/esm/components/Agent/AgentDeleteConfirmationModal.js +1 -2
- package/dist/esm/components/Agent/AgentProfileCard.js +29 -13
- package/dist/esm/components/Agent/AgentProfileCardCompiled.compiled.css +8 -0
- package/dist/esm/components/Agent/AgentProfileCardCompiled.js +248 -0
- package/dist/esm/components/Agent/AgentProfileCardResourced.js +8 -5
- package/dist/esm/components/Agent/AgentProfileCardTrigger.js +6 -2
- package/dist/esm/components/Agent/AgentProfileCardWrapper.compiled.css +1 -0
- package/dist/esm/components/Agent/AgentProfileCardWrapper.js +8 -7
- package/dist/esm/components/Agent/ConversationStarters.js +1 -3
- package/dist/esm/components/Agent/hooks/useAgentActions.js +61 -30
- package/dist/esm/components/Error/ErrorMessage.js +1 -2
- package/dist/esm/components/Team/TeamForbiddenErrorState.js +22 -7
- package/dist/esm/components/Team/TeamLoadingState.js +22 -7
- package/dist/esm/components/Team/TeamProfileCard.js +156 -61
- package/dist/esm/components/Team/TeamProfileCardTrigger.js +106 -36
- package/dist/esm/components/User/ProfileCardDetails.compiled.css +0 -1
- package/dist/esm/components/User/ProfileCardDetails.js +1 -4
- package/dist/esm/components/User/ReportingLinesDetails.js +4 -1
- package/dist/esm/components/User/ReportingLinesDetailsCompiled.compiled.css +11 -0
- package/dist/esm/components/User/ReportingLinesDetailsCompiled.js +102 -0
- package/dist/esm/components/common/ProfileCardWrapper.compiled.css +1 -0
- package/dist/esm/components/common/ProfileCardWrapper.js +8 -7
- package/dist/esm/components/team-profile-card/main.js +18 -9
- package/dist/esm/components/team-profile-card/team-actions/more-actions/index.js +1 -2
- package/dist/esm/components/team-profile-card/team-connections/main.js +36 -17
- package/dist/esm/styled/CoverImage.compiled.css +2 -0
- package/dist/esm/styled/CoverImage.js +4 -2
- package/dist/esm/styled/Error.compiled.css +0 -2
- package/dist/esm/styled/Error.js +6 -4
- package/dist/esm/util/analytics.js +57 -2
- package/dist/types/client/ProfileCardClient.d.ts +5 -5
- package/dist/types/client/RovoAgentCardClient.d.ts +5 -4
- package/dist/types/client/TeamProfileCardClient.d.ts +2 -1
- package/dist/types/client/errorUtils.d.ts +2 -1
- package/dist/types/client/types.d.ts +14 -2
- package/dist/types/components/Agent/Actions.d.ts +10 -1
- package/dist/types/components/Agent/ActionsCompiled.d.ts +14 -0
- package/dist/types/components/Agent/AgentProfileCard.d.ts +13 -3
- package/dist/types/components/Agent/AgentProfileCardCompiled.d.ts +4 -0
- package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +12 -1
- package/dist/types/components/Team/TeamForbiddenErrorState.d.ts +2 -1
- package/dist/types/components/Team/TeamLoadingState.d.ts +2 -1
- package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +7 -2
- package/dist/types/components/User/ReportingLinesDetails.d.ts +2 -2
- package/dist/types/components/User/ReportingLinesDetailsCompiled.d.ts +5 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/util/analytics.d.ts +46 -2
- package/dist/types-ts4.5/client/ProfileCardClient.d.ts +5 -5
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +5 -4
- package/dist/types-ts4.5/client/TeamProfileCardClient.d.ts +2 -1
- package/dist/types-ts4.5/client/errorUtils.d.ts +2 -1
- package/dist/types-ts4.5/client/types.d.ts +14 -2
- package/dist/types-ts4.5/components/Agent/Actions.d.ts +10 -1
- package/dist/types-ts4.5/components/Agent/ActionsCompiled.d.ts +14 -0
- package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +13 -3
- package/dist/types-ts4.5/components/Agent/AgentProfileCardCompiled.d.ts +4 -0
- package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +12 -1
- package/dist/types-ts4.5/components/Team/TeamForbiddenErrorState.d.ts +2 -1
- package/dist/types-ts4.5/components/Team/TeamLoadingState.d.ts +2 -1
- package/dist/types-ts4.5/components/Team/TeamProfileCardTrigger.d.ts +7 -2
- package/dist/types-ts4.5/components/User/ReportingLinesDetails.d.ts +2 -2
- package/dist/types-ts4.5/components/User/ReportingLinesDetailsCompiled.d.ts +5 -0
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/dist/types-ts4.5/util/analytics.d.ts +46 -2
- package/package.json +15 -9
|
@@ -9,10 +9,13 @@ import { defineMessages, useIntl } from 'react-intl-next';
|
|
|
9
9
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
10
10
|
import Button from '@atlaskit/button/new';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
|
|
12
13
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
13
14
|
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
14
15
|
import { AgentDropdownMenu, ChatPillIcon } from '@atlaskit/rovo-agent-components';
|
|
16
|
+
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
|
|
15
17
|
import { fireEvent } from '../../util/analytics';
|
|
18
|
+
import { AgentActions as AgentActionsCompiled } from './ActionsCompiled';
|
|
16
19
|
import { AgentDeleteConfirmationModal } from './AgentDeleteConfirmationModal';
|
|
17
20
|
var chatToAgentButtonContainer = xcss({
|
|
18
21
|
width: '100%'
|
|
@@ -43,7 +46,7 @@ var actionsWrapperStyles = xcss({
|
|
|
43
46
|
marginBlockStart: 'space.200',
|
|
44
47
|
color: 'color.text'
|
|
45
48
|
});
|
|
46
|
-
|
|
49
|
+
var _AgentActions = function _AgentActions(_ref) {
|
|
47
50
|
var onEditAgent = _ref.onEditAgent,
|
|
48
51
|
onDeleteAgent = _ref.onDeleteAgent,
|
|
49
52
|
onDuplicateAgent = _ref.onDuplicateAgent,
|
|
@@ -56,6 +59,8 @@ export var AgentActions = function AgentActions(_ref) {
|
|
|
56
59
|
formatMessage = _useIntl.formatMessage;
|
|
57
60
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
58
61
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
62
|
+
var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
|
|
63
|
+
fireEventNext = _useAnalyticsEventsNe.fireEvent;
|
|
59
64
|
var _useState = useState(false),
|
|
60
65
|
_useState2 = _slicedToArray(_useState, 2),
|
|
61
66
|
isDeleteModalOpen = _useState2[0],
|
|
@@ -87,17 +92,24 @@ export var AgentActions = function AgentActions(_ref) {
|
|
|
87
92
|
}, _callee);
|
|
88
93
|
})), [agent.id, resourceClient]);
|
|
89
94
|
var handleDeleteAgent = useCallback(function () {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
actionSubject: 'button',
|
|
93
|
-
actionSubjectId: 'deleteAgentButton',
|
|
94
|
-
attributes: {
|
|
95
|
+
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
96
|
+
fireEventNext('ui.button.clicked.deleteAgentButton', {
|
|
95
97
|
agentId: agent.id,
|
|
96
98
|
source: 'agentProfileCard'
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
fireEvent(createAnalyticsEvent, {
|
|
102
|
+
action: 'clicked',
|
|
103
|
+
actionSubject: 'button',
|
|
104
|
+
actionSubjectId: 'deleteAgentButton',
|
|
105
|
+
attributes: {
|
|
106
|
+
agentId: agent.id,
|
|
107
|
+
source: 'agentProfileCard'
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
99
111
|
setIsDeleteModalOpen(true);
|
|
100
|
-
}, [agent.id, createAnalyticsEvent]);
|
|
112
|
+
}, [agent.id, createAnalyticsEvent, fireEventNext]);
|
|
101
113
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Inline, {
|
|
102
114
|
space: "space.100",
|
|
103
115
|
xcss: actionsWrapperStyles
|
|
@@ -129,7 +141,8 @@ export var AgentActions = function AgentActions(_ref) {
|
|
|
129
141
|
loadPermissionsOnMount: true,
|
|
130
142
|
onViewAgentFullProfileClick: onViewFullProfileClick,
|
|
131
143
|
doesAgentHaveIdentityAccountId: !!agent.identity_account_id,
|
|
132
|
-
shouldTriggerStopPropagation: true
|
|
144
|
+
shouldTriggerStopPropagation: true,
|
|
145
|
+
dropdownMenuTestId: "agent-dropdown-menu"
|
|
133
146
|
})), /*#__PURE__*/React.createElement(AgentDeleteConfirmationModal, {
|
|
134
147
|
isOpen: isDeleteModalOpen,
|
|
135
148
|
onClose: function onClose() {
|
|
@@ -146,4 +159,5 @@ var messages = defineMessages({
|
|
|
146
159
|
defaultMessage: 'Chat to Agent',
|
|
147
160
|
description: 'Text for the "chat to agent" action to chat to the agent'
|
|
148
161
|
}
|
|
149
|
-
});
|
|
162
|
+
});
|
|
163
|
+
export var AgentActions = componentWithFG('profilecard_primitives_compiled', AgentActionsCompiled, _AgentActions);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
3
|
+
._18zrv77o{padding-inline:var(--ds-space-025,2px)}
|
|
4
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}._15a5nqa1{border-top-style:solid}
|
|
5
|
+
._19bvpxbi{padding-left:var(--ds-space-200,1pc)}
|
|
6
|
+
._1bah1h6o{justify-content:center}
|
|
7
|
+
._1bsb1osq{width:100%}
|
|
8
|
+
._1e0c1txw{display:flex}
|
|
9
|
+
._1nmz1hna{word-break:break-word}
|
|
10
|
+
._1pfhpxbi{margin-block-start:var(--ds-space-200,1pc)}
|
|
11
|
+
._1ul9gktf{min-width:20px}
|
|
12
|
+
._4t3igktf{height:20px}
|
|
13
|
+
._ca0qpxbi{padding-top:var(--ds-space-200,1pc)}
|
|
14
|
+
._k48p1wq8{font-weight:var(--ds-font-weight-medium,500)}
|
|
15
|
+
._n3tdpxbi{padding-bottom:var(--ds-space-200,1pc)}
|
|
16
|
+
._o5721jtm{white-space:pre-wrap}
|
|
17
|
+
._syaz1fxt{color:var(--ds-text,#172b4d)}
|
|
18
|
+
._u5f3pxbi{padding-right:var(--ds-space-200,1pc)}
|
|
19
|
+
._y3gn1e5h{text-align:left}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* ActionsCompiled.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
import "./ActionsCompiled.compiled.css";
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
import React, { useCallback, useState } from 'react';
|
|
11
|
+
import { defineMessages, useIntl } from 'react-intl-next';
|
|
12
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
|
+
import Button from '@atlaskit/button/new';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
|
+
import { Box, Inline } from '@atlaskit/primitives/compiled';
|
|
16
|
+
import { AgentDropdownMenu, ChatPillIcon } from '@atlaskit/rovo-agent-components';
|
|
17
|
+
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
|
|
18
|
+
import { fireEvent } from '../../util/analytics';
|
|
19
|
+
import { AgentDeleteConfirmationModal } from './AgentDeleteConfirmationModal';
|
|
20
|
+
var styles = {
|
|
21
|
+
chatToAgentButtonContainer: "_1bsb1osq",
|
|
22
|
+
chatToAgentButtonWrapper: "_1e0c1txw _1bah1h6o _k48p1wq8 _4t3igktf",
|
|
23
|
+
chatPillButtonInlineStyles: "_18zrv77o",
|
|
24
|
+
chatPillTextStyles: "_1nmz1hna _y3gn1e5h _o5721jtm",
|
|
25
|
+
chatPillIconWrapper: "_1ul9gktf _4t3igktf",
|
|
26
|
+
actionsWrapperStyles: "_189ee4h9 _1h6dmuej _15a5nqa1 _ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi _1pfhpxbi _syaz1fxt"
|
|
27
|
+
};
|
|
28
|
+
export var AgentActions = function AgentActions(_ref) {
|
|
29
|
+
var onEditAgent = _ref.onEditAgent,
|
|
30
|
+
onDeleteAgent = _ref.onDeleteAgent,
|
|
31
|
+
onDuplicateAgent = _ref.onDuplicateAgent,
|
|
32
|
+
onCopyAgent = _ref.onCopyAgent,
|
|
33
|
+
onChatClick = _ref.onChatClick,
|
|
34
|
+
onViewFullProfileClick = _ref.onViewFullProfileClick,
|
|
35
|
+
agent = _ref.agent,
|
|
36
|
+
resourceClient = _ref.resourceClient;
|
|
37
|
+
var _useIntl = useIntl(),
|
|
38
|
+
formatMessage = _useIntl.formatMessage;
|
|
39
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
40
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
41
|
+
var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
|
|
42
|
+
fireEventNext = _useAnalyticsEventsNe.fireEvent;
|
|
43
|
+
var _useState = useState(false),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
isDeleteModalOpen = _useState2[0],
|
|
46
|
+
setIsDeleteModalOpen = _useState2[1];
|
|
47
|
+
var isForgeAgent = agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY';
|
|
48
|
+
var loadAgentPermissions = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
49
|
+
var _yield$resourceClient, _yield$resourceClient2, AGENT_CREATE, AGENT_UPDATE, AGENT_DEACTIVATE;
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
_context.next = 2;
|
|
54
|
+
return resourceClient.getRovoAgentPermissions(agent.id);
|
|
55
|
+
case 2:
|
|
56
|
+
_yield$resourceClient = _context.sent;
|
|
57
|
+
_yield$resourceClient2 = _yield$resourceClient.permissions;
|
|
58
|
+
AGENT_CREATE = _yield$resourceClient2.AGENT_CREATE;
|
|
59
|
+
AGENT_UPDATE = _yield$resourceClient2.AGENT_UPDATE;
|
|
60
|
+
AGENT_DEACTIVATE = _yield$resourceClient2.AGENT_DEACTIVATE;
|
|
61
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, fg('agent_studio_fe_permissions_settings_m1') && {
|
|
62
|
+
isCreateEnabled: AGENT_CREATE.permitted
|
|
63
|
+
}), {}, {
|
|
64
|
+
isEditEnabled: AGENT_UPDATE.permitted,
|
|
65
|
+
isDeleteEnabled: AGENT_DEACTIVATE.permitted
|
|
66
|
+
}));
|
|
67
|
+
case 8:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
})), [agent.id, resourceClient]);
|
|
73
|
+
var handleDeleteAgent = useCallback(function () {
|
|
74
|
+
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
75
|
+
fireEventNext('ui.button.clicked.deleteAgentButton', {
|
|
76
|
+
agentId: agent.id,
|
|
77
|
+
source: 'agentProfileCard'
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
fireEvent(createAnalyticsEvent, {
|
|
81
|
+
action: 'clicked',
|
|
82
|
+
actionSubject: 'button',
|
|
83
|
+
actionSubjectId: 'deleteAgentButton',
|
|
84
|
+
attributes: {
|
|
85
|
+
agentId: agent.id,
|
|
86
|
+
source: 'agentProfileCard'
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
setIsDeleteModalOpen(true);
|
|
91
|
+
}, [agent.id, createAnalyticsEvent, fireEventNext]);
|
|
92
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Inline, {
|
|
93
|
+
space: "space.100",
|
|
94
|
+
xcss: styles.actionsWrapperStyles
|
|
95
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
96
|
+
xcss: styles.chatToAgentButtonContainer
|
|
97
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
98
|
+
shouldFitContainer: true,
|
|
99
|
+
onClick: function onClick(e) {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
onChatClick(e);
|
|
102
|
+
}
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
104
|
+
xcss: styles.chatToAgentButtonWrapper
|
|
105
|
+
}, /*#__PURE__*/React.createElement(Inline, {
|
|
106
|
+
space: "space.050",
|
|
107
|
+
xcss: styles.chatPillButtonInlineStyles,
|
|
108
|
+
alignBlock: "center"
|
|
109
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
110
|
+
xcss: styles.chatPillIconWrapper
|
|
111
|
+
}, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
|
|
112
|
+
xcss: styles.chatPillTextStyles
|
|
113
|
+
}, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/React.createElement(AgentDropdownMenu, {
|
|
114
|
+
agentId: agent.id,
|
|
115
|
+
onDeleteAgent: handleDeleteAgent,
|
|
116
|
+
onEditAgent: onEditAgent,
|
|
117
|
+
onDuplicateAgent: onDuplicateAgent,
|
|
118
|
+
onCopyAgent: onCopyAgent,
|
|
119
|
+
isForgeAgent: isForgeAgent,
|
|
120
|
+
loadAgentPermissions: loadAgentPermissions,
|
|
121
|
+
loadPermissionsOnMount: true,
|
|
122
|
+
onViewAgentFullProfileClick: onViewFullProfileClick,
|
|
123
|
+
doesAgentHaveIdentityAccountId: !!agent.identity_account_id,
|
|
124
|
+
shouldTriggerStopPropagation: true
|
|
125
|
+
})), /*#__PURE__*/React.createElement(AgentDeleteConfirmationModal, {
|
|
126
|
+
isOpen: isDeleteModalOpen,
|
|
127
|
+
onClose: function onClose() {
|
|
128
|
+
setIsDeleteModalOpen(false);
|
|
129
|
+
},
|
|
130
|
+
onSubmit: onDeleteAgent,
|
|
131
|
+
agentId: agent.id,
|
|
132
|
+
agentName: agent.name
|
|
133
|
+
}));
|
|
134
|
+
};
|
|
135
|
+
var messages = defineMessages({
|
|
136
|
+
actionChatToAgent: {
|
|
137
|
+
id: 'ptc-directory.agent-profile.action.dropdown.chat-to-agent.nonfinal',
|
|
138
|
+
defaultMessage: 'Chat to Agent',
|
|
139
|
+
description: 'Text for the "chat to agent" action to chat to the agent'
|
|
140
|
+
}
|
|
141
|
+
});
|
|
@@ -4,8 +4,7 @@ import React, { useCallback } from 'react';
|
|
|
4
4
|
import { defineMessages, useIntl } from 'react-intl-next';
|
|
5
5
|
import Button from '@atlaskit/button/new';
|
|
6
6
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
7
|
-
|
|
8
|
-
import { Text } from '@atlaskit/primitives';
|
|
7
|
+
import { Text } from '@atlaskit/primitives/compiled';
|
|
9
8
|
export var AgentDeleteConfirmationModal = function AgentDeleteConfirmationModal(_ref) {
|
|
10
9
|
var onClose = _ref.onClose,
|
|
11
10
|
agentName = _ref.agentName,
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
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
|
+
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; }
|
|
3
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
7
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
5
8
|
import { useIntl } from 'react-intl-next';
|
|
6
9
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
|
|
7
12
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
8
13
|
import { Box, Stack, xcss } from '@atlaskit/primitives';
|
|
9
14
|
import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
|
|
10
|
-
import {
|
|
15
|
+
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
|
|
16
|
+
import { fireEvent, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
|
|
17
|
+
import { getPageTime } from '../../util/performance';
|
|
11
18
|
import { LoadingState } from '../common/LoadingState';
|
|
12
19
|
import { ErrorMessage } from '../Error';
|
|
13
20
|
import { AgentActions } from './Actions';
|
|
21
|
+
import { default as AgentProfileCardCompiled } from './AgentProfileCardCompiled';
|
|
14
22
|
import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
|
|
15
23
|
import { ConversationStarters } from './ConversationStarters';
|
|
16
24
|
import { useAgentUrlActions } from './hooks/useAgentActions';
|
|
@@ -61,6 +69,8 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
61
69
|
setStarCount = _useState4[1];
|
|
62
70
|
var _useIntl = useIntl(),
|
|
63
71
|
formatMessage = _useIntl.formatMessage;
|
|
72
|
+
var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
|
|
73
|
+
fireEventNext = _useAnalyticsEventsNe.fireEvent;
|
|
64
74
|
var userDefinedConversationStarters = agent === null || agent === void 0 || (_agent$user_defined_c = agent.user_defined_conversation_starters) === null || _agent$user_defined_c === void 0 ? void 0 : _agent$user_defined_c.map(function (starter) {
|
|
65
75
|
return {
|
|
66
76
|
message: starter,
|
|
@@ -88,7 +98,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
88
98
|
}
|
|
89
99
|
_context.prev = 1;
|
|
90
100
|
_context.next = 4;
|
|
91
|
-
return resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics);
|
|
101
|
+
return resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics, fireEventNext);
|
|
92
102
|
case 4:
|
|
93
103
|
if (isStarred) {
|
|
94
104
|
setStarCount(starCount ? starCount - 1 : 0);
|
|
@@ -106,7 +116,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
106
116
|
return _context.stop();
|
|
107
117
|
}
|
|
108
118
|
}, _callee, null, [[1, 8]]);
|
|
109
|
-
})), [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, isStarred, resourceClient, starCount]);
|
|
119
|
+
})), [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, fireEventNext, isStarred, resourceClient, starCount]);
|
|
110
120
|
var handleOnDelete = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
111
121
|
var _onDeleteAgent, restore;
|
|
112
122
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -120,7 +130,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
120
130
|
_onDeleteAgent = onDeleteAgent(agent.id), restore = _onDeleteAgent.restore;
|
|
121
131
|
_context2.prev = 2;
|
|
122
132
|
_context2.next = 5;
|
|
123
|
-
return resourceClient.deleteAgent(agent.id, fireAnalytics);
|
|
133
|
+
return resourceClient.deleteAgent(agent.id, fireAnalytics, fireEventNext);
|
|
124
134
|
case 5:
|
|
125
135
|
addFlag === null || addFlag === void 0 || addFlag({
|
|
126
136
|
title: formatMessage(messages.agentDeletedSuccessFlagTitle),
|
|
@@ -148,25 +158,30 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
148
158
|
return _context2.stop();
|
|
149
159
|
}
|
|
150
160
|
}, _callee2, null, [[2, 8]]);
|
|
151
|
-
})), [addFlag, agent, formatMessage, onDeleteAgent, resourceClient, fireAnalytics]);
|
|
161
|
+
})), [addFlag, agent, formatMessage, onDeleteAgent, resourceClient, fireAnalytics, fireEventNext]);
|
|
152
162
|
useEffect(function () {
|
|
153
163
|
if (!isLoading && agent) {
|
|
154
|
-
|
|
164
|
+
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
165
|
+
fireEventNext("ui.rovoAgentProfilecard.rendered.content", _objectSpread(_objectSpread({}, PACKAGE_META_DATA), {}, {
|
|
166
|
+
firedAt: Math.round(getPageTime())
|
|
167
|
+
}));
|
|
168
|
+
} else {
|
|
169
|
+
fireAnalytics(profileCardRendered('agent', 'content'));
|
|
170
|
+
}
|
|
155
171
|
}
|
|
156
|
-
}, [agent, fireAnalytics, isLoading]);
|
|
172
|
+
}, [agent, fireAnalytics, fireEventNext, isLoading]);
|
|
157
173
|
if (isLoading) {
|
|
158
174
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(LoadingState, {
|
|
159
175
|
profileType: "agent",
|
|
160
|
-
fireAnalytics: fireAnalytics
|
|
176
|
+
fireAnalytics: fireAnalytics,
|
|
177
|
+
fireAnalyticsNext: fireEventNext
|
|
161
178
|
}));
|
|
162
179
|
}
|
|
163
180
|
if (hasError || !agent) {
|
|
164
181
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
165
182
|
errorType: errorType,
|
|
166
|
-
fireAnalytics: fireAnalytics
|
|
167
|
-
|
|
168
|
-
,
|
|
169
|
-
fireAnalyticsNext: function fireAnalyticsNext() {}
|
|
183
|
+
fireAnalytics: fireAnalytics,
|
|
184
|
+
fireAnalyticsNext: fireEventNext
|
|
170
185
|
}));
|
|
171
186
|
}
|
|
172
187
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -239,4 +254,5 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
239
254
|
}
|
|
240
255
|
})));
|
|
241
256
|
};
|
|
242
|
-
|
|
257
|
+
var AgentProfileCardExport = componentWithFG('profilecard_primitives_compiled', AgentProfileCardCompiled, AgentProfileCard);
|
|
258
|
+
export default AgentProfileCardExport;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko1mok{border-radius:var(--ds-radius-large,8px)}
|
|
3
|
+
._18zrpxbi{padding-inline:var(--ds-space-200,1pc)}._154i1ejb{top:var(--ds-space-300,24px)}
|
|
4
|
+
._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
|
|
5
|
+
._1ltvpxbi{left:var(--ds-space-200,1pc)}
|
|
6
|
+
._1q51xy5q{padding-block-start:var(--ds-space-400,2pc)}
|
|
7
|
+
._kqswh2mm{position:relative}
|
|
8
|
+
._kqswstnw{position:absolute}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/* AgentProfileCardCompiled.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
import "./AgentProfileCardCompiled.compiled.css";
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
11
|
+
import { useIntl } from 'react-intl-next';
|
|
12
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { Box, Stack } from '@atlaskit/primitives/compiled';
|
|
15
|
+
import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
|
|
16
|
+
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
|
|
17
|
+
import { fireEvent, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
|
|
18
|
+
import { getPageTime } from '../../util/performance';
|
|
19
|
+
import { LoadingState } from '../common/LoadingState';
|
|
20
|
+
import { ErrorMessage } from '../Error';
|
|
21
|
+
import { AgentActions } from './Actions';
|
|
22
|
+
import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
|
|
23
|
+
import { ConversationStarters } from './ConversationStarters';
|
|
24
|
+
import { useAgentUrlActions } from './hooks/useAgentActions';
|
|
25
|
+
import { messages } from './messages';
|
|
26
|
+
var styles = {
|
|
27
|
+
detailWrapper: "_18zrpxbi _1q51xy5q",
|
|
28
|
+
avatarStyles: "_kqswstnw _154i1ejb _1ltvpxbi",
|
|
29
|
+
cardContainerStyles: "_2rko1mok _16qs1cd0 _kqswh2mm"
|
|
30
|
+
};
|
|
31
|
+
var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
32
|
+
var _agent$user_defined_c, _agent$external_confi, _agent$external_confi2, _agent$creatorInfo, _agent$creatorInfo2, _agent$creatorInfo3, _agent$creatorInfo4;
|
|
33
|
+
var agent = _ref.agent,
|
|
34
|
+
isLoading = _ref.isLoading,
|
|
35
|
+
cloudId = _ref.cloudId,
|
|
36
|
+
onChatClick = _ref.onChatClick,
|
|
37
|
+
hasError = _ref.hasError,
|
|
38
|
+
errorType = _ref.errorType,
|
|
39
|
+
onConversationStartersClick = _ref.onConversationStartersClick,
|
|
40
|
+
resourceClient = _ref.resourceClient,
|
|
41
|
+
addFlag = _ref.addFlag,
|
|
42
|
+
onDeleteAgent = _ref.onDeleteAgent;
|
|
43
|
+
var _useAgentUrlActions = useAgentUrlActions({
|
|
44
|
+
cloudId: cloudId || '',
|
|
45
|
+
source: 'agentProfileCard'
|
|
46
|
+
}),
|
|
47
|
+
_onEditAgent = _useAgentUrlActions.onEditAgent,
|
|
48
|
+
_onCopyAgent = _useAgentUrlActions.onCopyAgent,
|
|
49
|
+
_onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
|
|
50
|
+
onOpenChatFullScreen = _useAgentUrlActions.onOpenChat,
|
|
51
|
+
onConversationStarter = _useAgentUrlActions.onConversationStarter,
|
|
52
|
+
onViewFullProfile = _useAgentUrlActions.onViewFullProfile;
|
|
53
|
+
var _useState = useState(false),
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
isStarred = _useState2[0],
|
|
56
|
+
setIsStarred = _useState2[1];
|
|
57
|
+
var _useState3 = useState(),
|
|
58
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
+
starCount = _useState4[0],
|
|
60
|
+
setStarCount = _useState4[1];
|
|
61
|
+
var _useIntl = useIntl(),
|
|
62
|
+
formatMessage = _useIntl.formatMessage;
|
|
63
|
+
var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
|
|
64
|
+
fireAnalyticsNext = _useAnalyticsEventsNe.fireEvent;
|
|
65
|
+
var userDefinedConversationStarters = agent === null || agent === void 0 || (_agent$user_defined_c = agent.user_defined_conversation_starters) === null || _agent$user_defined_c === void 0 ? void 0 : _agent$user_defined_c.map(function (starter) {
|
|
66
|
+
return {
|
|
67
|
+
message: starter,
|
|
68
|
+
type: 'user-defined'
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
setIsStarred(!!(agent !== null && agent !== void 0 && agent.favourite));
|
|
73
|
+
setStarCount(agent === null || agent === void 0 ? void 0 : agent.favourite_count);
|
|
74
|
+
}, [agent === null || agent === void 0 ? void 0 : agent.favourite, agent === null || agent === void 0 ? void 0 : agent.favourite_count]);
|
|
75
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
76
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
77
|
+
var fireAnalytics = useCallback(function (payload) {
|
|
78
|
+
if (createAnalyticsEvent) {
|
|
79
|
+
fireEvent(createAnalyticsEvent, payload);
|
|
80
|
+
}
|
|
81
|
+
}, [createAnalyticsEvent]);
|
|
82
|
+
var handleSetFavourite = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
83
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
|
85
|
+
case 0:
|
|
86
|
+
if (!(agent !== null && agent !== void 0 && agent.id)) {
|
|
87
|
+
_context.next = 10;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
_context.prev = 1;
|
|
91
|
+
_context.next = 4;
|
|
92
|
+
return resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics, fireAnalyticsNext);
|
|
93
|
+
case 4:
|
|
94
|
+
if (isStarred) {
|
|
95
|
+
setStarCount(starCount ? starCount - 1 : 0);
|
|
96
|
+
} else {
|
|
97
|
+
setStarCount((starCount || 0) + 1);
|
|
98
|
+
}
|
|
99
|
+
setIsStarred(!isStarred);
|
|
100
|
+
_context.next = 10;
|
|
101
|
+
break;
|
|
102
|
+
case 8:
|
|
103
|
+
_context.prev = 8;
|
|
104
|
+
_context.t0 = _context["catch"](1);
|
|
105
|
+
case 10:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context.stop();
|
|
108
|
+
}
|
|
109
|
+
}, _callee, null, [[1, 8]]);
|
|
110
|
+
})), [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, fireAnalyticsNext, isStarred, resourceClient, starCount]);
|
|
111
|
+
var handleOnDelete = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
112
|
+
var _onDeleteAgent, restore;
|
|
113
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
114
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
if (!(agent && onDeleteAgent)) {
|
|
117
|
+
_context2.next = 12;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
// Optimistically remove from cache
|
|
121
|
+
_onDeleteAgent = onDeleteAgent(agent.id), restore = _onDeleteAgent.restore;
|
|
122
|
+
_context2.prev = 2;
|
|
123
|
+
_context2.next = 5;
|
|
124
|
+
return resourceClient.deleteAgent(agent.id, fireAnalytics, fireAnalyticsNext);
|
|
125
|
+
case 5:
|
|
126
|
+
addFlag === null || addFlag === void 0 || addFlag({
|
|
127
|
+
title: formatMessage(messages.agentDeletedSuccessFlagTitle),
|
|
128
|
+
description: formatMessage(messages.agentDeletedSuccessFlagDescription, {
|
|
129
|
+
agentName: agent.name
|
|
130
|
+
}),
|
|
131
|
+
type: 'success',
|
|
132
|
+
id: 'ptc-directory.agent-profile.delete-agent-success'
|
|
133
|
+
});
|
|
134
|
+
_context2.next = 12;
|
|
135
|
+
break;
|
|
136
|
+
case 8:
|
|
137
|
+
_context2.prev = 8;
|
|
138
|
+
_context2.t0 = _context2["catch"](2);
|
|
139
|
+
// Restore agent to cache on error
|
|
140
|
+
restore();
|
|
141
|
+
addFlag === null || addFlag === void 0 || addFlag({
|
|
142
|
+
title: formatMessage(messages.agentDeletedErrorFlagTitle),
|
|
143
|
+
description: formatMessage(messages.agentDeletedErrorFlagDescription),
|
|
144
|
+
type: 'error',
|
|
145
|
+
id: 'ptc-directory.agent-profile.delete-agent-error'
|
|
146
|
+
});
|
|
147
|
+
case 12:
|
|
148
|
+
case "end":
|
|
149
|
+
return _context2.stop();
|
|
150
|
+
}
|
|
151
|
+
}, _callee2, null, [[2, 8]]);
|
|
152
|
+
})), [addFlag, agent, formatMessage, onDeleteAgent, resourceClient, fireAnalytics, fireAnalyticsNext]);
|
|
153
|
+
useEffect(function () {
|
|
154
|
+
if (!isLoading && agent) {
|
|
155
|
+
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
156
|
+
fireAnalyticsNext("ui.rovoAgentProfilecard.rendered.content", _objectSpread(_objectSpread({}, PACKAGE_META_DATA), {}, {
|
|
157
|
+
firedAt: Math.round(getPageTime())
|
|
158
|
+
}));
|
|
159
|
+
} else {
|
|
160
|
+
fireAnalytics(profileCardRendered('agent', 'content'));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, [agent, fireAnalytics, isLoading, fireAnalyticsNext]);
|
|
164
|
+
if (isLoading) {
|
|
165
|
+
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(LoadingState, {
|
|
166
|
+
profileType: "agent",
|
|
167
|
+
fireAnalytics: fireAnalytics,
|
|
168
|
+
fireAnalyticsNext: fireAnalyticsNext
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
if (hasError || !agent) {
|
|
172
|
+
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
173
|
+
fireAnalyticsNext: fireAnalyticsNext,
|
|
174
|
+
errorType: errorType,
|
|
175
|
+
fireAnalytics: fireAnalytics
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
|
|
179
|
+
xcss: styles.cardContainerStyles
|
|
180
|
+
}, /*#__PURE__*/React.createElement(AgentBanner, {
|
|
181
|
+
agentId: agent.id,
|
|
182
|
+
agentNamedId: (_agent$external_confi = agent.external_config_reference) !== null && _agent$external_confi !== void 0 ? _agent$external_confi : agent.named_id,
|
|
183
|
+
height: 96,
|
|
184
|
+
agentIdentityAccountId: agent.identity_account_id
|
|
185
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
186
|
+
xcss: styles.avatarStyles
|
|
187
|
+
}, /*#__PURE__*/React.createElement(AgentAvatar, {
|
|
188
|
+
agentId: agent.id,
|
|
189
|
+
agentNamedId: (_agent$external_confi2 = agent.external_config_reference) !== null && _agent$external_confi2 !== void 0 ? _agent$external_confi2 : agent.named_id,
|
|
190
|
+
agentIdentityAccountId: agent.identity_account_id,
|
|
191
|
+
size: "xlarge",
|
|
192
|
+
isForgeAgent: agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY',
|
|
193
|
+
forgeAgentIconUrl: agent.icon
|
|
194
|
+
})), /*#__PURE__*/React.createElement(Stack, {
|
|
195
|
+
space: "space.100",
|
|
196
|
+
xcss: styles.detailWrapper
|
|
197
|
+
}, /*#__PURE__*/React.createElement(AgentProfileInfo, {
|
|
198
|
+
agentName: agent.name,
|
|
199
|
+
isStarred: isStarred,
|
|
200
|
+
onStarToggle: handleSetFavourite,
|
|
201
|
+
isHidden: agent.visibility === 'PRIVATE',
|
|
202
|
+
creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/React.createElement(AgentProfileCreator, {
|
|
203
|
+
creator: {
|
|
204
|
+
type: (_agent$creatorInfo2 = agent.creatorInfo) === null || _agent$creatorInfo2 === void 0 ? void 0 : _agent$creatorInfo2.type,
|
|
205
|
+
name: ((_agent$creatorInfo3 = agent.creatorInfo) === null || _agent$creatorInfo3 === void 0 ? void 0 : _agent$creatorInfo3.name) || '',
|
|
206
|
+
profileLink: ((_agent$creatorInfo4 = agent.creatorInfo) === null || _agent$creatorInfo4 === void 0 ? void 0 : _agent$creatorInfo4.profileLink) || ''
|
|
207
|
+
},
|
|
208
|
+
isLoading: false,
|
|
209
|
+
onCreatorLinkClick: function onCreatorLinkClick() {}
|
|
210
|
+
}),
|
|
211
|
+
starCountRender: /*#__PURE__*/React.createElement(AgentStarCount, {
|
|
212
|
+
starCount: starCount,
|
|
213
|
+
isLoading: false
|
|
214
|
+
}),
|
|
215
|
+
agentDescription: agent.description
|
|
216
|
+
}), /*#__PURE__*/React.createElement(ConversationStarters, {
|
|
217
|
+
isAgentDefault: agent.is_default,
|
|
218
|
+
userDefinedConversationStarters: userDefinedConversationStarters,
|
|
219
|
+
onConversationStarterClick: function onConversationStarterClick(conversationStarter) {
|
|
220
|
+
onConversationStartersClick ? onConversationStartersClick(conversationStarter) : onConversationStarter({
|
|
221
|
+
agentId: agent.id,
|
|
222
|
+
prompt: conversationStarter.message
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
})), /*#__PURE__*/React.createElement(AgentActions, {
|
|
226
|
+
agent: agent,
|
|
227
|
+
onEditAgent: function onEditAgent() {
|
|
228
|
+
return _onEditAgent(agent.id);
|
|
229
|
+
},
|
|
230
|
+
onCopyAgent: function onCopyAgent() {
|
|
231
|
+
return _onCopyAgent(agent.id);
|
|
232
|
+
},
|
|
233
|
+
onDuplicateAgent: function onDuplicateAgent() {
|
|
234
|
+
return _onDuplicateAgent(agent.id);
|
|
235
|
+
},
|
|
236
|
+
onDeleteAgent: handleOnDelete,
|
|
237
|
+
onChatClick: onChatClick ? function (event) {
|
|
238
|
+
return onChatClick(event);
|
|
239
|
+
} : function () {
|
|
240
|
+
return onOpenChatFullScreen(agent.id, agent.name);
|
|
241
|
+
},
|
|
242
|
+
resourceClient: resourceClient,
|
|
243
|
+
onViewFullProfileClick: function onViewFullProfileClick() {
|
|
244
|
+
return onViewFullProfile(agent.id);
|
|
245
|
+
}
|
|
246
|
+
})));
|
|
247
|
+
};
|
|
248
|
+
export default AgentProfileCard;
|