The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Implement expiry options in file explorer row menu
Joshen Limddfb9beb9213
diff --git a/studio/components/to-be-cleaned/Storage/Storage.constants.ts b/studio/components/to-be-cleaned/Storage/Storage.constants.tsindex 2620cf9fb2d..94fecf605f3 100644--- a/studio/components/to-be-cleaned/Storage/Storage.constants.ts+++ b/studio/components/to-be-cleaned/Storage/Storage.constants.ts@@ -1,3 +1,9 @@+export const URL_EXPIRY_DURATION = {+ WEEK: 60 * 60 * 24 * 7,+ MONTH: 60 * 60 * 24 * 30,+ YEAR: 60 * 60 * 24 * 365,+}+export const STORAGE_VIEWS = {COLUMNS: 'COLUMNS',LIST: 'LIST',diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsxindex 53e9ed0a043..08b26f795de 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/CustomExpiryModal.tsx@@ -13,8 +13,6 @@ const CustomExpiryModal: FC<Props> = () => {const visible = selectedFileCustomExpiry !== undefinedconst onClose = () => setSelectedFileCustomExpiry(undefined)- console.log(selectedFileCustomExpiry)-return (<ModalhideFooterdiff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsxindex 7795203fa55..b5bd5982c23 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx@@ -15,6 +15,7 @@ import {IconMove,IconClipboard,IconTrash2,+ IconChevronRight,} from 'ui'import SVG from 'react-inlinesvg'import * as Tooltip from '@radix-ui/react-tooltip'@@ -24,6 +25,7 @@ import {STORAGE_ROW_TYPES,STORAGE_ROW_STATUS,CONTEXT_MENU_KEYS,+ URL_EXPIRY_DURATION,} from '../Storage.constants'import { formatBytes } from 'lib/helpers'import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'@@ -97,6 +99,7 @@ const FileExplorerRow: FC<Props> = ({setSelectedItemsToDelete,setSelectedItemToRename,setSelectedItemsToMove,+ setSelectedFileCustomExpiry,fetchFolderContents,downloadFile,downloadFolder,@@ -207,12 +210,29 @@ const FileExplorerRow: FC<Props> = ({{name: 'Get URL',icon: <IconClipboard size="tiny" />,- onClick: async () => await copyFileURLToClipboard(itemWithColumnIndex),children: [- { name: 'Expire in 1 week' },- { name: 'Expire in 1 month' },- { name: 'Expire in 1 year' },- { name: 'Custom expiry' },+ {+ name: 'Expire in 1 week',+ onClick: async () =>+ await copyFileURLToClipboard(itemWithColumnIndex, URL_EXPIRY_DURATION.WEEK),+ },+ {+ name: 'Expire in 1 month',+ onClick: async () =>+ await copyFileURLToClipboard(+ itemWithColumnIndex,+ URL_EXPIRY_DURATION.MONTH+ ),+ },+ {+ name: 'Expire in 1 year',+ onClick: async () =>+ await copyFileURLToClipboard(itemWithColumnIndex, URL_EXPIRY_DURATION.YEAR),+ },+ {+ name: 'Custom expiry',+ onClick: async () => setSelectedFileCustomExpiry(itemWithColumnIndex),+ },],},{@@ -382,7 +402,36 @@ const FileExplorerRow: FC<Props> = ({align="end"overlay={[rowOptions.map((option) => {- if (option.name === 'Separator') {+ if ((option?.children ?? []).length > 0) {+ return (+ <Dropdown+ isNested+ key={option.name}+ side="right"+ align="start"+ overlay={(option?.children ?? [])?.map((child) => {+ return (+ <Dropdown.Item key={child.name} onClick={child.onClick}>+ {child.name}+ </Dropdown.Item>+ )+ })}+ >+ <div+ className={[+ 'flex items-center justify-between px-4 py-1.5 text-xs text-scale-1100',+ 'w-full focus:bg-scale-300 dark:focus:bg-scale-500 focus:text-scale-1200',+ ].join(' ')}+ >+ <div className="flex items-center space-x-2">+ {option.icon}+ <p>{option.name}</p>+ </div>+ <IconChevronRight size="tiny" />+ </div>+ </Dropdown>+ )+ } else if (option.name === 'Separator') {return <Dropdown.Separator key="row-separator" />} else {return (diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.jsindex 1b948c8bf12..eb48047e271 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/ItemContextMenu.js@@ -1,8 +1,10 @@+import { observer } from 'mobx-react-lite'import { Menu, Item, Separator, Submenu } from 'react-contexify'import 'react-contexify/dist/ReactContexify.css'import { IconClipboard, IconEdit, IconMove, IconDownload, IconTrash2, IconChevronRight } from 'ui'++import { URL_EXPIRY_DURATION } from '../Storage.constants'import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'-import { observer } from 'mobx-react-lite'const ItemContextMenu = ({ id = '' }) => {const storageExplorerStore = useStorageStore()@@ -39,25 +41,31 @@ const ItemContextMenu = ({ id = '' }) => {{isPublic ? (<Item onClick={({ props }) => onHandleClick('copy', props.item)}><IconClipboard size="tiny" />- <span className="ml-2 text-xs">Copy URL</span>+ <span className="ml-2 text-xs">Get URL</span></Item>) : (<Submenulabel={<div className="flex items-center space-x-2"><IconClipboard size="tiny" />- <span className="text-xs">Copy URL</span>+ <span className="text-xs">Get URL</span></div>}arrow={<IconChevronRight size="tiny" />}>- <Item onClick={({ props }) => onHandleClick('copy', props.item, 60 * 60 * 24 * 7)}>+ <Item+ onClick={({ props }) => onHandleClick('copy', props.item, URL_EXPIRY_DURATION.WEEK)}+ ><span className="ml-2 text-xs">Expire in 1 week</span></Item>- <Item onClick={({ props }) => onHandleClick('copy', props.item, 60 * 60 * 24 * 30)}>+ <Item+ onClick={({ props }) => onHandleClick('copy', props.item, URL_EXPIRY_DURATION.MONTH)}+ ><span className="ml-2 text-xs">Expire in 1 month</span></Item>- <Item onClick={({ props }) => onHandleClick('copy', props.item, 60 * 60 * 24 * 365)}>+ <Item+ onClick={({ props }) => onHandleClick('copy', props.item, URL_EXPIRY_DURATION.YEAR)}+ ><span className="ml-2 text-xs">Expire in 1 year</span></Item><Item onClick={({ props }) => onHandleClick('copy', props.item, -1)}>diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsxindex d4b8d87b1d2..205e6fbbba6 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx@@ -1,9 +1,8 @@+import Link from 'next/link'import { isEmpty } from 'lodash'-import { useState } from 'react'import {Button,Dropdown,- Form,IconX,IconLoader,IconClipboard,@@ -11,13 +10,11 @@ import {IconTrash2,IconAlertCircle,IconChevronDown,- Modal,- Input,} from 'ui'import SVG from 'react-inlinesvg'import { formatBytes } from 'lib/helpers'import { Transition } from '@headlessui/react'-import Link from 'next/link'+import { URL_EXPIRY_DURATION } from '../Storage.constants'import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'const PreviewFile = ({ mimeType, previewUrl }: { mimeType: string; previewUrl: string }) => {@@ -205,17 +202,23 @@ const PreviewPane = () => {align="center"overlay={[<Dropdown.Item- onClick={async () => await copyFileURLToClipboard(file, 60 * 60 * 24 * 7)}+ onClick={async () =>+ await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.WEEK)+ }>Expire in 1 week</Dropdown.Item>,<Dropdown.Item- onClick={async () => await copyFileURLToClipboard(file, 60 * 60 * 24 * 30)}+ onClick={async () =>+ await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.MONTH)+ }>Expire in 1 month</Dropdown.Item>,<Dropdown.Item- onClick={async () => await copyFileURLToClipboard(file, 60 * 60 * 24 * 365)}+ onClick={async () =>+ await copyFileURLToClipboard(file, URL_EXPIRY_DURATION.YEAR)+ }>Expire in 1 year</Dropdown.Item>,