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:
Yiling-J
2026-08-08 10:25:02 +08:00
committed by GitHub
parent 70b6c33204
commit d3f5892dd2
39 changed files with 572 additions and 208 deletions
@@ -25,6 +25,8 @@ interface CompareControlBarProps {
onFit: () => void
onDownload: (key?: string) => void
onToggleFullScreen: () => void
/** When false, hides the download affordance. Defaults to true. */
allowDownload?: boolean
}
export function CompareControlBar({
@@ -44,6 +46,7 @@ export function CompareControlBar({
onFit,
onDownload,
onToggleFullScreen,
allowDownload = true,
}: CompareControlBarProps) {
// Active side is a video: reuse the shared VideoControlBar.
if (activeState?.kind === 'video' && activeState.video && activeAsset) {
@@ -94,6 +97,7 @@ export function CompareControlBar({
totalFrames={v.totalFrames}
currentFrame={v.currentFrame}
seekToFrame={onSeek}
allowDownload={allowDownload}
/>
)
}
@@ -109,6 +113,7 @@ export function CompareControlBar({
onDownload={() => onDownload()}
canDownload={!!activeAsset?.media?.original?.key}
fullscreen={{ isFullScreen, onToggle: onToggleFullScreen }}
allowDownload={allowDownload}
/>
)
}
@@ -33,6 +33,8 @@ interface CompareViewerProps {
onActiveAssetChange: (asset: AssetInfo | null) => void
onPlay?: () => void
onTimeUpdate?: (second: number) => void
/** When false, hides the download affordance. Defaults to true. */
allowDownload?: boolean
}
function useCompareAsset(id: string, isPublic: boolean, shareId?: string) {
@@ -73,6 +75,7 @@ export function CompareViewer({
onActiveAssetChange,
onPlay,
onTimeUpdate,
allowDownload = true,
}: CompareViewerProps) {
const rootRef = useRef<HTMLDivElement>(null)
const leftRef = useRef<ComparePaneHandle | null>(null)
@@ -378,6 +381,7 @@ export function CompareViewer({
onFit={handleFit}
onDownload={handleDownload}
onToggleFullScreen={handleToggleFullScreen}
allowDownload={allowDownload}
/>
</div>
)