mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 00:19:26 +00:00
feat(file-browser): rename menu item to Copy name and download link
This commit is contained in:
@@ -30,7 +30,7 @@ interface FileBrowserContextMenuProps {
|
||||
onRename: (item: AssetInfo) => void
|
||||
onDelete: (items: AssetInfo[]) => void
|
||||
onDownload: (items: AssetInfo[]) => void
|
||||
onCopyNameAndPath?: (items: AssetInfo[]) => void
|
||||
onCopyNameAndDownloadLink?: (items: AssetInfo[]) => void
|
||||
onRestore: (items: AssetInfo[]) => void
|
||||
onNewFolder: (name: string) => void
|
||||
onUploadFile: () => void
|
||||
@@ -56,7 +56,7 @@ export function FileBrowserContextMenu({
|
||||
onRename,
|
||||
onDelete,
|
||||
onDownload,
|
||||
onCopyNameAndPath,
|
||||
onCopyNameAndDownloadLink,
|
||||
onRestore,
|
||||
onNewFolder,
|
||||
onUploadFile,
|
||||
@@ -100,11 +100,11 @@ export function FileBrowserContextMenu({
|
||||
}
|
||||
}
|
||||
|
||||
const handleCopyNameAndPath = () => {
|
||||
const handleCopyNameAndDownloadLink = () => {
|
||||
if (isItemSelected) {
|
||||
onCopyNameAndPath?.(selectedItems)
|
||||
onCopyNameAndDownloadLink?.(selectedItems)
|
||||
} else if (item) {
|
||||
onCopyNameAndPath?.([item])
|
||||
onCopyNameAndDownloadLink?.([item])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ export function FileBrowserContextMenu({
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem onSelect={handleCopyNameAndPath}>
|
||||
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink}>
|
||||
<Copy className="mr-2 h-4 w-4" />
|
||||
<span>{m.copy_name_and_path()}</span>
|
||||
<span>{m.copy_name_and_download_link()}</span>
|
||||
</ContextMenuItem>
|
||||
{canEdit && (
|
||||
<ContextMenuItem
|
||||
@@ -191,9 +191,9 @@ export function FileBrowserContextMenu({
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem onSelect={handleCopyNameAndPath}>
|
||||
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink}>
|
||||
<Copy className="mr-2 h-4 w-4" />
|
||||
<span>{m.copy_name_and_path()}</span>
|
||||
<span>{m.copy_name_and_download_link()}</span>
|
||||
</ContextMenuItem>
|
||||
{canEdit && (
|
||||
<ContextMenuItem onSelect={() => onMoveTo(itemsToModify)}>
|
||||
@@ -265,9 +265,9 @@ export function FileBrowserContextMenu({
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem onSelect={handleCopyNameAndPath}>
|
||||
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink}>
|
||||
<Copy className="mr-2 h-4 w-4" />
|
||||
<span>{m.copy_name_and_path()}</span>
|
||||
<span>{m.copy_name_and_download_link()}</span>
|
||||
</ContextMenuItem>
|
||||
|
||||
{canEdit && (
|
||||
|
||||
@@ -400,7 +400,7 @@ export function FileBrowser({
|
||||
handleRename,
|
||||
handleRestore,
|
||||
handleDownload,
|
||||
handleCopyNameAndPath,
|
||||
handleCopyNameAndDownloadLink,
|
||||
handleAction,
|
||||
onRenameSubmit,
|
||||
isDeleteDialogOpen,
|
||||
@@ -1162,7 +1162,7 @@ export function FileBrowser({
|
||||
onRename={handleRename}
|
||||
onDelete={handleDelete}
|
||||
onDownload={handleDownload}
|
||||
onCopyNameAndPath={handleCopyNameAndPath}
|
||||
onCopyNameAndDownloadLink={handleCopyNameAndDownloadLink}
|
||||
onNewFolder={handleNewFolder}
|
||||
onUploadFile={handleUploadFilesClick}
|
||||
onUploadFolder={handleUploadFolderClick}
|
||||
|
||||
@@ -228,7 +228,7 @@ export function useFileActions({
|
||||
}
|
||||
}
|
||||
|
||||
const handleCopyNameAndPath = async (items: AssetInfo[]) => {
|
||||
const handleCopyNameAndDownloadLink = async (items: AssetInfo[]) => {
|
||||
if (items.length === 0) return
|
||||
try {
|
||||
const res = await getDownloadLinks({
|
||||
@@ -246,10 +246,10 @@ export function useFileActions({
|
||||
|
||||
const ok = await copyToClipboard(text)
|
||||
if (ok) {
|
||||
toast.success(m.copied_name_and_path_to_clipboard())
|
||||
toast.success(m.copied_name_and_download_link_to_clipboard())
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error('Failed to copy name and path')
|
||||
toast.error('Failed to copy name and download link')
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
@@ -350,7 +350,7 @@ export function useFileActions({
|
||||
}
|
||||
|
||||
const handleAction = (
|
||||
action: 'rename' | 'delete' | 'download' | 'restore' | 'copy-name-and-path',
|
||||
action: 'rename' | 'delete' | 'download' | 'restore' | 'copy-name-and-download-link',
|
||||
item: AssetInfo,
|
||||
) => {
|
||||
const isSelected = selectedIds.has(item.id!)
|
||||
@@ -371,8 +371,8 @@ export function useFileActions({
|
||||
case 'restore':
|
||||
handleRestore(targetItems)
|
||||
break
|
||||
case 'copy-name-and-path':
|
||||
handleCopyNameAndPath(targetItems)
|
||||
case 'copy-name-and-download-link':
|
||||
handleCopyNameAndDownloadLink(targetItems)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ export function useFileActions({
|
||||
handleDelete,
|
||||
handleRestore,
|
||||
handleDownload,
|
||||
handleCopyNameAndPath,
|
||||
handleCopyNameAndDownloadLink,
|
||||
handleNewFolder,
|
||||
handleAction,
|
||||
onRenameSubmit,
|
||||
|
||||
Reference in New Issue
Block a user