mirror of https://github.com/langgenius/dify.git
feat: add i18n type generation scripts and improve code formatting
This commit is contained in:
parent
f89d6376dd
commit
253b8dbc0a
|
|
@ -54,10 +54,10 @@ const FileInAttachmentItem = ({
|
|||
progress === -1 && 'border-state-destructive-border bg-state-destructive-hover',
|
||||
canPreview && previewMode === PreviewMode.NewPage && 'cursor-pointer',
|
||||
)}
|
||||
onClick={() => {
|
||||
if (canPreview && previewMode === PreviewMode.NewPage)
|
||||
window.open(url || base64Url || '', '_blank')
|
||||
}}
|
||||
onClick={() => {
|
||||
if (canPreview && previewMode === PreviewMode.NewPage)
|
||||
window.open(url || base64Url || '', '_blank')
|
||||
}}
|
||||
>
|
||||
<div className='flex h-12 w-12 items-center justify-center'>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@ const ErrorMessage = ({
|
|||
'flex gap-x-0.5 rounded-xl border-[0.5px] border-components-panel-border bg-opacity-40 bg-toast-error-bg p-2 shadow-xs shadow-shadow-shadow-3',
|
||||
className,
|
||||
)}>
|
||||
<div className='flex size-6 items-center justify-center'>
|
||||
<RiErrorWarningFill className='h-4 w-4 text-text-destructive' />
|
||||
</div>
|
||||
<div className='flex flex-col gap-y-0.5 py-1'>
|
||||
<div className='system-xs-medium text-text-primary'>{title}</div>
|
||||
{errorMsg && (
|
||||
<div className='system-xs-regular text-text-secondary'>{errorMsg}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className='flex size-6 items-center justify-center'>
|
||||
<RiErrorWarningFill className='h-4 w-4 text-text-destructive' />
|
||||
</div>
|
||||
<div className='flex flex-col gap-y-0.5 py-1'>
|
||||
<div className='system-xs-medium text-text-primary'>{title}</div>
|
||||
{errorMsg && (
|
||||
<div className='system-xs-regular text-text-secondary'>{errorMsg}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const ActionButtons: FC<IActionButtonsProps> = ({
|
|||
return
|
||||
handleSave()
|
||||
},
|
||||
{ exactMatch: true, useCapture: true })
|
||||
{ exactMatch: true, useCapture: true })
|
||||
|
||||
const isParentChildParagraphMode = useMemo(() => {
|
||||
return docForm === ChunkingMode.parentChild && parentMode === 'paragraph'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
// import { useAppContext } from '@/context/app-context'
|
||||
// import Button from '@/app/components/base/button'
|
||||
// import Toast from '@/app/components/base/toast'
|
||||
// import Indicator from '@/app/components/header/indicator'
|
||||
|
|
@ -18,7 +18,7 @@ const ActionList = ({
|
|||
detail,
|
||||
}: Props) => {
|
||||
const { t } = useTranslation()
|
||||
const { isCurrentWorkspaceManager } = useAppContext()
|
||||
// const { isCurrentWorkspaceManager } = useAppContext()
|
||||
// const providerBriefInfo = detail.declaration.datasource?.identity
|
||||
// const providerKey = `${detail.plugin_id}/${providerBriefInfo?.name}`
|
||||
const { data: dataSourceList } = useDataSourceList(true)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ export const usePipelineInit = () => {
|
|||
|
||||
useEffect(() => {
|
||||
handleGetInitialWorkflowData()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ const Marketplace = ({
|
|||
<span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
|
||||
{t('plugin.category.tools')}
|
||||
</span>
|
||||
,
|
||||
<span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
|
||||
{t('plugin.category.datasources')}
|
||||
</span>
|
||||
,
|
||||
<span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
|
||||
{t('plugin.category.datasources')}
|
||||
</span>
|
||||
,
|
||||
<span className="body-md-medium relative ml-1 text-text-secondary after:absolute after:bottom-[1.5px] after:left-0 after:h-2 after:w-full after:bg-text-text-selected after:content-['']">
|
||||
{t('plugin.category.agents')}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const ManageInputField = ({
|
|||
}: ManageInputFieldProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
return (
|
||||
<div className='flex items-center border-t border-divider-subtle pt-1'>
|
||||
<div
|
||||
className='flex h-8 grow cursor-pointer items-center px-3'
|
||||
|
|
|
|||
|
|
@ -120,41 +120,41 @@ describe('match the schema type', () => {
|
|||
title: 'File',
|
||||
description: 'Schema for file objects (v1)',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'file name',
|
||||
},
|
||||
size: {
|
||||
type: 'number',
|
||||
description: 'file size',
|
||||
},
|
||||
extension: {
|
||||
type: 'string',
|
||||
description: 'file extension',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'file type',
|
||||
},
|
||||
mime_type: {
|
||||
type: 'string',
|
||||
description: 'file mime type',
|
||||
},
|
||||
transfer_method: {
|
||||
type: 'string',
|
||||
description: 'file transfer method',
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
description: 'file url',
|
||||
},
|
||||
related_id: {
|
||||
type: 'string',
|
||||
description: 'file related id',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'file name',
|
||||
},
|
||||
size: {
|
||||
type: 'number',
|
||||
description: 'file size',
|
||||
},
|
||||
extension: {
|
||||
type: 'string',
|
||||
description: 'file extension',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'file type',
|
||||
},
|
||||
mime_type: {
|
||||
type: 'string',
|
||||
description: 'file mime type',
|
||||
},
|
||||
transfer_method: {
|
||||
type: 'string',
|
||||
description: 'file transfer method',
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
description: 'file url',
|
||||
},
|
||||
related_id: {
|
||||
type: 'string',
|
||||
description: 'file related id',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
'name',
|
||||
'name',
|
||||
],
|
||||
}
|
||||
expect(matchTheSchemaType(fileSchema, file)).toBe(true)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import type { AnyObj } from './match-schema-type'
|
|||
import matchTheSchemaType from './match-schema-type'
|
||||
|
||||
export const getMatchedSchemaType = (obj: AnyObj, schemaTypeDefinitions?: SchemaTypeDefinition[]): string => {
|
||||
if(!schemaTypeDefinitions) return ''
|
||||
const matched = schemaTypeDefinitions.find(def => matchTheSchemaType(obj, def.schema))
|
||||
return matched ? matched.name : ''
|
||||
if(!schemaTypeDefinitions) return ''
|
||||
const matched = schemaTypeDefinitions.find(def => matchTheSchemaType(obj, def.schema))
|
||||
return matched ? matched.name : ''
|
||||
}
|
||||
|
||||
const useMatchSchemaType = () => {
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ const VarReferencePicker: FC<Props> = ({
|
|||
})
|
||||
|
||||
const node = nodes.find(n => n.id === nodeId)
|
||||
const isInIteration = !!(node?.data as any).isInIteration
|
||||
const isInIteration = !!(node?.data as any)?.isInIteration
|
||||
const iterationNode = isInIteration ? nodes.find(n => n.id === node?.parentId) : null
|
||||
|
||||
const isInLoop = !!(node?.data as any).isInLoop
|
||||
const isInLoop = !!(node?.data as any)?.isInLoop
|
||||
const loopNode = isInLoop ? nodes.find(n => n.id === node?.parentId) : null
|
||||
|
||||
const triggerRef = useRef<HTMLDivElement>(null)
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ const useAvailableVarList = (nodeId: string, {
|
|||
hideChatVar,
|
||||
passedInAvailableNodes,
|
||||
}: Params = {
|
||||
onlyLeafNodeVar: false,
|
||||
filterVar: () => true,
|
||||
}) => {
|
||||
onlyLeafNodeVar: false,
|
||||
filterVar: () => true,
|
||||
}) => {
|
||||
const { getTreeLeafNodes, getNodeById, getBeforeNodesInSameBranchIncludeParent } = useWorkflow()
|
||||
const { getNodeAvailableVars } = useWorkflowVariables()
|
||||
const isChatMode = useIsChatMode()
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export const useConfig = (id: string) => {
|
|||
retrieval_model,
|
||||
chunk_structure,
|
||||
index_chunk_variable_selector,
|
||||
} = nodeData?.data
|
||||
} = nodeData?.data || {}
|
||||
const { search_method } = retrieval_model || {}
|
||||
handleNodeDataUpdate({
|
||||
chunk_structure: chunkStructure,
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ const DatasetItem: FC<Props> = ({
|
|||
<div className={`group/dataset-item flex h-10 cursor-pointer items-center justify-between rounded-lg
|
||||
border-[0.5px] border-components-panel-border-subtle px-2
|
||||
${isDeleteHovered
|
||||
? 'border-state-destructive-border bg-state-destructive-hover'
|
||||
: 'bg-components-panel-on-panel-item-bg hover:bg-components-panel-on-panel-item-bg-hover'
|
||||
}`}>
|
||||
? 'border-state-destructive-border bg-state-destructive-hover'
|
||||
: 'bg-components-panel-on-panel-item-bg hover:bg-components-panel-on-panel-item-bg-hover'
|
||||
}`}>
|
||||
<div className='flex w-0 grow items-center space-x-1.5'>
|
||||
<AppIcon
|
||||
size='tiny'
|
||||
|
|
|
|||
|
|
@ -37,25 +37,25 @@ import { createLayoutSlice } from './layout-slice'
|
|||
import type { WorkflowSliceShape as WorkflowAppSliceShape } from '@/app/components/workflow-app/store/workflow/workflow-slice'
|
||||
import type { RagPipelineSliceShape } from '@/app/components/rag-pipeline/store'
|
||||
|
||||
export type SliceFromInjection =
|
||||
Partial<WorkflowAppSliceShape> &
|
||||
Partial<RagPipelineSliceShape>
|
||||
export type SliceFromInjection
|
||||
= Partial<WorkflowAppSliceShape>
|
||||
& Partial<RagPipelineSliceShape>
|
||||
|
||||
export type Shape =
|
||||
ChatVariableSliceShape &
|
||||
EnvVariableSliceShape &
|
||||
FormSliceShape &
|
||||
HelpLineSliceShape &
|
||||
HistorySliceShape &
|
||||
NodeSliceShape &
|
||||
PanelSliceShape &
|
||||
ToolSliceShape &
|
||||
VersionSliceShape &
|
||||
WorkflowDraftSliceShape &
|
||||
WorkflowSliceShape &
|
||||
InspectVarsSliceShape &
|
||||
LayoutSliceShape &
|
||||
SliceFromInjection
|
||||
export type Shape
|
||||
= ChatVariableSliceShape
|
||||
& EnvVariableSliceShape
|
||||
& FormSliceShape
|
||||
& HelpLineSliceShape
|
||||
& HistorySliceShape
|
||||
& NodeSliceShape
|
||||
& PanelSliceShape
|
||||
& ToolSliceShape
|
||||
& VersionSliceShape
|
||||
& WorkflowDraftSliceShape
|
||||
& WorkflowSliceShape
|
||||
& InspectVarsSliceShape
|
||||
& LayoutSliceShape
|
||||
& SliceFromInjection
|
||||
|
||||
export type InjectWorkflowStoreSliceFn = StateCreator<SliceFromInjection>
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
"uglify-embed": "node ./bin/uglify-embed",
|
||||
"check-i18n": "node ./i18n-config/check-i18n.js",
|
||||
"auto-gen-i18n": "node ./i18n-config/auto-gen-i18n.js",
|
||||
"gen:i18n-types": "node ./i18n-config/generate-i18n-types.js",
|
||||
"check:i18n-types": "node ./i18n-config/check-i18n-sync.js",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"storybook": "storybook dev -p 6006",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ type CustomMessages = typeof import('../i18n/en-US/custom').default
|
|||
type DatasetCreationMessages = typeof import('../i18n/en-US/dataset-creation').default
|
||||
type DatasetDocumentsMessages = typeof import('../i18n/en-US/dataset-documents').default
|
||||
type DatasetHitTestingMessages = typeof import('../i18n/en-US/dataset-hit-testing').default
|
||||
type DatasetPipelineMessages = typeof import('../i18n/en-US/dataset-pipeline').default
|
||||
type DatasetSettingsMessages = typeof import('../i18n/en-US/dataset-settings').default
|
||||
type DatasetMessages = typeof import('../i18n/en-US/dataset').default
|
||||
type EducationMessages = typeof import('../i18n/en-US/education').default
|
||||
|
|
@ -24,6 +25,7 @@ type ExploreMessages = typeof import('../i18n/en-US/explore').default
|
|||
type LayoutMessages = typeof import('../i18n/en-US/layout').default
|
||||
type LoginMessages = typeof import('../i18n/en-US/login').default
|
||||
type OauthMessages = typeof import('../i18n/en-US/oauth').default
|
||||
type PipelineMessages = typeof import('../i18n/en-US/pipeline').default
|
||||
type PluginTagsMessages = typeof import('../i18n/en-US/plugin-tags').default
|
||||
type PluginMessages = typeof import('../i18n/en-US/plugin').default
|
||||
type RegisterMessages = typeof import('../i18n/en-US/register').default
|
||||
|
|
@ -47,6 +49,7 @@ export type Messages = {
|
|||
datasetCreation: DatasetCreationMessages;
|
||||
datasetDocuments: DatasetDocumentsMessages;
|
||||
datasetHitTesting: DatasetHitTestingMessages;
|
||||
datasetPipeline: DatasetPipelineMessages;
|
||||
datasetSettings: DatasetSettingsMessages;
|
||||
dataset: DatasetMessages;
|
||||
education: EducationMessages;
|
||||
|
|
@ -54,6 +57,7 @@ export type Messages = {
|
|||
layout: LayoutMessages;
|
||||
login: LoginMessages;
|
||||
oauth: OauthMessages;
|
||||
pipeline: PipelineMessages;
|
||||
pluginTags: PluginTagsMessages;
|
||||
plugin: PluginMessages;
|
||||
register: RegisterMessages;
|
||||
|
|
|
|||
Loading…
Reference in New Issue