@atlaskit/profilecard 24.13.7 → 24.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/__tests__/vr-tests/__snapshots__/user-profilecard/error-state--default.png +0 -0
  3. package/__tests__/vr-tests/agent-profilecard.vr.tsx +7 -1
  4. package/__tests__/vr-tests/user-profilecard.vr.tsx +42 -6
  5. package/afm-cc/tsconfig.json +6 -0
  6. package/afm-dev-agents/tsconfig.json +6 -0
  7. package/afm-jira/tsconfig.json +6 -0
  8. package/afm-passionfruit/tsconfig.json +6 -0
  9. package/afm-post-office/tsconfig.json +6 -0
  10. package/afm-rovo-extension/tsconfig.json +6 -0
  11. package/afm-townsquare/tsconfig.json +6 -0
  12. package/dist/cjs/client/ProfileCardClient.js +2 -2
  13. package/dist/cjs/client/UserProfileCardClient.js +45 -11
  14. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  15. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  16. package/dist/cjs/components/Agent/Actions.js +5 -2
  17. package/dist/cjs/components/Agent/ActionsCompiled.compiled.css +19 -0
  18. package/dist/cjs/components/Agent/ActionsCompiled.js +140 -0
  19. package/dist/cjs/components/Agent/AgentDeleteConfirmationModal.js +2 -4
  20. package/dist/cjs/components/Agent/AgentProfileCard.js +8 -1
  21. package/dist/cjs/components/Agent/AgentProfileCardCompiled.compiled.css +8 -0
  22. package/dist/cjs/components/Agent/AgentProfileCardCompiled.js +242 -0
  23. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +2 -1
  24. package/dist/cjs/components/Agent/AgentProfileCardWrapper.compiled.css +1 -0
  25. package/dist/cjs/components/Agent/AgentProfileCardWrapper.js +9 -8
  26. package/dist/cjs/components/Agent/ConversationStarters.js +2 -4
  27. package/dist/cjs/components/Error/ErrorMessage.js +20 -9
  28. package/dist/cjs/components/Team/TeamProfileCardTrigger.js +3 -3
  29. package/dist/cjs/components/User/OverflowProfileCardButtons.js +22 -7
  30. package/dist/cjs/components/User/ProfileCard.js +80 -28
  31. package/dist/cjs/components/User/ProfileCardDetails.compiled.css +0 -1
  32. package/dist/cjs/components/User/ProfileCardDetails.js +4 -5
  33. package/dist/cjs/components/User/ProfileCardResourced.js +40 -16
  34. package/dist/cjs/components/User/ProfileCardTrigger.js +52 -12
  35. package/dist/cjs/components/User/ReportingLinesDetails.js +40 -12
  36. package/dist/cjs/components/User/ReportingLinesDetailsCompiled.compiled.css +11 -0
  37. package/dist/cjs/components/User/ReportingLinesDetailsCompiled.js +109 -0
  38. package/dist/cjs/components/User/UserLoadingState.js +15 -3
  39. package/dist/cjs/components/common/LoadingState.js +17 -3
  40. package/dist/cjs/components/common/ProfileCardTrigger.js +29 -7
  41. package/dist/cjs/components/common/ProfileCardWrapper.compiled.css +1 -0
  42. package/dist/cjs/components/common/ProfileCardWrapper.js +12 -9
  43. package/dist/cjs/components/team-profile-card/team-actions/more-actions/index.js +2 -4
  44. package/dist/cjs/styled/CoverImage.compiled.css +2 -0
  45. package/dist/cjs/styled/CoverImage.js +4 -2
  46. package/dist/cjs/styled/Error.compiled.css +0 -2
  47. package/dist/cjs/styled/Error.js +5 -3
  48. package/dist/cjs/util/analytics.js +7 -3
  49. package/dist/es2019/client/ProfileCardClient.js +2 -2
  50. package/dist/es2019/client/UserProfileCardClient.js +50 -13
  51. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  52. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  53. package/dist/es2019/components/Agent/Actions.js +5 -2
  54. package/dist/es2019/components/Agent/ActionsCompiled.compiled.css +19 -0
  55. package/dist/es2019/components/Agent/ActionsCompiled.js +116 -0
  56. package/dist/es2019/components/Agent/AgentDeleteConfirmationModal.js +1 -2
  57. package/dist/es2019/components/Agent/AgentProfileCard.js +8 -1
  58. package/dist/es2019/components/Agent/AgentProfileCardCompiled.compiled.css +8 -0
  59. package/dist/es2019/components/Agent/AgentProfileCardCompiled.js +186 -0
  60. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +2 -1
  61. package/dist/es2019/components/Agent/AgentProfileCardWrapper.compiled.css +1 -0
  62. package/dist/es2019/components/Agent/AgentProfileCardWrapper.js +8 -7
  63. package/dist/es2019/components/Agent/ConversationStarters.js +1 -3
  64. package/dist/es2019/components/Error/ErrorMessage.js +18 -8
  65. package/dist/es2019/components/Team/TeamProfileCardTrigger.js +1 -2
  66. package/dist/es2019/components/User/OverflowProfileCardButtons.js +18 -7
  67. package/dist/es2019/components/User/ProfileCard.js +72 -25
  68. package/dist/es2019/components/User/ProfileCardDetails.compiled.css +0 -1
  69. package/dist/es2019/components/User/ProfileCardDetails.js +3 -5
  70. package/dist/es2019/components/User/ProfileCardResourced.js +25 -4
  71. package/dist/es2019/components/User/ProfileCardTrigger.js +54 -13
  72. package/dist/es2019/components/User/ReportingLinesDetails.js +34 -10
  73. package/dist/es2019/components/User/ReportingLinesDetailsCompiled.compiled.css +11 -0
  74. package/dist/es2019/components/User/ReportingLinesDetailsCompiled.js +96 -0
  75. package/dist/es2019/components/User/UserLoadingState.js +14 -4
  76. package/dist/es2019/components/common/LoadingState.js +16 -4
  77. package/dist/es2019/components/common/ProfileCardTrigger.js +26 -7
  78. package/dist/es2019/components/common/ProfileCardWrapper.compiled.css +1 -0
  79. package/dist/es2019/components/common/ProfileCardWrapper.js +11 -8
  80. package/dist/es2019/components/team-profile-card/team-actions/more-actions/index.js +1 -2
  81. package/dist/es2019/styled/CoverImage.compiled.css +2 -0
  82. package/dist/es2019/styled/CoverImage.js +4 -2
  83. package/dist/es2019/styled/Error.compiled.css +0 -2
  84. package/dist/es2019/styled/Error.js +6 -4
  85. package/dist/es2019/util/analytics.js +6 -2
  86. package/dist/esm/client/ProfileCardClient.js +2 -2
  87. package/dist/esm/client/UserProfileCardClient.js +46 -12
  88. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  89. package/dist/esm/client/getTeamFromAGG.js +1 -1
  90. package/dist/esm/components/Agent/Actions.js +5 -2
  91. package/dist/esm/components/Agent/ActionsCompiled.compiled.css +19 -0
  92. package/dist/esm/components/Agent/ActionsCompiled.js +131 -0
  93. package/dist/esm/components/Agent/AgentDeleteConfirmationModal.js +1 -2
  94. package/dist/esm/components/Agent/AgentProfileCard.js +8 -1
  95. package/dist/esm/components/Agent/AgentProfileCardCompiled.compiled.css +8 -0
  96. package/dist/esm/components/Agent/AgentProfileCardCompiled.js +233 -0
  97. package/dist/esm/components/Agent/AgentProfileCardResourced.js +2 -1
  98. package/dist/esm/components/Agent/AgentProfileCardWrapper.compiled.css +1 -0
  99. package/dist/esm/components/Agent/AgentProfileCardWrapper.js +8 -7
  100. package/dist/esm/components/Agent/ConversationStarters.js +1 -3
  101. package/dist/esm/components/Error/ErrorMessage.js +20 -8
  102. package/dist/esm/components/Team/TeamProfileCardTrigger.js +1 -2
  103. package/dist/esm/components/User/OverflowProfileCardButtons.js +23 -8
  104. package/dist/esm/components/User/ProfileCard.js +80 -28
  105. package/dist/esm/components/User/ProfileCardDetails.compiled.css +0 -1
  106. package/dist/esm/components/User/ProfileCardDetails.js +3 -5
  107. package/dist/esm/components/User/ProfileCardResourced.js +40 -16
  108. package/dist/esm/components/User/ProfileCardTrigger.js +53 -13
  109. package/dist/esm/components/User/ReportingLinesDetails.js +41 -12
  110. package/dist/esm/components/User/ReportingLinesDetailsCompiled.compiled.css +11 -0
  111. package/dist/esm/components/User/ReportingLinesDetailsCompiled.js +102 -0
  112. package/dist/esm/components/User/UserLoadingState.js +16 -4
  113. package/dist/esm/components/common/LoadingState.js +18 -4
  114. package/dist/esm/components/common/ProfileCardTrigger.js +30 -8
  115. package/dist/esm/components/common/ProfileCardWrapper.compiled.css +1 -0
  116. package/dist/esm/components/common/ProfileCardWrapper.js +11 -8
  117. package/dist/esm/components/team-profile-card/team-actions/more-actions/index.js +1 -2
  118. package/dist/esm/styled/CoverImage.compiled.css +2 -0
  119. package/dist/esm/styled/CoverImage.js +4 -2
  120. package/dist/esm/styled/Error.compiled.css +0 -2
  121. package/dist/esm/styled/Error.js +6 -4
  122. package/dist/esm/util/analytics.js +6 -2
  123. package/dist/types/client/ProfileCardClient.d.ts +2 -1
  124. package/dist/types/client/UserProfileCardClient.d.ts +2 -1
  125. package/dist/types/components/Agent/Actions.d.ts +10 -1
  126. package/dist/types/components/Agent/ActionsCompiled.d.ts +14 -0
  127. package/dist/types/components/Agent/AgentProfileCard.d.ts +13 -3
  128. package/dist/types/components/Agent/AgentProfileCardCompiled.d.ts +4 -0
  129. package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +12 -1
  130. package/dist/types/components/Error/ErrorMessage.d.ts +2 -0
  131. package/dist/types/components/User/ProfileCard.d.ts +3 -2
  132. package/dist/types/components/User/ProfileCardResourced.d.ts +4 -2
  133. package/dist/types/components/User/ReportingLinesDetails.d.ts +2 -2
  134. package/dist/types/components/User/ReportingLinesDetailsCompiled.d.ts +5 -0
  135. package/dist/types/components/User/UserLoadingState.d.ts +3 -1
  136. package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
  137. package/dist/types/components/common/LoadingState.d.ts +3 -1
  138. package/dist/types/components/common/ProfileCardWrapper.d.ts +2 -1
  139. package/dist/types/components/common/types.d.ts +3 -0
  140. package/dist/types/types.d.ts +13 -6
  141. package/dist/types/util/analytics.d.ts +5 -0
  142. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -1
  143. package/dist/types-ts4.5/client/UserProfileCardClient.d.ts +2 -1
  144. package/dist/types-ts4.5/components/Agent/Actions.d.ts +10 -1
  145. package/dist/types-ts4.5/components/Agent/ActionsCompiled.d.ts +14 -0
  146. package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +13 -3
  147. package/dist/types-ts4.5/components/Agent/AgentProfileCardCompiled.d.ts +4 -0
  148. package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +12 -1
  149. package/dist/types-ts4.5/components/Error/ErrorMessage.d.ts +2 -0
  150. package/dist/types-ts4.5/components/User/ProfileCard.d.ts +3 -2
  151. package/dist/types-ts4.5/components/User/ProfileCardResourced.d.ts +4 -2
  152. package/dist/types-ts4.5/components/User/ReportingLinesDetails.d.ts +2 -2
  153. package/dist/types-ts4.5/components/User/ReportingLinesDetailsCompiled.d.ts +5 -0
  154. package/dist/types-ts4.5/components/User/UserLoadingState.d.ts +3 -1
  155. package/dist/types-ts4.5/components/User/lazyProfileCard.d.ts +1 -1
  156. package/dist/types-ts4.5/components/common/LoadingState.d.ts +3 -1
  157. package/dist/types-ts4.5/components/common/ProfileCardWrapper.d.ts +2 -1
  158. package/dist/types-ts4.5/components/common/types.d.ts +3 -0
  159. package/dist/types-ts4.5/types.d.ts +13 -6
  160. package/dist/types-ts4.5/util/analytics.d.ts +5 -0
  161. package/package.json +20 -9
