mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
feat: remove documents limit (#1697)
This commit is contained in:
parent
5789d76582
commit
cb3a55dae6
|
@ -1,6 +1,4 @@
|
|||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import useSWR from 'swr'
|
||||
import cn from 'classnames'
|
||||
import s from './base.module.css'
|
||||
|
@ -10,7 +8,6 @@ import PageSelector from './page-selector'
|
|||
import { preImportNotionPages } from '@/service/datasets'
|
||||
import { NotionConnector } from '@/app/components/datasets/create/step-one'
|
||||
import type { DataSourceNotionPageMap, DataSourceNotionWorkspace, NotionPage } from '@/models/common'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
|
||||
type NotionPageSelectorProps = {
|
||||
|
@ -20,8 +17,6 @@ type NotionPageSelectorProps = {
|
|||
previewPageId?: string
|
||||
onPreview?: (selectedPage: NotionPage) => void
|
||||
datasetId?: string
|
||||
countLimit: number
|
||||
countUsed: number
|
||||
}
|
||||
|
||||
const NotionPageSelector = ({
|
||||
|
@ -31,11 +26,7 @@ const NotionPageSelector = ({
|
|||
previewPageId,
|
||||
onPreview,
|
||||
datasetId = '',
|
||||
countLimit,
|
||||
countUsed,
|
||||
}: NotionPageSelectorProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { notify } = useContext(ToastContext)
|
||||
const { data, mutate } = useSWR({ url: '/notion/pre-import/pages', datasetId }, preImportNotionPages)
|
||||
const [prevData, setPrevData] = useState(data)
|
||||
const [searchValue, setSearchValue] = useState('')
|
||||
|
@ -80,10 +71,7 @@ const NotionPageSelector = ({
|
|||
}, [])
|
||||
const handleSelecPages = (newSelectedPagesId: Set<string>) => {
|
||||
const selectedPages = Array.from(newSelectedPagesId).map(pageId => getPagesMapAndSelectedPagesId[0][pageId])
|
||||
if (selectedPages.length > countLimit - countUsed) {
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.overCountLimit', { countLimit }) })
|
||||
return false
|
||||
}
|
||||
|
||||
setSelectedPagesId(new Set(Array.from(newSelectedPagesId)))
|
||||
onSelect(selectedPages)
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ type IFileUploaderProps = {
|
|||
onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void
|
||||
onFileListUpdate?: (files: FileItem[]) => void
|
||||
onPreview: (file: File) => void
|
||||
countLimit: number
|
||||
countUsed: number
|
||||
}
|
||||
|
||||
const ACCEPTS = [
|
||||
|
@ -41,8 +39,6 @@ const FileUploader = ({
|
|||
onFileUpdate,
|
||||
onFileListUpdate,
|
||||
onPreview,
|
||||
countLimit,
|
||||
countUsed,
|
||||
}: IFileUploaderProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { notify } = useContext(ToastContext)
|
||||
|
@ -149,10 +145,7 @@ const FileUploader = ({
|
|||
const initialUpload = useCallback((files: File[]) => {
|
||||
if (!files.length)
|
||||
return false
|
||||
if (files.length > countLimit - countUsed) {
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.overCountLimit', { countLimit }) })
|
||||
return false
|
||||
}
|
||||
|
||||
const preparedFiles = files.map((file, index) => ({
|
||||
fileID: `file${index}-${Date.now()}`,
|
||||
file,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
'use client'
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import cn from 'classnames'
|
||||
import FilePreview from '../file-preview'
|
||||
|
@ -14,7 +13,6 @@ import { DataSourceType } from '@/models/datasets'
|
|||
import Button from '@/app/components/base/button'
|
||||
import { NotionPageSelector } from '@/app/components/base/notion-page-selector'
|
||||
import { useDatasetDetailContext } from '@/context/dataset-detail'
|
||||
import { fetchDocumentsLimit } from '@/service/common'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import VectorSpaceFull from '@/app/components/billing/vector-space-full'
|
||||
|
||||
|
@ -63,7 +61,6 @@ const StepOne = ({
|
|||
notionPages = [],
|
||||
updateNotionPages,
|
||||
}: IStepOneProps) => {
|
||||
const { data: limitsData } = useSWR('/datasets/limit', fetchDocumentsLimit)
|
||||
const { dataset } = useDatasetDetailContext()
|
||||
const [showModal, setShowModal] = useState(false)
|
||||
const [currentFile, setCurrentFile] = useState<File | undefined>()
|
||||
|
@ -163,7 +160,7 @@ const StepOne = ({
|
|||
</div>
|
||||
)
|
||||
}
|
||||
{dataSourceType === DataSourceType.FILE && limitsData && (
|
||||
{dataSourceType === DataSourceType.FILE && (
|
||||
<>
|
||||
<FileUploader
|
||||
fileList={files}
|
||||
|
@ -172,8 +169,6 @@ const StepOne = ({
|
|||
onFileListUpdate={updateFileList}
|
||||
onFileUpdate={updateFile}
|
||||
onPreview={updateCurrentFile}
|
||||
countLimit={limitsData.documents_limit}
|
||||
countUsed={limitsData.documents_count}
|
||||
/>
|
||||
{isShowVectorSpaceFull && (
|
||||
<div className='max-w-[640px] mb-4'>
|
||||
|
@ -186,15 +181,13 @@ const StepOne = ({
|
|||
{dataSourceType === DataSourceType.NOTION && (
|
||||
<>
|
||||
{!hasConnection && <NotionConnector onSetting={onSetting} />}
|
||||
{hasConnection && limitsData && (
|
||||
{hasConnection && (
|
||||
<>
|
||||
<div className='mb-8 w-[640px]'>
|
||||
<NotionPageSelector
|
||||
value={notionPages.map(page => page.page_id)}
|
||||
onSelect={updateNotionPages}
|
||||
onPreview={updateCurrentPage}
|
||||
countLimit={limitsData.documents_limit}
|
||||
countUsed={limitsData.documents_count}
|
||||
/>
|
||||
</div>
|
||||
{isShowVectorSpaceFull && (
|
||||
|
|
|
@ -49,7 +49,6 @@ const translation = {
|
|||
confirmButton: 'Create',
|
||||
failed: 'Creation failed',
|
||||
},
|
||||
overCountLimit: 'All your documents have overed limit {{countLimit}}.',
|
||||
},
|
||||
stepTwo: {
|
||||
segmentation: 'Chunk settings',
|
||||
|
|
|
@ -49,7 +49,6 @@ const translation = {
|
|||
confirmButton: '创建',
|
||||
failed: '创建失败',
|
||||
},
|
||||
overCountLimit: '您的文件总数已超出限制 {{countLimit}}。',
|
||||
},
|
||||
stepTwo: {
|
||||
segmentation: '分段设置',
|
||||
|
|
|
@ -179,11 +179,6 @@ export type FileUploadConfigResponse = {
|
|||
image_file_size_limit?: number | string
|
||||
}
|
||||
|
||||
export type DocumentsLimitResponse = {
|
||||
documents_count: number
|
||||
documents_limit: number
|
||||
}
|
||||
|
||||
export type InvitationResult = {
|
||||
status: 'success'
|
||||
email: string
|
||||
|
|
|
@ -6,7 +6,6 @@ import type {
|
|||
CodeBasedExtension,
|
||||
CommonResponse,
|
||||
DataSourceNotion,
|
||||
DocumentsLimitResponse,
|
||||
FileUploadConfigResponse,
|
||||
ICurrentWorkspace,
|
||||
IWorkspace,
|
||||
|
@ -195,10 +194,6 @@ export const fetchFileUploadConfig: Fetcher<FileUploadConfigResponse, { url: str
|
|||
return get<FileUploadConfigResponse>(url)
|
||||
}
|
||||
|
||||
export const fetchDocumentsLimit: Fetcher<DocumentsLimitResponse, string> = (url) => {
|
||||
return get<DocumentsLimitResponse>(url)
|
||||
}
|
||||
|
||||
export const fetchFreeQuotaVerify: Fetcher<{ result: string; flag: boolean; reason: string }, string> = (url) => {
|
||||
return get(url) as Promise<{ result: string; flag: boolean; reason: string }>
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user