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
+2 -1
View File
@@ -77,7 +77,8 @@ apps/web/e2e/
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
| Owner deletes a folder and still sees its contents preview and countdown in recently deleted | `tests/project/delete-restore.spec.ts` |
| Owner deletes a version stack and restores it from recently deleted | `tests/project/delete-restore.spec.ts` |
| Owner creates a share link from a file context menu and lands on the share page | `tests/project/create-share-link.spec.ts` |
| Owner creates a share link from a file context menu, edits it in the quick dialog, and opens advanced settings | `tests/project/create-share-link.spec.ts` |
| Owner creates a share link and adds to an existing share link from media view | `tests/project/create-share-link.spec.ts` |
| Owner protects a share with a password; guests must enter it to view | `tests/project/share-password.spec.ts` |
| Owner creates a collection from the sidebar; the collection shows project files | `tests/project/create-collection.spec.ts` |
| Owner invites a member to a project; the member only sees the invited project | `tests/project/invite-member.spec.ts` |
@@ -1,7 +1,7 @@
import { expect, test } from '../../fixtures'
import { fileCard } from '../../helpers/files'
import { apiCreateShare, fileCard } from '../../helpers/files'
test('owner creates a share link from a file context menu and lands on the share page', async ({
test('owner creates a share link from a file context menu, edits it in the quick dialog, and opens advanced settings', async ({
file,
prisma,
}) => {
@@ -14,19 +14,38 @@ test('owner creates a share link from a file context menu and lands on the share
await fileCard(page, fileName).click({ button: 'right' })
await page.getByRole('menuitem', { name: 'Create Share Link' }).click()
// The toast offers a "View" action that navigates to the share page
const toast = page.locator('[data-sonner-toast]').filter({ hasText: 'Share link created' })
await expect(toast).toBeVisible()
await toast.getByRole('button', { name: 'View' }).click()
// Quick share dialog opens with share name, URL, security controls, and footer actions
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible()
await expect(dialog.getByText(fileName)).toBeVisible()
await expect(dialog.getByRole('button', { name: 'Copy Link' }).last()).toBeVisible()
await expect(dialog.getByRole('button', { name: 'Done' })).toBeVisible()
// Rename share link inline via the pen icon
await dialog.getByRole('button', { name: 'Rename Share Link' }).click()
const nameInput = dialog.getByRole('textbox', { name: 'Rename Share Link' })
await expect(nameInput).toBeVisible()
await nameInput.fill('Client Review Cut')
await nameInput.press('Enter')
await expect(dialog.getByText('Client Review Cut')).toBeVisible()
// Toggle Allow download off in quick security settings
const allowDownloadRow = dialog.getByText('Allow download').locator('..')
await allowDownloadRow.getByRole('switch').click()
await expect(page.getByText('Settings updated')).toBeVisible()
// Navigate to full settings via Advanced settings
await dialog.getByRole('button', { name: 'Advanced settings' }).click()
await expect(page).toHaveURL(/\/projects\/[^/]+\/shares\/[^/]+/)
// The shared file is listed in the share contents
await expect(fileCard(page, fileName)).toBeVisible()
// DB: the share exists and the file is symlinked under the share root
// DB: the share exists with updated settings and the file is symlinked under the share root
const share = await prisma.shareLink.findFirst({ where: { projectId } })
expect(share).not.toBeNull()
expect(share?.name).toBe('Client Review Cut')
expect(share?.allowDownload).toBe(false)
const symlink = await prisma.asset.findFirst({
where: { parentId: share?.rootFolderId, targetId: fileId },
@@ -34,3 +53,58 @@ test('owner creates a share link from a file context menu and lands on the share
expect(symlink).not.toBeNull()
expect(symlink?.type).toBe('symlink')
})
test('owner creates a share link and adds to an existing share link from media view', async ({
file,
prisma,
}) => {
const { context, page, projectId, fileName, fileId } = file
// Seed an existing share link so "Add to Share Links" submenu is available
const existingShare = await apiCreateShare(context.request, projectId, 'Existing Client Share')
await page.goto(`/projects/${projectId}/files/${fileId}`)
const headerTrigger = page.getByRole('button', { name: fileName })
await expect(headerTrigger).toBeVisible()
// Open the media view header arrow dropdown and create a new share link
await headerTrigger.click()
await page.getByRole('menuitem', { name: 'Create Share Link' }).click()
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible()
await expect(dialog.getByText(fileName)).toBeVisible()
await expect(page).toHaveURL(new RegExp(`/projects/${projectId}/files/${fileId}$`))
// Close the dialog with Done and stay on the media view
await dialog.getByRole('button', { name: 'Done' }).click()
await expect(dialog).toBeHidden()
await expect(page).toHaveURL(new RegExp(`/projects/${projectId}/files/${fileId}$`))
// DB: new share link created with symlink to the file
const createdShare = await prisma.shareLink.findFirst({
where: { projectId, id: { not: existingShare.id } },
})
expect(createdShare).not.toBeNull()
expect(createdShare?.name).toBe(fileName)
const createdSymlink = await prisma.asset.findFirst({
where: { parentId: createdShare?.rootFolderId, targetId: fileId },
})
expect(createdSymlink).not.toBeNull()
expect(createdSymlink?.type).toBe('symlink')
// Open the header dropdown again and add the file to the existing share link
await headerTrigger.click()
await page.getByRole('menuitem', { name: 'Add to Share Links' }).hover()
await page.getByRole('menuitem', { name: 'Existing Client Share' }).click()
const addedToast = page.locator('[data-sonner-toast]').filter({ hasText: 'Added to share link' })
await expect(addedToast).toBeVisible()
const addedSymlink = await prisma.asset.findFirst({
where: { parentId: existingShare.rootFolderId, targetId: fileId },
})
expect(addedSymlink).not.toBeNull()
expect(addedSymlink?.type).toBe('symlink')
})
@@ -147,8 +147,10 @@ test('dissolving a shared version stack renders the remaining standalone file na
// Share the version stack
await fileCard(page, fileB.name).click({ button: 'right' })
await page.getByRole('menuitem', { name: 'Create Share Link' }).click()
const toast = page.locator('[data-sonner-toast]').filter({ hasText: 'Share link created' })
await expect(toast).toBeVisible()
const shareDialog = page.getByRole('dialog')
await expect(shareDialog).toBeVisible()
await shareDialog.getByRole('button', { name: 'Done' }).click()
await expect(shareDialog).toBeHidden()
const share = await prisma.shareLink.findFirstOrThrow({
where: { projectId },