@@ -0,0 +1,116 @@
1
+ /* ActionsCompiled.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./ActionsCompiled.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useCallback, useState } from 'react';
5
+ import { defineMessages, useIntl } from 'react-intl-next';
6
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
7
+ import Button from '@atlaskit/button/new';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { Box, Inline } from '@atlaskit/primitives/compiled';
10
+ import { AgentDropdownMenu, ChatPillIcon } from '@atlaskit/rovo-agent-components';
11
+ import { fireEvent } from '../../util/analytics';
12
+ import { AgentDeleteConfirmationModal } from './AgentDeleteConfirmationModal';
13
+ const styles = {
14
+ chatToAgentButtonContainer: "_1bsb1osq",
15
+ chatToAgentButtonWrapper: "_1e0c1txw _1bah1h6o _k48p1wq8 _4t3igktf",
16
+ chatPillButtonInlineStyles: "_18zrv77o",
17
+ chatPillTextStyles: "_1nmz1hna _y3gn1e5h _o5721jtm",
18
+ chatPillIconWrapper: "_1ul9gktf _4t3igktf",
19
+ actionsWrapperStyles: "_189ee4h9 _1h6dmuej _15a5nqa1 _ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi _1pfhpxbi _syaz1fxt"
20
+ };
21
+ export const AgentActions = ({
22
+ onEditAgent,
23
+ onDeleteAgent,
24
+ onDuplicateAgent,
25
+ onCopyAgent,
26
+ onChatClick,
27
+ onViewFullProfileClick,
28
+ agent,
29
+ resourceClient
30
+ }) => {
31
+ const {
32
+ formatMessage
33
+ } = useIntl();
34
+ const {
35
+ createAnalyticsEvent
36
+ } = useAnalyticsEvents();
37
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
38
+ const isForgeAgent = agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY';
39
+ const loadAgentPermissions = useCallback(async () => {
40
+ const {
41
+ permissions: {
42
+ AGENT_CREATE,
43
+ AGENT_UPDATE,
44
+ AGENT_DEACTIVATE
45
+ }
46
+ } = await resourceClient.getRovoAgentPermissions(agent.id);
47
+ return {
48
+ ...(fg('agent_studio_fe_permissions_settings_m1') && {
49
+ isCreateEnabled: AGENT_CREATE.permitted
50
+ }),
51
+ isEditEnabled: AGENT_UPDATE.permitted,
52
+ isDeleteEnabled: AGENT_DEACTIVATE.permitted
53
+ };
54
+ }, [agent.id, resourceClient]);
55
+ const handleDeleteAgent = useCallback(() => {
56
+ fireEvent(createAnalyticsEvent, {
57
+ action: 'clicked',
58
+ actionSubject: 'button',
59
+ actionSubjectId: 'deleteAgentButton',
60
+ attributes: {
61
+ agentId: agent.id,
62
+ source: 'agentProfileCard'
63
+ }
64
+ });
65
+ setIsDeleteModalOpen(true);
66
+ }, [agent.id, createAnalyticsEvent]);
67
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Inline, {
68
+ space: "space.100",
69
+ xcss: styles.actionsWrapperStyles
70
+ }, /*#__PURE__*/React.createElement(Box, {
71
+ xcss: styles.chatToAgentButtonContainer
72
+ }, /*#__PURE__*/React.createElement(Button, {
73
+ shouldFitContainer: true,
74
+ onClick: e => {
75
+ e.stopPropagation();
76
+ onChatClick(e);
77
+ }
78
+ }, /*#__PURE__*/React.createElement(Box, {
79
+ xcss: styles.chatToAgentButtonWrapper
80
+ }, /*#__PURE__*/React.createElement(Inline, {
81
+ space: "space.050",
82
+ xcss: styles.chatPillButtonInlineStyles,
83
+ alignBlock: "center"
84
+ }, /*#__PURE__*/React.createElement(Box, {
85
+ xcss: styles.chatPillIconWrapper
86
+ }, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
87
+ xcss: styles.chatPillTextStyles
88
+ }, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/React.createElement(AgentDropdownMenu, {
89
+ agentId: agent.id,
90
+ onDeleteAgent: handleDeleteAgent,
91
+ onEditAgent: onEditAgent,
92
+ onDuplicateAgent: onDuplicateAgent,
93
+ onCopyAgent: onCopyAgent,
94
+ isForgeAgent: isForgeAgent,
95
+ loadAgentPermissions: loadAgentPermissions,
96
+ loadPermissionsOnMount: true,
97
+ onViewAgentFullProfileClick: onViewFullProfileClick,
98
+ doesAgentHaveIdentityAccountId: !!agent.identity_account_id,
99
+ shouldTriggerStopPropagation: true
100
+ })), /*#__PURE__*/React.createElement(AgentDeleteConfirmationModal, {
101
+ isOpen: isDeleteModalOpen,
102
+ onClose: () => {
103
+ setIsDeleteModalOpen(false);
104
+ },
105
+ onSubmit: onDeleteAgent,
106
+ agentId: agent.id,
107
+ agentName: agent.name
108
+ }));
109
+ };
110
+ const messages = defineMessages({
111
+ actionChatToAgent: {
112
+ id: 'ptc-directory.agent-profile.action.dropdown.chat-to-agent.nonfinal',
113
+ defaultMessage: 'Chat to Agent',
114
+ description: 'Text for the "chat to agent" action to chat to the agent'
115
+ }
116
+ });
@@ -2,8 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import { defineMessages, useIntl } from 'react-intl-next';
3
3
  import Button from '@atlaskit/button/new';
4
4
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
5
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
6
- import { Text } from '@atlaskit/primitives';
5
+ import { Text } from '@atlaskit/primitives/compiled';
7
6
  export const AgentDeleteConfirmationModal = ({
8
7
  onClose,
9
8
  agentName,
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
4
5
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
5
6
  import { Box, Stack, xcss } from '@atlaskit/primitives';
6
7
  import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
@@ -8,6 +9,7 @@ import { fireEvent, profileCardRendered } from '../../util/analytics';
8
9
  import { LoadingState } from '../common/LoadingState';
9
10
  import { ErrorMessage } from '../Error';
10
11
  import { AgentActions } from './Actions';
12
+ import { default as AgentProfileCardCompiled } from './AgentProfileCardCompiled';
11
13
  import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
12
14
  import { ConversationStarters } from './ConversationStarters';
13
15
  import { useAgentUrlActions } from './hooks/useAgentActions';
@@ -129,6 +131,10 @@ const AgentProfileCard = ({
129
131
  return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
130
132
  errorType: errorType,
131
133
  fireAnalytics: fireAnalytics
134
+ // TODO: Add fireAnalyticsNext
135
+ // NOTE: Add it to AgentProfileCardCompiled
136
+ ,
137
+ fireAnalyticsNext: () => {}
132
138
  }));
133
139
  }
134
140
  return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
@@ -189,4 +195,5 @@ const AgentProfileCard = ({
189
195
  onViewFullProfileClick: () => onViewFullProfile(agent.id)
190
196
  })));
