diff --git a/packages/api/src/file.test.ts b/packages/api/src/file.test.ts index 4811c365..ec54533e 100644 --- a/packages/api/src/file.test.ts +++ b/packages/api/src/file.test.ts @@ -57,6 +57,7 @@ describe('file api', () => { vi.spyOn(assetService, 'deleteAssets').mockImplementation(vi.fn()) vi.spyOn(assetService, 'createComment').mockImplementation(vi.fn()) vi.spyOn(assetService, 'completeComment').mockImplementation(vi.fn()) + vi.spyOn(assetService, 'deleteComment').mockImplementation(vi.fn()) vi.spyOn(assetService, 'listComments').mockImplementation(vi.fn()) vi.spyOn(assetService, 'restoreAssets').mockImplementation(vi.fn()) vi.spyOn(metadataService, 'updateAssetMetadata').mockImplementation(vi.fn()) @@ -358,6 +359,30 @@ describe('file api', () => { }) }) + it('DELETE /comments/:commentId', async () => { + vi.mocked(assetService.deleteComment).mockResolvedValue(undefined) + + const app = new Hono().use('*', authMiddleware).route('/', fileRoute) + const res = await app.request('/comments/comment-id', { + method: 'DELETE', + }) + + expect(res.status).toBe(200) + const json = await res.json() + expect(json.success).toBe(true) + + expect(authzService.hasPermission).toHaveBeenCalledWith({ + user: { id: 'user1', name: 'Test User' }, + permission: Permission.Read, + type: ResourceType.Comment, + id: 'comment-id', + }) + expect(assetService.deleteComment).toHaveBeenCalledWith({ + commentId: 'comment-id', + userId: 'user1', + }) + }) + it('POST /teams/:teamId/files - image with compression', async () => { vi.mocked(s3Service.putObject).mockResolvedValue(undefined) diff --git a/packages/api/src/file.ts b/packages/api/src/file.ts index c40be830..1b8a2aee 100644 --- a/packages/api/src/file.ts +++ b/packages/api/src/file.ts @@ -220,6 +220,20 @@ const route = new Hono<{ Variables: { user: User } }>() return c.json(updated) }, ) + .delete('/comments/:commentId', async (c) => { + const commentId = c.req.param('commentId') + const user = c.get('user') + + await authzService.hasPermission({ + user, + permission: Permission.Read, + type: ResourceType.Comment, + id: commentId, + }) + + await assetService.deleteComment({ commentId, userId: user.id }) + return c.json({ success: true }) + }) .post('/files/restore', zValidator('json', restoreFilesRequestSchema), async (c) => { const user = c.get('user') const req = c.req.valid('json') diff --git a/packages/core/src/asset/asset.test.ts b/packages/core/src/asset/asset.test.ts index 588cb0ef..f660211d 100644 --- a/packages/core/src/asset/asset.test.ts +++ b/packages/core/src/asset/asset.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest' import { prisma } from '@shumai/db' import { setupTestDbHooks } from '@shumai/db/test' +import { HTTPException } from 'hono/http-exception' import { AssetType, AssetStatus, Prisma } from '@shumai/db' import { AssetService } from './asset' @@ -721,6 +722,161 @@ describe('AssetService', () => { expect(list.data[0].replies.length).toBe(1) }) + it('deleteComment validation and execution', async () => { + const { user, project, assets } = await setupBasicAssets() + + // 1. Create a comment + const comment = await assetService.createComment({ + assetId: assets.fileA1.id, + userId: user.id, + message: 'Self Comment', + attachmentIds: [], + }) + + // 2. Add user as a team member with owner role (team owner) + await prisma.teamMember.create({ + data: { + teamId: project.teamId, + userId: user.id, + role: 'owner', + }, + }) + + // Create another user + const otherUser = await prisma.user.create({ + data: { + name: 'OtherUser', + type: 'human', + email: `other-${Date.now()}@example.com`, + }, + }) + + // Add other user to the team as editor + await prisma.teamMember.create({ + data: { + teamId: project.teamId, + userId: otherUser.id, + role: 'editor', + }, + }) + + // Create comment by other user + const otherComment = await assetService.createComment({ + assetId: assets.fileA1.id, + userId: otherUser.id, + message: 'Other Comment', + attachmentIds: [], + }) + + // 3. User (owner) should be able to delete their own comment + await expect( + assetService.deleteComment({ commentId: comment.id, userId: user.id }), + ).resolves.not.toThrow() + // Verify it is deleted from DB + await expect(prisma.assetComment.findUnique({ where: { id: comment.id } })).resolves.toBeNull() + + // 4. User (owner) should be able to delete other user's comment + await expect( + assetService.deleteComment({ commentId: otherComment.id, userId: user.id }), + ).resolves.not.toThrow() + // Verify it is deleted from DB + await expect( + prisma.assetComment.findUnique({ where: { id: otherComment.id } }), + ).resolves.toBeNull() + + // Create a new comment by user + const comment2 = await assetService.createComment({ + assetId: assets.fileA1.id, + userId: user.id, + message: 'Self Comment 2', + attachmentIds: [], + }) + + // 5. Other user (editor, non-creator) should NOT be able to delete user's comment + await expect( + assetService.deleteComment({ commentId: comment2.id, userId: otherUser.id }), + ).rejects.toThrow(HTTPException) + + // 6. Other user (editor, creator) should be able to delete their own comment + const otherComment2 = await assetService.createComment({ + assetId: assets.fileA1.id, + userId: otherUser.id, + message: 'Other Comment 2', + attachmentIds: [], + }) + await expect( + assetService.deleteComment({ commentId: otherComment2.id, userId: otherUser.id }), + ).resolves.not.toThrow() + }) + + it('deleteComment cleans up S3 attachment files and database records', async () => { + const { user, project, assets } = await setupBasicAssets() + + // 1. Add user as team owner + await prisma.teamMember.create({ + data: { + teamId: project.teamId, + userId: user.id, + role: 'owner', + }, + }) + + // 2. Create StorageKey and Asset for attachment + const storageKey = await prisma.storageKey.create({ + data: { + key: 'attachments/test-attachment-file.png', + status: 'active', + }, + }) + + const attachmentAsset = await prisma.asset.create({ + data: { + name: 'test-attachment-file.png', + type: AssetType.file, + projectId: project.id, + parentId: assets.root.id, + creatorId: user.id, + storageKeyId: storageKey.id, + sizeByte: 100, + status: 'uploaded', + }, + }) + + // 3. Create a comment with this attachment + const comment = await assetService.createComment({ + assetId: assets.fileA1.id, + userId: user.id, + message: 'Comment with attachment', + attachmentIds: [attachmentAsset.id], + }) + + // Verify it is created in DB + const dbComment = await prisma.assetComment.findUnique({ + where: { id: comment.id }, + include: { attachments: true }, + }) + expect(dbComment?.attachments.length).toBe(1) + + // 4. Delete the comment + await expect( + assetService.deleteComment({ commentId: comment.id, userId: user.id }), + ).resolves.not.toThrow() + + // 5. Verify the comment is deleted from DB + await expect(prisma.assetComment.findUnique({ where: { id: comment.id } })).resolves.toBeNull() + + // 6. Verify that the attachment Asset and StorageKey are deleted from DB + await expect(prisma.asset.findUnique({ where: { id: attachmentAsset.id } })).resolves.toBeNull() + await expect(prisma.storageKey.findUnique({ where: { id: storageKey.id } })).resolves.toBeNull() + + // 7. Verify S3 deletion was called + const { s3Service } = await import('@shumai/core/src/s3/s3') + expect(s3Service.deleteObject).toHaveBeenCalledWith( + 'shumai', + 'attachments/test-attachment-file.png', + ) + }) + it('can create and retrieve comments with video timestamp', async () => { const { user, assets } = await setupBasicAssets() diff --git a/packages/core/src/asset/asset.ts b/packages/core/src/asset/asset.ts index 099aeac5..ca7ccc6d 100644 --- a/packages/core/src/asset/asset.ts +++ b/packages/core/src/asset/asset.ts @@ -18,6 +18,7 @@ import { AssetUserInfo, } from '@shumai/dtos' import { type Asset, AssetStatus, AssetType, Prisma, type StorageKey } from '@shumai/db' +import { HTTPException } from 'hono/http-exception' import { logger } from '@shumai/core/src/logger' import { PaginatedData, paginateQuery, PaginationParams } from '@shumai/core/src/pagination' import { s3Service } from '@shumai/core/src/s3/s3' @@ -1413,6 +1414,91 @@ export class AssetService { return this.getComment(commentId) } + async deleteComment({ commentId, userId }: { commentId: string; userId: string }): Promise { + const comment = await this.prismaClient.assetComment.findUnique({ + where: { id: commentId }, + include: { + attachments: { + include: { + asset: { + include: { + storageKey: true, + }, + }, + }, + }, + asset: { + select: { + project: { select: { id: true, teamId: true } }, + }, + }, + }, + }) + + if (!comment) { + throw new HTTPException(404, { message: 'Comment not found' }) + } + + const teamId = comment.asset.project?.teamId + + if (!teamId) { + throw new HTTPException(400, { + message: 'Data corruption: Comment asset is not associated with a project', + }) + } + + const member = await this.prismaClient.teamMember.findUnique({ + where: { + teamIdUserId: { + teamId, + userId, + }, + }, + }) + + if (!member) { + throw new HTTPException(403, { message: 'User is not a member of the team' }) + } + + const isOwner = member.role === 'owner' + const isCreator = comment.creatorId === userId + + if (!isOwner && !isCreator) { + throw new HTTPException(403, { message: 'You do not have permission to delete this comment' }) + } + + // Clean up attachment files from S3/storage and delete their DB records + const bucket = process.env.S3_BUCKET || 'shumai' + for (const att of comment.attachments) { + const asset = att.asset + if (asset.storageKey) { + try { + await s3Service.deleteObject(bucket, asset.storageKey.key) + } catch (err) { + logger.error({ err, assetId: asset.id }, 'Failed to delete attachment file from S3') + } + } + + await this.prismaClient.asset.delete({ + where: { id: asset.id }, + }) + + if (asset.storageKey) { + await this.prismaClient.storageKey + .delete({ + where: { id: asset.storageKey.id }, + }) + .catch(() => { + // Silently ignore if already deleted + }) + } + } + + await this.prismaClient.assetComment.delete({ + where: { id: commentId }, + }) + } + async listComments( assetId: string, params: PaginationParams, diff --git a/packages/webui/components/chat/message-card.tsx b/packages/webui/components/chat/message-card.tsx index 10e7eab4..7c6d0cb7 100644 --- a/packages/webui/components/chat/message-card.tsx +++ b/packages/webui/components/chat/message-card.tsx @@ -7,11 +7,27 @@ import { DialogHeader, DialogTitle, } from '@/ui/components/ui/dialog' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@/ui/components/ui/dropdown-menu' +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from '@/ui/components/ui/alert-dialog' import { Separator } from '@/ui/components/ui/separator' import { formatTimeAgo } from '@/ui/lib/time' import type { AttachmentInfo, CommentInfo, UserInfo } from '@shumai/dtos' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' -import { Download, File, Terminal } from 'lucide-react' +import { Download, File, Terminal, MoreHorizontal, Trash2 } from 'lucide-react' import React from 'react' import Markdown from 'react-markdown' import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar' @@ -145,6 +161,31 @@ export const MessageCard: React.FC = ({ }, }) + const [isDeleteDialogOpen, setIsDeleteDialogOpen] = React.useState(false) + + const { mutate: deleteComment, isPending: isDeleting } = useMutation({ + mutationFn: async () => { + const res = await client.api.comments[':commentId'].$delete({ + param: { commentId: message.id }, + }) + if (!res.ok) throw new Error('Failed to delete comment') + return await res.json() + }, + onSuccess: () => { + queryClient.invalidateQueries({ + predicate: (query) => query.queryKey.includes('comments'), + }) + setIsDeleteDialogOpen(false) + }, + }) + + const canDelete = React.useMemo(() => { + if (!me) return false + if (me.role === 'owner') return true + if (message.creator?.id === me.id) return true + return false + }, [me, message.creator?.id]) + const { data: logs, isLoading: isLogsLoading } = useQuery({ queryKey: ['agent-sessions', message.sessionId, 'entries'], queryFn: async () => { @@ -222,14 +263,44 @@ export const MessageCard: React.FC = ({ {/* Content */}
-
- {creator?.name || 'Unknown'} - - {new Date(message.createdAt!).toLocaleTimeString([], { - hour: '2-digit', - minute: '2-digit', - })} - +
+
+ {creator?.name || 'Unknown'} + + {new Date(message.createdAt!).toLocaleTimeString([], { + hour: '2-digit', + minute: '2-digit', + })} + +
+ {canDelete && ( +
+ + + + + e.stopPropagation()}> + { + e.stopPropagation() + setIsDeleteDialogOpen(true) + }} + > + + {m.delete()} + + + +
+ )}
@@ -664,6 +735,36 @@ export const MessageCard: React.FC = ({
+ + + e.stopPropagation()}> + + {m.delete_comment_confirm()} + {m.delete_comment_description()} + + + { + e.stopPropagation() + setIsDeleteDialogOpen(false) + }} + > + {m.cancel()} + + { + e.stopPropagation() + deleteComment() + }} + > + {m.delete()} + + + +
) } diff --git a/packages/webui/components/compare/compare-viewer.tsx b/packages/webui/components/compare/compare-viewer.tsx index 8331234d..503fa8fb 100644 --- a/packages/webui/components/compare/compare-viewer.tsx +++ b/packages/webui/components/compare/compare-viewer.tsx @@ -149,6 +149,47 @@ export function CompareViewer({ applyBoth((h) => (shouldPlay ? h.play() : h.pause())) }, [activeState?.video?.isPlaying, applyBoth]) + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + const activeEl = document.activeElement + if ( + activeEl && + (activeEl.tagName === 'INPUT' || + activeEl.tagName === 'TEXTAREA' || + (activeEl instanceof HTMLElement && activeEl.isContentEditable)) + ) { + return + } + + const isSpace = e.key === ' ' + const isInteractive = + activeEl && + (activeEl.tagName === 'BUTTON' || + activeEl.tagName === 'A' || + activeEl.tagName === 'SELECT' || + activeEl.tagName === 'OPTION' || + activeEl.getAttribute('role') === 'button' || + activeEl.getAttribute('role') === 'link' || + activeEl.getAttribute('role') === 'checkbox' || + activeEl.getAttribute('role') === 'radio' || + activeEl.getAttribute('role') === 'menuitem') + + if (isSpace && isInteractive) { + return + } + + if (e.key === ' ' || e.key.toLowerCase() === 'k') { + e.preventDefault() + handleTogglePlay() + } + } + + window.addEventListener('keydown', handleKeyDown) + return () => { + window.removeEventListener('keydown', handleKeyDown) + } + }, [handleTogglePlay]) + const handleSeek = useCallback( (frame: number) => applyBoth((h) => h.seekToFrame(frame)), [applyBoth], diff --git a/packages/webui/components/file-browser/file-card.tsx b/packages/webui/components/file-browser/file-card.tsx index 6f1af899..a1b3bea3 100644 --- a/packages/webui/components/file-browser/file-card.tsx +++ b/packages/webui/components/file-browser/file-card.tsx @@ -1,30 +1,30 @@ import { client } from '@/ui/api/client' -import type { AssetInfo, FieldValueInfo } from '@shumai/dtos' import { m } from '@/ui/paraglide/messages.js' +import type { AssetInfo, FieldValueInfo } from '@shumai/dtos' import { useQuery } from '@tanstack/react-query' import { Badge } from '@/ui/components/ui/badge' import { Button } from '@/ui/components/ui/button' import { Checkbox } from '@/ui/components/ui/checkbox' import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSeparator, + DropdownMenuTrigger, } from '@/ui/components/ui/dropdown-menu' import { EditableText } from '@/ui/components/ui/editable-text' +import { ProgressCircle } from '@/ui/components/ui/progress-circle' import { Skeleton } from '@/ui/components/ui/skeleton' import { formatTimeAgo } from '@/ui/lib/time' import { cn } from '@/ui/lib/utils' +import { useUploadStore } from '@/ui/stores/upload' import { useDraggable, useDroppable } from '@dnd-kit/react' import { Download, Edit, History, MoreHorizontal, Trash2 } from 'lucide-react' import React, { useEffect, useMemo, useRef, useState } from 'react' import type { DragState } from '../dnd-types' import FieldRenderer from '../field-renderer' import { FilePreview } from './file-preview' -import { useUploadStore } from '@/ui/stores/upload' -import { ProgressCircle } from '@/ui/components/ui/progress-circle' import { FieldType, type FieldInfo as MetadataFieldInfo } from '@shumai/dtos' import { FIELD_TYPE_ICONS } from '../fields-manager' @@ -282,7 +282,7 @@ export function FileCard({
-
+
( className={cn( 'h-auto min-h-0 w-full rounded-sm border px-1 py-0.5 text-base shadow-none transition-all outline-none focus-visible:ring-0', !disabled - ? 'border-blue-500 bg-muted/10 ring-1 ring-blue-500' - : 'border-transparent bg-transparent cursor-default opacity-100 focus-visible:border-transparent focus-visible:ring-0 caret-transparent select-none', + ? 'border-blue-500 !bg-muted/10 ring-1 ring-blue-500' + : 'border-transparent !bg-transparent cursor-default opacity-100 focus-visible:border-transparent focus-visible:ring-0 caret-transparent select-none', className, )} onClick={(e) => { diff --git a/packages/webui/components/viewers/image/compare-image-pane.tsx b/packages/webui/components/viewers/image/compare-image-pane.tsx index ea1ea03d..283432f6 100644 --- a/packages/webui/components/viewers/image/compare-image-pane.tsx +++ b/packages/webui/components/viewers/image/compare-image-pane.tsx @@ -194,7 +194,7 @@ export const CompareImagePane = forwardRef ( } }, []) + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + const activeEl = document.activeElement + if ( + activeEl && + (activeEl.tagName === 'INPUT' || + activeEl.tagName === 'TEXTAREA' || + (activeEl instanceof HTMLElement && activeEl.isContentEditable)) + ) { + return + } + + const isSpace = e.key === ' ' + const isInteractive = + activeEl && + (activeEl.tagName === 'BUTTON' || + activeEl.tagName === 'A' || + activeEl.tagName === 'SELECT' || + activeEl.tagName === 'OPTION' || + activeEl.getAttribute('role') === 'button' || + activeEl.getAttribute('role') === 'link' || + activeEl.getAttribute('role') === 'checkbox' || + activeEl.getAttribute('role') === 'radio' || + activeEl.getAttribute('role') === 'menuitem') + + if (isSpace && isInteractive) { + return + } + + if (e.key === ' ' || e.key.toLowerCase() === 'k') { + e.preventDefault() + togglePlay() + } + } + + window.addEventListener('keydown', handleKeyDown) + return () => { + window.removeEventListener('keydown', handleKeyDown) + } + }, [togglePlay]) + const toggleLoop = () => { const player = playerRef.current if (!player) return diff --git a/packages/webui/messages/en.json b/packages/webui/messages/en.json index 94957c8e..fb6f259e 100644 --- a/packages/webui/messages/en.json +++ b/packages/webui/messages/en.json @@ -840,6 +840,7 @@ "global_chatbot_description": "Select the agent that handles conversation inside the global chatbot sidebar.", "select_chatbot_agent": "Select chatbot agent", "no_chat_agents_warning": "No chat agents found. Please create a Chat Agent below first.", - "settings_saved": "Settings saved successfully", - "select_agent": "Select Agent" + "select_agent": "Select Agent", + "delete_comment_confirm": "Delete Comment?", + "delete_comment_description": "Are you sure you want to delete this comment? This action cannot be undone." } diff --git a/packages/webui/messages/zh.json b/packages/webui/messages/zh.json index 95a2817f..35731673 100644 --- a/packages/webui/messages/zh.json +++ b/packages/webui/messages/zh.json @@ -840,6 +840,7 @@ "global_chatbot_description": "选择在全局聊天机器人边栏中进行对话的智能体。", "select_chatbot_agent": "选择聊天机器人智能体", "no_chat_agents_warning": "未找到聊天智能体。请先在下方创建聊天智能体。", - "settings_saved": "设置保存成功", - "select_agent": "选择智能体" + "select_agent": "选择智能体", + "delete_comment_confirm": "删除评论?", + "delete_comment_description": "您确定要删除这条评论吗?此操作将无法撤回。" } diff --git a/packages/webui/paraglide/messages/_index.d.ts b/packages/webui/paraglide/messages/_index.d.ts index d01cd3ae..a8b3e03f 100644 --- a/packages/webui/paraglide/messages/_index.d.ts +++ b/packages/webui/paraglide/messages/_index.d.ts @@ -786,6 +786,7 @@ export * from "./global_chatbot.js"; export * from "./global_chatbot_description.js"; export * from "./select_chatbot_agent.js"; export * from "./no_chat_agents_warning.js"; -export * from "./settings_saved.js"; export * from "./select_agent.js"; +export * from "./delete_comment_confirm.js"; +export * from "./delete_comment_description.js"; export type LocalizedString = import("../runtime.js").LocalizedString; diff --git a/packages/webui/paraglide/messages/_index.js b/packages/webui/paraglide/messages/_index.js index 2926fc15..119aee9f 100644 --- a/packages/webui/paraglide/messages/_index.js +++ b/packages/webui/paraglide/messages/_index.js @@ -788,5 +788,6 @@ export * from './global_chatbot.js' export * from './global_chatbot_description.js' export * from './select_chatbot_agent.js' export * from './no_chat_agents_warning.js' -export * from './settings_saved.js' -export * from './select_agent.js' \ No newline at end of file +export * from './select_agent.js' +export * from './delete_comment_confirm.js' +export * from './delete_comment_description.js' \ No newline at end of file diff --git a/packages/webui/paraglide/messages/settings_saved.d.ts b/packages/webui/paraglide/messages/delete_comment_confirm.d.ts similarity index 55% rename from packages/webui/paraglide/messages/settings_saved.d.ts rename to packages/webui/paraglide/messages/delete_comment_confirm.d.ts index c2376844..58d40ee5 100644 --- a/packages/webui/paraglide/messages/settings_saved.d.ts +++ b/packages/webui/paraglide/messages/delete_comment_confirm.d.ts @@ -1,16 +1,16 @@ /** * | output | * | --- | -* | "Settings saved successfully" | +* | "Delete Comment?" | * -* @param {Settings_SavedInputs} inputs +* @param {Delete_Comment_ConfirmInputs} inputs * @param {{ locale?: "en" | "zh" }} options * @returns {LocalizedString} */ -export const settings_saved: ((inputs?: Settings_SavedInputs, options?: { +export const delete_comment_confirm: ((inputs?: Delete_Comment_ConfirmInputs, options?: { locale?: "en" | "zh"; -}) => LocalizedString) & import("../runtime.js").MessageMetadata LocalizedString) & import("../runtime.js").MessageMetadata; export type LocalizedString = import("../runtime.js").LocalizedString; -export type Settings_SavedInputs = {}; +export type Delete_Comment_ConfirmInputs = {}; diff --git a/packages/webui/paraglide/messages/delete_comment_confirm.js b/packages/webui/paraglide/messages/delete_comment_confirm.js new file mode 100644 index 00000000..d9d4e72f --- /dev/null +++ b/packages/webui/paraglide/messages/delete_comment_confirm.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Delete_Comment_ConfirmInputs */ + +const en_delete_comment_confirm = /** @type {(inputs: Delete_Comment_ConfirmInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Delete Comment?`) +}; + +const zh_delete_comment_confirm = /** @type {(inputs: Delete_Comment_ConfirmInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`删除评论?`) +}; + +/** +* | output | +* | --- | +* | "Delete Comment?" | +* +* @param {Delete_Comment_ConfirmInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const delete_comment_confirm = /** @type {((inputs?: Delete_Comment_ConfirmInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_delete_comment_confirm(inputs) + return zh_delete_comment_confirm(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/delete_comment_description.d.ts b/packages/webui/paraglide/messages/delete_comment_description.d.ts new file mode 100644 index 00000000..3a8f1211 --- /dev/null +++ b/packages/webui/paraglide/messages/delete_comment_description.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Are you sure you want to delete this comment? This action cannot be undone." | +* +* @param {Delete_Comment_DescriptionInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const delete_comment_description: ((inputs?: Delete_Comment_DescriptionInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Delete_Comment_DescriptionInputs = {}; diff --git a/packages/webui/paraglide/messages/delete_comment_description.js b/packages/webui/paraglide/messages/delete_comment_description.js new file mode 100644 index 00000000..1f3f803c --- /dev/null +++ b/packages/webui/paraglide/messages/delete_comment_description.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Delete_Comment_DescriptionInputs */ + +const en_delete_comment_description = /** @type {(inputs: Delete_Comment_DescriptionInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Are you sure you want to delete this comment? This action cannot be undone.`) +}; + +const zh_delete_comment_description = /** @type {(inputs: Delete_Comment_DescriptionInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`您确定要删除这条评论吗?此操作将无法撤回。`) +}; + +/** +* | output | +* | --- | +* | "Are you sure you want to delete this comment? This action cannot be undone." | +* +* @param {Delete_Comment_DescriptionInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const delete_comment_description = /** @type {((inputs?: Delete_Comment_DescriptionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_delete_comment_description(inputs) + return zh_delete_comment_description(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/settings_saved.js b/packages/webui/paraglide/messages/settings_saved.js deleted file mode 100644 index ee681b7e..00000000 --- a/packages/webui/paraglide/messages/settings_saved.js +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-disable */ -import { getLocale, experimentalStaticLocale } from '../runtime.js'; - -/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ - -/** @typedef {{}} Settings_SavedInputs */ - -const en_settings_saved = /** @type {(inputs: Settings_SavedInputs) => LocalizedString} */ () => { - return /** @type {LocalizedString} */ (`Settings saved successfully`) -}; - -const zh_settings_saved = /** @type {(inputs: Settings_SavedInputs) => LocalizedString} */ () => { - return /** @type {LocalizedString} */ (`设置保存成功`) -}; - -/** -* | output | -* | --- | -* | "Settings saved successfully" | -* -* @param {Settings_SavedInputs} inputs -* @param {{ locale?: "en" | "zh" }} options -* @returns {LocalizedString} -*/ -export const settings_saved = /** @type {((inputs?: Settings_SavedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { - const locale = experimentalStaticLocale ?? options.locale ?? getLocale() - if (locale === "en") return en_settings_saved(inputs) - return zh_settings_saved(inputs) -}); \ No newline at end of file