mirror of
https://github.com/langgenius/dify.git
synced 2026-09-07 10:23:54 +08:00
Signed-off-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: 盐粒 Yanli <mail@yanli.one> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: zyssyz123 <916125788@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: 盐粒 Yanli <yanli@dify.ai> Co-authored-by: 林玮 (Jade Lin) <linw1995@icloud.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
'use client'
|
|
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectItemIndicator,
|
|
SelectItemText,
|
|
SelectTrigger,
|
|
} from '@langgenius/dify-ui/select'
|
|
import { useQueryState } from 'nuqs'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { rosterQueryParamNames, rosterSortByQueryParser } from '../query-params'
|
|
import { DEFAULT_ROSTER_SORT_BY, rosterSortOptions } from './roster-sort'
|
|
|
|
export function RosterSortSelect() {
|
|
const { t } = useTranslation('agentV2')
|
|
const [value, setValue] = useQueryState(rosterQueryParamNames.sortBy, rosterSortByQueryParser)
|
|
const selectedOption = rosterSortOptions.find(option => option.value === value)
|
|
?? rosterSortOptions.find(option => option.value === DEFAULT_ROSTER_SORT_BY)!
|
|
|
|
return (
|
|
<Select
|
|
value={value}
|
|
onValueChange={(nextValue) => {
|
|
void setValue(nextValue)
|
|
}}
|
|
>
|
|
<SelectTrigger
|
|
aria-label={t('roster.sort.label')}
|
|
className="h-8 w-fit max-w-45 min-w-0 gap-0 py-1 pr-2.5 pl-2"
|
|
>
|
|
<span className="flex min-w-0 items-center gap-1 px-1">
|
|
<span className="shrink-0 system-sm-regular text-text-tertiary">
|
|
{t('roster.sort.label')}
|
|
</span>
|
|
<span className="truncate system-sm-medium text-text-secondary">
|
|
{t(selectedOption.labelKey)}
|
|
</span>
|
|
</span>
|
|
</SelectTrigger>
|
|
<SelectContent
|
|
placement="bottom-start"
|
|
sideOffset={4}
|
|
popupClassName="w-60"
|
|
listProps={{ 'aria-label': t('roster.sort.optionsLabel') }}
|
|
>
|
|
{rosterSortOptions.map(option => (
|
|
<SelectItem
|
|
key={option.value}
|
|
value={option.value}
|
|
>
|
|
<SelectItemText title={t(option.labelKey)}>{t(option.labelKey)}</SelectItemText>
|
|
<SelectItemIndicator />
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
)
|
|
}
|