191
197
  };
192
- export default AgentProfileCard;
198
+ const AgentProfileCardExport = componentWithFG('profilecard_primitives_compiled', AgentProfileCardCompiled, AgentProfileCard);
199
+ 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,186 @@
1
+ /* AgentProfileCardCompiled.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./AgentProfileCardCompiled.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useCallback, useEffect, useState } from 'react';
5
+ import { useIntl } from 'react-intl-next';
6
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
7
+ import { Box, Stack } from '@atlaskit/primitives/compiled';
8
+ import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
9
+ import { fireEvent, profileCardRendered } from '../../util/analytics';
10
+ import { LoadingState } from '../common/LoadingState';
11
+ import { ErrorMessage } from '../Error';
12
+ import { AgentActions } from './Actions';
13
+ import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
14
+ import { ConversationStarters } from './ConversationStarters';
15
+ import { useAgentUrlActions } from './hooks/useAgentActions';
16
+ import { messages } from './messages';
17
+ const styles = {
18
+ detailWrapper: "_18zrpxbi _1q51xy5q",
19
+ avatarStyles: "_kqswstnw _154i1ejb _1ltvpxbi",
20
+ cardContainerStyles: "_2rko1mok _16qs1cd0 _kqswh2mm"
21
+ };
22
+ const AgentProfileCard = ({
23
+ agent,
24
+ isLoading,
25
+ cloudId,
26
+ onChatClick,
27
+ hasError,
28
+ errorType,
29
+ onConversationStartersClick,
30
+ resourceClient,
31
+ addFlag,
32
+ onDeleteAgent
33
+ }) => {
34
+ var _agent$user_defined_c, _agent$external_confi, _agent$external_confi2, _agent$creatorInfo, _agent$creatorInfo2, _agent$creatorInfo3, _agent$creatorInfo4;
35
+ const {
36
+ onEditAgent,
37
+ onCopyAgent,
38
+ onDuplicateAgent,
39
+ onOpenChat: onOpenChatFullScreen,
40
+ onConversationStarter,
41
+ onViewFullProfile
42
+ } = useAgentUrlActions({
43
+ cloudId: cloudId || '',
44
+ source: 'agentProfileCard'
45
+ });
46
+ const [isStarred, setIsStarred] = useState(false);
47
+ const [starCount, setStarCount] = useState();
48
+ const {
49
+ formatMessage
50
+ } = useIntl();
51
+ const userDefinedConversationStarters = agent === null || agent === void 0 ? 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(starter => {
52
+ return {
53
+ message: starter,
54
+ type: 'user-defined'
55
+ };
56
+ });
57
+ useEffect(() => {
58
+ setIsStarred(!!(agent !== null && agent !== void 0 && agent.favourite));
59
+ setStarCount(agent === null || agent === void 0 ? void 0 : agent.favourite_count);
60
+ }, [agent === null || agent === void 0 ? void 0 : agent.favourite, agent === null || agent === void 0 ? void 0 : agent.favourite_count]);
61
+ const {
62
+ createAnalyticsEvent
63
+ } = useAnalyticsEvents();
64
+ const fireAnalytics = useCallback(payload => {
65
+ if (createAnalyticsEvent) {
66
+ fireEvent(createAnalyticsEvent, payload);
67
+ }
68
+ }, [createAnalyticsEvent]);
69
+ const handleSetFavourite = useCallback(async () => {
70
+ if (agent !== null && agent !== void 0 && agent.id) {
71
+ try {
72
+ await resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics);
73
+ if (isStarred) {
74
+ setStarCount(starCount ? starCount - 1 : 0);
75
+ } else {
76
+ setStarCount((starCount || 0) + 1);
77
+ }
78
+ setIsStarred(!isStarred);
79
+ } catch (error) {}
80
+ }
81
+ }, [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, isStarred, resourceClient, starCount]);
82
+ const handleOnDelete = useCallback(async () => {
83
+ if (agent && onDeleteAgent) {
84
+ // Optimistically remove from cache
85
+ const {
86
+ restore
87
+ } = onDeleteAgent(agent.id);
88
+ try {
89
+ await resourceClient.deleteAgent(agent.id, fireAnalytics);
90
+ addFlag === null || addFlag === void 0 ? void 0 : addFlag({
91
+ title: formatMessage(messages.agentDeletedSuccessFlagTitle),
92
+ description: formatMessage(messages.agentDeletedSuccessFlagDescription, {
93
+ agentName: agent.name
94
+ }),
95
+ type: 'success',
96
+ id: 'ptc-directory.agent-profile.delete-agent-success'
97
+ });
98
+ } catch (error) {
99
+ // Restore agent to cache on error
100
+ restore();
101
+ addFlag === null || addFlag === void 0 ? void 0 : addFlag({
102
+ title: formatMessage(messages.agentDeletedErrorFlagTitle),
103
+ description: formatMessage(messages.agentDeletedErrorFlagDescription),
104
+ type: 'error',
105
+ id: 'ptc-directory.agent-profile.delete-agent-error'
106
+ });
107
+ }
108
+ }
109
+ }, [addFlag, agent, formatMessage, onDeleteAgent, resourceClient, fireAnalytics]);
110
+ useEffect(() => {
111
+ if (!isLoading && agent) {
112
+ fireAnalytics(profileCardRendered('agent', 'content'));
113
+ }
114
+ }, [agent, fireAnalytics, isLoading]);
115
+ if (isLoading) {
116
+ return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(LoadingState, {
117
+ profileType: "agent",
118
+ fireAnalytics: fireAnalytics
119
+ }));
120
+ }
121
+ if (hasError || !agent) {
122
+ return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
123
+ fireAnalyticsNext: () => {},
124
+ errorType: errorType,
125
+ fireAnalytics: fireAnalytics
126
+ }));
127
+ }
128
+ return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
129
+ xcss: styles.cardContainerStyles
130
+ }, /*#__PURE__*/React.createElement(AgentBanner, {
131
+ agentId: agent.id,
132
+ agentNamedId: (_agent$external_confi = agent.external_config_reference) !== null && _agent$external_confi !== void 0 ? _agent$external_confi : agent.named_id,
133
+ height: 96,
134
+ agentIdentityAccountId: agent.identity_account_id
135
+ }), /*#__PURE__*/React.createElement(Box, {
136
+ xcss: styles.avatarStyles
137
+ }, /*#__PURE__*/React.createElement(AgentAvatar, {
138
+ agentId: agent.id,
139
+ agentNamedId: (_agent$external_confi2 = agent.external_config_reference) !== null && _agent$external_confi2 !== void 0 ? _agent$external_confi2 : agent.named_id,
140
+ agentIdentityAccountId: agent.identity_account_id,
141
+ size: "xlarge",
142
+ isForgeAgent: agent.creator_type === 'FORGE' || agent.creator_type === 'THIRD_PARTY',
143
+ forgeAgentIconUrl: agent.icon
144
+ })), /*#__PURE__*/React.createElement(Stack, {
145
+ space: "space.100",
146
+ xcss: styles.detailWrapper
147
+ }, /*#__PURE__*/React.createElement(AgentProfileInfo, {
148
+ agentName: agent.name,
149
+ isStarred: isStarred,
150
+ onStarToggle: handleSetFavourite,
151
+ isHidden: agent.visibility === 'PRIVATE',
152
+ creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/React.createElement(AgentProfileCreator, {
153
+ creator: {
154
+ type: (_agent$creatorInfo2 = agent.creatorInfo) === null || _agent$creatorInfo2 === void 0 ? void 0 : _agent$creatorInfo2.type,
155
+ name: ((_agent$creatorInfo3 = agent.creatorInfo) === null || _agent$creatorInfo3 === void 0 ? void 0 : _agent$creatorInfo3.name) || '',
156
+ profileLink: ((_agent$creatorInfo4 = agent.creatorInfo) === null || _agent$creatorInfo4 === void 0 ? void 0 : _agent$creatorInfo4.profileLink) || ''
157
+ },
158
+ isLoading: false,
159
+ onCreatorLinkClick: () => {}
160
+ }),
161
+ starCountRender: /*#__PURE__*/React.createElement(AgentStarCount, {
162
+ starCount: starCount,
163
+ isLoading: false
164
+ }),
165
+ agentDescription: agent.description
166
+ }), /*#__PURE__*/React.createElement(ConversationStarters, {
167
+ isAgentDefault: agent.is_default,
168
+ userDefinedConversationStarters: userDefinedConversationStarters,
169
+ onConversationStarterClick: conversationStarter => {
170
+ onConversationStartersClick ? onConversationStartersClick(conversationStarter) : onConversationStarter({
171
+ agentId: agent.id,
172
+ prompt: conversationStarter.message
173
+ });
174
+ }
175
+ })), /*#__PURE__*/React.createElement(AgentActions, {
176
+ agent: agent,
177
+ onEditAgent: () => onEditAgent(agent.id),
178
+ onCopyAgent: () => onCopyAgent(agent.id),
179
+ onDuplicateAgent: () => onDuplicateAgent(agent.id),
180
+ onDeleteAgent: handleOnDelete,
181
+ onChatClick: onChatClick ? event => onChatClick(event) : () => onOpenChatFullScreen(agent.id, agent.name),
182
+ resourceClient: resourceClient,
183
+ onViewFullProfileClick: () => onViewFullProfile(agent.id)
184
+ })));
185
+ };
186
+ export default AgentProfileCard;
@@ -89,7 +89,8 @@ export const AgentProfileCardResourced = props => {
89
89
  fetchData();
90
90
  },
