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
3c589c44
Commit
3c589c44
authored
Jun 12, 2023
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: dataset document notion-page-selector-modal
parent
94b112fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
12 deletions
+46
-12
index.tsx
web/app/components/datasets/documents/index.tsx
+8
-3
list.tsx
web/app/components/datasets/documents/list.tsx
+36
-9
dataset-documents.en.ts
web/i18n/lang/dataset-documents.en.ts
+1
-0
dataset-documents.zh.ts
web/i18n/lang/dataset-documents.zh.ts
+1
-0
No files found.
web/app/components/datasets/documents/index.tsx
View file @
3c589c44
...
...
@@ -112,7 +112,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
type
:
dataset
?.
data_source_type
,
info_list
:
{
data_source_type
:
dataset
?.
data_source_type
,
notion_info_list
:
{
notion_info_list
:
[
{
workspace_id
:
selectedPages
[
0
].
workspace_id
,
pages
:
selectedPages
.
map
((
selectedPage
)
=>
{
const
{
page_id
,
page_name
,
page_icon
,
type
}
=
selectedPage
...
...
@@ -123,7 +123,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
type
,
}
}),
},
}
]
,
},
},
indexing_technique
:
dataset
?.
indexing_technique
,
...
...
@@ -140,6 +140,11 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
mutate
()
}
const
handleSync
=
async
()
=>
{
if
(
dataset
?.
data_source_type
===
'notion_import'
)
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'
>
...
...
@@ -167,7 +172,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
{
isLoading
?
<
Loading
type=
'app'
/>
:
total
>
0
?
<
List
documents=
{
documentsRes
?.
data
||
[]
}
datasetId=
{
datasetId
}
onUpdate=
{
mutate
}
/>
?
<
List
documents=
{
documentsRes
?.
data
||
[]
}
datasetId=
{
datasetId
}
onUpdate=
{
mutate
}
onSync=
{
handleSync
}
/>
:
<
EmptyElement
onClick=
{
routeToDocCreate
}
/>
}
{
/* Show Pagination only if the total is more than the limit */
}
...
...
web/app/components/datasets/documents/list.tsx
View file @
3c589c44
...
...
@@ -24,6 +24,7 @@ import { asyncRunSafe } from '@/utils'
import
{
formatNumber
}
from
'@/utils/format'
import
{
archiveDocument
,
deleteDocument
,
disableDocument
,
enableDocument
}
from
'@/service/datasets'
import
type
{
DocumentDisplayStatus
,
DocumentListResponse
}
from
'@/models/datasets'
import
{
syncDataSourceNotion
}
from
'@/service/common'
import
type
{
CommonResponse
}
from
'@/models/common'
export
const
SettingsIcon
:
FC
<
{
className
?:
string
}
>
=
({
className
})
=>
{
...
...
@@ -32,6 +33,12 @@ export const SettingsIcon: FC<{ className?: string }> = ({ className }) => {
</
svg
>
}
export
const
SyncIcon
:
FC
<
{
className
?:
string
}
>
=
()
=>
{
return
<
svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<
path
d=
"M5.69773 13.1783C7.29715 13.8879 9.20212 13.8494 10.8334 12.9075C13.5438 11.3427 14.4724 7.87704 12.9076 5.16672L12.7409 4.87804M3.09233 10.8335C1.52752 8.12314 2.45615 4.65746 5.16647 3.09265C6.7978 2.15081 8.70277 2.11227 10.3022 2.82185M1.66226 10.8892L3.48363 11.3773L3.97166 9.5559M12.0284 6.44393L12.5164 4.62256L14.3378 5.1106"
stroke=
"#667085"
stroke
-
width=
"1.5"
stroke
-
linecap=
"round"
stroke
-
linejoin=
"round"
/>
</
svg
>
}
export
const
FilePlusIcon
:
FC
<
{
className
?:
string
}
>
=
({
className
})
=>
{
return
<
svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
className=
{
className
??
''
}
>
<
path
d=
"M13.3332 6.99992V4.53325C13.3332 3.41315 13.3332 2.85309 13.1152 2.42527C12.9234 2.04895 12.6175 1.74299 12.2412 1.55124C11.8133 1.33325 11.2533 1.33325 10.1332 1.33325H5.8665C4.7464 1.33325 4.18635 1.33325 3.75852 1.55124C3.3822 1.74299 3.07624 2.04895 2.88449 2.42527C2.6665 2.85309 2.6665 3.41315 2.6665 4.53325V11.4666C2.6665 12.5867 2.6665 13.1467 2.88449 13.5746C3.07624 13.9509 3.3822 14.2569 3.75852 14.4486C4.18635 14.6666 4.7464 14.6666 5.8665 14.6666H7.99984M9.33317 7.33325H5.33317M6.6665 9.99992H5.33317M10.6665 4.66659H5.33317M11.9998 13.9999V9.99992M9.99984 11.9999H13.9998"
stroke=
"#667085"
strokeWidth=
"1.5"
strokeLinecap=
"round"
strokeLinejoin=
"round"
/>
...
...
@@ -77,7 +84,7 @@ export const StatusItem: FC<{
</
div
>
}
type
OperationName
=
'delete'
|
'archive'
|
'enable'
|
'disable'
type
OperationName
=
'delete'
|
'archive'
|
'enable'
|
'disable'
|
'sync'
// operation action for list and detail
export
const
OperationAction
:
FC
<
{
...
...
@@ -85,13 +92,18 @@ export const OperationAction: FC<{
enabled
:
boolean
archived
:
boolean
id
:
string
data_source_type
:
string
data_source_info
:
{
notion_workspace_id
:
string
}
}
datasetId
:
string
onUpdate
:
()
=>
void
scene
?:
'list'
|
'detail'
className
?:
string
}
>
=
({
datasetId
,
detail
,
onUpdate
,
scene
=
'list'
,
className
=
''
})
=>
{
const
{
id
,
enabled
=
false
,
archived
=
false
}
=
detail
||
{}
onSync
:
(
workspaceId
:
string
)
=>
void
}
>
=
({
datasetId
,
detail
,
onUpdate
,
scene
=
'list'
,
className
=
''
,
onSync
})
=>
{
const
{
id
,
enabled
=
false
,
archived
=
false
,
data_source_type
,
data_source_info
}
=
detail
||
{}
const
[
showModal
,
setShowModal
]
=
useState
(
false
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
t
}
=
useTranslation
()
...
...
@@ -111,6 +123,9 @@ export const OperationAction: FC<{
case
'disable'
:
opApi
=
disableDocument
break
case
'sync'
:
onSync
(
data_source_info
.
notion_workspace_id
)
break
default
:
opApi
=
deleteDocument
break
...
...
@@ -173,10 +188,14 @@ export const OperationAction: FC<{
<
SettingsIcon
/>
<
span
className=
{
s
.
actionName
}
>
{
t
(
'datasetDocuments.list.action.settings'
)
}
</
span
>
</
div
>
{
/* <div className={s.actionItem} onClick={() => router.push(`/datasets/${datasetId}/documents/create`)}>
<FilePlusIcon />
<span className={s.actionName}>{t('datasetDocuments.list.action.uploadFile')}</span>
</div> */
}
{
data_source_type
===
'notion_import'
&&
(
<
div
className=
{
s
.
actionItem
}
onClick=
{
()
=>
onOperate
(
'sync'
)
}
>
<
SyncIcon
/>
<
span
className=
{
s
.
actionName
}
>
{
t
(
'datasetDocuments.list.action.sync'
)
}
</
span
>
</
div
>
)
}
<
Divider
className=
'my-1'
/>
</>
)
}
...
...
@@ -240,12 +259,13 @@ type IDocumentListProps = {
documents
:
DocumentListResponse
[
'data'
]
datasetId
:
string
onUpdate
:
()
=>
void
onSync
:
()
=>
void
}
/**
* Document list component including basic information
*/
const
DocumentList
:
FC
<
IDocumentListProps
>
=
({
documents
=
[],
datasetId
,
onUpdate
})
=>
{
const
DocumentList
:
FC
<
IDocumentListProps
>
=
({
documents
=
[],
datasetId
,
onUpdate
,
onSync
})
=>
{
const
{
t
}
=
useTranslation
()
const
router
=
useRouter
()
const
[
localDocs
,
setLocalDocs
]
=
useState
<
DocumentListResponse
[
'data'
]
>
(
documents
)
...
...
@@ -266,6 +286,12 @@ const DocumentList: FC<IDocumentListProps> = ({ documents = [], datasetId, onUpd
}
}
const
handleSync
=
async
(
workspaceId
:
string
)
=>
{
await
syncDataSourceNotion
({
url
:
`/oauth/data-source/notion/
${
workspaceId
}
/sync`
})
onSync
()
}
return
(
<>
<
table
className=
{
`w-full border-collapse border-0 text-sm mt-3 ${s.documentTable}`
}
>
...
...
@@ -310,8 +336,9 @@ const DocumentList: FC<IDocumentListProps> = ({ documents = [], datasetId, onUpd
<
td
>
<
OperationAction
datasetId=
{
datasetId
}
detail=
{
pick
(
doc
,
[
'enabled'
,
'archived'
,
'id'
])
}
detail=
{
pick
(
doc
,
[
'enabled'
,
'archived'
,
'id'
,
'data_source_type'
,
'data_source_info'
])
}
onUpdate=
{
onUpdate
}
onSync=
{
handleSync
}
/>
</
td
>
</
tr
>
...
...
web/i18n/lang/dataset-documents.en.ts
View file @
3c589c44
...
...
@@ -20,6 +20,7 @@ const translation = {
archive
:
'Archive'
,
delete
:
'Delete'
,
enableWarning
:
'Archived file cannot be enabled'
,
sync
:
'Sync'
,
},
index
:
{
enable
:
'Enable'
,
...
...
web/i18n/lang/dataset-documents.zh.ts
View file @
3c589c44
...
...
@@ -20,6 +20,7 @@ const translation = {
archive
:
'归档'
,
delete
:
'删除'
,
enableWarning
:
'归档的文件无法启用'
,
sync
:
'同步'
,
},
index
:
{
enable
:
'启用中'
,
...
...
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