diff --git a/src/ui/components/file-browser/file-browser.tsx b/src/ui/components/file-browser/file-browser.tsx index 44d1da22..b654b548 100644 --- a/src/ui/components/file-browser/file-browser.tsx +++ b/src/ui/components/file-browser/file-browser.tsx @@ -741,7 +741,9 @@ export function FileBrowser({ > {!isShareView && !isPublic && onFilterChange && onSortChange && ( void @@ -26,7 +28,9 @@ type FileBrowserToolbarProps = { } export function FileBrowserToolbar({ + teamId, projectId, + assetId, fields, filterConditions, onFilterChange, @@ -35,10 +39,12 @@ export function FileBrowserToolbar({ isRecentlyDeleted, }: FileBrowserToolbarProps) { const [popoverOpen, setPopoverOpen] = useState(false) - const [filterPopoverOpen, setFilterPopoverOpen] = useState(false) + const [searchDialogOpen, setSearchDialogOpen] = useState(false) const [manageDialogOpen, setManageDialogOpen] = useState(false) const [isMembersDialogOpen, setIsMembersDialogOpen] = useState(false) + const activeFiltersCount = filterConditions.length + const { data: members } = useQuery({ queryKey: ['projects', projectId, 'members'], queryFn: async () => { @@ -134,27 +140,22 @@ export function FileBrowserToolbar({ - - - - - - - - + + + + ) } diff --git a/src/ui/components/search/filter-panel.tsx b/src/ui/components/search/filter-panel.tsx index 2bfb5e37..e4808588 100644 --- a/src/ui/components/search/filter-panel.tsx +++ b/src/ui/components/search/filter-panel.tsx @@ -18,6 +18,8 @@ interface FilterPanelProps { conditions: SearchCondition[] onChange: (conditions: SearchCondition[]) => void className?: string + excludeFields?: string[] + hidePrefix?: boolean } const SYSTEM_FIELDS = [ @@ -27,7 +29,14 @@ const SYSTEM_FIELDS = [ { id: 'sizeByte', label: 'Size', type: 'number' }, ] -export function FilterPanel({ fields, conditions, onChange, className }: FilterPanelProps) { +export function FilterPanel({ + fields, + conditions, + onChange, + className, + excludeFields, + hidePrefix, +}: FilterPanelProps) { const allFields = [ ...SYSTEM_FIELDS, ...fields.map((f) => ({ @@ -36,14 +45,14 @@ export function FilterPanel({ fields, conditions, onChange, className }: FilterP type: getFieldType(f), options: f.config?.select?.options, })), - ] + ].filter((f) => !excludeFields?.includes(f.id)) const handleAddCondition = () => { onChange([ ...conditions, { - field: 'name', - operator: 'contains', + field: allFields[0]?.id || 'name', + operator: 'eq', value: '', }, ]) @@ -75,9 +84,11 @@ export function FilterPanel({ fields, conditions, onChange, className }: FilterP
{conditions.map((condition, index) => (
-
- {index === 0 ? 'Where' : 'and'} -
+ {!hidePrefix && ( +
+ {index === 0 ? 'Where' : 'and'} +
+ )}
setSearchInput(e.target.value)} + placeholder="Search records by name..." + className="w-full pl-4 pr-24 py-3 bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-800 rounded-xl text-sm h-12 focus-visible:ring-2 focus-visible:ring-indigo-500/20 shadow-sm" + /> + {searchInput && ( + + )} + + + +
setIsFiltersExpanded(!isFiltersExpanded)} + className="flex items-center justify-between py-1.5 px-1 mt-1 rounded-lg hover:bg-neutral-100/50 dark:hover:bg-neutral-900/50 cursor-pointer select-none transition-colors group" + > +
+ {isFiltersExpanded ? ( + + ) : ( + + )} + + Filters + + + {activeFiltersCount > 0 && ( + + {activeFiltersCount} active + + )} +
+ + {(activeFiltersCount > 0 || searchInput) && ( + + )} +
+ + {isFiltersExpanded && ( +
+ +
+ )} +
+ + {/* Results Body ported from Demo */} +
+
+ + Search Results + + {isLoading && ( + + + Querying database... + + )} +
+ +
+ {!hasActiveCriteria ? ( +
+ +

+ Ready to Search +

+

+ Enter a name or add a filter rule to start discovering assets. +

+
+ ) : isLoading ? ( + Array.from({ length: 3 }).map((_, idx) => ( +
+
+
+
+
+
+
+ )) + ) : searchResults?.data?.length === 0 ? ( +
+ +

+ No records matched your criteria +

+

+ Try adjusting spelling or removing filter rows. +

+
+ ) : ( + searchResults?.data?.map((record) => ( +
handleResultClick(record)} + className="p-3.5 flex items-center gap-3 hover:bg-neutral-50 dark:hover:bg-neutral-900/40 transition-colors group/record cursor-pointer" + > +
+ {record.preview?.thumbnailUrl ? ( + + ) : record.type === 'folder' ? ( + + ) : ( + + )} +
+ +
+
+
+ + {record.name} + + + {record.type === 'folder' + ? 'Folder' + : `Size: ${formatBytes(record.sizeByte || 0)}`} + +
+ + {new Date(record.createdAt).toLocaleDateString(undefined, { + year: 'numeric', + month: 'short', + })} + +
+
+
+ )) + )} +
+
+ + {/* Footer ported from Demo */} +
+
+ + Matched{' '} + + {searchResults?.data?.length || 0} + {' '} + items + +
+ +
+ +
+
+ + + ) +} + +function formatBytes(bytes: number) { + if (bytes === 0) return '0 B' + const k = 1024 + const sizes = ['B', 'KB', 'MB', 'GB'] + const i = Math.floor(Math.log(bytes) / Math.log(k)) + return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i] +}