Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Make project head optional
Alexis Sellier committed 4 years ago
commit 0a830432f767ae62b250d986ce2fbb795b32cb1e
parent cfc5f4a095064bbeea14825b890fd3c9b18904e8
6 files changed +25 -23
modified src/base/orgs/View/Projects.svelte
@@ -65,19 +65,21 @@
    {#each projects as project}
      {@const anchor = anchors[project.urn]}
      {@const pendingAnchor = pendingAnchors[project.urn]}
-
      <div class="project">
-
        <Widget {project} {anchor} on:click={() => onClick(project)}>
-
          <span class="actions" slot="actions">
-
            {#if profile?.org?.safe && account && anchor}
-
              {#if pendingAnchor} <!-- Pending anchor -->
-
                <AnchorActions
-
                  {account} {config} anchor={pendingAnchor} safe={profile.org.safe}
-
                  on:success={() => loadAnchors()} />
+
      {#if project.head}
+
        <div class="project">
+
          <Widget {project} {anchor} on:click={() => onClick(project)}>
+
            <span class="actions" slot="actions">
+
              {#if profile?.org?.safe && account && anchor}
+
                {#if pendingAnchor} <!-- Pending anchor -->
+
                  <AnchorActions
+
                    {account} {config} anchor={pendingAnchor} safe={profile.org.safe}
+
                    on:success={() => loadAnchors()} />
+
                {/if}
              {/if}
-
            {/if}
-
          </span>
-
        </Widget>
-
      </div>
+
            </span>
+
          </Widget>
+
        </div>
+
      {/if}
    {/each}
  {:catch err}
    <Message error>
modified src/base/profiles/AnchorBadge.svelte
@@ -4,7 +4,7 @@
  const dispatch = createEventDispatcher();

  export let anchors: Array<string> = [];
-
  export let head: string;
+
  export let head: string | null;
  export let commit: string;
  export let noText = false;
  export let noBg = false;
@@ -44,7 +44,7 @@
  }
</style>

-
{#if anchors}
+
{#if anchors && head}
  <!-- commit is head and latest anchor  -->
  {#if commit == anchors[0] && commit === head}
    <span class="anchor-widget anchor-latest" class:no-bg={noBg}>
modified src/base/projects/Browser.svelte
@@ -1,6 +1,6 @@
<script lang="ts">
  import type { Readable } from 'svelte/store';
-
  import * as proj from '@app/project';
+
  import type * as proj from '@app/project';
  import Loading from '@app/Loading.svelte';
  import Placeholder from '@app/Placeholder.svelte';
  import * as utils from '@app/utils';
@@ -21,10 +21,11 @@
  export let project: proj.Project;
  export let tree: proj.Tree;
  export let browserStore: Readable<proj.Browser>;
+
  export let commit: string;

  $: browser = $browserStore;
  $: path = browser.path || "/";
-
  $: revision = browser.revision || project.branches[project.head];
+
  $: revision = browser.revision;

  // When the component is loaded the first time, the blob is yet to be loaded.
  let state: State = { status: Status.Loading, path };
@@ -70,7 +71,6 @@
    mobileFileTree = !mobileFileTree;
  };

-
  $: commit = proj.getOid(revision, project.branches) || project.head;
  $: getBlob = loadBlob(path);
  $: loadingPath = state.status == Status.Loading ? state.path : null;
</script>
modified src/base/projects/Project.svelte
@@ -141,7 +141,7 @@
    <Header {tree} {commit} {browserStore} {project} peerSelector={! project.profile} />

    {#if content == proj.ProjectContent.Tree}
-
      <Browser {project} {tree} {browserStore} />
+
      <Browser {project} {commit} {tree} {browserStore} />
    {:else if content == proj.ProjectContent.History}
      <History {project} {commit} />
    {:else if content == proj.ProjectContent.Commit}
modified src/base/projects/Widget.svelte
@@ -93,7 +93,7 @@
        {#if project.head}
          {project.head}
        {:else}
-
          <span class="subtle">Could not retrieve HEAD</span>
+
          <span class="subtle">✗ No head</span>
        {/if}
      </slot>
    </span>
@@ -104,7 +104,7 @@
      </span>
      <span class="anchor-badge">
        <slot name="anchor">
-
          {#if anchor}
+
          {#if anchor && project.head}
            <AnchorBadge
              commit={project.head}
              head={project.head} noText noBg
modified src/project.ts
@@ -37,7 +37,7 @@ export enum ProjectContent {
}

export interface ProjectInfo {
-
  head: string;
+
  head: string | null;
  urn: string;
  name: string;
  description: string;
@@ -205,7 +205,7 @@ export function parseRoute(input: string, branches: Branches): { path?: string;

export class Project implements ProjectInfo {
  urn: string;
-
  head: string;
+
  head: string | null;
  name: string;
  description: string;
  defaultBranch: string;
@@ -345,7 +345,7 @@ export class Project implements ProjectInfo {
      : [];

    let remote: Remote = {
-
      heads: { [info.defaultBranch]: info.head }
+
      heads: info.head ? { [info.defaultBranch]: info.head } : {}
    };

    if (peer) {