The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
UI clean up and ensure formatting of SQL in policy review is formatted nicely
Joshen Lim91e838ff9de0
diff --git a/studio/components/interfaces/Authentication/Policies/Policies.utils.ts b/studio/components/interfaces/Authentication/Policies/Policies.utils.tsindex cebb9443387..d536f5f21d9 100644--- a/studio/components/interfaces/Authentication/Policies/Policies.utils.ts+++ b/studio/components/interfaces/Authentication/Policies/Policies.utils.ts@@ -49,16 +49,14 @@ export const createSQLStatementForCreatePolicy = (policyFormFields: any) => {const { name, definition, check, command, schema, table } = policyFormFieldsconst roles = policyFormFields.roles.length === 0 ? ['public'] : policyFormFields.rolesconst description = `Add policy for the ${command} operation under the policy "${name}"`- const statement =- `- CREATE POLICY "${name}" ON "${schema}"."${table}"- AS PERMISSIVE FOR ${command}- TO ${roles.join(', ')}- ${definition ? `USING (${definition})` : ''}- ${check ? `WITH CHECK (${check})` : ''}- `- .replace(/\s+/g, ' ')- .trim() + ';'+ const statement = [+ `CREATE POLICY "${name}" ON "${schema}"."${table}"`,+ `AS PERMISSIVE FOR ${command}`,+ `TO ${roles.join(', ')}`,+ `${definition ? `USING (${definition})` : ''}`,+ `${check ? `WITH CHECK (${check})` : ''}`,+ ].join('\n')+return { description, statement }}@@ -83,16 +81,14 @@ export const createSQLStatementForUpdatePolicy = (} `const alterStatement = `ALTER POLICY "${name}" ON "${schema}"."${table}"`- const statement = `- BEGIN;- ${definitionChanged ? `${alterStatement} USING (${fieldsToUpdate.definition});` : ''}- ${checkChanged ? `${alterStatement} WITH CHECK (${fieldsToUpdate.check});` : ''}- ${rolesChanged ? `${alterStatement} TO ${fieldsToUpdate.roles.join(', ')};` : ''}- ${nameChanged ? `${alterStatement} RENAME TO "${fieldsToUpdate.name}";` : ''}- COMMIT;- `- .replace(/\s+/g, ' ')- .trim()+ const statement = [+ 'BEGIN;',+ ...(definitionChanged ? [` ${alterStatement} USING (${fieldsToUpdate.definition});`] : []),+ ...(checkChanged ? [` ${alterStatement} WITH CHECK (${fieldsToUpdate.check});`] : []),+ ...(rolesChanged ? [` ${alterStatement} TO ${fieldsToUpdate.roles.join(', ')};`] : []),+ ...(nameChanged ? [` ${alterStatement} RENAME TO "${fieldsToUpdate.name}";`] : []),+ 'COMMIT;',+ ].join('\n')return { description, statement }}diff --git a/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyAllowedOperation.tsx b/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyAllowedOperation.tsxindex fc6adc8ac6e..e485ebb1587 100644--- a/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyAllowedOperation.tsx+++ b/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyAllowedOperation.tsx@@ -13,11 +13,11 @@ const PolicyAllowedOperation: FC<Props> = ({ operation = '', onSelectOperation }<label className="text-scale-1100 text-base" htmlFor="allowed-operation">Allowed operation</label>- <p className="text-scale-900 text-sm">Selection an operation for this policy</p>+ <p className="text-scale-900 text-sm">Select an operation for this policy</p></div><div className="w-2/3"><div className="flex items-center space-x-8">- <Radio.Group type="small-cards" id="allowed-operation">+ <Radio.Group type="small-cards" size="tiny" id="allowed-operation"><Radioname="allowed-operation"label="SELECT"diff --git a/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyRoles.tsx b/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyRoles.tsxindex 3ace51e6b1d..3c617fc31c4 100644--- a/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyRoles.tsx+++ b/studio/components/interfaces/Authentication/Policies/PolicyEditor/PolicyRoles.tsx@@ -24,20 +24,17 @@ const PolicyRoles: FC<Props> = ({ roles, selectedRoles, onUpdateSelectedRoles })<div className="flex space-x-12"><div className="flex w-1/3 flex-col space-y-2"><label className="text-scale-1100 text-base" htmlFor="policy-name">- Roles+ Target roles</label>- <p className="text-scale-900 text-sm">Apply policy to the specified roles</p>+ <p className="text-scale-900 text-sm">Apply policy to the selected roles</p></div><div className="relative w-2/3"><MultiSelectoptions={formattedRoles}value={selectedRoles}- placeholder='Defaults to "public" role if none selected'+ placeholder="Defaults to all roles if none selected"searchPlaceholder="Search for a role"- onChange={(updatedRoles) => {- // const selectedRoles = roles.filter((role) => updatedRoles.includes(role.name))- onUpdateSelectedRoles(updatedRoles)- }}+ onChange={onUpdateSelectedRoles}/></div></div>diff --git a/studio/components/interfaces/Authentication/Policies/PolicyEditor/index.tsx b/studio/components/interfaces/Authentication/Policies/PolicyEditor/index.tsxindex 1e47165d4d6..454a6f7da33 100644--- a/studio/components/interfaces/Authentication/Policies/PolicyEditor/index.tsx+++ b/studio/components/interfaces/Authentication/Policies/PolicyEditor/index.tsx@@ -35,7 +35,7 @@ const PolicyEditor: FC<Props> = ({return (<div className="">- <div className="space-y-8 py-8">+ <div className="max-h-[600px] space-y-8 overflow-y-auto py-8"><Modal.Content><PolicyNamename={policyFormFields.name}