feat(share): allow creating share links from media view with quick share dialog (#548)

* feat(share): allow creating share links from media view with quick share dialog

* fix(share): prevent horizontal overflow in quick share dialog
This commit is contained in:
Yiling-J
2026-11-24 19:39:06 +08:00
committed by GitHub
parent dc9adcf9ac
commit 9c8eb16259
24 changed files with 1457 additions and 266 deletions
@@ -9,8 +9,11 @@ import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sideba
import { MobileFileDetail } from '@/ui/components/file-viewer/mobile-file-detail'
import { FileDetailSkeleton } from '@/ui/components/loading-skeletons'
import { ResizeHandle } from '@/ui/components/resize-handle'
import { ShareLinkCreatedDialog } from '@/ui/components/share-link-created-dialog'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
import { useIsMobile } from '@/ui/hooks/use-mobile'
import { usePermissions } from '@/ui/hooks/use-permissions'
import { useShareLinkActions } from '@/ui/hooks/use-share-link-actions'
import { m } from '@/ui/paraglide/messages.js'
import { useAnnotationStore } from '@/ui/stores/annotation-store'
import { useChatbotStore } from '@/ui/stores/chatbot'
@@ -67,6 +70,15 @@ function FileViewPage() {
const mediaControllerRef = useRef<MediaController | null>(null)
const { archiveStorageEnabled } = useArchiveConfig()
const { canEdit } = usePermissions(projectId)
const {
shareLinks,
createShareLink,
addToShareLink,
isShareActionPending,
createdShareLink,
clearCreatedShareLink,
} = useShareLinkActions({ projectId, enabled: canEdit })
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
const [annotations, setAnnotations] = useState<Annotation[]>([])
@@ -406,6 +418,17 @@ function FileViewPage() {
onRestoreArchive: () => {
setArchiveConfirmState({ open: true, mode: 'restore' })
},
shareLinks,
onCreateShareLink: () => {
createShareLink([{ id: fileId, name: stackData?.name ?? fileData.name }])
},
onAddToShareLink: (targetShareId: string) => {
addToShareLink({
shareId: targetShareId,
items: [{ id: fileId, name: stackData?.name ?? fileData.name }],
})
},
isShareActionPending,
})
}
@@ -415,10 +438,15 @@ function FileViewPage() {
projectId,
projectInfo,
fileData,
stackData?.name,
versionsDataList,
activeFileId,
fileId,
isCompareMode,
shareLinks,
createShareLink,
addToShareLink,
isShareActionPending,
setProjectState,
clearProjectState,
navigate,
@@ -747,8 +775,27 @@ function FileViewPage() {
? () => setArchiveConfirmState({ open: true, mode: 'restore' })
: undefined
}
shareLinks={shareLinks}
onCreateShareLink={() => {
createShareLink([{ id: fileId, name: stackData?.name ?? fileData.name }])
}}
onAddToShareLink={(targetShareId) => {
addToShareLink({
shareId: targetShareId,
items: [{ id: fileId, name: stackData?.name ?? fileData.name }],
})
}}
isShareActionPending={isShareActionPending}
onSaveField={handleSaveField}
/>
<ShareLinkCreatedDialog
open={!!createdShareLink}
onOpenChange={(open) => {
if (!open) clearCreatedShareLink()
}}
shareLink={createdShareLink}
projectId={projectId}
/>
<ArchiveConfirmDialog
open={archiveConfirmState.open}
onOpenChange={(open) => setArchiveConfirmState((prev) => ({ ...prev, open }))}
@@ -917,6 +964,15 @@ function FileViewPage() {
</AlertDialogContent>
</AlertDialog>
<ShareLinkCreatedDialog
open={!!createdShareLink}
onOpenChange={(open) => {
if (!open) clearCreatedShareLink()
}}
shareLink={createdShareLink}
projectId={projectId}
/>
<ArchiveConfirmDialog
open={archiveConfirmState.open}
onOpenChange={(open) => setArchiveConfirmState((prev) => ({ ...prev, open }))}