Skip to content

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

771 B
Raw Blame
import { Unlink } from "lucide-react";
import { EngineIcon, getEngineIconSrc } from "@/components/EngineIcon";
import {
  getConnectionForSQLEditorTab,
  isConnectedSQLEditorTab,
} from "@/lib/sqlEditorConnection";
import type { SQLEditorTab } from "@/types";

type Props = {
  readonly tab: SQLEditorTab;
};

/**
 * Renders the engine icon when the tab has a live connection, otherwise the
 * "unlink" glyph.
 */
export function SheetConnectionIcon({ tab }: Props) {
  const connected = isConnectedSQLEditorTab(tab);
  const { instance } = getConnectionForSQLEditorTab(tab);

  if (connected && instance && getEngineIconSrc(instance.engine)) {
    return <EngineIcon engine={instance.engine} className="size-4" />;
  }
  return <Unlink className="size-4 shrink-0" />;
}