mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Add Download button to commit view
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, Commit, Repo, SeedingPolicy } from "@http-client";
|
||||
|
||||
import { formatObjectId } from "@app/lib/utils";
|
||||
import { baseUrlToString, formatObjectId } from "@app/lib/utils";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Changeset from "@app/views/repos/Changeset.svelte";
|
||||
@@ -20,6 +20,17 @@
|
||||
export let repo: Repo;
|
||||
export let nodeAvatarUrl: string | undefined;
|
||||
|
||||
let enabledArchiveDownload = false;
|
||||
|
||||
void fetch(
|
||||
`${baseUrlToString(baseUrl)}/raw/${repo.rid}/${commit.commit.id}.tar.gz`,
|
||||
{
|
||||
method: "HEAD",
|
||||
},
|
||||
).then(response => {
|
||||
enabledArchiveDownload = response.ok;
|
||||
});
|
||||
|
||||
$: header = commit.commit;
|
||||
</script>
|
||||
|
||||
@@ -88,6 +99,14 @@
|
||||
<Icon name="chevron-left-right" />
|
||||
</Button>
|
||||
</Link>
|
||||
{#if enabledArchiveDownload}
|
||||
<a
|
||||
href={`${baseUrlToString(baseUrl)}/raw/${repo.rid}/${commit.commit.id}.tar.gz`}>
|
||||
<Button variant="outline">
|
||||
<Icon name="archive" />Download
|
||||
</Button>
|
||||
</a>
|
||||
{/if}
|
||||
<Share />
|
||||
</div>
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user