mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
chore: remove the old test connection component
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useRef } from "react";
|
||||
|
||||
import { checkConnectionProvider } from "@/actions/providers";
|
||||
|
||||
import { CustomButtonClientAction } from "../ui/custom";
|
||||
import { useToast } from "../ui/toast";
|
||||
|
||||
export const CheckConnectionProvider = ({ id }: { id: string }) => {
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
const { toast } = useToast();
|
||||
|
||||
async function clientAction(formData: FormData) {
|
||||
// reset the form
|
||||
ref.current?.reset();
|
||||
// client-side validation
|
||||
const data = await checkConnectionProvider(formData);
|
||||
if (data?.errors && data.errors.length > 0) {
|
||||
const error = data.errors[0];
|
||||
const errorMessage = `${error.detail}`;
|
||||
// show error
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Oops! Something went wrong",
|
||||
description: errorMessage,
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
title: "Checking",
|
||||
description: "The task was launched successfully",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form ref={ref} action={clientAction} className="flex gap-x-2">
|
||||
<input type="hidden" name="id" value={id} />
|
||||
<CustomButtonClientAction buttonLabel="Check connection" />
|
||||
</form>
|
||||
);
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
export * from "./add-provider";
|
||||
export * from "./CheckConnectionProvider";
|
||||
export * from "./forms/delete-form";
|
||||
export * from "./provider-info";
|
||||
export * from "./radio-group-provider";
|
||||
|
||||
@@ -20,7 +20,6 @@ import { useState } from "react";
|
||||
import { VerticalDotsIcon } from "@/components/icons";
|
||||
import { CustomAlertModal } from "@/components/ui/custom";
|
||||
|
||||
import { CheckConnectionProvider } from "../CheckConnectionProvider";
|
||||
import { EditForm } from "../forms";
|
||||
import { DeleteForm } from "../forms/delete-form";
|
||||
|
||||
@@ -80,7 +79,7 @@ export function DataTableRowActions<ProviderProps>({
|
||||
textValue="Check Connection"
|
||||
startContent={<AddNoteBulkIcon className={iconClasses} />}
|
||||
>
|
||||
<CheckConnectionProvider id={providerId} />
|
||||
{/* TODO: add the provider type to the search params */}
|
||||
</DropdownItem>
|
||||
<DropdownItem
|
||||
key="edit"
|
||||
|
||||
Reference in New Issue
Block a user