mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 13:34:33 +00:00
feat(share): add allow download config to share links (#275)
* feat(share): add allow download config to share links * fix(share): hide download in public share list page when disabled
This commit is contained in:
@@ -92,6 +92,8 @@ interface FileBrowserProps {
|
||||
onUpdateCollection?: (updates: { name?: string; filter?: any }) => void
|
||||
rootFolderId?: string
|
||||
shareId?: string
|
||||
/** When false, hides download affordances (used by public share views). Defaults to true. */
|
||||
allowDownload?: boolean
|
||||
}
|
||||
|
||||
type FileWithId = {
|
||||
@@ -138,6 +140,7 @@ export function FileBrowser({
|
||||
onUpdateCollection,
|
||||
rootFolderId,
|
||||
shareId,
|
||||
allowDownload = true,
|
||||
}: FileBrowserProps) {
|
||||
const [contextMenuItem, setContextMenuItem] = useState<AssetInfo | null>(null)
|
||||
const [moveCopyMode, setMoveCopyMode] = useState<'move' | 'copy' | null>(null)
|
||||
@@ -680,6 +683,7 @@ export function FileBrowser({
|
||||
isRecentlyDeleted,
|
||||
selectedCount: selectedIds.size,
|
||||
isShareView,
|
||||
allowDownload,
|
||||
fields: displayedFields,
|
||||
canEdit,
|
||||
isExternalDragging,
|
||||
@@ -1136,19 +1140,21 @@ export function FileBrowser({
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleDownload(
|
||||
[...folders, ...displayedFiles].filter((i) => selectedIds.has(i.id!)),
|
||||
)
|
||||
}
|
||||
className="gap-2"
|
||||
>
|
||||
<Download className="h-4 w-4" />
|
||||
Download
|
||||
</Button>
|
||||
{allowDownload && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleDownload(
|
||||
[...folders, ...displayedFiles].filter((i) => selectedIds.has(i.id!)),
|
||||
)
|
||||
}
|
||||
className="gap-2"
|
||||
>
|
||||
<Download className="h-4 w-4" />
|
||||
Download
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{isExternalDragging && !externalOverFolderId && (
|
||||
|
||||
@@ -55,6 +55,8 @@ interface FileCardProps {
|
||||
fields: MetadataFieldInfo[]
|
||||
isShareView?: boolean
|
||||
canEdit?: boolean
|
||||
/** When false, hides the download action. Defaults to true. */
|
||||
allowDownload?: boolean
|
||||
}
|
||||
|
||||
export function FileCard({
|
||||
@@ -81,6 +83,7 @@ export function FileCard({
|
||||
fields,
|
||||
isShareView,
|
||||
canEdit = true,
|
||||
allowDownload = true,
|
||||
}: FileCardProps) {
|
||||
const [name, setName] = useState(item.name)
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
@@ -314,15 +317,17 @@ export function FileCard({
|
||||
<DropdownMenuContent align="end">
|
||||
{isShareView ? (
|
||||
<>
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
{allowDownload && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{canEdit && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
@@ -359,15 +364,17 @@ export function FileCard({
|
||||
<span>{m.rename()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
{allowDownload && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{canEdit && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
@@ -45,6 +45,8 @@ interface FolderCardProps {
|
||||
setExternalOverFolderId?: (id: string | null) => void
|
||||
resetExternalDragState?: () => void
|
||||
onExternalDrop?: (files: File[], folderId: string) => void
|
||||
/** When false, hides the download action. Defaults to true. */
|
||||
allowDownload?: boolean
|
||||
}
|
||||
|
||||
const FolderPreviewGrid = ({ items }: { items: ChildPreview[] }) => {
|
||||
@@ -126,6 +128,7 @@ export function FolderCard({
|
||||
setExternalOverFolderId,
|
||||
resetExternalDragState,
|
||||
onExternalDrop,
|
||||
allowDownload = true,
|
||||
}: FolderCardProps) {
|
||||
const [name, setName] = useState(item.name || '')
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
@@ -361,15 +364,17 @@ export function FolderCard({
|
||||
<DropdownMenuContent align="end">
|
||||
{isShareView ? (
|
||||
<>
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
{allowDownload && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{canEdit && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
@@ -406,15 +411,17 @@ export function FolderCard({
|
||||
<span>{m.rename()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
{allowDownload && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onAction?.('download', item)
|
||||
}}
|
||||
>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
<span>{m.download()}</span>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{canEdit && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
Reference in New Issue
Block a user