Skip to content

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

1.4 KB
Raw Blame
import { ShieldAlert } from "lucide-react";
import { Trans, useTranslation } from "react-i18next";
import { EngineIcon } from "@/components/EngineIcon";
import { useConnectionOfCurrentSQLEditorTab } from "@/modules/sql-editor/hooks/useSQLEditorState";
import { AdminModeButton } from "./AdminModeButton";

/**
 * Shown when the current tab targets an instance without read-only mode —
 * prompts the user to switch to admin mode instead.
 */
export function ReadonlyModeNotSupported() {
  const { t } = useTranslation();
  const { instance } = useConnectionOfCurrentSQLEditorTab();

  return (
    <div className="w-full h-full flex flex-col items-center justify-center gap-y-2 p-4">
      <div className="flex items-center gap-x-2 text-error">
        <ShieldAlert className="size-6" />
        <span className="text-base font-medium">
          {t("common.missing-permission")}
        </span>
      </div>
      <div className="text-sm text-control-light flex items-center gap-x-1">
        <Trans
          t={t}
          i18nKey="sql-editor.allow-admin-mode-only"
          components={{
            instance: (
              <span className="inline-flex items-center gap-x-1 font-medium text-control">
                <EngineIcon engine={instance.engine} className="size-4" />
                <span>{instance.title}</span>
              </span>
            ),
          }}
        />
      </div>
      <AdminModeButton />
    </div>
  );
}