ensure all timeout -> hook (#2718)

This commit is contained in:
pablodanswer 2024-10-08 08:48:38 -07:00 committed by GitHub
parent 79d37156c6
commit a0124e4e50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 29 deletions

View File

@ -50,14 +50,8 @@ function Main({ ccPairId }: { ccPairId: number }) {
const { popup, setPopup } = usePopup(); const { popup, setPopup } = usePopup();
const finishConnectorDeletion = useCallback(() => { const finishConnectorDeletion = useCallback(() => {
setPopup({ router.push("/admin/indexing/status?message=connector-deleted");
message: "Connector deleted successfully", }, [router]);
type: "success",
});
setTimeout(() => {
router.push("/admin/indexing/status");
}, 2000);
}, [router, setPopup]);
useEffect(() => { useEffect(() => {
if (isEditing && inputRef.current) { if (isEditing && inputRef.current) {
@ -80,14 +74,7 @@ function Main({ ccPairId }: { ccPairId: number }) {
) { ) {
finishConnectorDeletion(); finishConnectorDeletion();
} }
}, [ }, [isLoading, ccPair, error, hasLoadedOnce]);
isLoading,
ccPair,
error,
hasLoadedOnce,
router,
finishConnectorDeletion,
]);
const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setEditableName(e.target.value); setEditableName(e.target.value);

View File

@ -10,12 +10,6 @@ import { useConnectorCredentialIndexingStatus } from "@/lib/hooks";
import { usePopupFromQuery } from "@/components/popup/PopupFromQuery"; import { usePopupFromQuery } from "@/components/popup/PopupFromQuery";
function Main() { function Main() {
const { popup } = usePopupFromQuery({
"connector-created": {
message: "Connector created successfully",
type: "success",
},
});
const { const {
data: indexAttemptData, data: indexAttemptData,
isLoading: indexAttemptIsLoading, isLoading: indexAttemptIsLoading,
@ -70,19 +64,28 @@ function Main() {
}); });
return ( return (
<> <CCPairIndexingStatusTable
{popup} ccPairsIndexingStatuses={indexAttemptData}
<CCPairIndexingStatusTable editableCcPairsIndexingStatuses={editableIndexAttemptData}
ccPairsIndexingStatuses={indexAttemptData} />
editableCcPairsIndexingStatuses={editableIndexAttemptData}
/>
</>
); );
} }
export default function Status() { export default function Status() {
const { popup } = usePopupFromQuery({
"connector-created": {
message: "Connector created successfully",
type: "success",
},
"connector-deleted": {
message: "Connector deleted successfully",
type: "success",
},
});
return ( return (
<div className="mx-auto container"> <div className="mx-auto container">
{popup}
<AdminPageTitle <AdminPageTitle
icon={<NotebookIcon size={32} />} icon={<NotebookIcon size={32} />}
title="Existing Connectors" title="Existing Connectors"