Copilot commented on code in PR #16078:
URL: https://github.com/apache/pinot/pull/16078#discussion_r2140628292
##########
pinot-controller/src/main/resources/app/pages/SegmentDetails.tsx:
##########
@@ -325,6 +325,29 @@ const SegmentDetails = ({ match }:
RouteComponentProps<Props>) => {
setConfirmDialog(true);
};
+ const handleResetSegmentClick = () => {
+ setDialogDetails({
+ title: 'Reset Segment',
+ content: 'Are you sure want to reset this segment?',
Review Comment:
Fix the confirmation message grammar: change to 'Are you sure you want to
reset this segment?'
```suggestion
content: 'Are you sure you want to reset this segment?',
```
##########
pinot-controller/src/main/resources/app/pages/SegmentDetails.tsx:
##########
@@ -325,6 +325,29 @@ const SegmentDetails = ({ match }:
RouteComponentProps<Props>) => {
setConfirmDialog(true);
};
+ const handleResetSegmentClick = () => {
+ setDialogDetails({
+ title: 'Reset Segment',
+ content: 'Are you sure want to reset this segment?',
+ successCb: () => handleResetOp(),
+ });
+ setConfirmDialog(true);
+ };
+
+ const handleResetOp = async () => {
+ const result = await PinotMethodUtils.resetSegmentOp(
+ tableName,
+ segmentName
+ );
+ if (result.status) {
+ dispatch({ type: 'success', message: result.status, show: true });
+ fetchData();
+ } else {
+ dispatch({ type: 'error', message: result.error, show: true });
+ }
+ closeDialog();
Review Comment:
Wrap the API call in a try-catch block to handle network or unexpected
errors and dispatch an error message instead of letting exceptions propagate.
```suggestion
try {
const result = await PinotMethodUtils.resetSegmentOp(
tableName,
segmentName
);
if (result.status) {
dispatch({ type: 'success', message: result.status, show: true });
fetchData();
} else {
dispatch({ type: 'error', message: result.error, show: true });
}
} catch (error) {
console.error('Error resetting segment:', error);
dispatch({ type: 'error', message: 'Failed to reset segment. Please
try again later.', show: true });
} finally {
closeDialog();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]