Skip to content

Commit

Permalink
Merge branch 'feat/firecrawl-fe' into deploy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjoel committed Jun 7, 2024
2 parents d7a1b7c + cd01ff7 commit 923cef1
Show file tree
Hide file tree
Showing 46 changed files with 1,822 additions and 123 deletions.
16 changes: 12 additions & 4 deletions web/app/(commonLayout)/apps/Apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SearchInput from '@/app/components/base/search-input'
import { useStore as useTagStore } from '@/app/components/base/tag-management/store'
import TagManagementModal from '@/app/components/base/tag-management'
import TagFilter from '@/app/components/base/tag-management/filter'
import { useModalContext } from '@/context/modal-context'

const getKey = (
pageIndex: number,
Expand All @@ -49,6 +50,13 @@ const getKey = (
}

const Apps = () => {
const { setShowAccountSettingModal } = useModalContext()
useEffect(() => {
setShowAccountSettingModal({
payload: 'data-source',
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const { t } = useTranslation()
const { isCurrentWorkspaceManager } = useAppContext()
const showTagManagementModal = useTagStore(s => s.showTagManagementModal)
Expand All @@ -73,10 +81,10 @@ const Apps = () => {

const anchorRef = useRef<HTMLDivElement>(null)
const options = [
{ value: 'all', text: t('app.types.all'), icon: <DotsGrid className='w-[14px] h-[14px] mr-1'/> },
{ value: 'chat', text: t('app.types.chatbot'), icon: <ChatBot className='w-[14px] h-[14px] mr-1'/> },
{ value: 'agent-chat', text: t('app.types.agent'), icon: <CuteRobot className='w-[14px] h-[14px] mr-1'/> },
{ value: 'workflow', text: t('app.types.workflow'), icon: <Route className='w-[14px] h-[14px] mr-1'/> },
{ value: 'all', text: t('app.types.all'), icon: <DotsGrid className='w-[14px] h-[14px] mr-1' /> },
{ value: 'chat', text: t('app.types.chatbot'), icon: <ChatBot className='w-[14px] h-[14px] mr-1' /> },
{ value: 'agent-chat', text: t('app.types.agent'), icon: <CuteRobot className='w-[14px] h-[14px] mr-1' /> },
{ value: 'workflow', text: t('app.types.workflow'), icon: <Route className='w-[14px] h-[14px] mr-1' /> },
]

useEffect(() => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions web/app/components/base/icons/src/public/other/RowStruct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"icon": {
"type": "element",
"isRootNode": true,
"name": "svg",
"attributes": {
"width": "624",
"height": "48",
"viewBox": "0 0 624 48",
"fill": "none",
"xmlns": "http://www.w3.org/2000/svg"
},
"children": [
{
"type": "element",
"name": "rect",
"attributes": {
"x": "8",
"y": "7",
"width": "16",
"height": "16",
"rx": "5",
"fill": "#F2F4F7"
},
"children": []
},
{
"type": "element",
"name": "rect",
"attributes": {
"x": "32",
"y": "10",
"width": "233",
"height": "10",
"rx": "3",
"fill": "#EAECF0"
},
"children": []
},
{
"type": "element",
"name": "rect",
"attributes": {
"x": "32",
"y": "31",
"width": "345",
"height": "6",
"rx": "3",
"fill": "#F2F4F7"
},
"children": []
}
]
},
"name": "RowStruct"
}
16 changes: 16 additions & 0 deletions web/app/components/base/icons/src/public/other/RowStruct.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// GENERATE BY script
// DON NOT EDIT IT MANUALLY

import * as React from 'react'
import data from './RowStruct.json'
import IconBase from '@/app/components/base/icons/IconBase'
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'

const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
props,
ref,
) => <IconBase {...props} ref={ref} data={data as IconData} />)

Icon.displayName = 'RowStruct'

export default Icon
1 change: 1 addition & 0 deletions web/app/components/base/icons/src/public/other/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as Icon3Dots } from './Icon3Dots'
export { default as DefaultToolIcon } from './DefaultToolIcon'
export { default as RowStruct } from './RowStruct'
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"icon": {
"type": "element",
"isRootNode": true,
"name": "svg",
"attributes": {
"width": "16",
"height": "16",
"viewBox": "0 0 16 16",
"fill": "none",
"xmlns": "http://www.w3.org/2000/svg"
},
"children": [
{
"type": "element",
"name": "g",
"attributes": {
"id": "Icon-3-dots"
},
"children": [
{
"type": "element",
"name": "path",
"attributes": {
"id": "Icon",
"d": "M5 6.5V5M8.93934 7.56066L10 6.5M10.0103 11.5H11.5103",
"stroke": "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
},
"children": []
}
]
}
]
},
"name": "Icon3Dots"
}
16 changes: 16 additions & 0 deletions web/app/components/base/icons/src/vender/line/others/Icon3Dots.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// GENERATE BY script
// DON NOT EDIT IT MANUALLY

import * as React from 'react'
import data from './Icon3Dots.json'
import IconBase from '@/app/components/base/icons/IconBase'
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'

const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
props,
ref,
) => <IconBase {...props} ref={ref} data={data as IconData} />)

Icon.displayName = 'Icon3Dots'

export default Icon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export { default as Colors } from './Colors'
export { default as DragHandle } from './DragHandle'
export { default as Exchange02 } from './Exchange02'
export { default as FileCode } from './FileCode'
export { default as Icon3Dots } from './Icon3Dots'
export { default as Tools } from './Tools'
11 changes: 9 additions & 2 deletions web/app/components/datasets/create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import StepOne from './step-one'
import StepTwo from './step-two'
import StepThree from './step-three'
import { DataSourceType } from '@/models/datasets'
import type { DataSet, FileItem, createDocumentResponse } from '@/models/datasets'
import type { CrawlResultItem, DataSet, FileItem, createDocumentResponse } from '@/models/datasets'
import { fetchDataSource } from '@/service/common'
import { fetchDatasetDetail } from '@/service/datasets'
import type { NotionPage } from '@/models/common'
Expand All @@ -23,7 +23,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
const { t } = useTranslation()
const { setShowAccountSettingModal } = useModalContext()
const [hasConnection, setHasConnection] = useState(true)
const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.FILE)
const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.WEB) // TODO: for test. DataSourceType.FILE
const [step, setStep] = useState(1)
const [indexingTypeCache, setIndexTypeCache] = useState('')
const [fileList, setFiles] = useState<FileItem[]>([])
Expand All @@ -36,9 +36,11 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
setNotionPages(value)
}

const [websitePages, setWebsitePages] = useState<CrawlResultItem[]>([])
const updateFileList = (preparedFiles: FileItem[]) => {
setFiles(preparedFiles)
}
const [fireCrawlJobId, setFireCrawlJobId] = useState('')

const updateFile = (fileItem: FileItem, progress: number, list: FileItem[]) => {
const targetIndex = list.findIndex(file => file.fileID === fileItem.fileID)
Expand Down Expand Up @@ -121,6 +123,9 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
notionPages={notionPages}
updateNotionPages={updateNotionPages}
onStepChange={nextStep}
websitePages={websitePages}
updateWebsitePages={setWebsitePages}
onFireCrawlJobIdChange={setFireCrawlJobId}
/>}
{(step === 2 && (!datasetId || (datasetId && !!detail))) && <StepTwo
isAPIKeySet={!!embeddingsDefaultModel}
Expand All @@ -130,6 +135,8 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
dataSourceType={dataSourceType}
files={fileList.map(file => file.file)}
notionPages={notionPages}
websitePages={websitePages}
fireCrawlJobId={fireCrawlJobId}
onStepChange={changeStep}
updateIndexingTypeCache={updateIndexingTypeCache}
updateResultCache={updateResultCache}
Expand Down
39 changes: 35 additions & 4 deletions web/app/components/datasets/create/step-one/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import FilePreview from '../file-preview'
import FileUploader from '../file-uploader'
import NotionPagePreview from '../notion-page-preview'
import EmptyDatasetCreationModal from '../empty-dataset-creation-modal'
import Website from '../website'
import WebsitePreview from '../website/preview'
import s from './index.module.css'
import type { FileItem } from '@/models/datasets'
import type { CrawlResultItem, FileItem } from '@/models/datasets'
import type { NotionPage } from '@/models/common'
import { DataSourceType } from '@/models/datasets'
import Button from '@/app/components/base/button'
Expand All @@ -29,6 +31,9 @@ type IStepOneProps = {
updateNotionPages: (value: NotionPage[]) => void
onStepChange: () => void
changeType: (type: DataSourceType) => void
websitePages?: CrawlResultItem[]
updateWebsitePages: (value: CrawlResultItem[]) => void
onFireCrawlJobIdChange: (jobId: string) => void
}

type NotionConnectorProps = {
Expand Down Expand Up @@ -60,11 +65,15 @@ const StepOne = ({
updateFile,
notionPages = [],
updateNotionPages,
websitePages = [],
updateWebsitePages,
onFireCrawlJobIdChange,
}: IStepOneProps) => {
const { dataset } = useDatasetDetailContext()
const [showModal, setShowModal] = useState(false)
const [currentFile, setCurrentFile] = useState<File | undefined>()
const [currentNotionPage, setCurrentNotionPage] = useState<NotionPage | undefined>()
const [currentWebsite, setCurrentWebsite] = useState<CrawlResultItem | undefined>()
const { t } = useTranslation()

const modalShowHandle = () => setShowModal(true)
Expand All @@ -85,6 +94,10 @@ const StepOne = ({
setCurrentNotionPage(undefined)
}

const hideWebsitePreview = () => {
setCurrentWebsite(undefined)
}

const shouldShowDataSourceTypeList = !datasetId || (datasetId && !dataset?.data_source_type)

const { plan, enableBilling } = useProviderContext()
Expand Down Expand Up @@ -150,10 +163,9 @@ const StepOne = ({
{t('datasetCreation.stepOne.dataSourceType.notion')}
</div>
<div
className={cn(s.dataSourceItem, s.disabled, dataSourceType === DataSourceType.WEB && s.active)}
// onClick={() => changeType(DataSourceType.WEB)}
className={cn(s.dataSourceItem, dataSourceType === DataSourceType.WEB ? s.active : s.disabled)}
onClick={() => changeType(DataSourceType.WEB)}
>
<span className={s.comingTag}>Coming soon</span>
<span className={cn(s.datasetIcon, s.web)} />
{t('datasetCreation.stepOne.dataSourceType.web')}
</div>
Expand Down Expand Up @@ -201,6 +213,24 @@ const StepOne = ({
)}
</>
)}
{dataSourceType === DataSourceType.WEB && (
<>
<div className='mb-8 w-[640px]'>
<Website
onPreview={setCurrentWebsite}
checkedCrawlResult={websitePages}
onCheckedCrawlResultChange={updateWebsitePages}
onJobIdChange={onFireCrawlJobIdChange}
/>
</div>
{isShowVectorSpaceFull && (
<div className='max-w-[640px] mb-4'>
<VectorSpaceFull />
</div>
)}
<Button disabled={isShowVectorSpaceFull || !websitePages.length} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
</>
)}
{!datasetId && (
<>
<div className={s.dividerLine} />
Expand All @@ -212,6 +242,7 @@ const StepOne = ({
</div>
{currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />}
{currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />}
{currentWebsite && <WebsitePreview payload={currentWebsite} hidePreview={hideWebsitePreview} />}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
}

.sourceContent {
width: 0;
flex: 1 1 auto;
}

Expand Down
Loading

0 comments on commit 923cef1

Please sign in to comment.