Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Simplify SourceBrowsingHeader props
Thomas Scholtes committed 2 years ago
commit 8f4b788a654e9cdd062571f2459b26a7a0fb2581
parent afbdf2f041e2d932e9f1b6afbc5eb829e1d63004
3 files changed +20 -30
modified src/views/projects/Browser.svelte
@@ -146,15 +146,12 @@
</style>

<SourceBrowsingHeader
-
  commitId={tree.lastCommit.id}
-
  defaultBranch={project.defaultBranch}
-
  projectId={project.id}
-
  {baseUrl}
-
  branches={branchesWithRoute}
-
  commitCount={tree.stats.commits}
-
  contributorCount={tree.stats.contributors}
+
  seed={baseUrl}
+
  {project}
  peers={peersWithRoute}
+
  branches={branchesWithRoute}
  {revision}
+
  {tree}
  historyLinkActive={false} />

<main>
modified src/views/projects/History.svelte
@@ -109,15 +109,12 @@
</style>

<SourceBrowsingHeader
-
  defaultBranch={project.defaultBranch}
-
  projectId={project.id}
-
  commitId={commitHeaders[0].id}
-
  {baseUrl}
-
  branches={branchesWithRoute}
-
  commitCount={tree.stats.commits}
-
  contributorCount={tree.stats.contributors}
+
  seed={baseUrl}
+
  {project}
  peers={peersWithRoute}
+
  branches={branchesWithRoute}
  {revision}
+
  {tree}
  historyLinkActive={true} />

<div class="history">
modified src/views/projects/SourceBrowsingHeader.svelte
@@ -1,5 +1,5 @@
<script lang="ts">
-
  import type { BaseUrl, Remote } from "@httpd-client";
+
  import type { BaseUrl, Project, Remote, Tree } from "@httpd-client";
  import { type Route } from "@app/lib/router";

  import { pluralize } from "@app/lib/pluralize";
@@ -9,29 +9,25 @@
  import Link from "@app/components/Link.svelte";
  import SquareButton from "@app/components/SquareButton.svelte";

-
  export let baseUrl: BaseUrl;
+
  export let seed: BaseUrl;
  export let branches: Array<{ name: string; route: Route }>;
-
  export let commitCount: number;
-
  export let contributorCount: number;
-
  export let defaultBranch: string;
  export let peers: Array<{ remote: Remote; selected: boolean; route: Route }>;
-
  export let projectId: string;
  export let historyLinkActive: boolean;
  export let revision: string | undefined;
-
  export let commitId: string;
+
  export let tree: Tree;
+
  export let project: Project;

  let selectedBranch: string | undefined;

  // Revision may be a commit ID, a branch name or `undefined` which means the
  // default branch. We assign `selectedBranch` accordingly.
-
  // TODO: Move this logic out of here and have `selectedBranch` be passed as a
-
  // prop.
  $: if (revision === commitId) {
    selectedBranch = undefined;
  } else {
-
    selectedBranch = revision || defaultBranch;
+
    selectedBranch = revision || project.defaultBranch;
  }

+
  $: commitId = tree.lastCommit.id;
  $: peer = peers.find(p => p.selected)?.remote.id;
</script>

@@ -67,19 +63,19 @@
  <Link
    route={{
      resource: "project.history",
-
      project: projectId,
-
      seed: baseUrl,
+
      project: project.id,
+
      seed: seed,
      peer,
      revision,
    }}>
    <SquareButton active={historyLinkActive}>
-
      <span class="txt-bold">{commitCount}</span>
-
      {pluralize("commit", commitCount)}
+
      <span class="txt-bold">{tree.stats.commits}</span>
+
      {pluralize("commit", tree.stats.commits)}
    </SquareButton>
  </Link>

  <SquareButton hoverable={false}>
-
    <span class="txt-bold">{contributorCount}</span>
-
    {pluralize("contributor", contributorCount)}
+
    <span class="txt-bold">{tree.stats.contributors}</span>
+
    {pluralize("contributor", tree.stats.contributors)}
  </SquareButton>
</div>