From e210612d19ca871109d60d2b755375226409bd9c Mon Sep 17 00:00:00 2001 From: Darshan Date: Sun, 26 Oct 2025 12:31:57 +0530 Subject: [PATCH] add: auto notify support. add: `deleteContent` snippet support. add: `multiSelectTable` to functions. --- src/lib/components/multiSelectTable.svelte | 33 +- .../database-[database]/table.svelte | 5 - .../function-[function]/table.svelte | 314 ++++++++---------- .../sites/site-[site]/logs/table.svelte | 5 - 4 files changed, 173 insertions(+), 184 deletions(-) diff --git a/src/lib/components/multiSelectTable.svelte b/src/lib/components/multiSelectTable.svelte index 31ed31df1..e87daa25f 100644 --- a/src/lib/components/multiSelectTable.svelte +++ b/src/lib/components/multiSelectTable.svelte @@ -14,23 +14,28 @@ } from '@appwrite.io/pink-svelte'; import { Button } from '$lib/elements/forms'; import { Confirm } from '$lib/components/index'; + import { addNotification } from '$lib/stores/notifications'; let { columns, resource, allowSelection = true, confirmDeletion = false, + showSuccessNotification = true, header, children, onDelete, - onCancel + onCancel, + deleteContent }: { resource: string; allowSelection?: boolean; confirmDeletion?: boolean; + showSuccessNotification?: boolean; columns: Array | number; header: Snippet<[root: TableRootProps]>; children: Snippet<[root: TableRootProps]>; + deleteContent?: Snippet<[count: number]>; onDelete?: (selectedRows: string[]) => Promise | DeleteOperationState; onCancel?: () => Promise | void; } = $props(); @@ -39,6 +44,20 @@ let disableModal: boolean = $state(false); let onDeleteError: string | null = $state(null); let showConfirmDeletion: boolean = $state(false); + + function notifySuccess() { + if (!showSuccessNotification) return; + + const count = selectedRows.length; + if (count === 0) return; + + const label = `${resource}${count > 1 ? 's' : ''}`; + + addNotification({ + type: 'success', + message: `${count} ${label} deleted` + }); + } @@ -75,6 +94,7 @@ if (typeof state === 'string') { // user should handle error on their own! } else { + notifySuccess(); selectedRows = []; } } @@ -100,14 +120,21 @@ disableModal = false; onDeleteError = state || `Failed to delete ${resource}s`; } else { + notifySuccess(); selectedRows = []; disableModal = false; showConfirmDeletion = false; } }}> - Are you sure you want to delete {selectedRows.length} - {selectedRows.length > 1 ? `${resource}s` : resource}. + {@const selectionCount = selectedRows.length} + {#if deleteContent} + + {@render deleteContent(selectionCount)} + {:else} + Are you sure you want to delete {selectionCount} + {selectionCount > 1 ? `${resource}s` : resource}. + {/if} This action is irreversible. 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 bf3db7853..cdfcf1cc3 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 @@ -30,11 +30,6 @@ subNavigation.update(); trackEvent(Submit.TableDelete); - addNotification({ - type: 'success', - message: `${selectedTables.length} table${selectedTables.length > 1 ? 's' : ''} deleted` - }); - return true; } catch (error) { trackError(error, Submit.TableDelete); diff --git a/src/routes/(console)/project-[region]-[project]/functions/function-[function]/table.svelte b/src/routes/(console)/project-[region]-[project]/functions/function-[function]/table.svelte index eecafbd5a..40c2eff46 100644 --- a/src/routes/(console)/project-[region]-[project]/functions/function-[function]/table.svelte +++ b/src/routes/(console)/project-[region]-[project]/functions/function-[function]/table.svelte @@ -1,5 +1,5 @@ - - + {#snippet header(root)} {#each columns as { id, title }} {title} {/each} - - {#each data.deploymentList.deployments as deployment (deployment.$id)} - - {#each columns as column} - - {#if column.id === '$id'} - {#key column.id} - {deployment.$id} - {/key} - {:else if column.id === 'status'} - {@const status = deployment.status} + {/snippet} - {#if data?.activeDeployment?.$id === deployment?.$id} - - {:else} - - {/if} - {:else if column.id === 'type'} - - {:else if column.id === '$updatedAt'} - - {:else if column.id === 'buildDuration'} - {#if ['waiting'].includes(deployment.status)} - - - {:else if ['processing', 'building'].includes(deployment.status)} - - {:else} - {formatTimeDetailed(deployment.buildDuration)} - {/if} - {:else if column.id === 'totalSize'} - {calculateSize(deployment.totalSize)} - {:else if column.id === 'sourceSize'} - {calculateSize(deployment.sourceSize)} - {:else if column.id === 'buildSize'} - {calculateSize(deployment.buildSize)} - {/if} - - {/each} - - - + {#snippet children(root)} + {#each data.deploymentList.deployments as deployment (deployment.$id)} + + {#each columns as column} + + {#if column.id === '$id'} + {#key column.id} + {deployment.$id} + {/key} + {:else if column.id === 'status'} + {@const status = deployment.status} - - - -
+ {#if data?.activeDeployment?.$id === deployment?.$id} + + {:else} + + {/if} + {:else if column.id === 'type'} + + {:else if column.id === '$updatedAt'} + + {:else if column.id === 'buildDuration'} + {#if ['waiting'].includes(deployment.status)} + - + {:else if ['processing', 'building'].includes(deployment.status)} + + {:else} + {formatTimeDetailed(deployment.buildDuration)} + {/if} + {:else if column.id === 'totalSize'} + {calculateSize(deployment.totalSize)} + {:else if column.id === 'sourceSize'} + {calculateSize(deployment.sourceSize)} + {:else if column.id === 'buildSize'} + {calculateSize(deployment.buildSize)} + {/if} + + {/each} + + + + + + + +
+ { + selectedDeployment = deployment; + showRedeploy = true; + toggle(); + trackEvent(Click.FunctionsRedeployClick); + }} + style="width: 100%"> + Redeploy + +
+
Source is empty
+
+ {#if deployment.status === 'ready' && deployment.$id !== $func.deploymentId} { selectedDeployment = deployment; - showRedeploy = true; + showActivate = true; toggle(); - trackEvent(Click.FunctionsRedeployClick); - }} - style="width: 100%"> - Redeploy + }}> + Activate -
-
Source is empty
-
- {#if deployment.status === 'ready' && deployment.$id !== $func.deploymentId} - { - selectedDeployment = deployment; - showActivate = true; - toggle(); - }}> - Activate - - {/if} + {/if} - + - {#if deployment.status === 'processing' || deployment.status === 'building' || deployment.status === 'waiting'} - { - selectedDeployment = deployment; - toggle(); + {#if deployment.status === 'processing' || deployment.status === 'building' || deployment.status === 'waiting'} + { + selectedDeployment = deployment; + toggle(); - showCancel = true; - trackEvent(Click.FunctionsDeploymentCancelClick); - }}> - Cancel - - {/if} - {#if deployment.status !== 'building' && deployment.status !== 'processing' && deployment.status !== 'waiting'} - { - selectedDeployment = deployment; - toggle(); + showCancel = true; + trackEvent(Click.FunctionsDeploymentCancelClick); + }}> + Cancel + + {/if} + {#if deployment.status !== 'building' && deployment.status !== 'processing' && deployment.status !== 'waiting'} + { + selectedDeployment = deployment; + toggle(); - showDelete = true; - trackEvent(Click.FunctionsDeploymentDeleteClick); - }}> - Delete - - {/if} -
-
-
-
-
- {/each} -
+ showDelete = true; + trackEvent(Click.FunctionsDeploymentDeleteClick); + }}> + Delete + + {/if} + + + + + + {/each} + {/snippet} + + {#snippet deleteContent(count)} +

+ Are you sure you want to delete {count} + {count > 1 ? 'deployments' : 'deployment'} from your function - + {page.data.function.name}? +

+ {/snippet} + {#if selectedDeployment} - + {/if} - -{#if selectedRows.length > 0} - - - - - {selectedRows.length > 1 ? 'deployments' : 'deployment'} - selected - - - - - - - -{/if} - - -

- Are you sure you want to delete {selectedRows.length} - {selectedRows.length > 1 ? 'deployments' : 'deployment'} from your function - - {$func.name}? -

- -

This action is irreversible.

-
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 57ef3a2cc..1ce01bb89 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 @@ -39,11 +39,6 @@ await Promise.all(promises); await invalidate(Dependencies.EXECUTIONS); - addNotification({ - type: 'success', - message: `${selectedRows.length} log${selectedRows.length > 1 ? 's' : ''} deleted` - }); - trackEvent(Submit.LogDelete); return true; } catch (error) {