The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: migrate auth policy editor modal to dialog (#46374)
hasithasandun108a7c2c11d2
diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/PolicyEditorFooter.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/PolicyEditorFooter.tsxindex 95de3c6d6aa..4cb1b279e9a 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/PolicyEditorFooter.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/PolicyEditorFooter.tsx@@ -1,5 +1,5 @@import { noop } from 'lodash'-import { Button } from 'ui'+import { Button, DialogFooter } from 'ui'interface PolicyEditorFooterProps {showTemplates: boolean@@ -12,18 +12,16 @@ const PolicyEditorFooter = ({onViewTemplates = noop,onReviewPolicy = noop,}: PolicyEditorFooterProps) => (- <div className="flex justify-between items-center border-t px-6 py-4 border-default">- <div className="flex w-full items-center justify-end gap-2">- {showTemplates && (- <Button type="default" onClick={onViewTemplates}>- View templates- </Button>- )}- <Button type="primary" onClick={onReviewPolicy}>- Review+ <DialogFooter>+ {showTemplates && (+ <Button type="default" onClick={onViewTemplates}>+ View templates</Button>- </div>- </div>+ )}+ <Button type="primary" onClick={onReviewPolicy}>+ Review+ </Button>+ </DialogFooter>)export default PolicyEditorFooterdiff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/index.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/index.tsxindex e004ff673b0..3121ed24808 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/index.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditor/index.tsx@@ -1,4 +1,4 @@-import { Modal } from 'ui'+import { DialogSection, DialogSectionSeparator } from 'ui'import PolicyAllowedOperation from './PolicyAllowedOperation'import PolicyDefinition from './PolicyDefinition'@@ -29,34 +29,34 @@ export const PolicyEditor = ({const selectedRoles = (policyFormFields?.roles ?? []).filter((role: string) => role !== 'public')return (- <div>- <Modal.Content>+ <>+ <DialogSection><PolicyNamename={policyFormFields.name}limit={63}onUpdatePolicyName={(name) => onUpdatePolicyFormFields({ name })}/>- </Modal.Content>- <Modal.Separator />+ </DialogSection>+ <DialogSectionSeparator />{isNewPolicy && (<>- <Modal.Content>+ <DialogSection><PolicyAllowedOperationoperation={operation}onSelectOperation={(command) => onUpdatePolicyFormFields({ command })}/>- </Modal.Content>- <Modal.Separator />+ </DialogSection>+ <DialogSectionSeparator /></>)}- <Modal.Content>+ <DialogSection><PolicyRolesselectedRoles={selectedRoles}onUpdateSelectedRoles={(roles) => onUpdatePolicyFormFields({ roles })}/>- </Modal.Content>- <Modal.Separator />- <Modal.Content>+ </DialogSection>+ <DialogSectionSeparator />+ <DialogSection><PolicyDefinitionoperation={operation}definition={definition}@@ -66,12 +66,12 @@ export const PolicyEditor = ({}onUpdatePolicyCheck={(check: string | undefined) => onUpdatePolicyFormFields({ check })}/>- </Modal.Content>+ </DialogSection><PolicyEditorFootershowTemplates={isNewPolicy}onViewTemplates={onViewTemplates}onReviewPolicy={onReviewPolicy}/>- </div>+ </>)}diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsxindex ba98ee0bdfb..0a59f44c760 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx@@ -2,7 +2,7 @@ import { acceptUntrustedSql, PGPolicy } from '@supabase/pg-meta'import { isEmpty, noop } from 'lodash'import { useCallback, useEffect, useState } from 'react'import { toast } from 'sonner'-import { Modal } from 'ui'+import { Dialog, DialogContent, DialogHeader, DialogTitle } from 'ui'import { POLICY_MODAL_VIEWS } from '../Policies.constants'import {@@ -201,57 +201,56 @@ export const PolicyEditorModal = ({}return (- <Modal- hideFooter- size={view === POLICY_MODAL_VIEWS.SELECTION ? 'medium' : 'xxlarge'}- visible={visible}- contentStyle={{ padding: 0 }}- header={[- <PolicyEditorModalTitle- key="0"- view={view}- isNewPolicy={isNewPolicy}- schema={schema}- table={table}- showAssistantPreview={showAssistantPreview}- onSelectBackFromTemplates={onSelectBackFromTemplates}- onToggleFeaturePreviewModal={onToggleFeaturePreviewModal}- />,- ]}- onCancel={confirmOnClose}- >- <div>- <DiscardChangesConfirmationDialog {...modalProps} />- {view === POLICY_MODAL_VIEWS.SELECTION ? (- <PolicySelection- description="Write rules with PostgreSQL's policies to fit your unique business needs."- onViewTemplates={onViewTemplates}- onViewEditor={onViewEditor}- showAssistantPreview={showAssistantPreview}- onToggleFeaturePreviewModal={onToggleFeaturePreviewModal}- />- ) : view === POLICY_MODAL_VIEWS.EDITOR ? (- <PolicyEditor- isNewPolicy={isNewPolicy}- policyFormFields={policyFormFields}- onUpdatePolicyFormFields={onUpdatePolicyFormFields}- onViewTemplates={onViewTemplates}- onReviewPolicy={validatePolicyFormFields}- />- ) : view === POLICY_MODAL_VIEWS.TEMPLATES ? (- <PolicyTemplates- templates={getGeneralPolicyTemplates(schema, table).filter((policy) => !policy.preview)}- templatesNote="* References a specific column in the table"- onUseTemplate={onUseTemplate}- />- ) : view === POLICY_MODAL_VIEWS.REVIEW && !!policyStatementForReview ? (- <PolicyReview- policy={policyStatementForReview}- onSelectBack={onViewEditor}- onSelectSave={onReviewSave}- />- ) : null}- </div>- </Modal>+ <Dialog open={visible} onOpenChange={(open) => !open && confirmOnClose()}>+ <DialogContent size={view === POLICY_MODAL_VIEWS.SELECTION ? 'medium' : 'xxlarge'}>+ <DialogHeader className="border-b">+ <DialogTitle>+ <PolicyEditorModalTitle+ view={view}+ isNewPolicy={isNewPolicy}+ schema={schema}+ table={table}+ showAssistantPreview={showAssistantPreview}+ onSelectBackFromTemplates={onSelectBackFromTemplates}+ onToggleFeaturePreviewModal={onToggleFeaturePreviewModal}+ />+ </DialogTitle>+ </DialogHeader>+ <div>+ <DiscardChangesConfirmationDialog {...modalProps} />+ {view === POLICY_MODAL_VIEWS.SELECTION ? (+ <PolicySelection+ description="Write rules with PostgreSQL's policies to fit your unique business needs."+ onViewTemplates={onViewTemplates}+ onViewEditor={onViewEditor}+ showAssistantPreview={showAssistantPreview}+ onToggleFeaturePreviewModal={onToggleFeaturePreviewModal}+ />+ ) : view === POLICY_MODAL_VIEWS.EDITOR ? (+ <PolicyEditor+ isNewPolicy={isNewPolicy}+ policyFormFields={policyFormFields}+ onUpdatePolicyFormFields={onUpdatePolicyFormFields}+ onViewTemplates={onViewTemplates}+ onReviewPolicy={validatePolicyFormFields}+ />+ ) : view === POLICY_MODAL_VIEWS.TEMPLATES ? (+ <PolicyTemplates+ templates={getGeneralPolicyTemplates(schema, table).filter(+ (policy) => !policy.preview+ )}+ templatesNote="* References a specific column in the table"+ onUseTemplate={onUseTemplate}+ />+ ) : view === POLICY_MODAL_VIEWS.REVIEW && !!policyStatementForReview ? (+ <PolicyReview+ policy={policyStatementForReview}+ onSelectBack={onViewEditor}+ onSelectSave={onReviewSave}+ />+ ) : null}+ </div>+ </DialogContent>+ </Dialog>)}diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyReview.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyReview.tsxindex fad0f484dc2..3b097cd5a21 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyReview.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyReview.tsx@@ -1,6 +1,6 @@import { isEmpty, noop } from 'lodash'import { useState } from 'react'-import { Button, Modal } from 'ui'+import { Button, DialogFooter, DialogSection } from 'ui'import type { PolicyForReview } from './Policies.types'import SqlEditor from '@/components/ui/SqlEditor'@@ -26,7 +26,7 @@ export const PolicyReview = ({return (<>- <Modal.Content>+ <DialogSection><div className="space-y-6"><div className="flex items-center justify-between space-y-8"><div className="flex flex-col">@@ -52,15 +52,15 @@ export const PolicyReview = ({)}</div></div>- </Modal.Content>- <div className="flex w-full items-center justify-end gap-2 border-t px-6 py-4 border-default">+ </DialogSection>+ <DialogFooter><Button type="default" onClick={onSelectBack}>Back to edit</Button><Button type="primary" disabled={isEmpty(policy)} onClick={onSavePolicy} loading={isSaving}>Save policy</Button>- </div>+ </DialogFooter></>)}