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
483536a2
Commit
483536a2
authored
Mar 13, 2024
by
crazywoola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update code
parent
b161faec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
37 deletions
+30
-37
index.tsx
web/app/components/base/retry-button/index.tsx
+30
-37
No files found.
web/app/components/base/retry-button/index.tsx
View file @
483536a2
...
...
@@ -20,37 +20,25 @@ type Props = {
type
IIndexState
=
{
value
:
string
}
type
ActionType
=
'retry'
|
'success'
|
'error'
type
IAction
=
{
type
:
string
type
:
ActionType
}
const
indexStateReducer
=
(
state
:
IIndexState
,
action
:
IAction
)
=>
{
switch
(
action
.
type
)
{
case
'retry'
:
return
{
...
state
,
value
:
'retry'
,
}
case
'success'
:
return
{
...
state
,
value
:
'success'
,
const
actionMap
=
{
retry
:
'retry'
,
success
:
'success'
,
error
:
'error'
,
}
case
'error'
:
return
{
...
state
,
value
:
'error'
,
}
default
:
return
{
...
state
,
value
:
'success'
,
}
value
:
actionMap
[
action
.
type
]
||
state
.
value
,
}
}
const
RetryButton
:
FC
<
Props
>
=
(
{
datasetId
},
)
=>
{
const
RetryButton
:
FC
<
Props
>
=
({
datasetId
})
=>
{
const
{
t
}
=
useTranslation
()
const
[
indexState
,
dispatch
]
=
useReducer
(
indexStateReducer
,
{
value
:
'success'
})
const
{
data
:
errorDocs
}
=
useSWR
({
datasetId
},
getErrorDocs
)
...
...
@@ -74,19 +62,24 @@ const RetryButton: FC<Props> = (
if
(
indexState
.
value
===
'success'
)
return
null
return
<
div
className=
{
classNames
(
'inline-flex justify-center items-center gap-2'
,
s
.
retryBtn
)
}
>
return
(
<
div
className=
{
classNames
(
'inline-flex justify-center items-center gap-2'
,
s
.
retryBtn
)
}
>
<
WarningIcon
/>
<
span
className=
'flex shrink-0 text-sm text-gray-500'
>
{
errorDocs
?.
total
}
{
t
(
'dataset.docsFailedNotice'
)
}
</
span
>
<
span
className=
'flex shrink-0 text-sm text-gray-500'
>
{
errorDocs
?.
total
}
{
t
(
'dataset.docsFailedNotice'
)
}
</
span
>
<
Divider
type=
'vertical'
className=
'!h-4'
/>
<
span
className=
{
classNames
(
className=
{
classNames
(
'text-primary-600 font-semibold text-sm cursor-pointer'
,
indexState
.
value
===
'retry'
&&
'!text-gray-500 !cursor-not-allowed'
,
)
}
)
}
onClick=
{
indexState
.
value
===
'error'
?
onRetryErrorDocs
:
undefined
}
>
{
t
(
'dataset.retry'
)
}
</
span
>
>
{
t
(
'dataset.retry'
)
}
</
span
>
</
div
>
)
}
export
default
RetryButton
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