diff --git a/studio/pages/project/[ref]/auth/policies.tsx b/studio/pages/project/[ref]/auth/policies.tsx index 742856bad92..ad05297811a 100644 --- a/studio/pages/project/[ref]/auth/policies.tsx +++ b/studio/pages/project/[ref]/auth/policies.tsx @@ -10,6 +10,7 @@ import { AuthLayout } from 'components/layouts' import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' import AlertError from 'components/ui/AlertError' import NoPermission from 'components/ui/NoPermission' +import SchemaSelector from 'components/ui/SchemaSelector' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useSchemasQuery } from 'data/database/schemas-query' import { useTablesQuery } from 'data/tables/tables-query' @@ -17,7 +18,7 @@ import { useCheckPermissions, useStore } from 'hooks' import { EXCLUDED_SCHEMAS } from 'lib/constants/schemas' import { useTableEditorStateSnapshot } from 'state/table-editor' import { NextPageWithLayout } from 'types' -import { Button, IconExternalLink, IconLock, IconSearch, Input, Listbox } from 'ui' +import { Button, IconExternalLink, IconSearch, Input } from 'ui' /** * Filter tables by table name and policy name @@ -65,17 +66,11 @@ const AuthPoliciesPage: NextPageWithLayout = () => { if (search) setSearchString(search) }, [search]) - const { - data: schemas, - isLoading: isLoadingSchemas, - isSuccess: isSuccessSchemas, - isError: isErrorSchemas, - error: errorSchemas, - } = useSchemasQuery({ + const { data: schemas } = useSchemasQuery({ projectRef: project?.ref, connectionString: project?.connectionString, }) - const [protectedSchemas, openSchemas] = partition(schemas, (schema) => + const [protectedSchemas] = partition(schemas, (schema) => EXCLUDED_SCHEMAS.includes(schema?.name ?? '') ) const schema = schemas?.find((schema) => schema.name === snap.selectedSchemaName) @@ -96,7 +91,6 @@ const AuthPoliciesPage: NextPageWithLayout = () => { }) const filteredTables = onFilterTables(tables ?? [], policies, searchString) - const canReadPolicies = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_READ, 'policies') if (!canReadPolicies) { @@ -108,64 +102,16 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
-
- {isLoadingSchemas && ( -
- )} - - {isErrorSchemas && ( - - )} - - {isSuccessSchemas && ( - { - snap.setSelectedSchemaName(schema) - setSearchString('') - }} - icon={isLocked && } - > - -

Schemas

-
- {openSchemas.map((schema) => ( - schema} - > - {schema.name} - - ))} - -

Protected schemas

-
- {protectedSchemas.map((schema) => ( - schema} - > - {schema.name} - - ))} -
- )} -
+ { + snap.setSelectedSchemaName(schema) + setSearchString('') + }} + />