@atlaskit/rovo-agent-components 3.31.0 → 3.32.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/rovo-agent-components
2
2
 
3
+ ## 3.32.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`32fb2d5d28925`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/32fb2d5d28925) -
8
+ Added 'Verify / Unverify agent' dropdown to rovo chat trigger
9
+
3
10
  ## 3.31.0
4
11
 
5
12
  ### Minor Changes
@@ -31,7 +31,8 @@ var AgentVerificationDropdownItem = exports.AgentVerificationDropdownItem = func
31
31
  userPermissionsRef = _ref.userPermissionsRef,
32
32
  onClick = _ref.onClick,
33
33
  onVerificationSuccess = _ref.onVerificationSuccess,
34
- testId = _ref.testId;
34
+ testId = _ref.testId,
35
+ renderItem = _ref.renderItem;
35
36
  var _useIntl = (0, _reactIntlNext.useIntl)(),
36
37
  formatMessage = _useIntl.formatMessage;
37
38
  var _useFlags = (0, _flag.useFlags)(),
@@ -49,8 +50,9 @@ var AgentVerificationDropdownItem = exports.AgentVerificationDropdownItem = func
49
50
  trackAgentAction = _useRovoAgentActionAn.trackAgentAction,
50
51
  trackAgentActionError = _useRovoAgentActionAn.trackAgentActionError;
51
52
  var _useMutation = (0, _reactRelay.useMutation)(_agentVerificationDropdownItem_AtlaskitRovoAgentComponents_updateAgentVerificationMutation2.default),
52
- _useMutation2 = (0, _slicedToArray2.default)(_useMutation, 1),
53
- commitUpdateVerification = _useMutation2[0];
53
+ _useMutation2 = (0, _slicedToArray2.default)(_useMutation, 2),
54
+ commitUpdateVerification = _useMutation2[0],
55
+ isPending = _useMutation2[1];
54
56
  var handleError = (0, _react.useCallback)(function (verified, errorMessage) {
55
57
  showFlag({
56
58
  title: formatMessage(verified ? _messages.default.verifyErrorTitle : _messages.default.unverifyErrorTitle),
@@ -107,6 +109,10 @@ var AgentVerificationDropdownItem = exports.AgentVerificationDropdownItem = func
107
109
  }
108
110
  });
109
111
  }, [agentId, commitUpdateVerification, formatMessage, handleError, onClick, onVerificationSuccess, showFlag, trackAgentAction, trackAgentActionError]);
112
+ var labelText = formatMessage(isVerified ? _messages.default.unverifyAgentLabel : _messages.default.verifyAgentLabel);
113
+ var handleOnClick = function handleOnClick() {
114
+ return handleUpdateVerification(!isVerified);
115
+ };
110
116
  if (
111
117
  // Don't render if agent ID is not available
112
118
  !agentId ||
@@ -114,10 +120,18 @@ var AgentVerificationDropdownItem = exports.AgentVerificationDropdownItem = func
114
120
  !isAbleToGovernAgents) {
115
121
  return null;
116
122
  }
123
+
124
+ // Use custom render or default to DropdownItem
125
+ if (renderItem) {
126
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderItem({
127
+ isPending: isPending,
128
+ isVerified: isVerified,
129
+ labelText: labelText,
130
+ onClick: handleOnClick
131
+ }));
132
+ }
117
133
  return /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
118
134
  testId: testId,
119
- onClick: function onClick() {
120
- return handleUpdateVerification(!isVerified);
121
- }
122
- }, formatMessage(isVerified ? _messages.default.unverifyAgentLabel : _messages.default.verifyAgentLabel));
135
+ onClick: handleOnClick
136
+ }, labelText);
123
137
  };
