Files
supabase/apps/studio/components/interfaces/Database/ProtectedSchemaWarning.tsx
T
Ivan VasilovandJoshen Lim 05a542ccea chore: Migrate all feather icons to lucide icons (#29038)
* Add lucide-react to docs (to make the autocomplete work).

* Migrate the docs app icons.

* Migrate the ui-patterns.

* Remove the old icons from ui package.

* Migrate the www app from react-feather icons.

* Migrate all of studio icons.

* Migrate the only component in design-system.

* Fix an old import in ui package. Revert an import in docs app.

* Fix some pages in www.

* Remove unneeded files used in generation of icons.

* Fix a prettier error.

* Fix more issues in www.

* Fix an issue in Log Date picker.

* Replace all string sizes with number sizes because the icons grew in some cases.

* Fix more imports in security page.

* Fix an extra import.

* Remove the size prop from all icons if they're in a button and they match the button size.

* Minor fixes for docs and www.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-09-04 19:46:21 +08:00

77 lines
2.4 KiB
TypeScript

import { useState } from 'react'
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, Modal } from 'ui'
import { EXCLUDED_SCHEMAS } from 'lib/constants/schemas'
import { AlertCircle } from 'lucide-react'
export const ProtectedSchemaModal = ({
visible,
onClose,
}: {
visible: boolean
onClose: () => void
}) => {
return (
<Modal
size="medium"
visible={visible}
header="Schemas managed by Supabase"
customFooter={
<div className="flex items-center justify-end space-x-2">
<Button type="default" onClick={() => onClose()}>
Understood
</Button>
</div>
}
onCancel={() => onClose()}
>
<Modal.Content className="space-y-2">
<p className="text-sm">
The following schemas are managed by Supabase and are currently protected from write
access through the dashboard.
</p>
<div className="flex flex-wrap gap-1">
{EXCLUDED_SCHEMAS.map((schema) => (
<code key={schema} className="text-xs">
{schema}
</code>
))}
</div>
<p className="text-sm !mt-4">
These schemas are critical to the functionality of your Supabase project and hence we
highly recommend not altering them.
</p>
<p className="text-sm">
You can, however, still interact with those schemas through the SQL Editor although we
advise you only do so if you know what you are doing.
</p>
</Modal.Content>
</Modal>
)
}
const ProtectedSchemaWarning = ({ schema, entity }: { schema: string; entity: string }) => {
const [showModal, setShowModal] = useState(false)
return (
<>
<Alert_Shadcn_>
<AlertCircle strokeWidth={2} />
<AlertTitle_Shadcn_>Currently viewing {entity} from a protected schema</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
<p className="mb-2">
The <code className="text-xs">{schema}</code> schema is managed by Supabase and is
read-only through the dashboard.
</p>
<Button type="default" size="tiny" onClick={() => setShowModal(true)}>
Learn more
</Button>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
<ProtectedSchemaModal visible={showModal} onClose={() => setShowModal(false)} />
</>
)
}
export default ProtectedSchemaWarning