91
91
  errorType: error || null,
92
- fireAnalytics: () => {}
92
+ fireAnalytics: () => {},
93
+ fireAnalyticsNext: () => {}
93
94
  }));
94
95
  }
95
96
  return /*#__PURE__*/React.createElement(Suspense, {
@@ -0,0 +1 @@
1
+ ._1bsb1gwv{width:360px}
@@ -1,14 +1,15 @@
1
+ /* AgentProfileCardWrapper.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./AgentProfileCardWrapper.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
1
4
  import React from 'react';
2
-
3
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
4
- import { Box, xcss } from '@atlaskit/primitives';
5
- const styles = xcss({
6
- width: '360px'
7
- });
5
+ import { Box } from '@atlaskit/primitives/compiled';
6
+ const styles = {
7
+ wrapper: "_1bsb1gwv"
8
+ };
8
9
  export const AgentProfileCardWrapper = ({
9
10
  children
10
11
  }) => {
11
12
  return /*#__PURE__*/React.createElement(Box, {
12
- xcss: styles
13
+ xcss: styles.wrapper
13
14
  }, children);
14
15
  };
@@ -1,7 +1,5 @@
1
1
  import React from 'react';
2
-
3
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
4
- import { Stack } from '@atlaskit/primitives';
2
+ import { Stack } from '@atlaskit/primitives/compiled';
5
3
  import { AgentConversationStarters } from '@atlaskit/rovo-agent-components';
6
4
  export const ConversationStarters = ({
7
5
  isAgentDefault,
@@ -2,10 +2,10 @@ import React, { useEffect } from 'react';
2
2
  import Button from '@atlaskit/button/new';
3
3
  import CrossCircleIcon from '@atlaskit/icon/core/cross-circle';
4
4
  import IconError from '@atlaskit/icon/glyph/cross-circle';
5
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
6
- import { Text } from '@atlaskit/primitives';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { Text } from '@atlaskit/primitives/compiled';
7
7
  import { ErrorTitle, ErrorWrapper } from '../../styled/Error';
8
- import { profileCardRendered } from '../../util/analytics';
8
+ import { PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
9
9
  const ErrorMessage = props => {
10
10
  const errorType = props.errorType || {
11
11
  reason: 'default'
@@ -13,15 +13,25 @@ const ErrorMessage = props => {
13
13
  const errorReason = errorType.reason;
14
14
  const {
15
15
  fireAnalytics,
16
+ fireAnalyticsNext,
16
17
  reload
17
18
  } = props;
18
19
  const hasRetry = !!reload;
19
20
  useEffect(() => {
20
- fireAnalytics(profileCardRendered('user', 'error', {
21
- hasRetry,
22
- errorType: errorReason
23
- }));
24
- }, [errorReason, fireAnalytics, hasRetry]);
21
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
22
+ fireAnalyticsNext('ui.profilecard.rendered.error', {
23
+ hasRetry,
24
+ errorType: errorReason,
25
+ firedAt: Math.round(performance.now()),
26
+ ...PACKAGE_META_DATA
27
+ });
28
+ } else {
29
+ fireAnalytics(profileCardRendered('user', 'error', {
30
+ hasRetry,
31
+ errorType: errorReason
32
+ }));
33
+ }
34
+ }, [errorReason, fireAnalytics, fireAnalyticsNext, hasRetry]);
25
35
  const errorContent = () => {
26
36
  if (errorReason === 'NotFound') {
27
37
  return /*#__PURE__*/React.createElement(ErrorTitle, null, "The user is no longer available for the site");
@@ -6,8 +6,7 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
6
6
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import Popup from '@atlaskit/popup';
9
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
10
- import { Box } from '@atlaskit/primitives';
9
+ import { Box } from '@atlaskit/primitives/compiled';
11
10
  import { layers } from '@atlaskit/theme/constants';
12
11
  import filterActions from '../../internal/filterActions';
13
12
  import messages from '../../messages';
@@ -7,7 +7,8 @@ import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import messages from '../../messages';
9
9
  import { OverflowActionButtonsWrapper } from '../../styled/Card';
10
- import { moreActionsClicked } from '../../util/analytics';
10
+ import { moreActionsClicked, PACKAGE_META_DATA } from '../../util/analytics';
11
+ import { getPageTime } from '../../util/performance';
11
12
  export const ACTION_OVERFLOW_THRESHOLD = 2;
12
13
  export const OverflowProfileCardButtons = props => {
13
14
  const intl = useIntl();
@@ -15,7 +16,8 @@ export const OverflowProfileCardButtons = props => {
15
16
  const {
16
17
  actions,
17
18
  onItemClick,
18
- fireAnalyticsWithDuration
19
+ fireAnalyticsWithDuration,
20
+ fireAnalyticsWithDurationNext
19
21
  } = props;
20
22
  const numActions = actions.length + ACTION_OVERFLOW_THRESHOLD;
21
23
  const onOpenChange = useCallback(({
@@ -23,14 +25,23 @@ export const OverflowProfileCardButtons = props => {
23
25
  }) => {
24
26
  setOpen(prevOpen => {
25
27
  if (nextOpen && !prevOpen) {
26
- fireAnalyticsWithDuration(duration => moreActionsClicked('user', {
27
- duration,
28
- numActions
29
- }));
28
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
29
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.moreActions', duration => ({
30
+ duration,
31
+ numActions,
32
+ firedAt: Math.round(getPageTime()),
33
+ ...PACKAGE_META_DATA
34
+ }));
35
+ } else {
36
+ fireAnalyticsWithDuration(duration => moreActionsClicked('user', {
37
+ duration,
38
+ numActions
39
+ }));
40
+ }
30
41
  }
31
42
  return nextOpen;
32
43
  });
33
- }, [numActions, fireAnalyticsWithDuration]);
44
+ }, [numActions, fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
34
45
  return /*#__PURE__*/React.createElement(OverflowActionButtonsWrapper, {
35
46
  testId: "profilecard-actions-overflow"
36
47
  }, /*#__PURE__*/React.createElement(DropdownMenu, {