Compare commits

...
Author SHA1 Message Date
CodingOnStar ed9623647e Merge remote-tracking branch 'origin/main' into refactor/base-comp 2026-03-03 16:00:41 +08:00
FFXNandGitHub 2068640a4b fix: Add the missing validation of doc_form in the service API. (#32892) 2026-03-03 15:54:43 +08:00
CodingOnStar aa5a22991b refactor(toast): streamline toast component structure and improve cleanup logic
- Adjusted class names for consistency in the Toast component.
- Refactored the toastHandler.clear function to improve cleanup logic by using a dedicated unmountAndRemove function.
- Ensured proper handling of the timer for toast notifications.
2026-03-02 11:54:51 +08:00
CodingOnStar 4928917878 Merge remote-tracking branch 'origin/main' into refactor/base-comp 2026-03-02 11:51:03 +08:00
CodingOnStar b00afff61e fix(tests): correct import paths in chat and context block test files 2026-03-02 11:31:59 +08:00
CodingOnStar 691248f477 test: add unit tests for various components including Alert, AppUnavailable, Badge, ThemeSelector, ThemeSwitcher, ActionButton, and AgentLogModal 2026-03-02 11:11:08 +08:00
6 changed files with 60 additions and 17 deletions
@@ -119,6 +119,14 @@ def _validate_indexing_technique(value: str | None) -> str | None:
return value
def _validate_doc_form(value: str | None) -> str | None:
if value is None:
return value
if value not in Dataset.DOC_FORM_LIST:
raise ValueError("Invalid doc_form.")
return value
class DatasetCreatePayload(BaseModel):
name: str = Field(..., min_length=1, max_length=40)
description: str = Field("", max_length=400)
@@ -179,6 +187,14 @@ class IndexingEstimatePayload(BaseModel):
raise ValueError("indexing_technique is required.")
return result
@field_validator("doc_form")
@classmethod
def validate_doc_form(cls, value: str) -> str:
result = _validate_doc_form(value)
if result is None:
return "text_model"
return result
class ConsoleDatasetListQuery(BaseModel):
page: int = Field(default=1, description="Page number")
@@ -4,7 +4,7 @@ from uuid import UUID
from flask import request
from flask_restx import marshal
from pydantic import BaseModel, Field, model_validator
from pydantic import BaseModel, Field, field_validator, model_validator
from sqlalchemy import desc, select
from werkzeug.exceptions import Forbidden, NotFound
@@ -60,6 +60,13 @@ class DocumentTextCreatePayload(BaseModel):
embedding_model: str | None = None
embedding_model_provider: str | None = None
@field_validator("doc_form")
@classmethod
def validate_doc_form(cls, value: str) -> str:
if value not in Dataset.DOC_FORM_LIST:
raise ValueError("Invalid doc_form.")
return value
DEFAULT_REF_TEMPLATE_SWAGGER_2_0 = "#/definitions/{model}"
@@ -72,6 +79,13 @@ class DocumentTextUpdate(BaseModel):
doc_language: str = "English"
retrieval_model: RetrievalModel | None = None
@field_validator("doc_form")
@classmethod
def validate_doc_form(cls, value: str) -> str:
if value not in Dataset.DOC_FORM_LIST:
raise ValueError("Invalid doc_form.")
return value
@model_validator(mode="after")
def check_text_and_name(self) -> Self:
if self.text is not None and self.name is None:
+2
View File
@@ -19,6 +19,7 @@ from sqlalchemy.orm import Mapped, Session, mapped_column
from configs import dify_config
from core.rag.index_processor.constant.built_in_field import BuiltInField, MetadataDataSource
from core.rag.index_processor.constant.index_type import IndexStructureType
from core.rag.index_processor.constant.query_type import QueryType
from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.tools.signature import sign_upload_file
@@ -51,6 +52,7 @@ class Dataset(Base):
INDEXING_TECHNIQUE_LIST = ["high_quality", "economy", None]
PROVIDER_LIST = ["vendor", "external", None]
DOC_FORM_LIST = [member.value for member in IndexStructureType]
id: Mapped[str] = mapped_column(StringUUID, default=lambda: str(uuid4()))
tenant_id: Mapped[str] = mapped_column(StringUUID)
@@ -1,8 +1,9 @@
from enum import StrEnum
from typing import Literal
from pydantic import BaseModel
from pydantic import BaseModel, field_validator
from core.rag.index_processor.constant.index_type import IndexStructureType
from core.rag.retrieval.retrieval_methods import RetrievalMethod
@@ -127,6 +128,18 @@ class KnowledgeConfig(BaseModel):
name: str | None = None
is_multimodal: bool = False
@field_validator("doc_form")
@classmethod
def validate_doc_form(cls, value: str) -> str:
valid_forms = [
IndexStructureType.PARAGRAPH_INDEX,
IndexStructureType.QA_INDEX,
IndexStructureType.PARENT_CHILD_INDEX,
]
if value not in valid_forms:
raise ValueError("Invalid doc_form.")
return value
class SegmentCreateArgs(BaseModel):
content: str | None = None
+13 -12
View File
@@ -77,11 +77,11 @@ const Toast = ({
</div>
<div className={cn('flex grow flex-col items-start gap-1 py-1', size === 'md' ? 'px-1' : 'px-0.5')}>
<div className="flex items-center gap-1">
<div className="system-sm-semibold text-text-primary [word-break:break-word]">{message}</div>
<div className="text-text-primary system-sm-semibold [word-break:break-word]">{message}</div>
{customComponent}
</div>
{!!children && (
<div className="system-xs-regular text-text-secondary">
<div className="text-text-secondary system-xs-regular">
{children}
</div>
)}
@@ -149,25 +149,26 @@ Toast.notify = ({
if (typeof window === 'object') {
const holder = document.createElement('div')
const root = createRoot(holder)
let timerId: ReturnType<typeof setTimeout> | undefined
toastHandler.clear = () => {
if (holder) {
const unmountAndRemove = () => {
if (timerId) {
clearTimeout(timerId)
timerId = undefined
}
if (typeof window !== 'undefined' && holder) {
root.unmount()
holder.remove()
}
onClose?.()
}
toastHandler.clear = unmountAndRemove
root.render(
<ToastContext.Provider value={{
notify: noop,
close: () => {
if (holder) {
root.unmount()
holder.remove()
}
onClose?.()
},
close: unmountAndRemove,
}}
>
<Toast type={type} size={size} message={message} duration={duration} className={className} customComponent={customComponent} />
@@ -176,7 +177,7 @@ Toast.notify = ({
document.body.appendChild(holder)
const d = duration ?? defaultDuring
if (d > 0)
setTimeout(toastHandler.clear, d)
timerId = setTimeout(unmountAndRemove, d)
}
return toastHandler
-3
View File
@@ -2516,9 +2516,6 @@
"app/components/base/toast/index.tsx": {
"react-refresh/only-export-components": {
"count": 2
},
"tailwindcss/enforce-consistent-class-order": {
"count": 2
}
},
"app/components/base/tooltip/index.tsx": {