mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
add: batch deletions to site deployments.
This commit is contained in:
1 parent
7e6dffc19c
commit
726212f919
1 file changed
+76
-4
+76
-4
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Id } from '$lib/components';
|
||||
import { Confirm, Id } from '$lib/components';
|
||||
import type { PageData } from './$types';
|
||||
import { type Models } from '@appwrite.io/console';
|
||||
import { formatTimeDetailed } from '$lib/helpers/timeConversion';
|
||||
@@ -11,12 +11,19 @@
|
||||
import RedeployModal from '../../redeployModal.svelte';
|
||||
import Cancel from './cancelDeploymentModal.svelte';
|
||||
import { base } from '$app/paths';
|
||||
import { Layout, Status, Table } from '@appwrite.io/pink-svelte';
|
||||
import { Badge, FloatingActionBar, Layout, Status, Table } from '@appwrite.io/pink-svelte';
|
||||
import { columns } from './store';
|
||||
import ActivateDeploymentModal from '../../activateDeploymentModal.svelte';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import DeploymentActionMenu from '../../(components)/deploymentActionMenu.svelte';
|
||||
import { deploymentStatusConverter } from '$lib/stores/git';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { site } from '$routes/(console)/project-[region]-[project]/sites/site-[site]/store';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -25,10 +32,43 @@
|
||||
let showRedeploy = false;
|
||||
let showCancel = false;
|
||||
|
||||
let selectedRows = [];
|
||||
let showBatchDeletion = false;
|
||||
let selectedDeployment: Models.Deployment = null;
|
||||
|
||||
async function deleteDeployments() {
|
||||
showBatchDeletion = false;
|
||||
|
||||
const promises = selectedRows.map((deploymentId) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.deleteDeployment(page.params.site, deploymentId)
|
||||
);
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.DeploymentDelete);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedRows.length} deployment${selectedRows.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.DeploymentDelete);
|
||||
} finally {
|
||||
selectedRows = [];
|
||||
invalidate(Dependencies.DEPLOYMENTS);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Table.Root columns={[...$columns, { id: 'actions', width: 40 }]} let:root>
|
||||
<Table.Root
|
||||
let:root
|
||||
allowSelection
|
||||
bind:selectedRows
|
||||
columns={[...$columns, { id: 'actions', width: 40 }]}>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $columns as { id, title }}
|
||||
<Table.Header.Cell column={id} {root}>
|
||||
@@ -37,9 +77,10 @@
|
||||
{/each}
|
||||
<Table.Header.Cell column="actions" {root} />
|
||||
</svelte:fragment>
|
||||
{#each data.deploymentList.deployments as deployment}
|
||||
{#each data.deploymentList.deployments as deployment (deployment.$id)}
|
||||
<Table.Row.Link
|
||||
{root}
|
||||
id={deployment.$id}
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/sites/site-${page.params.site}/deployments/deployment-${deployment.$id}`}>
|
||||
{#each $columns as column}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
@@ -102,9 +143,40 @@
|
||||
bind:show={showRedeploy}
|
||||
site={data.site} />
|
||||
{/if}
|
||||
|
||||
{#if selectedDeployment && showActivate}
|
||||
<ActivateDeploymentModal
|
||||
siteId={data.site.$id}
|
||||
selectedDeploymentId={selectedDeployment.$id}
|
||||
bind:show={showActivate} />
|
||||
{/if}
|
||||
|
||||
{#if selectedRows.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selectedRows.length.toString()} />
|
||||
<span>
|
||||
{selectedRows.length > 1 ? 'deployments' : 'deployment'}
|
||||
selected
|
||||
</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selectedRows = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showBatchDeletion = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
|
||||
<Confirm
|
||||
title="Delete deployments"
|
||||
confirmDeletion
|
||||
onSubmit={deleteDeployments}
|
||||
bind:open={showBatchDeletion}>
|
||||
<p>
|
||||
Are you sure you want to delete <b>{selectedRows.length}</b>
|
||||
{selectedRows.length > 1 ? 'deployments' : 'deployment'} from your site -
|
||||
<b>{$site.name}</b>?
|
||||
</p>
|
||||
|
||||
<p class="u-bold">This action is irreversible.</p>
|
||||
</Confirm>
|
||||
Reference in new issue
Block a user