diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts
index f93405528..8d99efda7 100644
--- a/src/lib/components/index.ts
+++ b/src/lib/components/index.ts
@@ -88,3 +88,4 @@ export { default as EstimatedCard } from './estimatedCard.svelte';
export { default as SortButton, type SortDirection } from './sortButton.svelte';
export { default as SendVerificationEmailModal } from './account/sendVerificationEmailModal.svelte';
export { default as MultiSelectionTable } from './multiSelectTable.svelte';
+export * from './multiSelectTable.svelte';
diff --git a/src/lib/components/multiSelectTable.svelte b/src/lib/components/multiSelectTable.svelte
index d2325ef10..31ed31df1 100644
--- a/src/lib/components/multiSelectTable.svelte
+++ b/src/lib/components/multiSelectTable.svelte
@@ -1,3 +1,7 @@
+
+
@@ -66,29 +71,45 @@
if (confirmDeletion) {
showConfirmDeletion = true;
} else {
- await onDelete?.(selectedRows);
+ const state = await onDelete?.(selectedRows);
+ if (typeof state === 'string') {
+ // user should handle error on their own!
+ } else {
+ selectedRows = [];
+ }
}
}}>Delete
{/if}
- {
- disableModal = true;
- await onDelete?.(selectedRows);
- disableModal = false;
- showConfirmDeletion = false;
- }}>
-
- Are you sure you want to delete {selectedRows.length}
- {selectedRows.length > 1 ? `${resource}s` : resource}.
-
+{#if allowSelection}
+ {
+ disableModal = true;
+ onDeleteError = null;
- This action is irreversible.
-
+ const state = await onDelete?.(selectedRows);
+ if (typeof state === 'string') {
+ disableModal = false;
+ onDeleteError = state || `Failed to delete ${resource}s`;
+ } else {
+ selectedRows = [];
+ disableModal = false;
+ showConfirmDeletion = false;
+ }
+ }}>
+
+ Are you sure you want to delete {selectedRows.length}
+ {selectedRows.length > 1 ? `${resource}s` : resource}.
+
+
+ This action is irreversible.
+
+{/if}
diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table.svelte
index 19cf12b52..bf3db7853 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table.svelte
+++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table.svelte
@@ -3,7 +3,7 @@
import { resolve } from '$app/paths';
import { page } from '$app/state';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
- import { Id, MultiSelectionTable } from '$lib/components';
+ import { Id, MultiSelectionTable, type DeleteOperationState } from '$lib/components';
import { Dependencies } from '$lib/constants';
import DualTimeView from '$lib/components/dualTimeView.svelte';
import { addNotification } from '$lib/stores/notifications';
@@ -17,7 +17,7 @@
let { data }: PageProps = $props();
- async function onDelete(selectedTables: string[]) {
+ async function onDelete(selectedTables: string[]): Promise {
const promises = selectedTables.map((tableId) =>
sdk.forProject(page.params.region, page.params.project).tablesDB.deleteTable({
databaseId: page.params.database,
@@ -26,19 +26,19 @@
);
try {
await Promise.all(promises);
+ await invalidate(Dependencies.TABLES);
+ subNavigation.update();
+
trackEvent(Submit.TableDelete);
addNotification({
type: 'success',
message: `${selectedTables.length} table${selectedTables.length > 1 ? 's' : ''} deleted`
});
- await invalidate(Dependencies.TABLES);
- subNavigation.update();
+
+ return true;
} catch (error) {
- addNotification({
- type: 'error',
- message: error.message
- });
trackError(error, Submit.TableDelete);
+ return error.message;
}
}
diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/table.svelte b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/table.svelte
index b530e4d2c..57ef3a2cc 100644
--- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/table.svelte
+++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/table.svelte
@@ -1,5 +1,5 @@