Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/lib/components/multiSelectTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<script lang="ts">
import type { Snippet } from 'svelte';
import { page } from '$app/state';
import {
Table,
Badge,
Expand Down Expand Up @@ -64,6 +65,19 @@
let onDeleteError: string | null = $state(null);
let showConfirmDeletion: boolean = $state(false);

// paginating, searching or switching resource swaps the rows out from under the
// selection, and deleting what is no longer on screen is silent data loss
const selectionKey = $derived(`${page.url.href}|${computeKey}`);

let renderedUrl: string | undefined;

$effect.pre(() => {
if (renderedUrl === page.url.href) return;

renderedUrl = page.url.href;
selectedRows = [];
});

function notifySuccess(count: number) {
if (!showSuccessNotification) return;
if (count === 0) return;
Expand Down Expand Up @@ -155,7 +169,7 @@
}
</script>

{#key computeKey}
{#key selectionKey}
<Table.Root let:root {columns} {allowSelection} bind:selectedRows>
<svelte:fragment slot="header" let:root>
{@render header?.(root)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
{/snippet}

{#snippet children(root)}
{#each data.users.users as user}
{#each data.users.users as user (user.$id)}
<Table.Row.Link
href={`${base}/project-${page.params.region}-${page.params.project}/auth/user-${user.$id}`}
{root}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{/snippet}

{#snippet children(root)}
{#each data.memberships.memberships as membership}
{#each data.memberships.memberships as membership (membership.$id)}
<Table.Row.Link
{root}
href={`${base}/project-${page.params.region}-${page.params.project}/auth/teams/team-${membership.teamId}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
{/snippet}

{#snippet children(root)}
{#each data.backups.archives as backup, index}
{#each data.backups.archives as backup, index (backup.$id)}
{@const policy = getPolicyDetails(backup.policyId)}
{@const retainedUntil = new Date(
new Date(policy?.$createdAt).getTime() + policy?.retention * 24 * 60 * 60 * 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
{/snippet}

{#snippet children(root)}
{#each data.platforms.platforms as platform}
{#each data.platforms.platforms as platform (platform.$id)}
<Table.Row.Link href={getPlatformPath(platform)} {root} id={platform.$id}>
<Table.Cell {root}>
{platform.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
{/snippet}

{#snippet children(root)}
{#each data.files.files as file}
{#each data.files.files as file (file.$id)}
{#if file.chunksTotal / file.chunksUploaded !== 1}
<Table.Row.Base {root} id={file.$id}>
<Table.Cell column="filename" {root}>
Expand Down