Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
d658ea8a
Commit
d658ea8a
authored
Jun 16, 2023
by
jyong
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/feat/dataset-notion-import' into feat/dataset-notion-import
parents
4c727d0d
a7cf7d6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
45 deletions
+59
-45
base.tsx
web/app/components/base/notion-page-selector/base.tsx
+41
-30
index.tsx
web/app/components/datasets/create/step-one/index.tsx
+17
-8
index.tsx
web/app/components/datasets/documents/index.tsx
+1
-6
list.tsx
web/app/components/datasets/documents/list.tsx
+0
-1
No files found.
web/app/components/base/notion-page-selector/base.tsx
View file @
d658ea8a
...
...
@@ -7,6 +7,7 @@ import SearchInput from './search-input'
import
PageSelector
from
'./page-selector'
import
{
preImportNotionPages
}
from
'@/service/datasets'
import
AccountSetting
from
'@/app/components/header/account-setting'
import
{
NotionConnector
}
from
'@/app/components/datasets/create/step-one'
import
type
{
DataSourceNotionPage
,
DataSourceNotionPageMap
,
DataSourceNotionWorkspace
}
from
'@/models/common'
export
type
NotionPageSelectorValue
=
DataSourceNotionPage
&
{
workspace_id
:
string
}
...
...
@@ -28,7 +29,7 @@ const NotionPageSelector = ({
onPreview
,
datasetId
=
''
,
}:
NotionPageSelectorProps
)
=>
{
const
{
data
,
mutate
}
=
useSWR
({
url
:
'/notion/pre-import/pages'
,
datasetId
},
preImportNotionPages
)
const
{
data
,
error
,
mutate
}
=
useSWR
({
url
:
'/notion/pre-import/pages'
,
datasetId
},
preImportNotionPages
)
const
[
prevData
,
setPrevData
]
=
useState
(
data
)
const
[
searchValue
,
setSearchValue
]
=
useState
(
''
)
const
[
showDataSourceSetting
,
setShowDataSourceSetting
]
=
useState
(
false
)
...
...
@@ -86,35 +87,45 @@ const NotionPageSelector = ({
return
(
<
div
className=
'bg-gray-25 border border-gray-200 rounded-xl'
>
<
div
className=
'flex items-center pl-[10px] pr-2 h-11 bg-white border-b border-b-gray-200 rounded-t-xl'
>
<
WorkspaceSelector
value=
{
currentWorkspaceId
}
items=
{
notionWorkspaces
}
onSelect=
{
handleSelectWorkspace
}
/>
<
div
className=
'mx-1 w-[1px] h-3 bg-gray-200'
/>
<
div
className=
{
cn
(
s
[
'setting-icon'
],
'w-6 h-6 cursor-pointer'
)
}
onClick=
{
()
=>
setShowDataSourceSetting
(
true
)
}
/>
<
div
className=
'grow'
/>
<
SearchInput
value=
{
searchValue
}
onChange=
{
handleSearchValueChange
}
/>
</
div
>
<
div
className=
'rounded-b-xl overflow-hidden'
>
<
PageSelector
value=
{
selectedPagesId
}
searchValue=
{
searchValue
}
list=
{
currentWorkspace
?.
pages
||
[]
}
pagesMap=
{
getPagesMapAndSelectedPagesId
[
0
]
}
onSelect=
{
handleSelecPages
}
canPreview=
{
canPreview
}
previewPageId=
{
previewPageId
}
onPreview=
{
handlePreviewPage
}
/>
</
div
>
{
error
?.
status
===
404
?
(
<
NotionConnector
onSetting=
{
()
=>
setShowDataSourceSetting
(
true
)
}
/>
)
:
(
<>
<
div
className=
'flex items-center pl-[10px] pr-2 h-11 bg-white border-b border-b-gray-200 rounded-t-xl'
>
<
WorkspaceSelector
value=
{
currentWorkspaceId
}
items=
{
notionWorkspaces
}
onSelect=
{
handleSelectWorkspace
}
/>
<
div
className=
'mx-1 w-[1px] h-3 bg-gray-200'
/>
<
div
className=
{
cn
(
s
[
'setting-icon'
],
'w-6 h-6 cursor-pointer'
)
}
onClick=
{
()
=>
setShowDataSourceSetting
(
true
)
}
/>
<
div
className=
'grow'
/>
<
SearchInput
value=
{
searchValue
}
onChange=
{
handleSearchValueChange
}
/>
</
div
>
<
div
className=
'rounded-b-xl overflow-hidden'
>
<
PageSelector
value=
{
selectedPagesId
}
searchValue=
{
searchValue
}
list=
{
currentWorkspace
?.
pages
||
[]
}
pagesMap=
{
getPagesMapAndSelectedPagesId
[
0
]
}
onSelect=
{
handleSelecPages
}
canPreview=
{
canPreview
}
previewPageId=
{
previewPageId
}
onPreview=
{
handlePreviewPage
}
/>
</
div
>
</>
)
}
{
showDataSourceSetting
&&
(
<
AccountSetting
activeTab=
'data-source'
onCancel=
{
()
=>
{
...
...
web/app/components/datasets/create/step-one/index.tsx
View file @
d658ea8a
...
...
@@ -29,6 +29,22 @@ type IStepOneProps = {
type
Page
=
DataSourceNotionPage
&
{
workspace_id
:
string
}
type
NotionConnectorProps
=
{
onSetting
:
()
=>
void
}
export
const
NotionConnector
=
({
onSetting
}:
NotionConnectorProps
)
=>
{
const
{
t
}
=
useTranslation
()
return
(
<
div
className=
{
s
.
notionConnectionTip
}
>
<
span
className=
{
s
.
notionIcon
}
/>
<
div
className=
{
s
.
title
}
>
{
t
(
'datasetCreation.stepOne.notionSyncTitle'
)
}
</
div
>
<
div
className=
{
s
.
tip
}
>
{
t
(
'datasetCreation.stepOne.notionSyncTip'
)
}
</
div
>
<
Button
className=
'h-8'
type=
'primary'
onClick=
{
onSetting
}
>
{
t
(
'datasetCreation.stepOne.connect'
)
}
</
Button
>
</
div
>
)
}
const
StepOne
=
({
datasetId
,
dataSourceType
,
...
...
@@ -116,14 +132,7 @@ const StepOne = ({
)
}
{
dataSourceType
===
DataSourceType
.
NOTION
&&
(
<>
{
!
hasConnection
&&
(
<
div
className=
{
s
.
notionConnectionTip
}
>
<
span
className=
{
s
.
notionIcon
}
/>
<
div
className=
{
s
.
title
}
>
{
t
(
'datasetCreation.stepOne.notionSyncTitle'
)
}
</
div
>
<
div
className=
{
s
.
tip
}
>
{
t
(
'datasetCreation.stepOne.notionSyncTip'
)
}
</
div
>
<
Button
className=
'h-8'
type=
'primary'
onClick=
{
onSetting
}
>
{
t
(
'datasetCreation.stepOne.connect'
)
}
</
Button
>
</
div
>
)
}
{
!
hasConnection
&&
<
NotionConnector
onSetting=
{
onSetting
}
/>
}
{
hasConnection
&&
(
<>
<
div
className=
'mb-8 w-[640px]'
>
...
...
web/app/components/datasets/documents/index.tsx
View file @
d658ea8a
...
...
@@ -193,11 +193,6 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
setNotionPageSelectorModalVisible
(
false
)
}
const
handleSync
=
async
()
=>
{
if
(
dataset
?.
data_source_type
===
DataSourceType
.
NOTION
)
mutate
()
}
return
(
<
div
className=
'flex flex-col h-full overflow-y-auto'
>
<
div
className=
'flex flex-col justify-center gap-1 px-6 pt-4'
>
...
...
@@ -225,7 +220,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
{
isLoading
?
<
Loading
type=
'app'
/>
:
total
>
0
?
<
List
documents=
{
documentsWithProgress
?.
data
||
[]
}
datasetId=
{
datasetId
}
onUpdate=
{
mutate
}
onSync=
{
handleSync
}
/>
?
<
List
documents=
{
documentsWithProgress
?.
data
||
[]
}
datasetId=
{
datasetId
}
onUpdate=
{
mutate
}
/>
:
<
EmptyElement
onClick=
{
routeToDocCreate
}
/>
}
{
/* Show Pagination only if the total is more than the limit */
}
...
...
web/app/components/datasets/documents/list.tsx
View file @
d658ea8a
...
...
@@ -256,7 +256,6 @@ type IDocumentListProps = {
documents
:
(
SimpleDocumentDetail
&
{
percent
:
number
})[]
datasetId
:
string
onUpdate
:
()
=>
void
onSync
:
()
=>
void
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment