| |
// 4. submit: create_or_open_release, then add_artifact per file,
|
| |
// and seed_artifact if the auto-seed setting is on
|
| |
|
| + |
import type { PaginatedQuery } from "@bindings/cob/PaginatedQuery";
|
| + |
import type { Commit } from "@bindings/repo/Commit";
|
| |
import type { RepoInfo } from "@bindings/repo/RepoInfo";
|
| |
|
| + |
import { onMount } from "svelte";
|
| + |
|
| |
import { invoke } from "@app/lib/invoke";
|
| |
import * as router from "@app/lib/router";
|
| |
|
| |
let submitting = $state(false);
|
| |
let autoSeed = $state(true);
|
| |
let submitError: string | undefined = $state();
|
| + |
// Recent commits offered as autocomplete suggestions for the OID input.
|
| + |
let commits = $state<Commit[]>([]);
|
| |
|
| |
void invoke<boolean>("get_auto_seed_artifacts").then(v => {
|
| |
autoSeed = v;
|
| |
});
|
| |
|
| + |
onMount(async () => {
|
| + |
try {
|
| + |
const result = await invoke<PaginatedQuery<Commit[]>>(
|
| + |
"list_repo_commits",
|
| + |
{ rid: repo.rid, skip: 0, take: 50 },
|
| + |
);
|
| + |
commits = result.content;
|
| + |
} catch (err) {
|
| + |
console.error("list_repo_commits failed", err);
|
| + |
}
|
| + |
});
|
| + |
|
| |
async function pickFiles() {
|
| |
const picked = await invoke<string[]>("pick_artifact_files");
|
| |
for (const p of picked) {
|
| |
|
| |
async function stageFile(path: string) {
|
| |
const baseName = path.split(/[\\/]/).filter(Boolean).pop() ?? path;
|
| - |
const entry: StagedFile = {
|
| + |
const idx = files.length;
|
| + |
files.push({
|
| |
path,
|
| |
name: baseName,
|
| |
computing: true,
|
| - |
};
|
| - |
files.push(entry);
|
| + |
});
|
| + |
// After push, files[idx] returns Svelte 5's reactive proxy view of the
|
| + |
// entry — write through that handle, not a local reference, otherwise
|
| + |
// mutations don't trigger re-renders and the row spins forever.
|
| |
try {
|
| - |
entry.cid = await invoke<string>("compute_artifact_cid", { path });
|
| + |
files[idx].cid = await invoke<string>("compute_artifact_cid", { path });
|
| |
} catch (err) {
|
| - |
entry.error = String(err);
|
| + |
files[idx].error = String(err);
|
| |
} finally {
|
| - |
entry.computing = false;
|
| + |
files[idx].computing = false;
|
| |
}
|
| |
}
|
| |
|