updated ui structs for snapshots

This commit is contained in:
Kiril Videlov 2024-04-26 23:34:09 +02:00
parent 9d534b09ca
commit 88c5fa249b

View File

@ -15,17 +15,28 @@
listSnapshots(projectId, snapshotsLimit); listSnapshots(projectId, snapshotsLimit);
}); });
type SnapshotEntry = { type Trailer = {
sha: string; key: string;
label: string; value: string;
};
type SnapshotDetails = {
title: string;
operation: string;
body: string | undefined;
trailers: Trailer[];
};
type Snapshot = {
id: string;
details: SnapshotDetails | undefined;
createdAt: number; createdAt: number;
}; };
let snapshots: SnapshotEntry[] = []; let snapshots: Snapshot[] = [];
async function listSnapshots(projectId: string, limit: number) { async function listSnapshots(projectId: string, limit: number) {
const resp = await invoke<SnapshotEntry[]>('list_snapshots', { const resp = await invoke<Snapshot[]>('list_snapshots', {
projectId: projectId, projectId: projectId,
limit: limit limit: limit
}); });
console.log(resp);
snapshots = resp; snapshots = resp;
} }
async function restoreSnapshot(projectId: string, sha: string) { async function restoreSnapshot(projectId: string, sha: string) {
@ -45,7 +56,7 @@
<div class="card"> <div class="card">
<div class="entry"> <div class="entry">
<div> <div>
{entry.label} {entry.details?.operation}
</div> </div>
<div> <div>
<span> <span>
@ -56,7 +67,7 @@
style="pop" style="pop"
size="tag" size="tag"
icon="undo-small" icon="undo-small"
on:click={async () => await restoreSnapshot(projectId, entry.sha)}>restore</Button on:click={async () => await restoreSnapshot(projectId, entry.id)}>restore</Button
> >
{/if} {/if}
</div> </div>