Make project head optional

This is useful since some seeds may not have delegates synced.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-03-02 14:41:04 +01:00
parent cfc5f4a095
commit 0a830432f7
6 changed files with 25 additions and 23 deletions
+14 -12
View File
@@ -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>
+2 -2
View File
@@ -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}>
+3 -3
View File
@@ -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>
+1 -1
View File
@@ -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}
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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) {