Skip to content

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

Provide helper to copy path to folder in storage explorer

Joshen Lim43c40dfc9117
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx
index 36a73884997..50852d22bb5 100644
--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.tsx
@@ -33,6 +33,7 @@ import { formatBytes } from 'lib/helpers'
import { BASE_PATH } from 'lib/constants'
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
import FileExplorerRowEditing from './FileExplorerRowEditing'
+import { copyPathToFolder } from './StorageExplorer.utils'
export const RowIcon = ({ view, status, fileType, mimeType }: any) => {
if (view === STORAGE_VIEWS.LIST && status === STORAGE_ROW_STATUS.LOADING) {
@@ -171,6 +172,11 @@ const FileExplorerRow = ({
icon: <IconDownload size="tiny" />,
onClick: () => downloadFolder(itemWithColumnIndex),
},
+ {
+ name: 'Copy path to folder',
+ icon: <IconClipboard size="tiny" />,
+ onClick: () => copyPathToFolder(openedFolders, itemWithColumnIndex),
+ },
...(canUpdateFiles
? [
{ name: 'Separator', icon: undefined, onClick: undefined },
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx
index 350f73302c5..9bbbd2a04f5 100644
--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FolderContextMenu.tsx
@@ -1,10 +1,11 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { Item, Menu, Separator } from 'react-contexify'
import 'react-contexify/dist/ReactContexify.css'
-import { IconDownload, IconEdit, IconTrash2 } from 'ui'
+import { IconClipboard, IconDownload, IconEdit, IconTrash2 } from 'ui'
import { useCheckPermissions } from 'hooks'
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
+import { copyPathToFolder } from './StorageExplorer.utils'
interface FolderContextMenuProps {
id: string
@@ -12,7 +13,8 @@ interface FolderContextMenuProps {
const FolderContextMenu = ({ id = '' }: FolderContextMenuProps) => {
const storageExplorerStore = useStorageStore()
- const { downloadFolder, setSelectedItemToRename, setSelectedItemsToDelete } = storageExplorerStore
+ const { openedFolders, downloadFolder, setSelectedItemToRename, setSelectedItemsToDelete } =
+ storageExplorerStore
const canUpdateFiles = useCheckPermissions(PermissionAction.STORAGE_ADMIN_WRITE, '*')
return (
@@ -27,6 +29,10 @@ const FolderContextMenu = ({ id = '' }: FolderContextMenuProps) => {
<IconDownload size="tiny" />
<span className="ml-2 text-xs">Download</span>
</Item>
+ <Item onClick={({ props }) => copyPathToFolder(openedFolders, props.item)}>
+ <IconClipboard size="tiny" />
+ <span className="ml-2 text-xs">Copy path to folder</span>
+ </Item>
{canUpdateFiles && [
<Separator key="separator" />,
<Item key="delete" onClick={({ props }) => setSelectedItemsToDelete([props.item])}>
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.utils.ts b/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.utils.ts
new file mode 100644
index 00000000000..20fa17aba92
--- /dev/null
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.utils.ts
@@ -0,0 +1,9 @@
+import { copyToClipboard } from 'lib/helpers'
+import toast from 'react-hot-toast'
+
+export const copyPathToFolder = (openedFolders: any[], item: any) => {
+ const folders = openedFolders.slice(0, item.columnIndex).map((folder: any) => folder.name)
+ const path = folders.length > 0 ? `${folders.join('/')}/${item.name}` : item.name
+ copyToClipboard(path)
+ toast.success(`Copied path to folder "${item.name}"`)
+}