Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

1017 B
Raw Blame
import { Upload } from "lucide-react";
import { useCallback } from "react";
import { useTranslation } from "react-i18next";
import { Tooltip } from "@/components/ui/tooltip";
import { useSQLEditorTabState } from "@/modules/sql-editor/store/tab";
import { SQLUploadButton } from "./SQLUploadButton";

interface UploadFileButtonProps {
  onUpload: (content: string) => void;
}

/**
 * Tooltip-wrapped icon button that delegates to `SQLUploadButton`.
 */
export function UploadFileButton({ onUpload }: UploadFileButtonProps) {
  const { t } = useTranslation();
  const tabId = useSQLEditorTabState((s) => s.tabsById.get(s.currentTabId)?.id);

  const handleUpdateSql = useCallback(
    (content: string) => {
      if (!tabId) return;
      onUpload(content);
    },
    [onUpload, tabId]
  );

  return (
    <Tooltip content={t("sql-editor.upload-file")} side="bottom">
      <SQLUploadButton iconOnly onUpdateSql={handleUpdateSql}>
        <Upload className="size-3" />
      </SQLUploadButton>
    </Tooltip>
  );
}