The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(studio): storage policy editor auto-selects select when update or delete is chose (#40924)
Vaibhav183e5c04c7a2
diff --git a/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx b/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsxindex 4b013668ce2..c3f2492d349 100644--- a/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx+++ b/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditPolicyModal.tsx@@ -102,9 +102,25 @@ const StoragePoliciesEditPolicyModal = ({allowedOperations: [operation],})}- const updatedAllowedOperations = policyFormFields.allowedOperations.includes(operation)- ? pull(policyFormFields.allowedOperations.slice(), operation)- : policyFormFields.allowedOperations.concat([operation])++ const currentOps = policyFormFields.allowedOperations+ const isRemoving = currentOps.includes(operation)+ let updatedAllowedOperations = isRemoving+ ? pull(currentOps.slice(), operation)+ : currentOps.concat([operation])++ if (!isRemoving && (operation === 'UPDATE' || operation === 'DELETE')) {+ if (!updatedAllowedOperations.includes('SELECT')) {+ updatedAllowedOperations = updatedAllowedOperations.concat(['SELECT'])+ }+ }++ if (isRemoving && operation === 'SELECT') {+ updatedAllowedOperations = updatedAllowedOperations.filter(+ (op: string) => op !== 'UPDATE' && op !== 'DELETE'+ )+ }+return setPolicyFormFields({...policyFormFields,allowedOperations: updatedAllowedOperations,diff --git a/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditor.tsx b/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditor.tsxindex ce58d3b5f36..b9e3a4b623e 100644--- a/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditor.tsx+++ b/apps/studio/components/interfaces/Storage/StoragePolicies/StoragePoliciesEditor.tsx@@ -28,6 +28,9 @@ const PolicyDefinition = ({ definition = '', onUpdatePolicyDefinition = () => {}const PolicyAllowedOperations = ({ allowedOperations = [], onToggleOperation = () => {} }: any) => {const allowedClientLibraryMethods = deriveAllowedClientLibraryMethods(allowedOperations)+ const hasUpdateOrDelete =+ allowedOperations.includes('UPDATE') || allowedOperations.includes('DELETE')+return (<div className="flex flex-col md:flex-row justify-between gap-4 md:gap-12"><div className="flex md:w-1/3 flex-col space-y-2">@@ -70,6 +73,12 @@ const PolicyAllowedOperations = ({ allowedOperations = [], onToggleOperation = (checked={allowedOperations.includes('DELETE')}/></div>+ {hasUpdateOrDelete && (+ <p className="text-sm text-foreground-light mt-3 prose [&>code]:text-xs">+ <code>SELECT</code> has been auto selected as <code>UPDATE</code> and{' '}+ <code>DELETE</code> require it+ </p>+ )}<div className="flex w-5/6 flex-wrap">{Object.keys(STORAGE_CLIENT_LIBRARY_MAPPINGS).map((method) => (<ul key={method} className="mr-2 mt-2 list-none">