Skip to content

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

Chore/lint gridheaderactions (#26750)

Terry Sutton24f9b54db13d
diff --git a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
index bc039ac81f4..e6b407c778f 100644
--- a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
@@ -23,7 +23,7 @@ import useEntityType from 'hooks/misc/useEntityType'
import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'
import { useProjectLintsQuery } from 'data/lint/lint-query'
import { TableLike } from 'hooks/misc/useTable'
-import { checkEntityForLints } from 'components/interfaces/TableGridEditor/TableEntity.utils'
+import { getEntityLintDetails } from 'components/interfaces/TableGridEditor/TableEntity.utils'
export interface GridHeaderActionsProps {
table: TableLike
@@ -99,20 +99,22 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
// This will change when we allow autogenerated API docs for schemas other than `public`
const doesHaveAutoGeneratedAPIDocs = table.schema === 'public'
- const viewHasLints = checkEntityForLints(
+ const viewHasLints: boolean = getEntityLintDetails(
table.name,
'security_definer_view',
['ERROR', 'WARN'],
lints,
table.schema
- )
- const materializedViewHasLints = checkEntityForLints(
+ ).hasLint
+
+ const materializedViewHasLints: boolean = getEntityLintDetails(
table.name,
'materialized_view_in_api',
['ERROR', 'WARN'],
lints,
table.schema
- )
+ ).hasLint
+
const toggleRealtime = async () => {
if (!project) return console.error('Project is required')
if (!realtimePublication) return console.error('Unable to find realtime publication')
diff --git a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts
index 41ab7d165b2..a0c828b34d1 100644
--- a/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts
+++ b/apps/studio/components/interfaces/TableGridEditor/TableEntity.utils.ts
@@ -1,6 +1,6 @@
import { Lint } from '../../../data/lint/lint-query'
-export const checkEntityForLints = (
+export const getEntityLintDetails = (
entityName: string,
lintName: string,
lintLevels: ('ERROR' | 'WARN')[],
diff --git a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
index de10485198e..45f41fe04ad 100644
--- a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
+++ b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
@@ -28,8 +28,7 @@ import {
} from 'ui'
import { useProjectContext } from '../ProjectLayout/ProjectContext'
import { useProjectLintsQuery } from 'data/lint/lint-query'
-import { Lint } from '../../../data/lint/lint-query'
-import { checkEntityForLints } from 'components/interfaces/TableGridEditor/TableEntity.utils'
+import { getEntityLintDetails } from 'components/interfaces/TableGridEditor/TableEntity.utils'
export interface EntityListItemProps {
id: number
@@ -52,28 +51,29 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({
projectRef: project?.ref,
})
- const tableHasLints = checkEntityForLints(
+ const tableHasLints: boolean = getEntityLintDetails(
entity.name,
'rls_disabled_in_public',
['ERROR'],
lints,
snap.selectedSchemaName
- )
+ ).hasLint
- const viewHasLints = checkEntityForLints(
+ const viewHasLints: boolean = getEntityLintDetails(
entity.name,
'security_definer_view',
['ERROR', 'WARN'],
lints,
snap.selectedSchemaName
- )
- const materializedViewHasLints = checkEntityForLints(
+ ).hasLint
+
+ const materializedViewHasLints: boolean = getEntityLintDetails(
entity.name,
'materialized_view_in_api',
['ERROR', 'WARN'],
lints,
snap.selectedSchemaName
- )
+ ).hasLint
const formatTooltipText = (entityType: string) => {
return Object.entries(ENTITY_TYPE)
@@ -140,17 +140,17 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({
switch (entity.type) {
case ENTITY_TYPE.TABLE:
- if (tableHasLints.hasLint) {
+ if (tableHasLints) {
tooltipContent = 'RLS Disabled'
}
break
case ENTITY_TYPE.VIEW:
- if (viewHasLints.hasLint) {
+ if (viewHasLints) {
tooltipContent = 'Security Definer view'
}
break
case ENTITY_TYPE.MATERIALIZED_VIEW:
- if (materializedViewHasLints.hasLint) {
+ if (materializedViewHasLints) {
tooltipContent = 'Security Definer view'
}