@@ -20,7 +20,8 @@ export const AgentVerificationDropdownItem = ({
20
20
  userPermissionsRef,
21
21
  onClick,
22
22
  onVerificationSuccess,
23
- testId
23
+ testId,
24
+ renderItem
24
25
  }) => {
25
26
  var _userPermissions$isAb, _agentData$isVerified;
26
27
  const {
@@ -42,7 +43,7 @@ export const AgentVerificationDropdownItem = ({
42
43
  agentId,
43
44
  isAbleToGovernAgents
44
45
  });
45
- const [commitUpdateVerification] = useMutation(_agentVerificationDropdownItem_AtlaskitRovoAgentComponents_updateAgentVerificationMutation);
46
+ const [commitUpdateVerification, isPending] = useMutation(_agentVerificationDropdownItem_AtlaskitRovoAgentComponents_updateAgentVerificationMutation);
46
47
  const handleError = useCallback((verified, errorMessage) => {
47
48
  showFlag({
48
49
  title: formatMessage(verified ? messages.verifyErrorTitle : messages.unverifyErrorTitle),
@@ -99,6 +100,8 @@ export const AgentVerificationDropdownItem = ({
99
100
  }
100
101
  });
101
102
  }, [agentId, commitUpdateVerification, formatMessage, handleError, onClick, onVerificationSuccess, showFlag, trackAgentAction, trackAgentActionError]);
103
+ const labelText = formatMessage(isVerified ? messages.unverifyAgentLabel : messages.verifyAgentLabel);
104
+ const handleOnClick = () => handleUpdateVerification(!isVerified);
102
105
  if (
103
106
  // Don't render if agent ID is not available
104
107
  !agentId ||
@@ -106,8 +109,18 @@ export const AgentVerificationDropdownItem = ({
106
109
  !isAbleToGovernAgents) {
107
110
  return null;
108
111
  }
112
+
113
+ // Use custom render or default to DropdownItem
114
+ if (renderItem) {
115
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderItem({
116
+ isPending,
117
+ isVerified,
118
+ labelText,
119
+ onClick: handleOnClick
120
+ }));
121
+ }
109
122
  return /*#__PURE__*/React.createElement(DropdownItem, {
110
123
  testId: testId,
111
- onClick: () => handleUpdateVerification(!isVerified)
112
- }, formatMessage(isVerified ? messages.unverifyAgentLabel : messages.verifyAgentLabel));
124
+ onClick: handleOnClick
125
+ }, labelText);
113
126
  };
@@ -22,7 +22,8 @@ export var AgentVerificationDropdownItem = function AgentVerificationDropdownIte
22
22
  userPermissionsRef = _ref.userPermissionsRef,
23
23
  onClick = _ref.onClick,
24
24
  onVerificationSuccess = _ref.onVerificationSuccess,
25
- testId = _ref.testId;
25
+ testId = _ref.testId,
26
+ renderItem = _ref.renderItem;
26
27
  var _useIntl = useIntl(),
27
28
  formatMessage = _useIntl.formatMessage;
28
29
  var _useFlags = useFlags(),
@@ -40,8 +41,9 @@ export var AgentVerificationDropdownItem = function AgentVerificationDropdownIte
40
41
  trackAgentAction = _useRovoAgentActionAn.trackAgentAction,
41
42
  trackAgentActionError = _useRovoAgentActionAn.trackAgentActionError;
42
43
  var _useMutation = useMutation(_agentVerificationDropdownItem_AtlaskitRovoAgentComponents_updateAgentVerificationMutation),
43
- _useMutation2 = _slicedToArray(_useMutation, 1),
44
- commitUpdateVerification = _useMutation2[0];
44
+ _useMutation2 = _slicedToArray(_useMutation, 2),
45
+ commitUpdateVerification = _useMutation2[0],
46
+ isPending = _useMutation2[1];
45
47
  var handleError = useCallback(function (verified, errorMessage) {
46
48
  showFlag({
47
49
  title: formatMessage(verified ? messages.verifyErrorTitle : messages.unverifyErrorTitle),
@@ -98,6 +100,10 @@ export var AgentVerificationDropdownItem = function AgentVerificationDropdownIte
98
100
  }
99
101
  });
100
102
  }, [agentId, commitUpdateVerification, formatMessage, handleError, onClick, onVerificationSuccess, showFlag, trackAgentAction, trackAgentActionError]);
