Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add isReadOnly flag into QueryEditor component (#49378)

Joshen Lim502e0f9b09ad
diff --git a/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx b/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx
index 8285eb878f0..87b9579e860 100644
--- a/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx
+++ b/apps/studio/components/interfaces/Explorer/QueryEditor/index.tsx
@@ -101,6 +101,7 @@ export type QueryEditorHandle = {
type QueryEditorProps = {
id: string
+ isReadOnly?: boolean
variant: 'embedded' | 'viewport'
title: string
query: ExplorerQueryModel
@@ -131,6 +132,7 @@ type QueryEditorProps = {
export const QueryEditor = forwardRef<QueryEditorHandle, QueryEditorProps>(function QueryEditor(
{
id,
+ isReadOnly = false,
variant,
title,
query,
@@ -261,7 +263,7 @@ export const QueryEditor = forwardRef<QueryEditorHandle, QueryEditorProps>(funct
}
const acceptSqlProposal = () => {
- if (!pendingProposal) return
+ if (isReadOnly || !pendingProposal) return
if (sql === pendingProposal.original) {
onSqlChange(pendingProposal.modified)
onSqlCommit?.(pendingProposal.modified)
@@ -381,6 +383,7 @@ export const QueryEditor = forwardRef<QueryEditorHandle, QueryEditorProps>(funct
<CodeEditor
id={`explorer-query-${id}`}
language="pgsql"
+ isReadOnly={isReadOnly}
value={sql}
placeholder={!promptState?.isOpen ? generatePlaceholder(os) : ''}
placeholderClassName="top-[13px]"
diff --git a/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx b/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx
index 6369797c915..d78769f65eb 100644
--- a/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/AssistantQueryCell.tsx
@@ -137,6 +137,7 @@ export const AssistantQueryCell = ({
onConfirm={onApprove}
>
<QueryEditor
+ isReadOnly
id={id}
variant="viewport"
title={title}