Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add `Download` button to commit view
Sebastian Martinez committed 1 year ago
commit 867a4de80560605df34c3273914311e9b4551647
parent 12a99340a9402012ff15bbcc59d3eea1c4708b01
1 file changed +21 -1
modified src/views/repos/Commit.svelte
@@ -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";
@@ -13,6 +13,7 @@
  import Link from "@app/components/Link.svelte";
  import Separator from "./Separator.svelte";
  import Share from "./Share.svelte";
+
  import { enableHide } from "@app/lib/modal";

  export let baseUrl: BaseUrl;
  export let seedingPolicy: SeedingPolicy;
@@ -20,6 +21,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 +100,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>