mirror of
https://github.com/langgenius/dify.git
synced 2026-03-27 17:19:55 +08:00
chore: skill in query to file
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
import { ViewType } from '@/app/components/workflow/types'
|
||||
import { parseAsViewType } from '../search-params'
|
||||
|
||||
describe('workflow-app search params', () => {
|
||||
it('should parse the new file view value and keep serializing it as file', () => {
|
||||
expect(parseAsViewType.parse('file')).toBe(ViewType.file)
|
||||
expect(parseAsViewType.serialize(ViewType.file)).toBe('file')
|
||||
})
|
||||
|
||||
it('should keep supporting legacy skill view links by mapping them to file', () => {
|
||||
expect(parseAsViewType.parse('skill')).toBe(ViewType.file)
|
||||
})
|
||||
|
||||
it('should reject unsupported view values', () => {
|
||||
expect(parseAsViewType.parse('invalid-view')).toBeNull()
|
||||
})
|
||||
})
|
||||
@ -1,7 +1,17 @@
|
||||
import { parseAsStringEnum } from 'nuqs'
|
||||
import { createParser } from 'nuqs'
|
||||
import { ViewType } from '@/app/components/workflow/types'
|
||||
|
||||
export const parseAsViewType = parseAsStringEnum<ViewType>(Object.values(ViewType))
|
||||
const VIEW_TYPES = Object.values(ViewType) as ViewType[]
|
||||
|
||||
export const parseAsViewType = createParser<ViewType>({
|
||||
parse: (value) => {
|
||||
if (value === 'skill')
|
||||
return ViewType.file
|
||||
|
||||
return VIEW_TYPES.includes(value as ViewType) ? value as ViewType : null
|
||||
},
|
||||
serialize: value => value,
|
||||
})
|
||||
.withDefault(ViewType.graph)
|
||||
.withOptions({
|
||||
history: 'push',
|
||||
|
||||
@ -82,7 +82,7 @@ const FilePreviewPanel = ({ resourceId, currentNode, className, style, onClose }
|
||||
if (!canOpenInEditor)
|
||||
return
|
||||
const nextUrl = new URL(window.location.href)
|
||||
nextUrl.searchParams.set('view', 'skill')
|
||||
nextUrl.searchParams.set('view', 'file')
|
||||
nextUrl.searchParams.set('fileId', resourceId)
|
||||
window.open(nextUrl.toString(), '_blank', 'noopener,noreferrer')
|
||||
}, [canOpenInEditor, resourceId])
|
||||
|
||||
@ -606,6 +606,6 @@ export type Block = {
|
||||
|
||||
export const ViewType = {
|
||||
graph: 'graph',
|
||||
skill: 'skill',
|
||||
file: 'file',
|
||||
} as const
|
||||
export type ViewType = typeof ViewType[keyof typeof ViewType]
|
||||
|
||||
@ -24,7 +24,7 @@ const ViewPicker: FC<ViewPickerProps> = ({
|
||||
const { t } = useTranslation()
|
||||
const options = useMemo(() => ([
|
||||
{ value: ViewType.graph, text: t('viewPicker.graph', { ns: 'workflow' }), disabled: disabled && value !== ViewType.graph },
|
||||
{ value: ViewType.skill, text: t('viewPicker.file', { ns: 'workflow' }), disabled: disabled && value !== ViewType.skill },
|
||||
{ value: ViewType.file, text: t('viewPicker.file', { ns: 'workflow' }), disabled: disabled && value !== ViewType.file },
|
||||
]), [t, disabled, value])
|
||||
|
||||
const handleChange = useCallback((nextValue: string | number | symbol) => {
|
||||
|
||||
Reference in New Issue
Block a user