From 66f2efd77fb6cc1799ba826fb2de3584675ce017 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 12 Jun 2026 11:11:00 +0800 Subject: [PATCH 1/7] feat(fields): improve fields popup options, group filter, and dropdown clipping --- packages/webui/components/fields-manager.tsx | 120 +++++++++- .../webui/components/fields/select-field.tsx | 92 ++++---- .../components/fields/select-multi-field.tsx | 205 ++++++++---------- .../webui/components/file-system-manager.tsx | 6 +- .../webui/components/manage-fields-dialog.tsx | 23 +- 5 files changed, 274 insertions(+), 172 deletions(-) diff --git a/packages/webui/components/fields-manager.tsx b/packages/webui/components/fields-manager.tsx index 901751c2..dfca6651 100644 --- a/packages/webui/components/fields-manager.tsx +++ b/packages/webui/components/fields-manager.tsx @@ -1,9 +1,14 @@ -import { FieldType, type FieldInfo, type FieldInfo as MetadataFieldInfo } from '@shumai/dtos' +import { + FieldType, + type FieldInfo, + type FieldInfo as MetadataFieldInfo, + type SelectOption, +} from '@shumai/dtos' import { client } from '@/ui/api/client' import { useFieldStore } from '@/ui/stores/fields' import { DragDropProvider, KeyboardSensor, PointerSensor, type DragEndEvent } from '@dnd-kit/react' import { useSortable } from '@dnd-kit/react/sortable' -import { useMutation } from '@tanstack/react-query' +import { useMutation, useQueryClient } from '@tanstack/react-query' import { InferRequestType, InferResponseType } from 'hono/client' import { Button } from '@/ui/components/ui/button' @@ -18,8 +23,35 @@ import { Label } from '@/ui/components/ui/label' import { Switch } from '@/ui/components/ui/switch' import { arrayMove } from '@/ui/lib/dnd-utils' import { PointerActivationConstraints } from '@dnd-kit/dom' -import { ChevronDown, GripVertical, Plus, Search, Settings, Sparkles } from 'lucide-react' -import { useMemo, useState } from 'react' +import { + AlignLeft, + Calendar, + ChevronDown, + GripVertical, + Hash, + List, + Plus, + Search, + Settings, + Sparkles, + Star, + Tags, + ToggleLeft, + Type, + X, +} from 'lucide-react' +import { useMemo, useState, useEffect } from 'react' + +export const FIELD_TYPE_ICONS: Record> = { + [FieldType.text]: Type, + [FieldType.longText]: AlignLeft, + [FieldType.select]: List, + [FieldType.selectMulti]: Tags, + [FieldType.rating]: Star, + [FieldType.number]: Hash, + [FieldType.toggle]: ToggleLeft, + [FieldType.date]: Calendar, +} type SortableFieldItemProps = { field: FieldInfo @@ -33,14 +65,17 @@ function SortableFieldItem({ field, index, onVisibilityChange }: SortableFieldIt index, }) + const Icon = field.config?.type ? FIELD_TYPE_ICONS[field.config.type as FieldType] : null + return (
- {field.aiAutofill && } - {field.config?.name} + {Icon && } + {field.aiAutofill && } + {field.config?.name}
('') const [newAiAutofill, setNewAiAutofill] = useState(false) const [newDescription, setNewDescription] = useState('') + const [newOptions, setNewOptions] = useState([]) + + const queryClient = useQueryClient() + useEffect(() => { + queryClient.invalidateQueries({ queryKey: ['fields', projectId] }) + }, [projectId, queryClient]) const $patchOrder = client.api.projects[':projectId'].fields.order.$patch const { mutate: updateFieldsOrder } = useMutation< @@ -96,6 +137,7 @@ export function FieldsManager({ projectId, onManageFields, onSave }: FieldsManag const newFieldsList = [...fields, newField] updateFields(newFieldsList) setNewFieldName('') + setNewOptions([]) updateFieldsOrder({ param: { projectId: projectId }, @@ -147,12 +189,19 @@ export function FieldsManager({ projectId, onManageFields, onSave }: FieldsManag const handleCreateField = () => { if (!newFieldName || !newFieldType) return + const typeConfig = + newFieldType === FieldType.select + ? { select: { options: newOptions } } + : newFieldType === FieldType.selectMulti + ? { selectMulti: { options: newOptions } } + : {} createField({ param: { projectId: projectId }, json: { config: { name: newFieldName, type: newFieldType, + ...typeConfig, }, label: newFieldName, aiAutofill: newAiAutofill, @@ -195,7 +244,10 @@ export function FieldsManager({ projectId, onManageFields, onSave }: FieldsManag {Object.values(FieldType).map((type) => ( setNewFieldType(type)} + onClick={() => { + setNewFieldType(type) + setNewOptions([]) + }} className="capitalize" > {type.replace(/_/g, ' ')} @@ -220,6 +272,59 @@ export function FieldsManager({ projectId, onManageFields, onSave }: FieldsManag
+ {(newFieldType === FieldType.select || newFieldType === FieldType.selectMulti) && ( +
+
+ + +
+
+ {newOptions.map((opt, idx) => ( +
+ { + const updated = [...newOptions] + updated[idx] = { ...opt, displayName: e.target.value } + setNewOptions(updated) + }} + placeholder="Option name" + className="h-8 flex-1" + /> +
+ +
+ ))} +
+
+ )} +
+ + + {selectedGroup === SCOPE_GROUPS.PROJECT && ( + + )}
Date: Fri, 12 Jun 2026 11:40:35 +0800 Subject: [PATCH 3/7] feat(fields): stop click propagation on fields and reduce middle column width --- packages/webui/components/file-browser/file-card.tsx | 2 +- packages/webui/components/file-browser/file-list-item.tsx | 1 + packages/webui/components/manage-fields-dialog.tsx | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/webui/components/file-browser/file-card.tsx b/packages/webui/components/file-browser/file-card.tsx index 900a4a20..f26be1fb 100644 --- a/packages/webui/components/file-browser/file-card.tsx +++ b/packages/webui/components/file-browser/file-card.tsx @@ -377,7 +377,7 @@ export function FileCard({ -
+
e.stopPropagation()}> e.stopPropagation()} > {/* Middle Column: Field List */} -
+
{groups.find((g) => g.id === selectedGroup)?.label} @@ -645,7 +645,7 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel
{/* Right Column: Config */} -
+
{renderConfigEditor()}
{(isCreating || (selectedField && !selectedField.readOnly)) && (
From 6c3e62789f82ffc204112c402797de7aec63cb5a Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 12 Jun 2026 11:49:08 +0800 Subject: [PATCH 4/7] fix(fields): hide delete button for system fields in dialog --- packages/webui/components/manage-fields-dialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webui/components/manage-fields-dialog.tsx b/packages/webui/components/manage-fields-dialog.tsx index 4dc3e2b4..bf00544d 100644 --- a/packages/webui/components/manage-fields-dialog.tsx +++ b/packages/webui/components/manage-fields-dialog.tsx @@ -555,7 +555,7 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel
)} - {!isReadOnly && ( + {!isReadOnly && selectedField.scope?.toLowerCase() !== 'system' && (
{fields && fields.length > 0 && (
- {fields.map((field) => ( -
- -
- onSaveField(field.id!, val) : undefined} - readOnly={field.readOnly || !canEdit} - /> + {fields.map((field) => { + const Icon = field.config?.type + ? FIELD_TYPE_ICONS[field.config.type as FieldType] + : null + return ( +
+ +
+ onSaveField(field.id!, val) : undefined} + readOnly={field.readOnly || !canEdit} + /> +
-
- ))} + ) + })}
)}
diff --git a/packages/webui/components/file-browser/list-view.tsx b/packages/webui/components/file-browser/list-view.tsx index 7a70ce53..f5a04030 100644 --- a/packages/webui/components/file-browser/list-view.tsx +++ b/packages/webui/components/file-browser/list-view.tsx @@ -3,6 +3,8 @@ import type { AssetInfo } from '@shumai/dtos' import type { FieldInfo } from '@shumai/dtos' import type { SearchSort } from '@shumai/dtos' +import { FieldType } from '@shumai/dtos' +import { FIELD_TYPE_ICONS } from '../fields-manager' import { useDroppable } from '@dnd-kit/react' import { flexRender, getCoreRowModel, useReactTable, type ColumnDef } from '@tanstack/react-table' import { useVirtualizer } from '@tanstack/react-virtual' @@ -198,9 +200,15 @@ export function FileBrowserListView({ ] displayedFields.forEach((field) => { + const Icon = field.config?.type ? FIELD_TYPE_ICONS[field.config.type as FieldType] : null cols.push({ id: field.id, - header: field.config?.name || field.id, + header: () => ( +
+ {Icon && } + {field.config?.name || field.id} +
+ ), size: 150, minSize: 100, }) diff --git a/packages/webui/components/manage-fields-dialog.tsx b/packages/webui/components/manage-fields-dialog.tsx index bf00544d..1e8f9530 100644 --- a/packages/webui/components/manage-fields-dialog.tsx +++ b/packages/webui/components/manage-fields-dialog.tsx @@ -25,7 +25,7 @@ import { import { useMemo, useState, useEffect } from 'react' import { toast } from 'sonner' import { Popover, PopoverTrigger, PopoverContent } from '@/ui/components/ui/popover' -import { FIELD_TYPE_ICONS, PREDEFINED_COLORS } from './fields-manager' +import { FIELD_TYPE_ICONS, PREDEFINED_COLORS, COLOR_MAP } from './fields-manager' import { Button } from '@/ui/components/ui/button' import { Dialog, DialogContent, DialogTitle } from '@/ui/components/ui/dialog' @@ -495,7 +495,10 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel