Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update storage policies styling

Joshen Lim66ad93f84736
diff --git a/studio/components/interfaces/SQLEditor/ResultsPane.tsx b/studio/components/interfaces/SQLEditor/ResultsPane.tsx
index 9e3f1dadf10..82a67e44ec2 100644
--- a/studio/components/interfaces/SQLEditor/ResultsPane.tsx
+++ b/studio/components/interfaces/SQLEditor/ResultsPane.tsx
@@ -29,8 +29,8 @@ const ResultsPane: FC<Props> = ({ results }) => {
}
const columnRender = (name: string) => {
return (
- <div className="flex items-center justify-center font-mono h-full">
- <Typography.Text small>{name}</Typography.Text>
+ <div className="flex items-center justify-center h-full">
+ <p className="text-sm font-mono">{name}</p>
</div>
)
}
diff --git a/studio/components/to-be-cleaned/SqlEditor/TabSqlQuery.js b/studio/components/to-be-cleaned/SqlEditor/TabSqlQuery.js
index 927179bfb1a..a01167d2099 100644
--- a/studio/components/to-be-cleaned/SqlEditor/TabSqlQuery.js
+++ b/studio/components/to-be-cleaned/SqlEditor/TabSqlQuery.js
@@ -479,9 +479,7 @@ const UtilityTabResults = observer(() => {
if (sqlEditorStore.activeTab.isExecuting) {
return (
<div className="bg-table-header-light dark:bg-table-header-dark">
- <Typography.Text>
- <p className="px-6 py-4 m-0 border-0 font-mono">Running...</p>
- </Typography.Text>
+ <p className="px-6 py-4 m-0 border-0 font-mono text-sm">Running...</p>
</div>
)
} else if (sqlEditorStore.activeTab.errorResult) {
@@ -540,9 +538,7 @@ const Results = ({ results }) => {
if (!results.length) {
return (
<div className="bg-table-header-light dark:bg-table-header-dark">
- <Typography.Text>
- <p className="px-6 py-4 m-0 font-mono border-0">Success. No rows returned</p>
- </Typography.Text>
+ <p className="px-6 py-4 m-0 font-mono border-0 text-sm">Success. No rows returned</p>
</div>
)
}
diff --git a/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.js b/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.js
index c581668b023..8f11e26795e 100644
--- a/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.js
+++ b/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePolicies.js
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'
import { observer } from 'mobx-react-lite'
-import { Typography, Modal } from '@supabase/ui'
+import { IconLoader, Typography } from '@supabase/ui'
import { find, get, isEmpty, filter } from 'lodash'
import { useStore } from 'hooks'
@@ -8,7 +8,7 @@ import { formatPoliciesForStorage } from '../Storage.utils'
import StoragePoliciesPlaceholder from './StoragePoliciesPlaceholder'
import StoragePoliciesBucketRow from './StoragePoliciesBucketRow'
import StoragePoliciesEditPolicyModal from './StoragePoliciesEditPolicyModal'
-import ConfirmationModal from 'components/ui/ConfirmationModal'
+import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
import PolicyEditorModal from 'components/to-be-cleaned/Auth/PolicyEditorModal'
@@ -16,7 +16,7 @@ import PolicyEditorModal from 'components/to-be-cleaned/Auth/PolicyEditorModal'
const StoragePolicies = () => {
const { ui, meta } = useStore()
const storageStore = useStorageStore()
- const { buckets } = storageStore
+ const { loaded, buckets } = storageStore
const [policies, setPolicies] = useState([])
const [selectedPolicyToEdit, setSelectedPolicyToEdit] = useState({})
@@ -141,64 +141,68 @@ const StoragePolicies = () => {
return (
<div className="flex flex-col w-full min-h-full">
- <Typography.Title level={4} className="mb-0">
- Storage policies
- </Typography.Title>
- <Typography.Text className="opacity-50">
+ <h4 className="text-xl">Storage policies</h4>
+ <p className="text-scale-1100">
Safeguard your files with policies that define the operations allowed for your users at the
bucket level.
- </Typography.Text>
-
- <div className="space-y-4 mt-4">
- {buckets.length === 0 && <StoragePoliciesPlaceholder />}
-
- {/* Sections for policies grouped by buckets */}
- {buckets.map((bucket) => {
- const bucketPolicies = get(
- find(formattedStorageObjectPolicies, { name: bucket.name }),
- ['policies'],
- []
- )
- return (
- <StoragePoliciesBucketRow
- key={bucket.name}
- table="objects"
- label={bucket.name}
- bucket={bucket}
- policies={bucketPolicies}
- onSelectPolicyAdd={onSelectPolicyAdd}
- onSelectPolicyEdit={onSelectPolicyEdit}
- onSelectPolicyDelete={onSelectPolicyDelete}
- />
- )
- })}
-
- <div className="w-full border-b border-gray-600 !mb-4" />
- <Typography.Text className="opacity-50">
- You may also write policies for the tables under the storage schema directly for greater
- control
- </Typography.Text>
-
- {/* Section for policies under storage.objects that are not tied to any buckets */}
- <StoragePoliciesBucketRow
- table="objects"
- label="Other policies under storage.objects"
- policies={ungroupedPolicies}
- onSelectPolicyAdd={onSelectPolicyAdd}
- onSelectPolicyEdit={onSelectPolicyEdit}
- onSelectPolicyDelete={onSelectPolicyDelete}
- />
-
- {/* Section for policies under storage.buckets */}
- <StoragePoliciesBucketRow
- table="buckets"
- label="Policies under storage.buckets"
- policies={storageBucketPolicies}
- onSelectPolicyAdd={onSelectPolicyAdd}
- onSelectPolicyEdit={onSelectPolicyEdit}
- onSelectPolicyDelete={onSelectPolicyDelete}
- />
- </div>
+ </p>
+
+ {!loaded ? (
+ <div className="h-full flex items-center justify-center">
+ <IconLoader className="animate-spin" size={16} />
+ </div>
+ ) : (
+ <div className="space-y-4 mt-4">
+ {buckets.length === 0 && <StoragePoliciesPlaceholder />}
+
+ {/* Sections for policies grouped by buckets */}
+ {buckets.map((bucket) => {
+ const bucketPolicies = get(
+ find(formattedStorageObjectPolicies, { name: bucket.name }),
+ ['policies'],
+ []
+ )
+ return (
+ <StoragePoliciesBucketRow
+ key={bucket.name}
+ table="objects"
+ label={bucket.name}
+ bucket={bucket}
+ policies={bucketPolicies}
+ onSelectPolicyAdd={onSelectPolicyAdd}
+ onSelectPolicyEdit={onSelectPolicyEdit}
+ onSelectPolicyDelete={onSelectPolicyDelete}
+ />
+ )
+ })}
+
+ <div className="w-full border-b border-gray-600 !mb-4" />
+ <Typography.Text className="opacity-50">
+ You may also write policies for the tables under the storage schema directly for greater
+ control
+ </Typography.Text>
+
+ {/* Section for policies under storage.objects that are not tied to any buckets */}
+ <StoragePoliciesBucketRow
+ table="objects"
+ label="Other policies under storage.objects"
+ policies={ungroupedPolicies}
+ onSelectPolicyAdd={onSelectPolicyAdd}
+ onSelectPolicyEdit={onSelectPolicyEdit}
+ onSelectPolicyDelete={onSelectPolicyDelete}
+ />
+
+ {/* Section for policies under storage.buckets */}
+ <StoragePoliciesBucketRow
+ table="buckets"
+ label="Policies under storage.buckets"
+ policies={storageBucketPolicies}
+ onSelectPolicyAdd={onSelectPolicyAdd}
+ onSelectPolicyEdit={onSelectPolicyEdit}
+ onSelectPolicyDelete={onSelectPolicyDelete}
+ />
+ </div>
+ )}
{/* Only used for adding policies to buckets */}
<StoragePoliciesEditPolicyModal
@@ -222,18 +226,11 @@ const StoragePolicies = () => {
onSaveSuccess={onSavePolicySuccess}
/>
- <ConfirmationModal
+ <ConfirmModal
danger
visible={!isEmpty(selectedPolicyToDelete)}
title="Confirm to delete policy"
- children={
- <Modal.Content>
- <p className="py-4 text-sm text-scale-1100">
- This is permanent! Are you sure you want to delete the policy "
- {selectedPolicyToDelete.name}"
- </p>
- </Modal.Content>
- }
+ description={`This is permanent! Are you sure you want to delete the policy "${selectedPolicyToDelete.name}"`}
buttonLabel="Delete"
buttonLoadingLabel="Deleting"
onSelectCancel={onCancelPolicyDelete}
diff --git a/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesBucketRow.js b/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesBucketRow.js
index 8236c3a57f6..5a711ed12bb 100644
--- a/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesBucketRow.js
+++ b/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesBucketRow.js
@@ -1,4 +1,13 @@
-import { Badge, Button, IconArchive, Typography } from '@supabase/ui'
+import {
+ Badge,
+ Button,
+ IconArchive,
+ Typography,
+ Dropdown,
+ IconEdit,
+ IconTrash,
+ IconMoreVertical,
+} from '@supabase/ui'
import { isEmpty } from 'lodash'
import Panel from 'components/to-be-cleaned/Panel'
@@ -10,6 +19,49 @@ const PolicyRow = ({
onSelectPolicyDelete = () => {},
}) => {
const { name, command } = policy
+ return (
+ <div className="group">
+ <Panel.Content className="flex gap-2 justify-between py-4 border-b border-panel-border-light dark:border-panel-border-dark">
+ <div className="flex flex-col lg:flex-row lg:items-center gap-3">
+ <div className="font-mono text-xs text-scale-900">{command}</div>
+ <div className="flex flex-col lg:flex-row gap-2">
+ <span className="text-sm text-scale-1200 truncate">{name}</span>
+ </div>
+ </div>
+ <Dropdown
+ side="bottom"
+ align="end"
+ size="small"
+ overlay={
+ <>
+ <Dropdown.Item
+ icon={<IconEdit size={14} />}
+ type="outline"
+ className="mx-2"
+ onClick={() => onSelectPolicyEdit(policy, bucketName, table)}
+ >
+ Edit
+ </Dropdown.Item>
+ <Dropdown.Seperator />
+ <Dropdown.Item
+ icon={<IconTrash size={14} />}
+ type="outline"
+ onClick={() => onSelectPolicyDelete(policy)}
+ >
+ Delete
+ </Dropdown.Item>
+ </>
+ }
+ >
+ <Button
+ type="default"
+ style={{ paddingLeft: 4, paddingRight: 4 }}
+ icon={<IconMoreVertical />}
+ />
+ </Dropdown>
+ </Panel.Content>
+ </div>
+ )
return (
<div className="grid grid-cols-10 p-4 px-6 group">
<div className="col-span-4">
@@ -78,9 +130,7 @@ const StoragePoliciesBucketRow = ({
>
{policies.length === 0 ? (
<div className="p-4 px-6">
- <Typography.Text type="secondary" className="opacity-50">
- No policies created yet
- </Typography.Text>
+ <p className="text-sm text-scale-900">No policies created yet</p>
</div>
) : (
<div className="grid grid-cols-1 divide-y dark:divide-dark">
@@ -96,9 +146,7 @@ const StoragePoliciesBucketRow = ({
))}
{policies.length !== 0 ? (
<div className="px-6 py-2">
- <Typography.Text type="secondary" className="opacity-50">
- {getFooterLabel()}
- </Typography.Text>
+ <p className="text-scale-1100 text-sm">{getFooterLabel()}</p>
</div>
) : null}
</div>
diff --git a/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesPlaceholder.js b/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesPlaceholder.js
index d18a42aba6a..d874c2336ca 100644
--- a/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesPlaceholder.js
+++ b/studio/components/to-be-cleaned/Storage/StoragePolicies/StoragePoliciesPlaceholder.js
@@ -1,4 +1,4 @@
-import { Typography, IconArchive } from '@supabase/ui'
+import { IconArchive } from '@supabase/ui'
import Panel from 'components/to-be-cleaned/Panel'
const StoragePoliciesPlaceholder = ({ guiHeight }) => (
@@ -6,20 +6,14 @@ const StoragePoliciesPlaceholder = ({ guiHeight }) => (
title={[
<div key="storagePlaceholder" className="flex items-center justify-between w-full">
<div className="flex items-center space-x-4">
- <Typography.Text type="secondary">
- <IconArchive size="small" />
- </Typography.Text>
- <Typography.Title level={4} className="m-0">
- <span>Bucket policies</span>
- </Typography.Title>
+ <IconArchive size="small" />
+ <h4>Bucket policies</h4>
</div>
</div>,
]}
>
<div className="p-4 px-6">
- <Typography.Text className="opacity-50 mt-5">
- Create a bucket first to start writing policies!
- </Typography.Text>
+ <p className="text-sm text-scale-1100">Create a bucket first to start writing policies!</p>
</div>
</Panel>
)
diff --git a/studio/components/ui/Dialogs/ConfirmDialog.js b/studio/components/ui/Dialogs/ConfirmDialog.js
index 8cfd3461ed5..9c476ef29af 100644
--- a/studio/components/ui/Dialogs/ConfirmDialog.js
+++ b/studio/components/ui/Dialogs/ConfirmDialog.js
@@ -1,8 +1,8 @@
import { Modal, Button, Form } from '@supabase/ui'
import { useState, useEffect } from 'react'
-// [Joshen] I feel like having the confirm modal as a component to import is better than firing
-// the confirmAlert helper function? We'd have the modal transitions too
+// [Joshen] As of 280222, let's just use THIS component as the one and only confirmation modal
+// deprecate all others, since it uses the Form component from the UI library as well
const ConfirmModal = ({
visible = false,
@@ -42,6 +42,7 @@ const ConfirmModal = ({
initialValues={{}}
validateOnBlur
onSubmit={() => {
+ console.log('onSubmit')
onConfirm()
}}
validate={() => {
@@ -58,7 +59,7 @@ const ConfirmModal = ({
<Modal.Seperator />
<Modal.Content>
<div className="flex items-center gap-2">
- <Button type="default" onClick={() => onSelectCancel} block>
+ <Button htmlType="button" type="default" onClick={onSelectCancel} block>
Cancel
</Button>
<Button
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.js
index fe85403497c..e425c273e1b 100644
--- a/studio/localStores/storageExplorer/StorageExplorerStore.js
+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js
@@ -2,7 +2,6 @@ import { createContext, useContext } from 'react'
import { makeAutoObservable } from 'mobx'
import {
find,
- findIndex,
compact,
isEqual,
isNull,