feat(version-stack): add manage versions dialog and version removal (#311)

* feat(version-stack): add manage versions dialog and version removal

* fix(webui): remove ellipsis and add pointer cursor to manage versions button

* fix(version-stack): handle symlink deduplication and name sync for share links

* refactor(version-stack): extract shared symlink dedup helper

The 'repoint first symlink per share folder, delete duplicates with
fileCount decrement' logic was triplicated across createVersionStack,
reparentAssets, and reparentFileToFile with subtle variations. Extract
it into dedupeSymlinksToTarget() in packages/core/src/asset/symlink.ts
and call it from all three sites (behavior unchanged), with a dedicated
test suite covering the edge cases.
This commit is contained in:
Yiling-J
2026-08-15 15:37:17 +08:00
committed by GitHub
parent ae86d56a7d
commit f66bb7af73
34 changed files with 1989 additions and 16 deletions
+28
View File
@@ -32,12 +32,14 @@ vi.mock('./middleware/auth', () => ({
describe('versionStack api', () => {
let mockCreateVersionStack: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockChangeStackFileVersion: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockRemoveVersionFromStack: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetAsset: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetStackVersions: any // eslint-disable-line @typescript-eslint/no-explicit-any
beforeEach(() => {
mockCreateVersionStack = vi.spyOn(versionStackService, 'createVersionStack')
mockChangeStackFileVersion = vi.spyOn(versionStackService, 'changeStackFileVersion')
mockRemoveVersionFromStack = vi.spyOn(versionStackService, 'removeVersionFromStack')
mockGetAsset = vi.spyOn(assetService, 'getAsset')
mockGetStackVersions = vi.spyOn(assetService, 'getStackVersions')
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
@@ -146,4 +148,30 @@ describe('versionStack api', () => {
expect(mockGetStackVersions).toHaveBeenCalledWith('stack1')
})
})
describe('DELETE /version_stacks/:stackId/versions/:versionId', () => {
it('should remove version from stack and return 200', async () => {
mockRemoveVersionFromStack.mockResolvedValue()
const app = new Hono().use('*', authMiddleware).route('/', versionStackRoute)
const res = await app.request('/version_stacks/stack1/versions/v1', {
method: 'DELETE',
})
expect(res.status).toBe(200)
expect(authzService.hasPermission).toHaveBeenCalledWith(
expect.objectContaining({
type: ResourceType.Asset,
id: 'stack1',
permission: Permission.Edit,
}),
)
expect(mockRemoveVersionFromStack).toHaveBeenCalledWith({
stackId: 'stack1',
fileId: 'v1',
})
})
})
})