mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 13:56:51 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
eaf69d5de9
commit
929e641792
4 changed files with 68 additions and 31 deletions
|
|
@ -20,6 +20,7 @@ import { invokeFunction } from "@/lib/invoke-function";
|
|||
interface Props {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onDisconnected?: () => void;
|
||||
integrationId: string;
|
||||
mcpSlug: string;
|
||||
mcpName: string;
|
||||
|
|
@ -28,6 +29,7 @@ interface Props {
|
|||
export function DisconnectMCPDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
onDisconnected,
|
||||
integrationId,
|
||||
mcpSlug,
|
||||
mcpName,
|
||||
|
|
@ -49,6 +51,7 @@ export function DisconnectMCPDialog({
|
|||
runtime_sync_warning?: string | null;
|
||||
}>("disconnect-integration", {
|
||||
integration_id: integrationId,
|
||||
force_pause_jobs: dependentJobs.length > 0,
|
||||
});
|
||||
setSubmitting(false);
|
||||
if (error) {
|
||||
|
|
@ -56,14 +59,19 @@ export function DisconnectMCPDialog({
|
|||
return;
|
||||
}
|
||||
toast.success(`${mcpName} desconectado.`);
|
||||
if ((data?.paused_jobs_count ?? 0) > 0) {
|
||||
toast.info(`${data!.paused_jobs_count} automação(ões) pausada(s).`);
|
||||
}
|
||||
if (data?.runtime_sync_warning) {
|
||||
toast.warning("Integração removida, mas o runtime do agente não sincronizou.");
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: ["user-integrations"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["user-integration-limits"] });
|
||||
onOpenChange(false);
|
||||
onDisconnected?.();
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||
<AlertDialogContent>
|
||||
|
|
@ -101,7 +109,8 @@ export function DisconnectMCPDialog({
|
|||
)}
|
||||
</ul>
|
||||
<p className="mt-2 text-xs">
|
||||
Pause ou exclua essas automações antes de desconectar.
|
||||
Elas serão pausadas automaticamente ao desconectar.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -117,7 +126,8 @@ export function DisconnectMCPDialog({
|
|||
e.preventDefault();
|
||||
handleDisconnect();
|
||||
}}
|
||||
disabled={submitting || isLoading || hasActiveJobs}
|
||||
disabled={submitting || isLoading}
|
||||
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{submitting ? "Desconectando..." : "Desconectar"}
|
||||
|
|
|
|||
|
|
@ -102,14 +102,19 @@ function IntegrationDetailPage() {
|
|||
|
||||
async function handleTest() {
|
||||
setTesting(true);
|
||||
const { data, error } = await invokeFunction<{ ok: boolean; account?: string }>(
|
||||
const { data, error } = await invokeFunction<{
|
||||
ok?: boolean;
|
||||
success?: boolean;
|
||||
account?: string;
|
||||
account_info?: unknown;
|
||||
}>(
|
||||
"test-integration",
|
||||
{ integration_id: integration!.id },
|
||||
);
|
||||
setTesting(false);
|
||||
if (error) {
|
||||
toast.error(error.message);
|
||||
} else if (data?.ok) {
|
||||
} else if (data?.ok || data?.success) {
|
||||
toast.success("Conexão funcionando perfeitamente.");
|
||||
} else {
|
||||
toast.warning("Conexão respondeu, mas com aviso. Verifique status.");
|
||||
|
|
@ -117,6 +122,7 @@ function IntegrationDetailPage() {
|
|||
queryClient.invalidateQueries({ queryKey: ["user-integrations"] });
|
||||
}
|
||||
|
||||
|
||||
async function handleRefresh() {
|
||||
setRefreshing(true);
|
||||
const { data, error } = await invokeFunction<{
|
||||
|
|
@ -289,22 +295,13 @@ function IntegrationDetailPage() {
|
|||
|
||||
<DisconnectMCPDialog
|
||||
open={disconnectOpen}
|
||||
onOpenChange={(o) => {
|
||||
setDisconnectOpen(o);
|
||||
if (!o) {
|
||||
// se desconectou, volta para a lista
|
||||
queryClient.invalidateQueries({ queryKey: ["user-integrations"] }).then(() => {
|
||||
const stillConnected = integs.some((i) => i.id === integration.id);
|
||||
if (!stillConnected) {
|
||||
navigate({ to: "/painel/integracoes", search: {} });
|
||||
}
|
||||
});
|
||||
}
|
||||
}}
|
||||
onOpenChange={setDisconnectOpen}
|
||||
onDisconnected={() => navigate({ to: "/painel/integracoes", search: {} })}
|
||||
integrationId={integration.id}
|
||||
mcpSlug={mcp.slug}
|
||||
mcpName={mcp.name}
|
||||
/>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue