Only show throttling warning when throttling happened. (#1976)

This commit is contained in:
Laurent Nguyen 2024-09-23 17:30:42 +02:00 committed by GitHub
parent 053dc9d76b
commit 7128133874
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 9 deletions

View File

@ -645,6 +645,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
throttledIds: DocumentId[]; throttledIds: DocumentId[];
failedIds: DocumentId[]; failedIds: DocumentId[];
beforeExecuteMs: number; // Delay before executing delete. Used for retrying throttling after a specified delay beforeExecuteMs: number; // Delay before executing delete. Used for retrying throttling after a specified delay
hasBeenThrottled: boolean; // Keep track if the operation has been throttled at least once
}>(undefined); }>(undefined);
const [bulkDeleteOperation, setBulkDeleteOperation] = useState<{ const [bulkDeleteOperation, setBulkDeleteOperation] = useState<{
onCompleted: (documentIds: DocumentId[]) => void; onCompleted: (documentIds: DocumentId[]) => void;
@ -754,6 +755,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
throttledIds: newThrottled, throttledIds: newThrottled,
failedIds: prev.failedIds.concat(newFailed), failedIds: prev.failedIds.concat(newFailed),
beforeExecuteMs: retryAfterMilliseconds, beforeExecuteMs: retryAfterMilliseconds,
hasBeenThrottled: prev.hasBeenThrottled || newThrottled.length > 0,
})); }));
}) })
.catch((error) => { .catch((error) => {
@ -764,6 +766,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
successfulIds: prev.successfulIds, successfulIds: prev.successfulIds,
failedIds: prev.failedIds.concat(prev.pendingIds), failedIds: prev.failedIds.concat(prev.pendingIds),
beforeExecuteMs: undefined, beforeExecuteMs: undefined,
hasBeenThrottled: prev.hasBeenThrottled,
})); }));
bulkDeleteOperation.onFailed(error); bulkDeleteOperation.onFailed(error);
}); });
@ -1142,6 +1145,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
successfulIds: [], successfulIds: [],
failedIds: [], failedIds: [],
beforeExecuteMs: 0, beforeExecuteMs: 0,
hasBeenThrottled: false,
}); });
setIsBulkDeleteDialogOpen(true); setIsBulkDeleteDialogOpen(true);
setBulkDeleteMode("inProgress"); setBulkDeleteMode("inProgress");
@ -2312,15 +2316,17 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
</MessageBarBody> </MessageBarBody>
</MessageBar> </MessageBar>
)} )}
<MessageBar intent="warning"> {bulkDeleteProcess.hasBeenThrottled && (
<MessageBarBody> <MessageBar intent="warning">
<MessageBarTitle>Warning</MessageBarTitle> <MessageBarBody>
{get429WarningMessageNoSql()}{" "} <MessageBarTitle>Warning</MessageBarTitle>
<Link href={NO_SQL_THROTTLING_DOC_URL} target="_blank"> {get429WarningMessageNoSql()}{" "}
Learn More <Link href={NO_SQL_THROTTLING_DOC_URL} target="_blank">
</Link> Learn More
</MessageBarBody> </Link>
</MessageBar> </MessageBarBody>
</MessageBar>
)}
</div> </div>
</ProgressModalDialog> </ProgressModalDialog>
)} )}