mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Implement new landing page
This commit is contained in:
+25
-33
@@ -1,24 +1,23 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
import type { ProjectActivity } from "@app/views/nodes/router";
|
||||
|
||||
import { isLocal, truncateId } from "@app/lib/utils";
|
||||
import { loadProjects } from "@app/views/nodes/router";
|
||||
|
||||
import AppLayout from "@app/App/AppLayout.svelte";
|
||||
import ErrorMessage from "@app/components/ErrorMessage.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import ProjectCard from "@app/components/ProjectCard.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import CopyableId from "@app/components/CopyableId.svelte";
|
||||
import { isDelegate } from "@app/lib/roles";
|
||||
import { api, httpdStore } from "@app/lib/httpd";
|
||||
import type { ProjectWithListingData } from "@app/lib/projects";
|
||||
|
||||
export let baseUrl: BaseUrl;
|
||||
export let nid: string;
|
||||
export let externalAddresses: string[];
|
||||
export let projectCount: number;
|
||||
export let projectPageIndex: number;
|
||||
export let projects: ProjectActivity[] = [];
|
||||
export let projects: ProjectWithListingData[] = [];
|
||||
export let version: string;
|
||||
|
||||
let error: any;
|
||||
@@ -44,6 +43,11 @@
|
||||
!error &&
|
||||
projectCount &&
|
||||
projects.length < projectCount;
|
||||
|
||||
$: session =
|
||||
$httpdStore.state === "authenticated" && isLocal(api.baseUrl.hostname)
|
||||
? $httpdStore.session
|
||||
: undefined;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -81,7 +85,7 @@
|
||||
}
|
||||
.projects {
|
||||
display: flex;
|
||||
gap: 2rem;
|
||||
gap: 1rem;
|
||||
flex-direction: column;
|
||||
}
|
||||
.more {
|
||||
@@ -140,33 +144,21 @@
|
||||
</div>
|
||||
|
||||
<div class="projects">
|
||||
{#each projects as { project, activity } (project.id)}
|
||||
<Link
|
||||
route={{
|
||||
resource: "project.source",
|
||||
project: project.id,
|
||||
node: baseUrl,
|
||||
}}>
|
||||
<div class="global-hide-on-mobile">
|
||||
<ProjectCard
|
||||
{activity}
|
||||
id={project.id}
|
||||
name={project.name}
|
||||
visibility={project.visibility?.type}
|
||||
description={project.description}
|
||||
head={project.head} />
|
||||
</div>
|
||||
<div class="global-hide-on-desktop">
|
||||
<ProjectCard
|
||||
compact
|
||||
{activity}
|
||||
id={project.id}
|
||||
name={project.name}
|
||||
visibility={project.visibility?.type}
|
||||
description={project.description}
|
||||
head={project.head} />
|
||||
</div>
|
||||
</Link>
|
||||
{#each projects as { project, activity, lastCommit } (project.id)}
|
||||
<ProjectCard
|
||||
compact
|
||||
id={project.id}
|
||||
name={project.name}
|
||||
description={project.description}
|
||||
{activity}
|
||||
{baseUrl}
|
||||
numberOfIssues={project.issues.open}
|
||||
numberOfPatches={project.patches.open}
|
||||
lastUpdatedTimestamp={lastCommit.commit.committer.time}
|
||||
isPrivate={project.visibility?.type === "private"}
|
||||
isSeeding={false}
|
||||
isDelegate={isDelegate(session?.publicKey, project.delegates) ??
|
||||
false} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
import type { BaseUrl, Project } from "@httpd-client";
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
import type {
|
||||
LoadErrorRoute,
|
||||
NotFoundRoute,
|
||||
} from "@app/lib/router/definitions";
|
||||
import type { WeeklyActivity } from "@app/lib/commit";
|
||||
import type { ProjectWithListingData } from "@app/lib/projects";
|
||||
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { loadProjectActivity } from "@app/lib/commit";
|
||||
import { config } from "@app/lib/config";
|
||||
import { getProjectsListingData } from "@app/lib/projects";
|
||||
|
||||
export interface NodesRouteParams {
|
||||
baseUrl: BaseUrl;
|
||||
projectPageIndex: number;
|
||||
}
|
||||
|
||||
export interface ProjectActivity {
|
||||
project: Project;
|
||||
activity: WeeklyActivity[];
|
||||
}
|
||||
|
||||
export interface NodesRoute {
|
||||
resource: "nodes";
|
||||
params: NodesRouteParams;
|
||||
@@ -32,7 +27,7 @@ export interface NodesLoadedRoute {
|
||||
version: string;
|
||||
externalAddresses: string[];
|
||||
nid: string;
|
||||
projects: ProjectActivity[];
|
||||
projects: ProjectWithListingData[];
|
||||
projectCount: number;
|
||||
};
|
||||
}
|
||||
@@ -44,7 +39,7 @@ export async function loadProjects(
|
||||
baseUrl: BaseUrl,
|
||||
): Promise<{
|
||||
total: number;
|
||||
projects: ProjectActivity[];
|
||||
projects: ProjectWithListingData[];
|
||||
}> {
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
@@ -53,23 +48,8 @@ export async function loadProjects(
|
||||
api.project.getAll({ page, perPage: PROJECTS_PER_PAGE, show: "all" }),
|
||||
]);
|
||||
|
||||
const results = await Promise.all(
|
||||
projects.map(async project => {
|
||||
let activity: WeeklyActivity[] = [];
|
||||
try {
|
||||
activity = await loadProjectActivity(project.id, baseUrl);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to obtain project activity for: ${project.id}`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
project,
|
||||
activity,
|
||||
};
|
||||
}),
|
||||
const results = await getProjectsListingData(
|
||||
projects.map(p => ({ project: p, baseUrl })),
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user