mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 18:07:17 +00:00
feat(ui): add collection and share link pages and management actions
This commit is contained in:
@@ -52,6 +52,8 @@ describe('Collection API', () => {
|
||||
projectId,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
creator: null,
|
||||
creatorId: null,
|
||||
})
|
||||
|
||||
const res = await app.request(`/projects/${projectId}/collections`, {
|
||||
@@ -67,7 +69,7 @@ describe('Collection API', () => {
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(mockCreate).toHaveBeenCalledWith(projectId, expect.any(Object))
|
||||
expect(mockCreate).toHaveBeenCalledWith(projectId, expect.any(Object), 'user-1')
|
||||
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||
user: expect.any(Object),
|
||||
permission: Permission.Edit,
|
||||
@@ -90,6 +92,8 @@ describe('Collection API', () => {
|
||||
projectId,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
creator: null,
|
||||
creatorId: null,
|
||||
},
|
||||
],
|
||||
pageInfo: { total: 1 },
|
||||
@@ -121,6 +125,8 @@ describe('Collection API', () => {
|
||||
projectId,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
creator: null,
|
||||
creatorId: null,
|
||||
})
|
||||
|
||||
const res = await app.request(`/collections/${collectionId}`)
|
||||
@@ -147,6 +153,8 @@ describe('Collection API', () => {
|
||||
projectId,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
creator: null,
|
||||
creatorId: null,
|
||||
})
|
||||
|
||||
const res = await app.request(`/collections/${collectionId}`, {
|
||||
|
||||
@@ -13,7 +13,9 @@ import type { Prisma } from '@shumai/db'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
function toCollectionInfo(c: Prisma.CollectionGetPayload<Record<string, never>>): CollectionInfo {
|
||||
function toCollectionInfo(
|
||||
c: Prisma.CollectionGetPayload<{ include: { creator: true } }>,
|
||||
): CollectionInfo {
|
||||
return {
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
@@ -21,6 +23,9 @@ function toCollectionInfo(c: Prisma.CollectionGetPayload<Record<string, never>>)
|
||||
projectId: c.projectId,
|
||||
createdAt: c.createdAt.toISOString(),
|
||||
updatedAt: c.updatedAt.toISOString(),
|
||||
creator: c.creator
|
||||
? { id: c.creator.id, name: c.creator.name, image: c.creator.image ?? undefined }
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +45,7 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: projectId,
|
||||
})
|
||||
|
||||
const collection = await collectionService.createCollection(projectId, req)
|
||||
const collection = await collectionService.createCollection(projectId, req, user.id)
|
||||
return c.json(toCollectionInfo(collection))
|
||||
},
|
||||
)
|
||||
|
||||
@@ -139,7 +139,7 @@ describe('Share API', () => {
|
||||
permission: Permission.Edit,
|
||||
}),
|
||||
)
|
||||
expect(shareService.createShareLink).toHaveBeenCalledWith('project1', { name: 'My Share' })
|
||||
expect(shareService.createShareLink).toHaveBeenCalledWith('project1', { name: 'My Share' }, 'user1')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: projectId,
|
||||
})
|
||||
|
||||
const shareLink = await shareService.createShareLink(projectId, req)
|
||||
const shareLink = await shareService.createShareLink(projectId, req, user.id)
|
||||
return c.json(shareLink)
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user