Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(web): use Select for the Studio app type filter (#44070)
yyh65d976182b9d
diff --git a/web/app/components/apps/__tests__/list.spec.tsx b/web/app/components/apps/__tests__/list.spec.tsxindex d9d08e617a0..1b81fd0f6fb 100644--- a/web/app/components/apps/__tests__/list.spec.tsx+++ b/web/app/components/apps/__tests__/list.spec.tsx@@ -526,7 +526,7 @@ type AppStarredListQueryOptions = {}const openAppTypeSelect = async (user = userEvent.setup()) => {- await user.click(screen.getByRole('button', { name: /^(Types|app\.types\.)/ }))+ await user.click(screen.getByRole('combobox', { name: 'Types' }))return user}@@ -869,7 +869,7 @@ describe('List', () => {expect(screen.getByText('app.firstEmpty.title'))!.toBeInTheDocument()expect(screen.getByText('app.firstEmpty.learnDifyTitle'))!.toBeInTheDocument()expect(screen.getByText('app.firstEmpty.or'))!.toBeInTheDocument()- expect(screen.getByRole('button', { name: 'Types' }))!.toBeInTheDocument()+ expect(screen.getByRole('combobox', { name: 'Types' }))!.toBeInTheDocument()expect(screen.queryByTestId('new-app-card')).not.toBeInTheDocument()expect(screen.queryByTestId('empty-state')).not.toBeInTheDocument()expect(@@ -911,7 +911,7 @@ describe('List', () => {renderList()expect(screen.queryByText('app.firstEmpty.title')).not.toBeInTheDocument()- expect(screen.getByRole('button', { name: 'Types' }))!.toBeInTheDocument()+ expect(screen.getByRole('combobox', { name: 'Types' }))!.toBeInTheDocument()})it('should not render first empty state from placeholder data during a filter transition', () => {@@ -936,7 +936,7 @@ describe('List', () => {'aria-busy','false',)- expect(screen.getByRole('button', { name: 'Types' }))!.toBeInTheDocument()+ expect(screen.getByRole('combobox', { name: 'Types' }))!.toBeInTheDocument()expect(screen.queryByTestId('new-app-card')).not.toBeInTheDocument()expect(screen.queryByText('app.firstEmpty.title')).not.toBeInTheDocument()})@@ -1033,13 +1033,15 @@ describe('List', () => {it('should render selected category in the trigger', () => {renderList('?category=workflow')- expect(screen.getByRole('button', { name: 'app.types.workflow' }))!.toBeInTheDocument()+ expect(screen.getByRole('combobox', { name: 'Types' })).toHaveTextContent(+ 'app.types.workflow',+ )})it('should reject API modes that the Studio category control does not support', () => {renderList('?category=channel')- expect(screen.getByRole('button', { name: 'Types' })).toBeInTheDocument()+ expect(screen.getByRole('combobox', { name: 'Types' })).toBeInTheDocument()const options = mockAppListInfiniteOptions.mock.calls.at(-1)?.[0] as AppListInfiniteOptionsexpect(options.input(1).query).not.toHaveProperty('mode')})@@ -1049,7 +1051,7 @@ describe('List', () => {const { onUrlUpdate } = renderList()await openAppTypeSelect(user)- await user.click(await screen.findByRole('menuitemradio', { name: 'app.types.workflow' }))+ await user.click(await screen.findByRole('option', { name: 'app.types.workflow' }))await waitFor(() => expect(onUrlUpdate).toHaveBeenCalled())expect(onUrlUpdate.mock.calls.at(-1)?.[0].searchParams.get('category')).toBe(@@ -1062,10 +1064,15 @@ describe('List', () => {const { onUrlUpdate } = renderList('?category=workflow')await openAppTypeSelect(user)- await user.click(await screen.findByRole('menuitemradio', { name: 'All' }))+ expect(await screen.findByRole('option', { name: 'app.types.workflow' })).toHaveAttribute(+ 'aria-selected',+ 'true',+ )+ await user.click(screen.getByRole('option', { name: 'All' }))await waitFor(() => expect(onUrlUpdate).toHaveBeenCalled())expect(onUrlUpdate.mock.calls.at(-1)?.[0].searchParams.has('category')).toBe(false)+ expect(screen.getByRole('combobox', { name: 'Types' })).toHaveTextContent('Types')})})@@ -1237,7 +1244,7 @@ describe('List', () => {const user = userEvent.setup()const { onUrlUpdate, unmount } = renderList()await openAppTypeSelect(user)- await user.click(await screen.findByRole('menuitemradio', { name: text }))+ await user.click(await screen.findByRole('option', { name: text }))await waitFor(() => expect(onUrlUpdate).toHaveBeenCalled())expect(onUrlUpdate.mock.calls.at(-1)?.[0].searchParams.get('category')).toBe(mode)unmount()diff --git a/web/app/components/apps/app-list-header.tsx b/web/app/components/apps/app-list-header.tsxindex a2d93f529d3..167dc4f7ca1 100644--- a/web/app/components/apps/app-list-header.tsx+++ b/web/app/components/apps/app-list-header.tsx@@ -87,7 +87,7 @@ export function AppListHeader({><div className="flex flex-wrap items-start justify-between gap-2"><div className="flex min-w-0 flex-1 flex-wrap items-center gap-2">- <AppTypeFilter value={category} onChange={onCategoryChange} />+ <AppTypeFilter value={category} onValueChange={onCategoryChange} /><TagFiltertype="app"value={tagIDs}diff --git a/web/app/components/apps/app-type-filter.tsx b/web/app/components/apps/app-type-filter.tsxindex 7d19e0a6ac2..56cb6742491 100644--- a/web/app/components/apps/app-type-filter.tsx+++ b/web/app/components/apps/app-type-filter.tsx@@ -3,57 +3,55 @@import type { AppListUrlQuery } from './query-params'import { cn } from '@langgenius/dify-ui/cn'import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuRadioGroup,- DropdownMenuRadioItem,- DropdownMenuRadioItemIndicator,- DropdownMenuTrigger,-} from '@langgenius/dify-ui/dropdown-menu'+ Select,+ SelectContent,+ SelectItem,+ SelectItemIndicator,+ SelectItemText,+ SelectTrigger,+ SelectValue,+} from '@langgenius/dify-ui/select'import { useMemo } from 'react'import { useTranslation } from 'react-i18next'import { studioAppListCategories } from './query-params'type AppListCategory = AppListUrlQuery['category']-const chipClassName =- 'flex h-8 items-center whitespace-nowrap rounded-lg border-[0.5px] px-2 text-[13px] leading-4 transition-colors'-type AppTypeFilterProps = {value: AppListCategory- onChange: (value: AppListCategory) => void+ onValueChange: (value: AppListCategory) => void}-export function AppTypeFilter({ value, onChange }: AppTypeFilterProps) {+export function AppTypeFilter({ value, onValueChange }: AppTypeFilterProps) {const { t } = useTranslation(['app'])const options = useMemo(() => {const optionsByCategory = {all: {- text: t(($) => $['types.all'], { ns: 'app' }),+ label: t(($) => $['types.all'], { ns: 'app' }),iconClassName: 'i-ri-apps-2-line',},workflow: {- text: t(($) => $['types.workflow'], { ns: 'app' }),+ label: t(($) => $['types.workflow'], { ns: 'app' }),iconClassName: 'i-ri-exchange-2-line',},'advanced-chat': {- text: t(($) => $['types.advanced'], { ns: 'app' }),+ label: t(($) => $['types.advanced'], { ns: 'app' }),iconClassName: 'i-ri-message-3-line',},chat: {- text: t(($) => $['types.chatbot'], { ns: 'app' }),+ label: t(($) => $['types.chatbot'], { ns: 'app' }),iconClassName: 'i-ri-message-3-line',},'agent-chat': {- text: t(($) => $['types.agent'], { ns: 'app' }),+ label: t(($) => $['types.agent'], { ns: 'app' }),iconClassName: 'i-ri-robot-3-line',},completion: {- text: t(($) => $['newApp.completeApp'], { ns: 'app' }),+ label: t(($) => $['newApp.completeApp'], { ns: 'app' }),iconClassName: 'i-ri-file-4-line',},- } satisfies Record<AppListCategory, { text: string; iconClassName: string }>+ } satisfies Record<AppListCategory, { label: string; iconClassName: string }>return studioAppListCategories.map((value) => ({value,@@ -61,47 +59,34 @@ export function AppTypeFilter({ value, onChange }: AppTypeFilterProps) {}))}, [t])- const activeOption = options.find((option) => option.value === value)- const isSelected = value !== 'all'- const triggerLabel = isSelected- ? activeOption?.text- : t(($) => $['studio.filters.types'], { ns: 'app' })+ const isFiltered = value !== 'all'+ const typesLabel = t(($) => $['studio.filters.types'], { ns: 'app' })return (- <DropdownMenu>- <DropdownMenuTrigger- render={- <button- type="button"- className={cn(- chipClassName,- isSelected- ? 'border-components-button-secondary-border bg-components-button-secondary-bg shadow-xs hover:bg-state-base-hover'- : 'border-transparent bg-components-input-bg-normal text-text-tertiary hover:bg-components-input-bg-hover',- )}- />- }- >- <span className="px-1 text-text-tertiary">{triggerLabel}</span>- <span aria-hidden className="i-ri-arrow-down-s-line h-4 w-4 shrink-0 text-text-tertiary" />- </DropdownMenuTrigger>- <DropdownMenuContent placement="bottom-start" className="w-55">- <DropdownMenuRadioGroup<AppListCategory>- value={value}- onValueChange={(nextValue) => onChange(nextValue)}- >- {options.map((option) => (- <DropdownMenuRadioItem<AppListCategory> key={option.value} value={option.value}>- <span- aria-hidden- className={cn('h-4 w-4 shrink-0 text-text-tertiary', option.iconClassName)}- />- <span>{option.text}</span>- <DropdownMenuRadioItemIndicator />- </DropdownMenuRadioItem>- ))}- </DropdownMenuRadioGroup>- </DropdownMenuContent>- </DropdownMenu>+ <Select<AppListCategory>+ items={options}+ value={value}+ onValueChange={(nextValue) => {+ if (nextValue !== null) onValueChange(nextValue)+ }}+ >+ <SelectTrigger aria-label={typesLabel} className="w-auto">+ <SelectValue className="text-text-tertiary">+ {isFiltered ? undefined : typesLabel}+ </SelectValue>+ </SelectTrigger>+ <SelectContent className="w-55">+ {options.map((option) => (+ <SelectItem<AppListCategory> key={option.value} value={option.value} className="gap-1">+ <span+ aria-hidden+ className={cn('h-4 w-4 shrink-0 text-text-tertiary', option.iconClassName)}+ />+ <SelectItemText>{option.label}</SelectItemText>+ <SelectItemIndicator />+ </SelectItem>+ ))}+ </SelectContent>+ </Select>)}