mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-30 16:50:47 +08:00
Move SourceBrowsingHeader into the respective sub views
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let branches: Record<string, string>;
|
||||
export let projectDefaultBranch: string;
|
||||
export let defaultBranch: string;
|
||||
export let revision: string | undefined;
|
||||
|
||||
let branchLabel: string | null = null;
|
||||
@@ -17,11 +17,11 @@
|
||||
.sort()
|
||||
.map(b => ({ key: b, value: b, title: `Switch to ${b}`, badge: null }));
|
||||
$: showSelector = branchList.length > 1;
|
||||
$: commit = parseRevisionToOid(revision, projectDefaultBranch, branches);
|
||||
$: commit = parseRevisionToOid(revision, defaultBranch, branches);
|
||||
$: if (revision && branches[revision]) {
|
||||
branchLabel = revision;
|
||||
} else if (commit === branches[projectDefaultBranch]) {
|
||||
branchLabel = projectDefaultBranch;
|
||||
} else if (commit === branches[defaultBranch]) {
|
||||
branchLabel = defaultBranch;
|
||||
} else {
|
||||
branchLabel = null;
|
||||
}
|
||||
@@ -103,9 +103,9 @@
|
||||
{utils.formatCommit(commit)}
|
||||
</div>
|
||||
<!-- If there is no branch listing available, show default branch name if commit is head and else show entire commit -->
|
||||
{:else if commit === branches[projectDefaultBranch]}
|
||||
{:else if commit === branches[defaultBranch]}
|
||||
<div class="stat branch not-allowed">
|
||||
{projectDefaultBranch}
|
||||
{defaultBranch}
|
||||
</div>
|
||||
<div class="hash">
|
||||
{utils.formatCommit(commit)}
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, Project, Tree } from "@httpd-client";
|
||||
import type { BaseUrl, Project, Remote, Tree } from "@httpd-client";
|
||||
import type { BlobResult } from "./router";
|
||||
import type { LoadedSourceBrowsingView } from "@app/views/projects/router";
|
||||
|
||||
import * as utils from "@app/lib/utils";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Placeholder from "@app/components/Placeholder.svelte";
|
||||
import SourceBrowsingHeader from "./SourceBrowsingHeader.svelte";
|
||||
|
||||
import BlobComponent from "./Blob.svelte";
|
||||
import TreeComponent from "./Tree.svelte";
|
||||
|
||||
export let path: string;
|
||||
export let hash: string | undefined = undefined;
|
||||
export let project: Project;
|
||||
export let baseUrl: BaseUrl;
|
||||
export let tree: Tree;
|
||||
export let revision: string | undefined;
|
||||
export let branches: Record<string, string>;
|
||||
export let commit: string;
|
||||
export let commitCount: number;
|
||||
export let contributorCount: number;
|
||||
export let hash: string | undefined;
|
||||
export let path: string;
|
||||
export let peer: string | undefined;
|
||||
export let peers: Remote[];
|
||||
export let project: Project;
|
||||
export let resource: LoadedSourceBrowsingView["resource"];
|
||||
export let revision: string | undefined;
|
||||
export let tree: Tree;
|
||||
|
||||
export let blobResult: BlobResult;
|
||||
|
||||
@@ -119,6 +127,18 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<SourceBrowsingHeader
|
||||
defaultBranch={project.defaultBranch}
|
||||
projectId={project.id}
|
||||
{baseUrl}
|
||||
{branches}
|
||||
{commitCount}
|
||||
{contributorCount}
|
||||
{peers}
|
||||
{peer}
|
||||
{resource}
|
||||
{revision} />
|
||||
|
||||
<main>
|
||||
<!-- Mobile navigation -->
|
||||
{#if tree.entries.length > 0}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { Commit } from "@httpd-client";
|
||||
import type { Commit, BaseUrl, Remote, Project } from "@httpd-client";
|
||||
import type { LoadedSourceBrowsingView } from "@app/views/projects/router";
|
||||
|
||||
import { formatCommit } from "@app/lib/utils";
|
||||
|
||||
@@ -7,8 +8,18 @@
|
||||
import Clipboard from "@app/components/Clipboard.svelte";
|
||||
import CommitAuthorship from "@app/views/projects/Commit/CommitAuthorship.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import SourceBrowsingHeader from "./SourceBrowsingHeader.svelte";
|
||||
|
||||
export let baseUrl: BaseUrl;
|
||||
export let branches: Record<string, string>;
|
||||
export let commit: Commit;
|
||||
export let commitCount: number;
|
||||
export let contributorCount: number;
|
||||
export let peer: string | undefined = undefined;
|
||||
export let peers: Remote[];
|
||||
export let project: Project;
|
||||
export let resource: LoadedSourceBrowsingView["resource"];
|
||||
export let revision: string | undefined;
|
||||
|
||||
const { commit: header } = commit;
|
||||
</script>
|
||||
@@ -47,6 +58,18 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<SourceBrowsingHeader
|
||||
defaultBranch={project.defaultBranch}
|
||||
projectId={project.id}
|
||||
{baseUrl}
|
||||
{branches}
|
||||
{commitCount}
|
||||
{contributorCount}
|
||||
{peers}
|
||||
{peer}
|
||||
{resource}
|
||||
{revision} />
|
||||
|
||||
<div class="commit">
|
||||
<div class="header">
|
||||
<div class="summary">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, CommitHeader } from "@httpd-client";
|
||||
import type { BaseUrl, CommitHeader, Project, Remote } from "@httpd-client";
|
||||
import type { LoadedSourceBrowsingView } from "@app/views/projects/router";
|
||||
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { groupCommits } from "@app/lib/commit";
|
||||
@@ -8,12 +9,19 @@
|
||||
import CommitTeaser from "./Commit/CommitTeaser.svelte";
|
||||
import ErrorMessage from "@app/components/ErrorMessage.svelte";
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import SourceBrowsingHeader from "./SourceBrowsingHeader.svelte";
|
||||
import { COMMITS_PER_PAGE } from "./router";
|
||||
|
||||
export let baseUrl: BaseUrl;
|
||||
export let branches: Record<string, string>;
|
||||
export let commitCount: number;
|
||||
export let commitHeaders: CommitHeader[];
|
||||
export let peer: string | undefined = undefined;
|
||||
export let projectId: string;
|
||||
export let contributorCount: number;
|
||||
export let peer: string | undefined;
|
||||
export let peers: Remote[];
|
||||
export let project: Project;
|
||||
export let resource: LoadedSourceBrowsingView["resource"];
|
||||
export let revision: string | undefined;
|
||||
export let totalCommitCount: number;
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
@@ -32,7 +40,7 @@
|
||||
loading = true;
|
||||
page += 1;
|
||||
try {
|
||||
const response = await api.project.getAllCommits(projectId, {
|
||||
const response = await api.project.getAllCommits(project.id, {
|
||||
parent: allCommitHeaders[0].id,
|
||||
page,
|
||||
perPage: COMMITS_PER_PAGE,
|
||||
@@ -74,13 +82,25 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<SourceBrowsingHeader
|
||||
defaultBranch={project.defaultBranch}
|
||||
projectId={project.id}
|
||||
{baseUrl}
|
||||
{branches}
|
||||
{commitCount}
|
||||
{contributorCount}
|
||||
{peers}
|
||||
{peer}
|
||||
{resource}
|
||||
{revision} />
|
||||
|
||||
<div class="history">
|
||||
{#each groupCommits(allCommitHeaders) as group (group.time)}
|
||||
<p style:color="var(--color-foreground-6)">{group.date}</p>
|
||||
<div class="group">
|
||||
{#each group.commits as commit (commit.id)}
|
||||
<div class="teaser-wrapper">
|
||||
<CommitTeaser {peer} {projectId} {baseUrl} {commit} />
|
||||
<CommitTeaser {peer} projectId={project.id} {baseUrl} {commit} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, Project, Remote } from "@httpd-client";
|
||||
import type { ProjectLoadedView } from "@app/views/projects/router";
|
||||
import type { BaseUrl, Remote } from "@httpd-client";
|
||||
import type { LoadedSourceBrowsingView } from "@app/views/projects/router";
|
||||
|
||||
import { closeFocused } from "@app/components/Floating.svelte";
|
||||
import { pluralize } from "@app/lib/pluralize";
|
||||
@@ -10,13 +10,14 @@
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import SquareButton from "@app/components/SquareButton.svelte";
|
||||
|
||||
export let project: Project;
|
||||
export let peer: string | undefined = undefined;
|
||||
export let baseUrl: BaseUrl;
|
||||
export let revision: string | undefined;
|
||||
export let peers: Remote[];
|
||||
export let branches: Record<string, string>;
|
||||
export let view: ProjectLoadedView;
|
||||
export let defaultBranch: string;
|
||||
export let peer: string | undefined;
|
||||
export let peers: Remote[];
|
||||
export let projectId: string;
|
||||
export let resource: LoadedSourceBrowsingView["resource"];
|
||||
export let revision: string | undefined;
|
||||
|
||||
export let commitCount: number;
|
||||
export let contributorCount: number;
|
||||
@@ -53,13 +54,13 @@
|
||||
{branches}
|
||||
{revision}
|
||||
on:click={() => closeFocused()}
|
||||
projectDefaultBranch={project.defaultBranch} />
|
||||
{defaultBranch} />
|
||||
|
||||
<Link
|
||||
route={{
|
||||
resource: "projects",
|
||||
params: {
|
||||
id: project.id,
|
||||
id: projectId,
|
||||
baseUrl,
|
||||
view: {
|
||||
resource: "history",
|
||||
@@ -68,8 +69,7 @@
|
||||
revision,
|
||||
},
|
||||
}}>
|
||||
<SquareButton
|
||||
active={view.resource === "history" || view.resource === "commits"}>
|
||||
<SquareButton active={resource === "history" || resource === "commits"}>
|
||||
<span class="txt-bold">{commitCount}</span>
|
||||
{pluralize("commit", commitCount)}
|
||||
</SquareButton>
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
import { unreachable } from "@app/lib/utils";
|
||||
|
||||
import SourceBrowsingHeader from "./SourceBrowsingHeader.svelte";
|
||||
|
||||
import Browser from "./Browser.svelte";
|
||||
import Commit from "./Commit.svelte";
|
||||
import Header from "./Header.svelte";
|
||||
@@ -17,10 +15,10 @@
|
||||
import Patches from "./Patches.svelte";
|
||||
import ProjectMeta from "./ProjectMeta.svelte";
|
||||
|
||||
export let baseUrl: BaseUrl;
|
||||
export let id: string;
|
||||
export let project: Project;
|
||||
export let view: ProjectLoadedView;
|
||||
export let baseUrl: BaseUrl;
|
||||
|
||||
export let hash: string | undefined = undefined;
|
||||
export let peer: string | undefined = undefined;
|
||||
@@ -60,38 +58,47 @@
|
||||
</div>
|
||||
|
||||
<main>
|
||||
{#if view.resource === "tree" || view.resource === "history" || view.resource === "commits"}
|
||||
<SourceBrowsingHeader
|
||||
{project}
|
||||
{peer}
|
||||
{view}
|
||||
{baseUrl}
|
||||
peers={view.params.loadedPeers}
|
||||
{#if view.resource === "tree"}
|
||||
<Browser
|
||||
blobResult={view.blobResult}
|
||||
branches={view.params.loadedBranches}
|
||||
commit={view.params.selectedCommit}
|
||||
commitCount={view.params.loadedTree.stats.commits}
|
||||
contributorCount={view.params.loadedTree.stats.contributors}
|
||||
path={view.path}
|
||||
peers={view.params.loadedPeers}
|
||||
resource={view.resource}
|
||||
tree={view.params.loadedTree}
|
||||
{baseUrl}
|
||||
{hash}
|
||||
{peer}
|
||||
{project}
|
||||
{revision} />
|
||||
{:else if view.resource === "history"}
|
||||
<History
|
||||
branches={view.params.loadedBranches}
|
||||
commitCount={view.params.loadedTree.stats.commits}
|
||||
commitHeaders={view.commitHeaders}
|
||||
contributorCount={view.params.loadedTree.stats.contributors}
|
||||
peers={view.params.loadedPeers}
|
||||
resource={view.resource}
|
||||
totalCommitCount={view.totalCommitCount}
|
||||
{baseUrl}
|
||||
{peer}
|
||||
{project}
|
||||
{revision} />
|
||||
{:else if view.resource === "commits"}
|
||||
<Commit
|
||||
branches={view.params.loadedBranches}
|
||||
commit={view.commit}
|
||||
commitCount={view.params.loadedTree.stats.commits}
|
||||
contributorCount={view.params.loadedTree.stats.contributors}
|
||||
peers={view.params.loadedPeers}
|
||||
resource={view.resource}
|
||||
{baseUrl}
|
||||
{peer}
|
||||
{project}
|
||||
{revision} />
|
||||
|
||||
{#if view.resource === "tree"}
|
||||
<Browser
|
||||
{baseUrl}
|
||||
{project}
|
||||
{revision}
|
||||
commit={view.params.selectedCommit}
|
||||
tree={view.params.loadedTree}
|
||||
blobResult={view.blobResult}
|
||||
path={view.path}
|
||||
{hash} />
|
||||
{:else if view.resource === "history"}
|
||||
<History
|
||||
projectId={id}
|
||||
{peer}
|
||||
{baseUrl}
|
||||
totalCommitCount={view.totalCommitCount}
|
||||
commitHeaders={view.commitHeaders} />
|
||||
{:else if view.resource === "commits"}
|
||||
<Commit commit={view.commit} />
|
||||
{/if}
|
||||
{:else if view.resource === "issues"}
|
||||
{#if view.params.view.resource === "new"}
|
||||
<NewIssue projectId={id} projectHead={project.head} {baseUrl} />
|
||||
|
||||
@@ -86,7 +86,7 @@ export type BlobResult =
|
||||
| { ok: true; blob: Blob; highlighted: Syntax.Root | undefined }
|
||||
| { ok: false; error: { message: string; path: string } };
|
||||
|
||||
export type ProjectLoadedView =
|
||||
export type LoadedSourceBrowsingView =
|
||||
| {
|
||||
resource: "tree";
|
||||
params: LoadedSourceBrowsingParams;
|
||||
@@ -105,7 +105,10 @@ export type ProjectLoadedView =
|
||||
params: LoadedSourceBrowsingParams;
|
||||
commitHeaders: CommitHeader[];
|
||||
totalCommitCount: number;
|
||||
}
|
||||
};
|
||||
|
||||
export type ProjectLoadedView =
|
||||
| LoadedSourceBrowsingView
|
||||
| { resource: "issue"; params: { issue: string; loadedIssue: Issue } }
|
||||
| {
|
||||
resource: "issues";
|
||||
|
||||
Reference in New Issue
Block a user