Skip to content

Commit ef2027f

Browse files
Check whether schema is protected when setting table editor actions Co-authored-by: Ali Waseem <[email protected]>
1 parent f2a0139 commit ef2027f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

apps/studio/components/layouts/Tabs/NewTab.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import { useEditorType } from '../editors/EditorsLayout.hooks'
4040
import { ActionCard } from './ActionCard'
4141
import { RecentItems } from './RecentItems'
4242
import { SIDEBAR_KEYS } from '../ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
43+
import { useQuerySchemaState } from 'hooks/misc/useSchemaQueryState'
44+
import { useIsProtectedSchema } from 'hooks/useProtectedSchemas'
4345

4446
const NEW_PROJECT_THRESHOLD_DAYS = 7
4547
const TABLE_QUICKSTART_FLAG = 'tableQuickstart'
@@ -57,6 +59,8 @@ export function NewTab() {
5759
const { profile } = useProfile()
5860
const { data: org } = useSelectedOrganizationQuery()
5961
const { data: project } = useSelectedProjectQuery()
62+
const { selectedSchema } = useQuerySchemaState()
63+
const { isSchemaLocked } = useIsProtectedSchema({ schema: selectedSchema })
6064

6165
const snap = useTableEditorStateSnapshot()
6266
const snapV2 = useSqlEditorV2StateSnapshot()
@@ -161,16 +165,18 @@ export function NewTab() {
161165
}
162166
}
163167

164-
const tableEditorActions = [
165-
{
166-
icon: <Table2 className="h-4 w-4 text-foreground" strokeWidth={1.5} />,
167-
title: 'Create a table',
168-
description: 'Design and create a new database table',
169-
bgColor: 'bg-blue-500',
170-
isBeta: false,
171-
onClick: () => snap.onAddTable(),
172-
},
173-
]
168+
const tableEditorActions = isSchemaLocked
169+
? []
170+
: [
171+
{
172+
icon: <Table2 className="h-4 w-4 text-foreground" strokeWidth={1.5} />,
173+
title: 'Create a table',
174+
description: 'Design and create a new database table',
175+
bgColor: 'bg-blue-500',
176+
isBeta: false,
177+
onClick: () => snap.onAddTable(),
178+
},
179+
]
174180

175181
const sqlEditorActions = [
176182
{

0 commit comments

Comments
 (0)