diff --git a/web/app/components/base/toast/index.tsx b/web/app/components/base/toast/index.tsx index b1b9ffe8c4..1f616a722c 100644 --- a/web/app/components/base/toast/index.tsx +++ b/web/app/components/base/toast/index.tsx @@ -21,6 +21,7 @@ export type IToastProps = { children?: ReactNode onClose?: () => void className?: string + customComponent?: ReactNode } type IToastContext = { notify: (props: IToastProps) => void @@ -35,6 +36,7 @@ const Toast = ({ message, children, className, + customComponent, }: IToastProps) => { const { close } = useToastContext() // sometimes message is react node array. Not handle it. @@ -49,7 +51,7 @@ const Toast = ({ 'top-0', 'right-0', )}> - -
-
{message}
+
+
+
{message}
+ {customComponent} +
{children &&
{children}
}
- +
@@ -117,13 +122,14 @@ Toast.notify = ({ message, duration, className, -}: Pick) => { + customComponent, +}: Pick) => { const defaultDuring = (type === 'success' || type === 'info') ? 3000 : 6000 if (typeof window === 'object') { const holder = document.createElement('div') const root = createRoot(holder) - root.render() + root.render() document.body.appendChild(holder) setTimeout(() => { if (holder) diff --git a/web/app/components/datasets/documents/detail/completed/display-toggle.tsx b/web/app/components/datasets/documents/detail/completed/display-toggle.tsx index 96a6f5922f..1128cca6ed 100644 --- a/web/app/components/datasets/documents/detail/completed/display-toggle.tsx +++ b/web/app/components/datasets/documents/detail/completed/display-toggle.tsx @@ -10,7 +10,6 @@ const DisplayToggle: FC = () => { + const handleCancel = () => { onCancel() @@ -68,9 +86,18 @@ const NewSegmentModal: FC = ({ setLoading(true) try { await addSegment({ datasetId, documentId, body: params }) - notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) + notify({ + type: 'success', + message: t('datasetDocuments.segment.chunkAdded'), + className: `!w-[296px] !bottom-0 ${appSidebarExpand === 'expand' ? '!left-[216px]' : '!left-14'} + !top-auto !right-auto !mb-[52px] !ml-11`, + duration: 6000, + customComponent: CustomButton, + }) handleCancel() - onSave() + refreshTimer.current = setTimeout(() => { + onSave() + }, 6000) } finally { setLoading(false) diff --git a/web/i18n/en-US/dataset-documents.ts b/web/i18n/en-US/dataset-documents.ts index a0bcb5bba0..2427e03faa 100644 --- a/web/i18n/en-US/dataset-documents.ts +++ b/web/i18n/en-US/dataset-documents.ts @@ -350,6 +350,8 @@ const translation = { newQaSegment: 'New Q&A Segment', addChunk: 'Add Chunk', delete: 'Delete this chunk ?', + chunkAdded: '1 chunk added', + viewAddedChunk: 'View', }, } diff --git a/web/i18n/zh-Hans/dataset-documents.ts b/web/i18n/zh-Hans/dataset-documents.ts index 355c4bee7f..349ec58340 100644 --- a/web/i18n/zh-Hans/dataset-documents.ts +++ b/web/i18n/zh-Hans/dataset-documents.ts @@ -348,6 +348,8 @@ const translation = { newQaSegment: '新问答分段', addChunk: '新增分段', delete: '删除这个分段?', + chunkAdded: '新增一个分段', + viewAddedChunk: '查看', }, } diff --git a/web/service/knowledge/use-segment.ts b/web/service/knowledge/use-segment.ts index f926468349..65ae2c17d3 100644 --- a/web/service/knowledge/use-segment.ts +++ b/web/service/knowledge/use-segment.ts @@ -5,7 +5,7 @@ import type { ChildSegmentResponse, SegmentsResponse } from '@/models/datasets' const NAME_SPACE = 'segment' -const useSegmentListKey = [NAME_SPACE, 'chunkList'] +export const useSegmentListKey = [NAME_SPACE, 'chunkList'] export const useSegmentList = ( payload: {