mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Hide RLS disabled CTA in table editor header if no lints (#41517)
* Hide RLS disabled CTA in table editor header if no lints * Clean * Update e2e tests * INvlidate lints when creating tbale * Revert * Invalidate lints when duplicating table
This commit is contained in:
1 parent
f9cbf661ca
commit
a88c88fa36
5 files changed
+27
-9
No files matched your search
@@ -35,11 +35,9 @@ import {
|
||||
Form_Shadcn_,
|
||||
Input_Shadcn_,
|
||||
PrePostTab,
|
||||
Separator,
|
||||
Skeleton,
|
||||
Switch,
|
||||
WarningIcon,
|
||||
cn,
|
||||
} from 'ui'
|
||||
import { GenericSkeletonLoader } from 'ui-patterns'
|
||||
import { Admonition } from 'ui-patterns/admonition'
|
||||
|
||||
@@ -161,6 +161,14 @@ export const GridHeaderActions = ({ table, isRefetching }: GridHeaderActionsProp
|
||||
// This will change when we allow autogenerated API docs for schemas other than `public`
|
||||
const doesHaveAutoGeneratedAPIDocs = table.schema === 'public'
|
||||
|
||||
const { hasLint: tableHasLints } = getEntityLintDetails(
|
||||
table.name,
|
||||
'rls_disabled_in_public',
|
||||
['ERROR'],
|
||||
lints,
|
||||
table.schema
|
||||
)
|
||||
|
||||
const { hasLint: viewHasLints, matchingLint: matchingViewLint } = getEntityLintDetails(
|
||||
table.name,
|
||||
'security_definer_view',
|
||||
@@ -301,7 +309,7 @@ export const GridHeaderActions = ({ table, isRefetching }: GridHeaderActionsProp
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
) : tableHasLints ? (
|
||||
<Popover_Shadcn_ modal={false} open={showWarning} onOpenChange={setShowWarning}>
|
||||
<PopoverTrigger_Shadcn_ asChild>
|
||||
<Button type="danger" icon={<Lock strokeWidth={1.5} />}>
|
||||
@@ -338,7 +346,7 @@ export const GridHeaderActions = ({ table, isRefetching }: GridHeaderActionsProp
|
||||
</div>
|
||||
</PopoverContent_Shadcn_>
|
||||
</Popover_Shadcn_>
|
||||
)
|
||||
) : null
|
||||
) : null}
|
||||
|
||||
{isTable && isIndexAdvisorAvailable && !isIndexAdvisorEnabled && (
|
||||
|
||||
@@ -15,6 +15,7 @@ import type { ForeignKeyConstraint } from 'data/database/foreign-key-constraints
|
||||
import { databaseKeys } from 'data/database/keys'
|
||||
import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'
|
||||
import { entityTypeKeys } from 'data/entity-types/keys'
|
||||
import { lintKeys } from 'data/lint/keys'
|
||||
import { privilegeKeys } from 'data/privileges/keys'
|
||||
import { tableEditorKeys } from 'data/table-editor/keys'
|
||||
import { isTableLike } from 'data/table-editor/table-editor-types'
|
||||
@@ -530,6 +531,7 @@ export const SidePanelEditor = ({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: privilegeKeys.tablePrivilegesList(project?.ref),
|
||||
}),
|
||||
queryClient.invalidateQueries({ queryKey: lintKeys.lint(project?.ref) }),
|
||||
])
|
||||
|
||||
// Show success toast after everything is complete
|
||||
@@ -583,6 +585,7 @@ export const SidePanelEditor = ({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: privilegeKeys.tablePrivilegesList(project?.ref),
|
||||
}),
|
||||
queryClient.invalidateQueries({ queryKey: lintKeys.lint(project?.ref) }),
|
||||
])
|
||||
|
||||
toast.success(
|
||||
|
||||
@@ -3,6 +3,7 @@ import { toast } from 'sonner'
|
||||
|
||||
import { components } from 'api-types'
|
||||
import { handleError, patch } from 'data/fetchers'
|
||||
import { lintKeys } from 'data/lint/keys'
|
||||
import type { ResponseError, UseCustomMutationOptions } from 'types'
|
||||
import { configKeys } from './keys'
|
||||
|
||||
@@ -63,7 +64,10 @@ export const useProjectPostgrestConfigUpdateMutation = ({
|
||||
mutationFn: (vars) => updateProjectPostgrestConfig(vars),
|
||||
async onSuccess(data, variables, context) {
|
||||
const { projectRef } = variables
|
||||
queryClient.invalidateQueries({ queryKey: configKeys.postgrest(projectRef) })
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: configKeys.postgrest(projectRef) }),
|
||||
queryClient.invalidateQueries({ queryKey: lintKeys.lint(projectRef) }),
|
||||
])
|
||||
await onSuccess?.(data, variables, context)
|
||||
},
|
||||
async onError(data, variables, context) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { expect, Locator, Page } from '@playwright/test'
|
||||
import { expect, Page } from '@playwright/test'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { isCLI } from '../utils/is-cli.js'
|
||||
import { env } from '../env.config.js'
|
||||
import { releaseFileOnceCleanup, withFileOnceSetup } from '../utils/once-per-file.js'
|
||||
import { resetLocalStorage } from '../utils/reset-local-storage.js'
|
||||
import { test } from '../utils/test.js'
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
waitForGridDataToLoad,
|
||||
waitForTableToLoad,
|
||||
} from '../utils/wait-for-response.js'
|
||||
import { env } from '../env.config.js'
|
||||
|
||||
const tableNamePrefix = 'pw_table'
|
||||
const columnName = 'pw_column'
|
||||
@@ -244,14 +243,20 @@ testRunner('table editor', () => {
|
||||
await page.getByTestId('table-name-input').fill(tableNameRlsDisabled)
|
||||
await page.getByLabel('Enable Row Level Security (').click()
|
||||
await page.getByRole('button', { name: 'Confirm' }).click()
|
||||
|
||||
// Wait for table creation
|
||||
const apiPromise = waitForApiResponse(
|
||||
page,
|
||||
'pg-meta',
|
||||
ref,
|
||||
'tables?include_columns=false&included_schemas=public'
|
||||
) // wait for table creation
|
||||
)
|
||||
// Wait for lints refresh
|
||||
const lintsPromise = waitForApiResponse(page, 'projects', ref, 'run-lints')
|
||||
|
||||
await page.getByRole('button', { name: 'Save' }).click()
|
||||
await apiPromise
|
||||
await lintsPromise
|
||||
await page.getByRole('button', { name: `View ${tableNameRlsDisabled}` }).click()
|
||||
await expect(page.getByRole('button', { name: 'RLS disabled' })).toBeVisible()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user