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
380b4b3d
Unverified
Commit
380b4b3d
authored
May 23, 2023
by
Nite Knite
Committed by
GitHub
May 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: refresh list on delete (#178)
parent
e2bf1805
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
6 deletions
+15
-6
AppCard.tsx
web/app/(commonLayout)/apps/AppCard.tsx
+5
-1
Apps.tsx
web/app/(commonLayout)/apps/Apps.tsx
+3
-1
DatasetCard.tsx
web/app/(commonLayout)/datasets/DatasetCard.tsx
+4
-3
Datasets.tsx
web/app/(commonLayout)/datasets/Datasets.tsx
+3
-1
No files found.
web/app/(commonLayout)/apps/AppCard.tsx
View file @
380b4b3d
...
@@ -16,10 +16,12 @@ import AppsContext from '@/context/app-context'
...
@@ -16,10 +16,12 @@ import AppsContext from '@/context/app-context'
export
type
AppCardProps
=
{
export
type
AppCardProps
=
{
app
:
App
app
:
App
onDelete
?:
()
=>
void
}
}
const
AppCard
=
({
const
AppCard
=
({
app
,
app
,
onDelete
}:
AppCardProps
)
=>
{
}:
AppCardProps
)
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
...
@@ -35,6 +37,8 @@ const AppCard = ({
...
@@ -35,6 +37,8 @@ const AppCard = ({
try
{
try
{
await
deleteApp
(
app
.
id
)
await
deleteApp
(
app
.
id
)
notify
({
type
:
'success'
,
message
:
t
(
'app.appDeleted'
)
})
notify
({
type
:
'success'
,
message
:
t
(
'app.appDeleted'
)
})
if
(
onDelete
)
onDelete
()
mutateApps
()
mutateApps
()
}
}
catch
(
e
:
any
)
{
catch
(
e
:
any
)
{
...
@@ -47,7 +51,7 @@ const AppCard = ({
...
@@ -47,7 +51,7 @@ const AppCard = ({
<>
<>
<
Link
href=
{
`/app/${app.id}/overview`
}
className=
{
style
.
listItem
}
>
<
Link
href=
{
`/app/${app.id}/overview`
}
className=
{
style
.
listItem
}
>
<
div
className=
{
style
.
listItemTitle
}
>
<
div
className=
{
style
.
listItemTitle
}
>
<
AppIcon
size=
'small'
icon=
{
app
.
icon
}
background=
{
app
.
icon_background
}
/>
<
AppIcon
size=
'small'
icon=
{
app
.
icon
}
background=
{
app
.
icon_background
}
/>
<
div
className=
{
style
.
listItemHeading
}
>
<
div
className=
{
style
.
listItemHeading
}
>
<
div
className=
{
style
.
listItemHeadingContent
}
>
{
app
.
name
}
</
div
>
<
div
className=
{
style
.
listItemHeadingContent
}
>
{
app
.
name
}
</
div
>
</
div
>
</
div
>
...
...
web/app/(commonLayout)/apps/Apps.tsx
View file @
380b4b3d
...
@@ -42,7 +42,9 @@ const Apps = () => {
...
@@ -42,7 +42,9 @@ const Apps = () => {
return
(
return
(
<
nav
className=
'grid content-start grid-cols-1 gap-4 px-12 pt-8 sm:grid-cols-2 lg:grid-cols-4 grow shrink-0'
>
<
nav
className=
'grid content-start grid-cols-1 gap-4 px-12 pt-8 sm:grid-cols-2 lg:grid-cols-4 grow shrink-0'
>
{
data
?.
map
(({
data
:
apps
})
=>
apps
.
map
(
app
=>
(<
AppCard
key=
{
app
.
id
}
app=
{
app
}
/>)))
}
{
data
?.
map
(({
data
:
apps
})
=>
apps
.
map
(
app
=>
(
<
AppCard
key=
{
app
.
id
}
app=
{
app
}
onDelete=
{
mutate
}
/>
)))
}
<
NewAppCard
ref=
{
anchorRef
}
onSuccess=
{
mutate
}
/>
<
NewAppCard
ref=
{
anchorRef
}
onSuccess=
{
mutate
}
/>
</
nav
>
</
nav
>
)
)
...
...
web/app/(commonLayout)/datasets/DatasetCard.tsx
View file @
380b4b3d
...
@@ -18,16 +18,16 @@ import classNames from 'classnames'
...
@@ -18,16 +18,16 @@ import classNames from 'classnames'
export
type
DatasetCardProps
=
{
export
type
DatasetCardProps
=
{
dataset
:
DataSet
dataset
:
DataSet
onDelete
?:
()
=>
void
}
}
const
DatasetCard
=
({
const
DatasetCard
=
({
dataset
,
dataset
,
onDelete
}:
DatasetCardProps
)
=>
{
}:
DatasetCardProps
)
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
mutate
:
mutateDatasets
}
=
useSWR
({
url
:
'/datasets'
,
params
:
{
page
:
1
}
},
fetchDatasets
)
const
[
showConfirmDelete
,
setShowConfirmDelete
]
=
useState
(
false
)
const
[
showConfirmDelete
,
setShowConfirmDelete
]
=
useState
(
false
)
const
onDeleteClick
:
MouseEventHandler
=
useCallback
((
e
)
=>
{
const
onDeleteClick
:
MouseEventHandler
=
useCallback
((
e
)
=>
{
e
.
preventDefault
()
e
.
preventDefault
()
...
@@ -37,7 +37,8 @@ const DatasetCard = ({
...
@@ -37,7 +37,8 @@ const DatasetCard = ({
try
{
try
{
await
deleteDataset
(
dataset
.
id
)
await
deleteDataset
(
dataset
.
id
)
notify
({
type
:
'success'
,
message
:
t
(
'dataset.datasetDeleted'
)
})
notify
({
type
:
'success'
,
message
:
t
(
'dataset.datasetDeleted'
)
})
mutateDatasets
()
if
(
onDelete
)
onDelete
()
}
}
catch
(
e
:
any
)
{
catch
(
e
:
any
)
{
notify
({
type
:
'error'
,
message
:
`
${
t
(
'dataset.datasetDeleteFailed'
)}${
'message'
in
e
?
`:
${
e
.
message
}
`
:
''
}
`
})
notify
({
type
:
'error'
,
message
:
`
${
t
(
'dataset.datasetDeleteFailed'
)}${
'message'
in
e
?
`:
${
e
.
message
}
`
:
''
}
`
})
...
...
web/app/(commonLayout)/datasets/Datasets.tsx
View file @
380b4b3d
...
@@ -42,7 +42,9 @@ const Datasets = () => {
...
@@ -42,7 +42,9 @@ const Datasets = () => {
return
(
return
(
<
nav
className=
'grid content-start grid-cols-1 gap-4 px-12 pt-8 sm:grid-cols-2 lg:grid-cols-4 grow shrink-0'
>
<
nav
className=
'grid content-start grid-cols-1 gap-4 px-12 pt-8 sm:grid-cols-2 lg:grid-cols-4 grow shrink-0'
>
{
data
?.
map
(({
data
:
datasets
})
=>
datasets
.
map
(
dataset
=>
(<
DatasetCard
key=
{
dataset
.
id
}
dataset=
{
dataset
}
/>)))
}
{
data
?.
map
(({
data
:
datasets
})
=>
datasets
.
map
(
dataset
=>
(
<
DatasetCard
key=
{
dataset
.
id
}
dataset=
{
dataset
}
onDelete=
{
mutate
}
/>)
))
}
<
NewDatasetCard
ref=
{
anchorRef
}
/>
<
NewDatasetCard
ref=
{
anchorRef
}
/>
</
nav
>
</
nav
>
)
)
...
...
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