diff --git a/web/app/(commonLayout)/apps/AppCard.tsx b/web/app/(commonLayout)/apps/AppCard.tsx
index aec4d6ab6e..f08ce3c7a9 100644
--- a/web/app/(commonLayout)/apps/AppCard.tsx
+++ b/web/app/(commonLayout)/apps/AppCard.tsx
@@ -16,10 +16,12 @@ import AppsContext from '@/context/app-context'
export type AppCardProps = {
app: App
+ onDelete?: () => void
}
const AppCard = ({
app,
+ onDelete
}: AppCardProps) => {
const { t } = useTranslation()
const { notify } = useContext(ToastContext)
@@ -35,6 +37,8 @@ const AppCard = ({
try {
await deleteApp(app.id)
notify({ type: 'success', message: t('app.appDeleted') })
+ if (onDelete)
+ onDelete()
mutateApps()
}
catch (e: any) {
@@ -47,7 +51,7 @@ const AppCard = ({
<>
-
+
diff --git a/web/app/(commonLayout)/apps/Apps.tsx b/web/app/(commonLayout)/apps/Apps.tsx
index aa3ac28458..11da845165 100644
--- a/web/app/(commonLayout)/apps/Apps.tsx
+++ b/web/app/(commonLayout)/apps/Apps.tsx
@@ -42,7 +42,9 @@ const Apps = () => {
return (
)
diff --git a/web/app/(commonLayout)/datasets/DatasetCard.tsx b/web/app/(commonLayout)/datasets/DatasetCard.tsx
index b6786d0519..a27ac5955c 100644
--- a/web/app/(commonLayout)/datasets/DatasetCard.tsx
+++ b/web/app/(commonLayout)/datasets/DatasetCard.tsx
@@ -18,16 +18,16 @@ import classNames from 'classnames'
export type DatasetCardProps = {
dataset: DataSet
+ onDelete?: () => void
}
const DatasetCard = ({
dataset,
+ onDelete
}: DatasetCardProps) => {
const { t } = useTranslation()
const { notify } = useContext(ToastContext)
- const { mutate: mutateDatasets } = useSWR({ url: '/datasets', params: { page: 1 } }, fetchDatasets)
-
const [showConfirmDelete, setShowConfirmDelete] = useState(false)
const onDeleteClick: MouseEventHandler = useCallback((e) => {
e.preventDefault()
@@ -37,7 +37,8 @@ const DatasetCard = ({
try {
await deleteDataset(dataset.id)
notify({ type: 'success', message: t('dataset.datasetDeleted') })
- mutateDatasets()
+ if (onDelete)
+ onDelete()
}
catch (e: any) {
notify({ type: 'error', message: `${t('dataset.datasetDeleteFailed')}${'message' in e ? `: ${e.message}` : ''}` })
diff --git a/web/app/(commonLayout)/datasets/Datasets.tsx b/web/app/(commonLayout)/datasets/Datasets.tsx
index 31e38d7fc0..649ba64000 100644
--- a/web/app/(commonLayout)/datasets/Datasets.tsx
+++ b/web/app/(commonLayout)/datasets/Datasets.tsx
@@ -42,7 +42,9 @@ const Datasets = () => {
return (
)