mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 01:58:24 +00:00
feat(share): improve share config page sidebars, layout options, and sorting
This commit is contained in:
@@ -224,17 +224,21 @@ describe('ShareService', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('updates a share link including fieldVisibility', async () => {
|
||||
it('updates a share link including fieldVisibility, viewMode, and defaultSortOrder', async () => {
|
||||
const shareLink = await shareService.createShareLink(projectId, { name: 'Old Name' })
|
||||
const updated = await shareService.updateShareLink(shareLink.id, {
|
||||
name: 'New Name',
|
||||
password: 'new-password',
|
||||
fieldVisibility: { field1: true, field2: false },
|
||||
viewMode: 'list',
|
||||
defaultSortOrder: 'name:desc',
|
||||
})
|
||||
|
||||
expect(updated.name).toBe('New Name')
|
||||
expect(updated.hasPassword).toBe(true)
|
||||
expect(updated.fieldVisibility).toEqual({ field1: true, field2: false })
|
||||
expect(updated.viewMode).toBe('list')
|
||||
expect(updated.defaultSortOrder).toBe('name:desc')
|
||||
|
||||
const rootAsset = await prisma.asset.findUnique({ where: { id: shareLink.rootFolderId } })
|
||||
expect(rootAsset?.name).toBe('New Name')
|
||||
|
||||
@@ -58,6 +58,7 @@ export class ShareService {
|
||||
password: req.password,
|
||||
isDisabled: req.isDisabled ?? false,
|
||||
defaultSortOrder: req.defaultSortOrder,
|
||||
viewMode: req.viewMode,
|
||||
projectId: projectId,
|
||||
rootFolderId: shareFolder.id,
|
||||
creatorId,
|
||||
@@ -84,6 +85,7 @@ export class ShareService {
|
||||
password: req.password,
|
||||
isDisabled: req.isDisabled,
|
||||
defaultSortOrder: req.defaultSortOrder,
|
||||
viewMode: req.viewMode,
|
||||
fieldVisibility: (req.fieldVisibility as PrismaJson.ShareLinkFieldVisibility) ?? undefined,
|
||||
},
|
||||
include: { creator: true },
|
||||
@@ -300,6 +302,7 @@ export class ShareService {
|
||||
isDisabled: l.isDisabled,
|
||||
hasPassword: !!l.password,
|
||||
defaultSortOrder: l.defaultSortOrder,
|
||||
viewMode: l.viewMode,
|
||||
fieldVisibility: l.fieldVisibility as Record<string, boolean> | undefined,
|
||||
rootFolderId: l.rootFolderId,
|
||||
projectId: l.projectId,
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "share_links" ADD COLUMN "view_mode" TEXT;
|
||||
@@ -338,6 +338,7 @@ model ShareLink {
|
||||
password String?
|
||||
isDisabled Boolean @default(false) @map("is_disabled")
|
||||
defaultSortOrder String? @map("default_sort_order")
|
||||
viewMode String? @map("view_mode")
|
||||
/// [ShareLinkFieldVisibility]
|
||||
fieldVisibility Json? @map("field_visibility")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3038,6 +3038,7 @@ export const ShareLinkScalarFieldEnum = {
|
||||
password: 'password',
|
||||
isDisabled: 'isDisabled',
|
||||
defaultSortOrder: 'defaultSortOrder',
|
||||
viewMode: 'viewMode',
|
||||
fieldVisibility: 'fieldVisibility',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
|
||||
@@ -253,6 +253,7 @@ export const ShareLinkScalarFieldEnum = {
|
||||
password: 'password',
|
||||
isDisabled: 'isDisabled',
|
||||
defaultSortOrder: 'defaultSortOrder',
|
||||
viewMode: 'viewMode',
|
||||
fieldVisibility: 'fieldVisibility',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
|
||||
@@ -32,6 +32,7 @@ export type ShareLinkMinAggregateOutputType = {
|
||||
password: string | null
|
||||
isDisabled: boolean | null
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
projectId: string | null
|
||||
@@ -46,6 +47,7 @@ export type ShareLinkMaxAggregateOutputType = {
|
||||
password: string | null
|
||||
isDisabled: boolean | null
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
projectId: string | null
|
||||
@@ -60,6 +62,7 @@ export type ShareLinkCountAggregateOutputType = {
|
||||
password: number
|
||||
isDisabled: number
|
||||
defaultSortOrder: number
|
||||
viewMode: number
|
||||
fieldVisibility: PrismaJson.ShareLinkFieldVisibility
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
@@ -76,6 +79,7 @@ export type ShareLinkMinAggregateInputType = {
|
||||
password?: true
|
||||
isDisabled?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
projectId?: true
|
||||
@@ -90,6 +94,7 @@ export type ShareLinkMaxAggregateInputType = {
|
||||
password?: true
|
||||
isDisabled?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
projectId?: true
|
||||
@@ -104,6 +109,7 @@ export type ShareLinkCountAggregateInputType = {
|
||||
password?: true
|
||||
isDisabled?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
fieldVisibility?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
@@ -195,6 +201,7 @@ export type ShareLinkGroupByOutputType = {
|
||||
password: string | null
|
||||
isDisabled: boolean
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
fieldVisibility: PrismaJson.ShareLinkFieldVisibility | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
@@ -228,6 +235,7 @@ export type ShareLinkWhereInput = {
|
||||
password?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
isDisabled?: Prisma.BoolFilter<'ShareLink'> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<'ShareLink'>
|
||||
createdAt?: Prisma.DateTimeFilter<'ShareLink'> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<'ShareLink'> | Date | string
|
||||
@@ -246,6 +254,7 @@ export type ShareLinkOrderByWithRelationInput = {
|
||||
password?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
@@ -269,6 +278,7 @@ export type ShareLinkWhereUniqueInput = Prisma.AtLeast<
|
||||
password?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
isDisabled?: Prisma.BoolFilter<'ShareLink'> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<'ShareLink'>
|
||||
createdAt?: Prisma.DateTimeFilter<'ShareLink'> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<'ShareLink'> | Date | string
|
||||
@@ -288,6 +298,7 @@ export type ShareLinkOrderByWithAggregationInput = {
|
||||
password?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
@@ -313,6 +324,7 @@ export type ShareLinkScalarWhereWithAggregatesInput = {
|
||||
password?: Prisma.StringNullableWithAggregatesFilter<'ShareLink'> | string | null
|
||||
isDisabled?: Prisma.BoolWithAggregatesFilter<'ShareLink'> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableWithAggregatesFilter<'ShareLink'> | string | null
|
||||
viewMode?: Prisma.StringNullableWithAggregatesFilter<'ShareLink'> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableWithAggregatesFilter<'ShareLink'>
|
||||
createdAt?: Prisma.DateTimeWithAggregatesFilter<'ShareLink'> | Date | string
|
||||
updatedAt?: Prisma.DateTimeWithAggregatesFilter<'ShareLink'> | Date | string
|
||||
@@ -328,6 +340,7 @@ export type ShareLinkCreateInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -343,6 +356,7 @@ export type ShareLinkUncheckedCreateInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -358,6 +372,7 @@ export type ShareLinkUpdateInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -373,6 +388,7 @@ export type ShareLinkUncheckedUpdateInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -388,6 +404,7 @@ export type ShareLinkCreateManyInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -403,6 +420,7 @@ export type ShareLinkUpdateManyMutationInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -415,6 +433,7 @@ export type ShareLinkUncheckedUpdateManyInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -440,6 +459,7 @@ export type ShareLinkCountOrderByAggregateInput = {
|
||||
password?: Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
@@ -455,6 +475,7 @@ export type ShareLinkMaxOrderByAggregateInput = {
|
||||
password?: Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -469,6 +490,7 @@ export type ShareLinkMinOrderByAggregateInput = {
|
||||
password?: Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -716,6 +738,7 @@ export type ShareLinkCreateWithoutCreatorInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -730,6 +753,7 @@ export type ShareLinkUncheckedCreateWithoutCreatorInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -788,6 +812,7 @@ export type ShareLinkScalarWhereInput = {
|
||||
password?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
isDisabled?: Prisma.BoolFilter<'ShareLink'> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<'ShareLink'> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<'ShareLink'>
|
||||
createdAt?: Prisma.DateTimeFilter<'ShareLink'> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<'ShareLink'> | Date | string
|
||||
@@ -803,6 +828,7 @@ export type ShareLinkCreateWithoutProjectInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -817,6 +843,7 @@ export type ShareLinkUncheckedCreateWithoutProjectInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -872,6 +899,7 @@ export type ShareLinkCreateWithoutRootFolderInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -886,6 +914,7 @@ export type ShareLinkUncheckedCreateWithoutRootFolderInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -928,6 +957,7 @@ export type ShareLinkUpdateWithoutRootFolderInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -942,6 +972,7 @@ export type ShareLinkUncheckedUpdateWithoutRootFolderInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -956,6 +987,7 @@ export type ShareLinkCreateManyCreatorInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -970,6 +1002,7 @@ export type ShareLinkUpdateWithoutCreatorInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -984,6 +1017,7 @@ export type ShareLinkUncheckedUpdateWithoutCreatorInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -998,6 +1032,7 @@ export type ShareLinkUncheckedUpdateManyWithoutCreatorInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -1012,6 +1047,7 @@ export type ShareLinkCreateManyProjectInput = {
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
@@ -1026,6 +1062,7 @@ export type ShareLinkUpdateWithoutProjectInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -1040,6 +1077,7 @@ export type ShareLinkUncheckedUpdateWithoutProjectInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -1054,6 +1092,7 @@ export type ShareLinkUncheckedUpdateManyWithoutProjectInput = {
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?: PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -1071,6 +1110,7 @@ export type ShareLinkSelect<
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
@@ -1094,6 +1134,7 @@ export type ShareLinkSelectCreateManyAndReturn<
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
@@ -1117,6 +1158,7 @@ export type ShareLinkSelectUpdateManyAndReturn<
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
@@ -1137,6 +1179,7 @@ export type ShareLinkSelectScalar = {
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
@@ -1154,6 +1197,7 @@ export type ShareLinkOmit<
|
||||
| 'password'
|
||||
| 'isDisabled'
|
||||
| 'defaultSortOrder'
|
||||
| 'viewMode'
|
||||
| 'fieldVisibility'
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
@@ -1201,6 +1245,7 @@ export type $ShareLinkPayload<
|
||||
password: string | null
|
||||
isDisabled: boolean
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
/**
|
||||
* [ShareLinkFieldVisibility]
|
||||
*/
|
||||
@@ -1823,6 +1868,7 @@ export interface ShareLinkFieldRefs {
|
||||
readonly password: Prisma.FieldRef<'ShareLink', 'String'>
|
||||
readonly isDisabled: Prisma.FieldRef<'ShareLink', 'Boolean'>
|
||||
readonly defaultSortOrder: Prisma.FieldRef<'ShareLink', 'String'>
|
||||
readonly viewMode: Prisma.FieldRef<'ShareLink', 'String'>
|
||||
readonly fieldVisibility: Prisma.FieldRef<'ShareLink', 'Json'>
|
||||
readonly createdAt: Prisma.FieldRef<'ShareLink', 'DateTime'>
|
||||
readonly updatedAt: Prisma.FieldRef<'ShareLink', 'DateTime'>
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface ShareLinkInfo {
|
||||
isDisabled: boolean
|
||||
hasPassword: boolean
|
||||
defaultSortOrder?: string
|
||||
viewMode?: string
|
||||
fieldVisibility?: Record<string, boolean>
|
||||
rootFolderId: string
|
||||
projectId: string
|
||||
@@ -23,6 +24,7 @@ export const createShareLinkRequestSchema = z.object({
|
||||
password: z.string().optional(),
|
||||
isDisabled: z.boolean().optional(),
|
||||
defaultSortOrder: z.string().optional(),
|
||||
viewMode: z.string().optional(),
|
||||
})
|
||||
|
||||
export type CreateShareLinkRequest = z.infer<typeof createShareLinkRequestSchema>
|
||||
@@ -33,6 +35,7 @@ export const updateShareLinkRequestSchema = z.object({
|
||||
password: z.string().optional().nullable(),
|
||||
isDisabled: z.boolean().optional(),
|
||||
defaultSortOrder: z.string().optional().nullable(),
|
||||
viewMode: z.string().optional().nullable(),
|
||||
fieldVisibility: z.record(z.string(), z.boolean()).optional().nullable(),
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import type { AncestorFolder, AssetInfo, AssetInfoPaginatedList } from '@shumai/dtos'
|
||||
import type {
|
||||
AncestorFolder,
|
||||
AssetInfo,
|
||||
AssetInfoPaginatedList,
|
||||
UpdateShareLinkRequest,
|
||||
} from '@shumai/dtos'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useMutation, useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useState, useMemo } from 'react'
|
||||
@@ -88,10 +93,18 @@ export default function ShareManager({
|
||||
const {
|
||||
shareConfigLeftSidebarCollapsed: isLeftSidebarCollapsed,
|
||||
shareConfigRightSidebarCollapsed: isRightSidebarCollapsed,
|
||||
viewModes,
|
||||
} = useUiStore()
|
||||
|
||||
const displayStyle = viewModes[projectId] ?? 'card'
|
||||
const defaultSortOrder = shareLink?.defaultSortOrder || null
|
||||
let sort: string | undefined
|
||||
let order: string | undefined
|
||||
if (defaultSortOrder) {
|
||||
const parts = defaultSortOrder.split(':')
|
||||
sort = parts[0]
|
||||
order = parts[1]
|
||||
}
|
||||
|
||||
const displayStyle = (shareLink?.viewMode as 'card' | 'list') ?? 'card'
|
||||
|
||||
const {
|
||||
data: foldersData,
|
||||
@@ -99,13 +112,15 @@ export default function ShareManager({
|
||||
hasNextPage: hasNextPageFolders,
|
||||
isFetchingNextPage: isFetchingNextFoldersPage,
|
||||
} = useInfiniteQuery<AssetInfoPaginatedList>({
|
||||
queryKey: ['folder-children', teamId, currentFolderId, 'folder'],
|
||||
queryKey: ['folder-children', teamId, currentFolderId, 'folder', sort, order],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const res = await client.api.folders[':folderId'].children.$get({
|
||||
param: { folderId: currentFolderId! },
|
||||
query: {
|
||||
assetType: 'folder',
|
||||
after: pageParam as string,
|
||||
sort,
|
||||
order,
|
||||
},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch folders')
|
||||
@@ -122,13 +137,15 @@ export default function ShareManager({
|
||||
hasNextPage: hasNextPageFiles,
|
||||
isFetchingNextPage: isFetchingNextFilesPage,
|
||||
} = useInfiniteQuery<AssetInfoPaginatedList>({
|
||||
queryKey: ['folder-children', teamId, currentFolderId, 'file'],
|
||||
queryKey: ['folder-children', teamId, currentFolderId, 'file', sort, order],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const res = await client.api.folders[':folderId'].children.$get({
|
||||
param: { folderId: currentFolderId! },
|
||||
query: {
|
||||
assetType: 'file',
|
||||
after: pageParam as string,
|
||||
sort,
|
||||
order,
|
||||
},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch files')
|
||||
@@ -212,6 +229,22 @@ export default function ShareManager({
|
||||
},
|
||||
})
|
||||
|
||||
const $updateShare = client.api.shares[':shareId'].$put
|
||||
const { mutate: updateShare } = useMutation({
|
||||
mutationFn: async (json: UpdateShareLinkRequest) => {
|
||||
const res = await $updateShare({
|
||||
param: { shareId },
|
||||
json,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['share', shareId] })
|
||||
toast.success('Settings updated')
|
||||
},
|
||||
})
|
||||
|
||||
const handleItemDoubleClick = (item: AssetInfo) => {
|
||||
if (item.type === 'folder' || item.targetType === 'folder') {
|
||||
const currentFolderName =
|
||||
@@ -305,8 +338,14 @@ export default function ShareManager({
|
||||
setRightSidebarWidth((p) => Math.max(240, Math.min(600, p - delta)))
|
||||
}
|
||||
/>
|
||||
<div style={{ width: rightSidebarWidth }} className="flex-shrink-0">
|
||||
<ShareSettingsSidebar shareLink={shareLink} />
|
||||
<div style={{ width: rightSidebarWidth }} className="flex-shrink-0 h-full">
|
||||
<ShareSettingsSidebar
|
||||
shareLink={shareLink}
|
||||
viewMode={displayStyle}
|
||||
onViewModeChange={(mode) => updateShare({ viewMode: mode })}
|
||||
defaultSortOrder={defaultSortOrder}
|
||||
onSortOrderChange={(sortOrder) => updateShare({ defaultSortOrder: sortOrder })}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -11,19 +11,39 @@ import {
|
||||
Copy,
|
||||
ExternalLink,
|
||||
Shield,
|
||||
Settings2,
|
||||
Palette,
|
||||
ListFilter,
|
||||
SortAsc,
|
||||
LayoutGrid,
|
||||
List,
|
||||
ArrowDownUp,
|
||||
} from 'lucide-react'
|
||||
import React, { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { DateTimePicker } from '@/ui/components/datetime-picker'
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/ui/components/ui/select'
|
||||
|
||||
interface ShareSettingsSidebarProps {
|
||||
shareLink: ShareLinkInfo
|
||||
viewMode: 'card' | 'list'
|
||||
onViewModeChange: (mode: 'card' | 'list') => void
|
||||
defaultSortOrder: string | null
|
||||
onSortOrderChange: (sortOrder: string | null) => void
|
||||
}
|
||||
|
||||
export function ShareSettingsSidebar({ shareLink }: ShareSettingsSidebarProps) {
|
||||
export function ShareSettingsSidebar({
|
||||
shareLink,
|
||||
viewMode,
|
||||
onViewModeChange,
|
||||
defaultSortOrder,
|
||||
onSortOrderChange,
|
||||
}: ShareSettingsSidebarProps) {
|
||||
const queryClient = useQueryClient()
|
||||
const [password, setPassword] = useState('')
|
||||
const [expireAt, setExpireAt] = useState<Date | undefined>(
|
||||
@@ -74,6 +94,15 @@ export function ShareSettingsSidebar({ shareLink }: ShareSettingsSidebarProps) {
|
||||
updateShare({ fieldVisibility: next })
|
||||
}
|
||||
|
||||
// Parse current sort field and order
|
||||
let currentSortField = 'index'
|
||||
let currentSortOrder = 'asc'
|
||||
if (defaultSortOrder) {
|
||||
const parts = defaultSortOrder.split(':')
|
||||
currentSortField = parts[0]
|
||||
currentSortOrder = parts[1] || 'asc'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full bg-background border-l border-border">
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
@@ -87,29 +116,20 @@ export function ShareSettingsSidebar({ shareLink }: ShareSettingsSidebarProps) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<div className="relative flex-1">
|
||||
<Input value={shareUrl} readOnly className="pr-10 bg-muted/50 text-xs" />
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="absolute right-0 top-0 h-full"
|
||||
onClick={() => copyToClipboard(shareUrl)}
|
||||
>
|
||||
<Copy className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
<Button variant="outline" className="px-3">
|
||||
<Settings2 className="h-4 w-4 mr-2" />
|
||||
Public
|
||||
<div className="relative w-full">
|
||||
<Input value={shareUrl} readOnly className="pr-10 bg-muted/50 text-xs" />
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="absolute right-0 top-0 h-full"
|
||||
onClick={() => copyToClipboard(shareUrl)}
|
||||
>
|
||||
<Copy className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Input placeholder="Send to name or email" className="text-sm" />
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<SidebarAccordionItem title="Permissions" icon={<Settings2 className="h-4 w-4" />} />
|
||||
<SidebarAccordionItem title="Security" icon={<Shield className="h-4 w-4" />}>
|
||||
<div className="p-3 space-y-4 pt-0">
|
||||
<div className="space-y-2">
|
||||
@@ -167,7 +187,28 @@ export function ShareSettingsSidebar({ shareLink }: ShareSettingsSidebarProps) {
|
||||
</div>
|
||||
</div>
|
||||
</SidebarAccordionItem>
|
||||
<SidebarAccordionItem title="Appearance" icon={<Palette className="h-4 w-4" />} />
|
||||
<SidebarAccordionItem title="Appearance" icon={<Palette className="h-4 w-4" />}>
|
||||
<div className="p-3 space-y-3 pt-0 flex gap-2">
|
||||
<Button
|
||||
variant={viewMode === 'card' ? 'secondary' : 'outline'}
|
||||
size="sm"
|
||||
className="flex-1 gap-2 text-xs"
|
||||
onClick={() => onViewModeChange('card')}
|
||||
>
|
||||
<LayoutGrid className="h-4 w-4" />
|
||||
Grid
|
||||
</Button>
|
||||
<Button
|
||||
variant={viewMode === 'list' ? 'secondary' : 'outline'}
|
||||
size="sm"
|
||||
className="flex-1 gap-2 text-xs"
|
||||
onClick={() => onViewModeChange('list')}
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
List
|
||||
</Button>
|
||||
</div>
|
||||
</SidebarAccordionItem>
|
||||
<SidebarAccordionItem title="Fields" icon={<ListFilter className="h-4 w-4" />}>
|
||||
<div className="p-3 space-y-3 pt-0">
|
||||
{(fields as MetadataFieldInfo[])?.map((field) => (
|
||||
@@ -181,7 +222,65 @@ export function ShareSettingsSidebar({ shareLink }: ShareSettingsSidebarProps) {
|
||||
))}
|
||||
</div>
|
||||
</SidebarAccordionItem>
|
||||
<SidebarAccordionItem title="Sort by" icon={<SortAsc className="h-4 w-4" />} />
|
||||
<SidebarAccordionItem title="Sort by" icon={<SortAsc className="h-4 w-4" />}>
|
||||
<div className="p-3 space-y-4 pt-0">
|
||||
<div className="space-y-2">
|
||||
<Label className="text-xs text-muted-foreground">Field</Label>
|
||||
<Select
|
||||
value={currentSortField}
|
||||
onValueChange={(val) => {
|
||||
if (val === 'index') {
|
||||
onSortOrderChange(null)
|
||||
} else {
|
||||
onSortOrderChange(`${val}:${currentSortOrder}`)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="w-full text-xs h-9">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="index">Custom</SelectItem>
|
||||
<SelectItem value="name">Name</SelectItem>
|
||||
<SelectItem value="createdAt">Date Created</SelectItem>
|
||||
<SelectItem value="size">Size</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="text-xs text-muted-foreground">Order</Label>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-between font-normal text-xs h-9"
|
||||
disabled={currentSortField === 'index'}
|
||||
onClick={() => {
|
||||
const nextOrder = currentSortOrder === 'asc' ? 'desc' : 'asc'
|
||||
onSortOrderChange(`${currentSortField}:${nextOrder}`)
|
||||
}}
|
||||
>
|
||||
<span>
|
||||
{currentSortField === 'name'
|
||||
? currentSortOrder === 'asc'
|
||||
? 'A → Z'
|
||||
: 'Z → A'
|
||||
: currentSortField === 'createdAt'
|
||||
? currentSortOrder === 'asc'
|
||||
? 'Oldest → Newest'
|
||||
: 'Newest → Oldest'
|
||||
: currentSortField === 'size'
|
||||
? currentSortOrder === 'asc'
|
||||
? 'Smallest → Largest'
|
||||
: 'Largest → Smallest'
|
||||
: currentSortOrder === 'asc'
|
||||
? 'Ascending'
|
||||
: 'Descending'}
|
||||
</span>
|
||||
<ArrowDownUp className="h-4 w-4 opacity-50" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarAccordionItem>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -70,8 +70,8 @@ export function TopNav() {
|
||||
ancestorFolders={ancestorFolders}
|
||||
currentAsset={currentAsset}
|
||||
isRootFolder={isRootFolder}
|
||||
displayStyle={isFileView ? undefined : displayStyle}
|
||||
onDisplayStyleChange={isFileView ? undefined : onDisplayStyleChange}
|
||||
displayStyle={isFileView || isShareConfig ? undefined : displayStyle}
|
||||
onDisplayStyleChange={isFileView || isShareConfig ? undefined : onDisplayStyleChange}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={onLeftSidebarToggle}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
|
||||
Reference in New Issue
Block a user