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
6cebdb3c
Commit
6cebdb3c
authored
Jun 16, 2023
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: delete document in document detail page
parent
dd1edab8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
18 deletions
+28
-18
index.tsx
web/app/components/datasets/documents/detail/index.tsx
+26
-16
list.tsx
web/app/components/datasets/documents/list.tsx
+2
-2
No files found.
web/app/components/datasets/documents/detail/index.tsx
View file @
6cebdb3c
...
...
@@ -8,15 +8,16 @@ import { useTranslation } from 'react-i18next'
import
{
useRouter
}
from
'next/navigation'
import
{
omit
}
from
'lodash-es'
import
cn
from
'classnames'
import
Divider
from
'@/app/components/base/divider'
import
Loading
from
'@/app/components/base/loading'
import
{
fetchDocumentDetail
,
MetadataType
}
from
'@/service/datasets'
import
{
OperationAction
,
StatusItem
}
from
'../list'
import
s
from
'../style.module.css'
import
Completed
from
'./completed'
import
Embedding
from
'./embedding'
import
Metadata
from
'./metadata'
import
s
from
'../style.module.css'
import
style
from
'./style.module.css'
import
Divider
from
'@/app/components/base/divider'
import
Loading
from
'@/app/components/base/loading'
import
type
{
MetadataType
}
from
'@/service/datasets'
import
{
fetchDocumentDetail
}
from
'@/service/datasets'
export
const
BackCircleBtn
:
FC
<
{
onClick
:
()
=>
void
}
>
=
({
onClick
})
=>
{
return
(
...
...
@@ -29,11 +30,11 @@ export const BackCircleBtn: FC<{ onClick: () => void }> = ({ onClick }) => {
export
const
DocumentContext
=
createContext
<
{
datasetId
?:
string
;
documentId
?:
string
}
>
({})
type
DocumentTitleProps
=
{
extension
?:
string
;
name
?:
string
;
iconCls
?:
string
;
textCls
?:
string
;
wrapperCls
?:
string
;
extension
?:
string
name
?:
string
iconCls
?:
string
textCls
?:
string
wrapperCls
?:
string
}
export
const
DocumentTitle
:
FC
<
DocumentTitleProps
>
=
({
extension
,
name
,
iconCls
,
textCls
,
wrapperCls
})
=>
{
...
...
@@ -58,15 +59,16 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {
action
:
'fetchDocumentDetail'
,
datasetId
,
documentId
,
params
:
{
metadata
:
'without'
as
MetadataType
}
params
:
{
metadata
:
'without'
as
MetadataType
}
,
},
apiParams
=>
fetchDocumentDetail
(
omit
(
apiParams
,
'action'
)))
const
{
data
:
documentMetadata
,
error
:
metadataErr
,
mutate
:
metadataMutate
}
=
useSWR
({
action
:
'fetchDocumentDetail'
,
datasetId
,
documentId
,
params
:
{
metadata
:
'only'
as
MetadataType
}
},
apiParams
=>
fetchDocumentDetail
(
omit
(
apiParams
,
'action'
)))
params
:
{
metadata
:
'only'
as
MetadataType
},
},
apiParams
=>
fetchDocumentDetail
(
omit
(
apiParams
,
'action'
)),
)
const
backToPrev
=
()
=>
{
router
.
push
(
`/datasets/
${
datasetId
}
/documents`
)
...
...
@@ -77,6 +79,13 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {
const
embedding
=
[
'queuing'
,
'indexing'
,
'paused'
].
includes
((
documentDetail
?.
display_status
||
''
).
toLowerCase
())
const
handleOperate
=
(
operateName
?:
string
)
=>
{
if
(
operateName
===
'delete'
)
backToPrev
()
else
detailMutate
()
}
return
(
<
DocumentContext
.
Provider
value=
{
{
datasetId
,
documentId
}
}
>
<
div
className=
'flex flex-col h-full'
>
...
...
@@ -90,10 +99,10 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {
detail=
{
{
enabled
:
documentDetail
?.
enabled
||
false
,
archived
:
documentDetail
?.
archived
||
false
,
id
:
documentId
id
:
documentId
,
}
}
datasetId=
{
datasetId
}
onUpdate=
{
detailMut
ate
}
onUpdate=
{
handleOper
ate
}
className=
'!w-[216px]'
/>
<
button
...
...
@@ -102,8 +111,9 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {
/>
</
div
>
<
div
className=
'flex flex-row flex-1'
style=
{
{
height
:
'calc(100% - 4rem)'
}
}
>
{
isDetailLoading
?
<
Loading
type=
'app'
/>
:
<
div
className=
{
`box-border h-full w-full overflow-y-scroll ${embedding ? 'py-12 px-16' : 'pb-[30px] pt-3 px-6'}`
}
>
{
isDetailLoading
?
<
Loading
type=
'app'
/>
:
<
div
className=
{
`box-border h-full w-full overflow-y-scroll ${embedding ? 'py-12 px-16' : 'pb-[30px] pt-3 px-6'}`
}
>
{
embedding
?
<
Embedding
detail=
{
documentDetail
}
/>
:
<
Completed
/>
}
</
div
>
}
...
...
web/app/components/datasets/documents/list.tsx
View file @
6cebdb3c
...
...
@@ -96,7 +96,7 @@ export const OperationAction: FC<{
data_source_type
:
string
}
datasetId
:
string
onUpdate
:
()
=>
void
onUpdate
:
(
operationName
?:
string
)
=>
void
scene
?:
'list'
|
'detail'
className
?:
string
}
>
=
({
datasetId
,
detail
,
onUpdate
,
scene
=
'list'
,
className
=
''
})
=>
{
...
...
@@ -132,7 +132,7 @@ export const OperationAction: FC<{
notify
({
type
:
'success'
,
message
:
t
(
'common.actionMsg.modifiedSuccessfully'
)
})
else
notify
({
type
:
'error'
,
message
:
t
(
'common.actionMsg.modificationFailed'
)
})
onUpdate
()
onUpdate
(
operationName
)
}
return
<
div
...
...
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