diff --git a/web/app/components/base/file-uploader/file-uploader-in-attachment/file-item.tsx b/web/app/components/base/file-uploader/file-uploader-in-attachment/file-item.tsx index 3430f56c52..b308e8d758 100644 --- a/web/app/components/base/file-uploader/file-uploader-in-attachment/file-item.tsx +++ b/web/app/components/base/file-uploader/file-uploader-in-attachment/file-item.tsx @@ -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') + }} >
{ diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx index 1b63e657d6..ca1cef246d 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx @@ -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, )}> -
- -
-
-
{title}
- {errorMsg && ( -
{errorMsg}
- )} -
+
+ +
+
+
{title}
+ {errorMsg && ( +
{errorMsg}
+ )} +
) } diff --git a/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsx b/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsx index b29682239f..4bed7b461d 100644 --- a/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsx +++ b/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsx @@ -38,7 +38,7 @@ const ActionButtons: FC = ({ return handleSave() }, - { exactMatch: true, useCapture: true }) + { exactMatch: true, useCapture: true }) const isParentChildParagraphMode = useMemo(() => { return docForm === ChunkingMode.parentChild && parentMode === 'paragraph' diff --git a/web/app/components/plugins/plugin-detail-panel/datasource-action-list.tsx b/web/app/components/plugins/plugin-detail-panel/datasource-action-list.tsx index 991e0aa671..5565f05b11 100644 --- a/web/app/components/plugins/plugin-detail-panel/datasource-action-list.tsx +++ b/web/app/components/plugins/plugin-detail-panel/datasource-action-list.tsx @@ -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) diff --git a/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts b/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts index 6cae5b89b9..c70bce8523 100644 --- a/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts +++ b/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts @@ -83,7 +83,6 @@ export const usePipelineInit = () => { useEffect(() => { handleGetInitialWorkflowData() - // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return { diff --git a/web/app/components/tools/marketplace/index.tsx b/web/app/components/tools/marketplace/index.tsx index b3a3f7da97..855a6c044b 100644 --- a/web/app/components/tools/marketplace/index.tsx +++ b/web/app/components/tools/marketplace/index.tsx @@ -57,10 +57,10 @@ const Marketplace = ({ {t('plugin.category.tools')} - , - - {t('plugin.category.datasources')} - + , + + {t('plugin.category.datasources')} + , {t('plugin.category.agents')} diff --git a/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx b/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx index 929e585157..a0588959ea 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx @@ -10,7 +10,7 @@ const ManageInputField = ({ }: ManageInputFieldProps) => { const { t } = useTranslation() - return ( + return (
{ 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) diff --git a/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts b/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts index 5650e88f06..fdde6685de 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts @@ -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 = () => { diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx index 42eb8b99f5..273e100f8e 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx @@ -132,10 +132,10 @@ const VarReferencePicker: FC = ({ }) 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(null) diff --git a/web/app/components/workflow/nodes/_base/hooks/use-available-var-list.ts b/web/app/components/workflow/nodes/_base/hooks/use-available-var-list.ts index 3e845ecdbf..2ce9dfe809 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-available-var-list.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-available-var-list.ts @@ -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() diff --git a/web/app/components/workflow/nodes/knowledge-base/hooks/use-config.ts b/web/app/components/workflow/nodes/knowledge-base/hooks/use-config.ts index c61fe0fab4..365722feba 100644 --- a/web/app/components/workflow/nodes/knowledge-base/hooks/use-config.ts +++ b/web/app/components/workflow/nodes/knowledge-base/hooks/use-config.ts @@ -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, diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx index dd280f7578..0e510ed58c 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx +++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx @@ -63,9 +63,9 @@ const DatasetItem: FC = ({
+ ? 'border-state-destructive-border bg-state-destructive-hover' + : 'bg-components-panel-on-panel-item-bg hover:bg-components-panel-on-panel-item-bg-hover' + }`}>
& - Partial +export type SliceFromInjection + = Partial + & Partial -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 diff --git a/web/app/signin/components/mail-and-password-auth.tsx b/web/app/signin/components/mail-and-password-auth.tsx index ca8a481feb..cccbd3a6ee 100644 --- a/web/app/signin/components/mail-and-password-auth.tsx +++ b/web/app/signin/components/mail-and-password-auth.tsx @@ -11,6 +11,7 @@ import Input from '@/app/components/base/input' import I18NContext from '@/context/i18n' import { noop } from 'lodash-es' import { resolvePostLoginRedirect } from '../utils/post-login-redirect' +import type { ResponseError } from '@/service/fetch' type MailAndPasswordAuthProps = { isInvite: boolean @@ -73,12 +74,6 @@ export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegis router.replace(redirectUrl || '/apps') } } - else if (res.code === 'authentication_failed') { - Toast.notify({ - type: 'error', - message: t('login.error.invalidEmailOrPassword'), - }) - } else { Toast.notify({ type: 'error', @@ -86,7 +81,14 @@ export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegis }) } } - + catch (error) { + if ((error as ResponseError).code === 'authentication_failed') { + Toast.notify({ + type: 'error', + message: t('login.error.invalidEmailOrPassword'), + }) + } + } finally { setIsLoading(false) } diff --git a/web/package.json b/web/package.json index b6223cea3c..2d20b9e5a3 100644 --- a/web/package.json +++ b/web/package.json @@ -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", diff --git a/web/service/base.ts b/web/service/base.ts index 87f1180c9e..be15af895d 100644 --- a/web/service/base.ts +++ b/web/service/base.ts @@ -464,42 +464,44 @@ export const ssePost = async ( } return } - return handleStream(res, (str: string, isFirstMessage: boolean, moreInfo: IOnDataMoreInfo) => { - if (moreInfo.errorMessage) { - onError?.(moreInfo.errorMessage, moreInfo.errorCode) - // TypeError: Cannot assign to read only property ... will happen in page leave, so it should be ignored. - if (moreInfo.errorMessage !== 'AbortError: The user aborted a request.' && !moreInfo.errorMessage.includes('TypeError: Cannot assign to read only property')) - Toast.notify({ type: 'error', message: moreInfo.errorMessage }) - return - } - onData?.(str, isFirstMessage, moreInfo) - }, - onCompleted, - onThought, - onMessageEnd, - onMessageReplace, - onFile, - onWorkflowStarted, - onWorkflowFinished, - onNodeStarted, - onNodeFinished, - onIterationStart, - onIterationNext, - onIterationFinish, - onLoopStart, - onLoopNext, - onLoopFinish, - onNodeRetry, - onParallelBranchStarted, - onParallelBranchFinished, - onTextChunk, - onTTSChunk, - onTTSEnd, - onTextReplace, - onAgentLog, - onDataSourceNodeProcessing, - onDataSourceNodeCompleted, - onDataSourceNodeError, + return handleStream( + res, + (str: string, isFirstMessage: boolean, moreInfo: IOnDataMoreInfo) => { + if (moreInfo.errorMessage) { + onError?.(moreInfo.errorMessage, moreInfo.errorCode) + // TypeError: Cannot assign to read only property ... will happen in page leave, so it should be ignored. + if (moreInfo.errorMessage !== 'AbortError: The user aborted a request.' && !moreInfo.errorMessage.includes('TypeError: Cannot assign to read only property')) + Toast.notify({ type: 'error', message: moreInfo.errorMessage }) + return + } + onData?.(str, isFirstMessage, moreInfo) + }, + onCompleted, + onThought, + onMessageEnd, + onMessageReplace, + onFile, + onWorkflowStarted, + onWorkflowFinished, + onNodeStarted, + onNodeFinished, + onIterationStart, + onIterationNext, + onIterationFinish, + onLoopStart, + onLoopNext, + onLoopFinish, + onNodeRetry, + onParallelBranchStarted, + onParallelBranchFinished, + onTextChunk, + onTTSChunk, + onTTSEnd, + onTextReplace, + onAgentLog, + onDataSourceNodeProcessing, + onDataSourceNodeCompleted, + onDataSourceNodeError, ) }).catch((e) => { if (e.toString() !== 'AbortError: The user aborted a request.' && !e.toString().includes('TypeError: Cannot assign to read only property')) @@ -517,18 +519,14 @@ export const request = async(url: string, options = {}, otherOptions?: IOther return resp const errResp: Response = err as any if (errResp.status === 401) { - if(/\/login/.test(url)) { - const clonedResponse = errResp.clone() - const bodyJson = await clonedResponse.json() as Promise - return bodyJson - } - const [parseErr, errRespData] = await asyncRunSafe(errResp.json()) const loginUrl = `${globalThis.location.origin}${basePath}/signin` if (parseErr) { globalThis.location.href = loginUrl return Promise.reject(err) } + if (/\/login/.test(url)) + return Promise.reject(errRespData) // special code const { code, message } = errRespData // webapp sso diff --git a/web/types/i18n.d.ts b/web/types/i18n.d.ts index 5020920bf2..a6ed8f0a1e 100644 --- a/web/types/i18n.d.ts +++ b/web/types/i18n.d.ts @@ -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;