diff --git a/packages/webui/components/search/filter-panel.tsx b/packages/webui/components/search/filter-panel.tsx index ecf70d3e..9c525e85 100644 --- a/packages/webui/components/search/filter-panel.tsx +++ b/packages/webui/components/search/filter-panel.tsx @@ -18,6 +18,7 @@ import RatingField from '../fields/rating-field' import { useEffect, useMemo } from 'react' import { useMemberStore } from '@/ui/stores/members' import { useTeamId } from '@/ui/hooks/use-team-id' +import { m } from '@/ui/paraglide/messages.js' interface FilterPanelProps { fields: FieldInfo[] @@ -28,13 +29,6 @@ interface FilterPanelProps { hidePrefix?: boolean } -const SYSTEM_FIELDS = [ - { id: 'name', label: 'Name', type: 'text' }, - { id: 'createdAt', label: 'Created At', type: 'date' }, - { id: 'updatedAt', label: 'Updated At', type: 'date' }, - { id: 'sizeByte', label: 'Size', type: 'number' }, -] - export function FilterPanel({ fields, conditions, @@ -60,19 +54,25 @@ export function FilterPanel({ })) }, [members]) - const allFields = [ - ...SYSTEM_FIELDS, - ...fields.map((f) => ({ + const allFields = useMemo(() => { + const sys = [ + { id: 'name', label: m.sort_name(), type: 'text' }, + { id: 'createdAt', label: m.field_created_at(), type: 'date' }, + { id: 'updatedAt', label: m.field_updated_at(), type: 'date' }, + { id: 'sizeByte', label: m.field_size(), type: 'number' }, + ] + const custom = fields.map((f) => ({ id: f.id!, - label: f.config?.name || f.description || 'Unknown', + label: f.config?.name || f.description || m.unknown(), type: getFieldType(f), options: f.config?.type === 'user' || f.config?.type === 'userMulti' ? memberOptions : f.config?.select?.options || f.config?.selectMulti?.options, config: f.config, - })), - ].filter((f) => !excludeFields?.includes(f.id)) + })) + return [...sys, ...custom].filter((f) => !excludeFields?.includes(f.id)) + }, [fields, memberOptions, excludeFields]) const handleAddCondition = () => { onChange([ @@ -136,7 +136,7 @@ export function FilterPanel({
{!hidePrefix && (
- {index === 0 ? 'Where' : 'and'} + {index === 0 ? m.filter_where() : m.filter_and()}
)}
@@ -145,7 +145,7 @@ export function FilterPanel({ onValueChange={(val) => handleConditionChange(index, 'field', val)} > - + {allFields.map((field) => ( @@ -161,7 +161,7 @@ export function FilterPanel({ onValueChange={(val) => handleConditionChange(index, 'operator', val)} > - + {getOperators( @@ -202,7 +202,7 @@ export function FilterPanel({ className="text-muted-foreground hover:text-foreground" onClick={handleAddCondition} > - + Add condition + {m.add_condition()}
@@ -242,22 +242,22 @@ function getOperators(field: { id: string; label: string; type: string }): { if (id === 'name') { return [ - { value: 'eq' as SearchConditionOperator, label: 'is' }, - { value: 'neq' as SearchConditionOperator, label: 'is not' }, - { value: 'contains' as SearchConditionOperator, label: 'contains' }, - { value: 'notContains' as SearchConditionOperator, label: 'does not contain' }, - { value: 'isEmpty' as SearchConditionOperator, label: 'is empty' }, - { value: 'isNotEmpty' as SearchConditionOperator, label: 'is not empty' }, + { value: 'eq' as SearchConditionOperator, label: m.operator_is() }, + { value: 'neq' as SearchConditionOperator, label: m.operator_is_not() }, + { value: 'contains' as SearchConditionOperator, label: m.operator_contains() }, + { value: 'notContains' as SearchConditionOperator, label: m.operator_does_not_contain() }, + { value: 'isEmpty' as SearchConditionOperator, label: m.operator_is_empty() }, + { value: 'isNotEmpty' as SearchConditionOperator, label: m.operator_is_not_empty() }, ] } switch (type) { case 'text': return [ - { value: 'eq' as SearchConditionOperator, label: 'is' }, - { value: 'neq' as SearchConditionOperator, label: 'is not' }, - { value: 'isEmpty' as SearchConditionOperator, label: 'is empty' }, - { value: 'isNotEmpty' as SearchConditionOperator, label: 'is not empty' }, + { value: 'eq' as SearchConditionOperator, label: m.operator_is() }, + { value: 'neq' as SearchConditionOperator, label: m.operator_is_not() }, + { value: 'isEmpty' as SearchConditionOperator, label: m.operator_is_empty() }, + { value: 'isNotEmpty' as SearchConditionOperator, label: m.operator_is_not_empty() }, ] case 'number': case 'rating': @@ -268,43 +268,43 @@ function getOperators(field: { id: string; label: string; type: string }): { { value: 'lt' as SearchConditionOperator, label: '<' }, { value: 'lte' as SearchConditionOperator, label: '≤' }, { value: 'gte' as SearchConditionOperator, label: '≥' }, - { value: 'isEmpty' as SearchConditionOperator, label: 'is empty' }, - { value: 'isNotEmpty' as SearchConditionOperator, label: 'is not empty' }, + { value: 'isEmpty' as SearchConditionOperator, label: m.operator_is_empty() }, + { value: 'isNotEmpty' as SearchConditionOperator, label: m.operator_is_not_empty() }, ] case 'select': return [ - { value: 'eq' as SearchConditionOperator, label: 'is' }, - { value: 'neq' as SearchConditionOperator, label: 'is not' }, - { value: 'in' as SearchConditionOperator, label: 'is any of' }, - { value: 'notIn' as SearchConditionOperator, label: 'is none of' }, - { value: 'isEmpty' as SearchConditionOperator, label: 'is empty' }, - { value: 'isNotEmpty' as SearchConditionOperator, label: 'is not empty' }, + { value: 'eq' as SearchConditionOperator, label: m.operator_is() }, + { value: 'neq' as SearchConditionOperator, label: m.operator_is_not() }, + { value: 'in' as SearchConditionOperator, label: m.operator_is_any_of() }, + { value: 'notIn' as SearchConditionOperator, label: m.operator_is_none_of() }, + { value: 'isEmpty' as SearchConditionOperator, label: m.operator_is_empty() }, + { value: 'isNotEmpty' as SearchConditionOperator, label: m.operator_is_not_empty() }, ] case 'selectMulti': return [ - { value: 'hasAny' as SearchConditionOperator, label: 'has any of' }, - { value: 'hasAll' as SearchConditionOperator, label: 'has all of' }, - { value: 'eq' as SearchConditionOperator, label: 'is exactly' }, - { value: 'hasNone' as SearchConditionOperator, label: 'has none of' }, - { value: 'isEmpty' as SearchConditionOperator, label: 'is empty' }, - { value: 'isNotEmpty' as SearchConditionOperator, label: 'is not empty' }, + { value: 'hasAny' as SearchConditionOperator, label: m.operator_has_any_of() }, + { value: 'hasAll' as SearchConditionOperator, label: m.operator_has_all_of() }, + { value: 'eq' as SearchConditionOperator, label: m.operator_is_exactly() }, + { value: 'hasNone' as SearchConditionOperator, label: m.operator_has_none_of() }, + { value: 'isEmpty' as SearchConditionOperator, label: m.operator_is_empty() }, + { value: 'isNotEmpty' as SearchConditionOperator, label: m.operator_is_not_empty() }, ] case 'date': return [ - { value: 'eq' as SearchConditionOperator, label: 'is' }, - { value: 'isWithin' as SearchConditionOperator, label: 'is within' }, - { value: 'lt' as SearchConditionOperator, label: 'is before' }, - { value: 'gt' as SearchConditionOperator, label: 'is after' }, - { value: 'lte' as SearchConditionOperator, label: 'is on or before' }, - { value: 'gte' as SearchConditionOperator, label: 'is on or after' }, - { value: 'neq' as SearchConditionOperator, label: 'is not' }, - { value: 'isEmpty' as SearchConditionOperator, label: 'is empty' }, - { value: 'isNotEmpty' as SearchConditionOperator, label: 'is not empty' }, + { value: 'eq' as SearchConditionOperator, label: m.operator_is() }, + { value: 'isWithin' as SearchConditionOperator, label: m.operator_is_within() }, + { value: 'lt' as SearchConditionOperator, label: m.operator_is_before() }, + { value: 'gt' as SearchConditionOperator, label: m.operator_is_after() }, + { value: 'lte' as SearchConditionOperator, label: m.operator_is_on_or_before() }, + { value: 'gte' as SearchConditionOperator, label: m.operator_is_on_or_after() }, + { value: 'neq' as SearchConditionOperator, label: m.operator_is_not() }, + { value: 'isEmpty' as SearchConditionOperator, label: m.operator_is_empty() }, + { value: 'isNotEmpty' as SearchConditionOperator, label: m.operator_is_not_empty() }, ] case 'toggle': - return [{ value: 'eq' as SearchConditionOperator, label: 'is' }] + return [{ value: 'eq' as SearchConditionOperator, label: m.operator_is() }] default: - return [{ value: 'eq' as SearchConditionOperator, label: 'is' }] + return [{ value: 'eq' as SearchConditionOperator, label: m.operator_is() }] } } @@ -362,7 +362,7 @@ function MultiSelectValueInput({ >
{selectedOptions.length === 0 ? ( - Select options... + {m.select_options()} ) : ( selectedOptions.map((option) => ( - + {field.options.map((opt) => ( @@ -453,13 +453,13 @@ function ConditionValueInput({ if (field.type === 'date') { const relativeDates = [ - { value: 'today', label: 'Today' }, - { value: 'yesterday', label: 'Yesterday' }, - { value: 'tomorrow', label: 'Tomorrow' }, - { value: 'one week ago', label: 'One week ago' }, - { value: 'one week from now', label: 'One week from now' }, - { value: 'one month ago', label: 'One month ago' }, - { value: 'one month from now', label: 'One month from now' }, + { value: 'today', label: m.date_today() }, + { value: 'yesterday', label: m.date_yesterday() }, + { value: 'tomorrow', label: m.date_tomorrow() }, + { value: 'one week ago', label: m.date_one_week_ago() }, + { value: 'one week from now', label: m.date_one_week_from_now() }, + { value: 'one month ago', label: m.date_one_month_ago() }, + { value: 'one month from now', label: m.date_one_month_from_now() }, ] const isRelative = relativeDates.some((rd) => rd.value === value) @@ -474,7 +474,7 @@ function ConditionValueInput({ }} > - + {relativeDates.map((rd) => ( @@ -482,7 +482,7 @@ function ConditionValueInput({ {rd.label} ))} - Exact date... + {m.exact_date()} {!isRelative && ( @@ -527,8 +527,8 @@ function ConditionValueInput({ - Checked - Unchecked + {m.toggle_checked()} + {m.toggle_unchecked()} ) @@ -537,7 +537,7 @@ function ConditionValueInput({ return ( diff --git a/packages/webui/components/search/search-filter-dialog.tsx b/packages/webui/components/search/search-filter-dialog.tsx index 1f649159..b802c8f1 100644 --- a/packages/webui/components/search/search-filter-dialog.tsx +++ b/packages/webui/components/search/search-filter-dialog.tsx @@ -26,6 +26,7 @@ import { useEffect, useMemo, useState } from 'react' import { useInView } from 'react-intersection-observer' import { toast } from 'sonner' import { FilterPanel } from './filter-panel' +import { m } from '@/ui/paraglide/messages.js' interface SearchFilterDialogProps { open: boolean @@ -72,7 +73,7 @@ export function SearchFilterDialog({ const res = await client.api.teams[':teamId'].settings.$get({ param: { teamId }, }) - if (!res.ok) throw new Error('Failed to fetch team settings') + if (!res.ok) throw new Error(m.failed_load_settings()) return (await res.json()) as { semanticSearchEnabled: boolean } }, enabled: open, @@ -123,7 +124,7 @@ export function SearchFilterDialog({ const fieldName = field?.config?.name || first.field name = `${fieldName} ${first.operator} ${first.value}` } - if (!name) name = 'Untitled Collection' + if (!name) name = m.untitled_collection() const res = await client.api.projects[':projectId'].collections.$post({ param: { projectId }, @@ -140,12 +141,12 @@ export function SearchFilterDialog({ }, }, }) - if (!res.ok) throw new Error('Failed to save collection') + if (!res.ok) throw new Error(m.failed_save_collection()) return await res.json() }, onSuccess: (data) => { queryClient.invalidateQueries({ queryKey: ['collections', projectId] }) - toast.success('Collection saved') + toast.success(m.collection_saved()) onOpenChange(false) navigate({ to: '/projects/$projectId/collections/$collectionId', @@ -184,7 +185,7 @@ export function SearchFilterDialog({ }) if (!res.ok) { const errorData = (await res.json().catch(() => ({}))) as Record - throw new Error((errorData.message as string) || 'Search failed') + throw new Error((errorData.message as string) || m.search_failed()) } return (await res.json()) as { data: AssetInfo[] @@ -255,7 +256,7 @@ export function SearchFilterDialog({ - Search + {m.search_dialog_title()}
@@ -271,7 +272,7 @@ export function SearchFilterDialog({ value={searchInput} onChange={(e) => setSearchInput(e.target.value)} placeholder={ - isSemantic ? 'Search records by content...' : 'Search records by name...' + isSemantic ? m.search_by_content_placeholder() : m.search_by_name_placeholder() } className="w-full pl-4 pr-24 py-3 bg-background border-border rounded-xl text-sm h-12 focus-visible:ring-2 focus-visible:ring-primary/20 shadow-sm" /> @@ -291,7 +292,7 @@ export function SearchFilterDialog({ type="submit" className="absolute right-1.5 top-1.5 bottom-1.5 px-4 bg-primary hover:bg-primary/90 text-primary-foreground text-xs font-semibold rounded-lg flex items-center justify-center transition-colors shadow-sm" > - Search + {m.search_button()}
@@ -315,12 +316,12 @@ export function SearchFilterDialog({ !semanticSearchEnabled && 'opacity-50 cursor-not-allowed', )} > - Semantic Search + {m.semantic_search()}
{!semanticSearchEnabled && ( - * Semantic search requires an enabled embedding agent. + {m.semantic_search_requires_embedding()} )} @@ -338,12 +339,12 @@ export function SearchFilterDialog({ ) : ( )} - Filters + {m.filters()} {activeFiltersCount > 0 && ( - {activeFiltersCount} active + {activeFiltersCount} {m.active_filters()} )} @@ -357,7 +358,7 @@ export function SearchFilterDialog({ }} className="text-[11px] font-medium text-destructive hover:text-destructive/80 underline underline-offset-2 transition-colors" > - Reset + {m.reset()} )} @@ -383,14 +384,12 @@ export function SearchFilterDialog({
- Search Results + {m.search_results()} {isLoading && ( - {isSemantic - ? 'Semantic search using media intelligence might be slow...' - : 'Querying database...'} + {isSemantic ? m.semantic_search_slow() : m.querying_database()} )}
@@ -399,25 +398,25 @@ export function SearchFilterDialog({ {!hasActiveCriteria ? (
-

Ready to Search

+

+ {m.ready_to_search()} +

- Type your query above and click the Search button to display results. + {m.type_query_instruction()}

{isSemantic && (

- Semantic search results will be ordered by their relevance to the search query - text, but won't be strictly filtered. If you need accurate filtering, please - add filter conditions to control that. + {m.semantic_search_note()}

)}
) : searchError ? (
-

Search failed

+

{m.search_failed()}

{searchError.message.includes('Embedding agent not configured') - ? 'Please create and enable an embedding agent in the team settings to use semantic search.' + ? m.enable_embedding_agent_hint() : searchError.message}

@@ -438,10 +437,10 @@ export function SearchFilterDialog({

- No records matched your criteria + {m.no_records_matched()}

- Try adjusting spelling or removing filter rows. + {m.try_adjusting_spelling()}

) : ( @@ -479,15 +478,15 @@ export function SearchFilterDialog({ {record.type === 'folder' - ? 'Folder' - : `Size: ${formatSize(record.sizeByte || 0)}`} + ? m.folder() + : `${m.size_prefix()} ${formatSize(record.sizeByte || 0)}`} {record.startTime !== undefined && record.startTime !== null && record.endTime !== undefined && record.endTime !== null && ( - Match found at {formatTimestamp(record.startTime)} -{' '} + {m.match_found_at()} {formatTimestamp(record.startTime)} -{' '} {formatTimestamp(record.endTime)} )} @@ -516,13 +515,7 @@ export function SearchFilterDialog({ {/* Footer ported from Demo */}
- - Matched{' '} - - {formatMatchedCount(totalCount)} - {' '} - items - + {m.matched_items({ count: formatMatchedCount(totalCount) })}
@@ -536,10 +529,10 @@ export function SearchFilterDialog({ {isSaving ? ( <> - Saving... + {m.saving_ellipsis()} ) : ( - 'Save as collection' + m.save_as_collection() )} @@ -548,7 +541,7 @@ export function SearchFilterDialog({ className="h-8 text-[10px] font-semibold uppercase tracking-wider" onClick={isSemantic ? () => onOpenChange(false) : handleApply} > - {isSemantic ? 'Close' : 'Apply and Close'} + {isSemantic ? m.close() : m.apply_and_close()}
diff --git a/packages/webui/components/search/sort-control.tsx b/packages/webui/components/search/sort-control.tsx index ef932c32..1ccff20b 100644 --- a/packages/webui/components/search/sort-control.tsx +++ b/packages/webui/components/search/sort-control.tsx @@ -10,6 +10,8 @@ import { SelectTrigger, SelectValue, } from '@/ui/components/ui/select' +import { useMemo } from 'react' +import { m } from '@/ui/paraglide/messages.js' interface SortControlProps { fields: MetadataFieldInfo[] @@ -18,22 +20,21 @@ interface SortControlProps { disabled?: boolean } -const SYSTEM_FIELDS = [ - { id: 'custom', label: 'Custom' }, - { id: 'name', label: 'Name' }, - { id: 'createdAt', label: 'Date Created' }, - { id: 'updatedAt', label: 'Date Modified' }, - { id: 'sizeByte', label: 'Size' }, -] - export function SortControl({ fields, sort, onSortChange, disabled }: SortControlProps) { - const allFields = [ - ...SYSTEM_FIELDS, - ...fields.map((f) => ({ + const allFields = useMemo(() => { + const sys = [ + { id: 'custom', label: m.sort_custom() }, + { id: 'name', label: m.sort_name() }, + { id: 'createdAt', label: m.sort_date_created() }, + { id: 'updatedAt', label: m.sort_date_modified() }, + { id: 'sizeByte', label: m.sort_size() }, + ] + const custom = fields.map((f) => ({ id: f.id!, - label: f.config?.name || f.description || 'Unknown', - })), - ] + label: f.config?.name || f.description || m.unknown(), + })) + return [...sys, ...custom] + }, [fields]) // Default to Custom if no sort selected const currentFieldId = sort?.field || 'custom' @@ -43,15 +44,15 @@ export function SortControl({ fields, sort, onSortChange, disabled }: SortContro const getDirectionOptions = (fieldId: string) => { if (fieldId === 'name') { - return { asc: 'A → Z', desc: 'Z → A' } + return { asc: m.sort_a_to_z(), desc: m.sort_z_to_a() } } if (['createdAt', 'updatedAt'].includes(fieldId)) { - return { asc: 'Oldest → Newest', desc: 'Newest → Oldest' } + return { asc: m.sort_oldest_to_newest(), desc: m.sort_newest_to_oldest() } } if (fieldId === 'sizeByte') { - return { asc: 'Smallest → Largest', desc: 'Largest → Smallest' } + return { asc: m.sort_smallest_to_largest(), desc: m.sort_largest_to_smallest() } } - return { asc: 'Ascending', desc: 'Descending' } + return { asc: m.ascending(), desc: m.descending() } } const dirOptions = getDirectionOptions(currentFieldId) @@ -79,13 +80,13 @@ export function SortControl({ fields, sort, onSortChange, disabled }: SortContro className="h-8" disabled={disabled} > - {sort ? `Sorted by ${currentField.label}` : 'Sort by'} + {sort ? m.sorted_by({ field: currentField.label }) : m.sort_by()}
- Sort by + {m.sort_by()}