103
+ var labelText = formatMessage(isVerified ? messages.unverifyAgentLabel : messages.verifyAgentLabel);
104
+ var handleOnClick = function handleOnClick() {
105
+ return handleUpdateVerification(!isVerified);
106
+ };
101
107
  if (
102
108
  // Don't render if agent ID is not available
103
109
  !agentId ||
@@ -105,10 +111,18 @@ export var AgentVerificationDropdownItem = function AgentVerificationDropdownIte
105
111
  !isAbleToGovernAgents) {
106
112
  return null;
107
113
  }
114
+
115
+ // Use custom render or default to DropdownItem
116
+ if (renderItem) {
117
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderItem({
118
+ isPending: isPending,
119
+ isVerified: isVerified,
120
+ labelText: labelText,
121
+ onClick: handleOnClick
122
+ }));
123
+ }
108
124
  return /*#__PURE__*/React.createElement(DropdownItem, {
109
125
  testId: testId,
110
- onClick: function onClick() {
111
- return handleUpdateVerification(!isVerified);
112
- }
113
- }, formatMessage(isVerified ? messages.unverifyAgentLabel : messages.verifyAgentLabel));
126
+ onClick: handleOnClick
127
+ }, labelText);
114
128
  };
@@ -17,10 +17,20 @@ export type AgentVerificationDropdownItemProps = {
17
17
  * Test ID for the dropdown item.
18
18
  */
19
19
  testId?: string;
20
+ /**
21
+ * Render function for custom dropdown component.
22
+ * If not provided, defaults to DropdownItem.
23
+ */
24
+ renderItem?: (props: {
25
+ isPending: boolean;
26
+ isVerified: boolean;
27
+ labelText: string;
28
+ onClick: () => void;
29
+ }) => React.ReactNode;
20
30
  };
21
31
  /**
22
32
  * A dropdown item for verifying or unverifying an agent.
23
33
  * Renders "Verify agent" if the agent is not verified, or "Remove verification" if it is.
24
34
  * Returns null if the user doesn't have permission to govern agents or the feature flag is off.
25
35
  */
26
- export declare const AgentVerificationDropdownItem: ({ agentRef, userPermissionsRef, onClick, onVerificationSuccess, testId, }: AgentVerificationDropdownItemProps) => React.JSX.Element | null;
36
+ export declare const AgentVerificationDropdownItem: ({ agentRef, userPermissionsRef, onClick, onVerificationSuccess, testId, renderItem, }: AgentVerificationDropdownItemProps) => React.JSX.Element | null;
@@ -17,10 +17,20 @@ export type AgentVerificationDropdownItemProps = {
17
17
  * Test ID for the dropdown item.
18
18
  */
19
19
  testId?: string;
20
+ /**
21
+ * Render function for custom dropdown component.
22
+ * If not provided, defaults to DropdownItem.
23
+ */
24
+ renderItem?: (props: {
25
+ isPending: boolean;
26
+ isVerified: boolean;
27
+ labelText: string;
28
+ onClick: () => void;
29
+ }) => React.ReactNode;
20
30
  };
21
31
  /**
22
32
  * A dropdown item for verifying or unverifying an agent.
23
33
  * Renders "Verify agent" if the agent is not verified, or "Remove verification" if it is.
24
34
  * Returns null if the user doesn't have permission to govern agents or the feature flag is off.
25
35
  */
26
- export declare const AgentVerificationDropdownItem: ({ agentRef, userPermissionsRef, onClick, onVerificationSuccess, testId, }: AgentVerificationDropdownItemProps) => React.JSX.Element | null;
36
+ export declare const AgentVerificationDropdownItem: ({ agentRef, userPermissionsRef, onClick, onVerificationSuccess, testId, renderItem, }: AgentVerificationDropdownItemProps) => React.JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/rovo-agent-components",
3
- "version": "3.31.0",
3
+ "version": "3.32.0",
4
4
  "description": "This package host public components related to rovo agents, the components here are needed for other public atlaskit packages",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",