mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Implement new landing page
This commit is contained in:
+182
-70
@@ -1,101 +1,213 @@
|
||||
<script lang="ts">
|
||||
import type { ProjectBaseUrlActivity } from "./router";
|
||||
import type { ProjectWithListingData } from "@app/lib/projects";
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
|
||||
import { isLocal, twemoji } from "@app/lib/utils";
|
||||
import { z } from "zod";
|
||||
import storedWritable from "@efstajas/svelte-stored-writable";
|
||||
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { isDelegate } from "@app/lib/roles";
|
||||
|
||||
import AppLayout from "@app/App/AppLayout.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import ConnectInstructions from "@app/components/ConnectInstructions.svelte";
|
||||
import ProjectCard from "@app/components/ProjectCard.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
|
||||
export let projects: ProjectBaseUrlActivity[];
|
||||
import FilterButton from "./components/FilterButton.svelte";
|
||||
import NewProjectButton from "./components/NewProjectButton.svelte";
|
||||
import PreferredSeedDropdown from "./components/PreferredSeedDropdown.svelte";
|
||||
import HomepageSection from "./components/HomepageSection.svelte";
|
||||
|
||||
export let localProjects: ProjectWithListingData[] | "error";
|
||||
export let preferredSeedProjects: ProjectWithListingData[] | "error";
|
||||
export let preferredSeed: BaseUrl;
|
||||
export let nodeId: string | undefined;
|
||||
|
||||
const localProjectsFilterSchema = z.union([
|
||||
z.literal("all"),
|
||||
z.literal("delegating"),
|
||||
]);
|
||||
|
||||
const localProjectsFilter = storedWritable(
|
||||
"localProjectsFilter",
|
||||
localProjectsFilterSchema,
|
||||
"all",
|
||||
);
|
||||
|
||||
$: filteredLocalProjects =
|
||||
$localProjectsFilter === "all" || localProjects === "error"
|
||||
? localProjects
|
||||
: localProjects.filter(p => isDelegate(nodeId, p.project.delegates));
|
||||
|
||||
function isSeeding(projectId: string) {
|
||||
if (localProjects === "error") return false;
|
||||
return localProjects.some(p => p.project.id === projectId);
|
||||
}
|
||||
|
||||
let prevHttpdState = $httpdStore.state;
|
||||
|
||||
function handleHttpdStateChange(newState: (typeof $httpdStore)["state"]) {
|
||||
if (prevHttpdState === newState) return;
|
||||
|
||||
if (newState === "stopped" || newState === "authenticated") {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
prevHttpdState = newState;
|
||||
}
|
||||
|
||||
$: handleHttpdStateChange($httpdStore.state);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.wrapper {
|
||||
padding: 3rem 16vw;
|
||||
padding: 3rem;
|
||||
max-width: 72rem;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
.blurb {
|
||||
color: var(--color-foreground-contrast);
|
||||
padding: 0rem;
|
||||
font-size: var(--font-size-medium);
|
||||
text-align: left;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.projects {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
gap: 2.5rem;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
gap: 3rem;
|
||||
}
|
||||
.project {
|
||||
width: 16rem;
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.heading {
|
||||
color: var(--color-foreground-emphasized);
|
||||
padding: 1rem 0rem;
|
||||
font-size: var(--font-size-medium);
|
||||
margin-bottom: 1rem;
|
||||
.empty-state .heading {
|
||||
font-size: var(--font-size-small);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
.empty-state .label {
|
||||
display: block;
|
||||
font-size: var(--font-size-small);
|
||||
font-weight: var(--font-weight-regular);
|
||||
}
|
||||
.empty-state .action {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
.project-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.project {
|
||||
width: 100%;
|
||||
}
|
||||
.projects {
|
||||
margin-bottom: 1.5rem;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
padding: 1rem 1.5rem 0 1.5rem;
|
||||
padding: 1rem 1.5rem 1.5rem 1.5rem;
|
||||
}
|
||||
|
||||
.seed-dropdown {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<AppLayout>
|
||||
<div class="wrapper">
|
||||
<div class="blurb">
|
||||
<p use:twemoji>
|
||||
Radicle 🌱 enables developers 🧙 to securely collaborate 🔐 on software
|
||||
<br class="global-hide-on-mobile" />
|
||||
over a peer-to-peer network 🌐 built on Git.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{#if projects.length > 0}
|
||||
<div class="heading">
|
||||
{#if isLocal(projects[0].baseUrl.hostname)}
|
||||
<!-- prettier-ignore -->
|
||||
<span>Explore projects on your <span class="txt-bold">local node</span>.</span>
|
||||
{:else}
|
||||
<!-- prettier-ignore -->
|
||||
<span>Explore projects on the <span class="txt-bold">Radicle network</span>.</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="projects">
|
||||
{#each projects as { project, baseUrl, activity }}
|
||||
<div class="project">
|
||||
<Link
|
||||
route={{
|
||||
resource: "project.source",
|
||||
project: project.id,
|
||||
node: baseUrl,
|
||||
}}>
|
||||
<div class="global-hide-on-mobile">
|
||||
<HomepageSection
|
||||
empty={localProjects === "error" ||
|
||||
!nodeId ||
|
||||
!filteredLocalProjects.length}
|
||||
title="Local projects"
|
||||
subtitle="Projects you’re seeding with your local node">
|
||||
<svelte:fragment slot="actions">
|
||||
<FilterButton disabled={!nodeId} bind:value={$localProjectsFilter} />
|
||||
<NewProjectButton disabled={!nodeId} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="empty">
|
||||
<div class="empty-state">
|
||||
{#if !nodeId}
|
||||
<div style:text-align="left">
|
||||
<ConnectInstructions />
|
||||
</div>
|
||||
{:else if localProjects === "error"}
|
||||
<div class="heading">Error loading projects</div>
|
||||
<div class="label">
|
||||
There was an error loading projects from your local node.
|
||||
</div>
|
||||
<div class="action"><Button>Learn more</Button></div>
|
||||
{:else if !localProjects.length}
|
||||
<div class="heading">No local projects</div>
|
||||
<div class="label">
|
||||
Seed or check out a project to work with it on your local node.
|
||||
</div>
|
||||
{:else}
|
||||
<div class="heading">Nothing to see here</div>
|
||||
<div class="label">
|
||||
No local projects matched your filter settings.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
<div class="project-grid">
|
||||
{#if filteredLocalProjects !== "error"}
|
||||
{#each filteredLocalProjects as { project, baseUrl, activity, lastCommit }}
|
||||
<ProjectCard
|
||||
compact
|
||||
description={project.description}
|
||||
head={project.head}
|
||||
visibility={project.visibility?.type}
|
||||
id={project.id}
|
||||
name={project.name}
|
||||
{activity} />
|
||||
</Link>
|
||||
</div>
|
||||
{/each}
|
||||
description={project.description}
|
||||
numberOfIssues={project.issues.open}
|
||||
numberOfPatches={project.patches.open}
|
||||
isPrivate={project.visibility?.type === "private"}
|
||||
isSeeding={true}
|
||||
isDelegate={isDelegate(nodeId, project.delegates) ?? false}
|
||||
lastUpdatedTimestamp={lastCommit.commit.committer.time}
|
||||
{activity}
|
||||
{baseUrl} />
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</HomepageSection>
|
||||
</div>
|
||||
|
||||
<HomepageSection
|
||||
empty={preferredSeedProjects === "error" ||
|
||||
preferredSeedProjects.length === 0}
|
||||
title="Explore"
|
||||
subtitle="Pinned projects on your selected seed node">
|
||||
<svelte:fragment slot="actions">
|
||||
<div class="seed-dropdown">
|
||||
<PreferredSeedDropdown disabled={!nodeId} {preferredSeed} />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="empty">
|
||||
<div class="empty-state">
|
||||
{#if preferredSeedProjects === "error"}
|
||||
<div class="heading">Something went wrong</div>
|
||||
<div class="label">
|
||||
There was an error loading projects from your preferred seed node.
|
||||
</div>
|
||||
{:else}
|
||||
<div class="heading">Nothing to see here</div>
|
||||
<div class="label">
|
||||
Your preferred seed node doesn't have any pinned projects.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
<div class="project-grid">
|
||||
{#if preferredSeedProjects !== "error"}
|
||||
{#each preferredSeedProjects as { project, baseUrl, activity, lastCommit }}
|
||||
<ProjectCard
|
||||
id={project.id}
|
||||
name={project.name}
|
||||
description={project.description}
|
||||
numberOfIssues={project.issues.open}
|
||||
numberOfPatches={project.patches.open}
|
||||
isPrivate={project.visibility?.type === "private"}
|
||||
isSeeding={isSeeding(project.id)}
|
||||
isDelegate={isDelegate(nodeId, project.delegates) ?? false}
|
||||
lastUpdatedTimestamp={lastCommit.commit.committer.time}
|
||||
{activity}
|
||||
{baseUrl} />
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</HomepageSection>
|
||||
</div>
|
||||
</AppLayout>
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<script lang="ts">
|
||||
import type { ComponentProps } from "svelte";
|
||||
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
import DropdownListItem from "@app/components/DropdownList/DropdownListItem.svelte";
|
||||
|
||||
const stateOptions: {
|
||||
value: typeof value;
|
||||
title: string;
|
||||
description: string;
|
||||
iconName: ComponentProps<IconSmall>["name"];
|
||||
}[] = [
|
||||
{
|
||||
value: "all",
|
||||
title: "All projects",
|
||||
description: "Show all projects you’re seeding with your local node.",
|
||||
iconName: "globe",
|
||||
},
|
||||
{
|
||||
value: "delegating",
|
||||
title: "Delegate only",
|
||||
description: "Show only projects that you’re seeding and a delegate of.",
|
||||
iconName: "badge",
|
||||
},
|
||||
];
|
||||
|
||||
export let value: "all" | "delegating" = "all";
|
||||
export let disabled = false;
|
||||
|
||||
let expanded = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.popover-content {
|
||||
width: 20rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
white-space: initial;
|
||||
}
|
||||
|
||||
.label .text > * {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dim {
|
||||
color: var(--color-foreground-dim);
|
||||
}
|
||||
</style>
|
||||
|
||||
<Popover
|
||||
bind:expanded
|
||||
popoverPositionTop="2.5rem"
|
||||
popoverPositionRight="0"
|
||||
popoverPadding="0.25rem"
|
||||
popoverBorderRadius="var(--border-radius-small)">
|
||||
<Button
|
||||
{disabled}
|
||||
variant="outline"
|
||||
let:toggle
|
||||
slot="toggle"
|
||||
on:click={toggle}>
|
||||
{#if value === "all"}
|
||||
<IconSmall name="globe" />
|
||||
All projects
|
||||
{:else}
|
||||
<IconSmall name="badge" />
|
||||
Only delegating
|
||||
{/if}
|
||||
<IconSmall name={expanded ? "chevron-up" : "chevron-down"} />
|
||||
</Button>
|
||||
|
||||
<div class="popover-content" slot="popover">
|
||||
<DropdownList items={stateOptions}>
|
||||
<DropdownListItem
|
||||
on:click={() => {
|
||||
value = item.value;
|
||||
closeFocused();
|
||||
}}
|
||||
slot="item"
|
||||
let:item
|
||||
selected={item.value === value}>
|
||||
<div class="label">
|
||||
<div class="text txt-small">
|
||||
<span class="txt-bold">
|
||||
<IconSmall name={item.iconName} />{item.title}
|
||||
</span>
|
||||
<span class="dim">{item.description}</span>
|
||||
</div>
|
||||
</div>
|
||||
</DropdownListItem>
|
||||
</DropdownList>
|
||||
</div>
|
||||
</Popover>
|
||||
@@ -0,0 +1,79 @@
|
||||
<script lang="ts">
|
||||
import TransitionedHeight from "@app/components/TransitionedHeight.svelte";
|
||||
|
||||
export let title: string;
|
||||
export let subtitle: string;
|
||||
|
||||
export let empty: boolean = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.section-header {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.title > * {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.title > p {
|
||||
margin-top: 0.25rem;
|
||||
color: var(--color-foreground-dim);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.empty-container {
|
||||
background-color: var(--color-background-float);
|
||||
border-radius: var(--border-radius-small);
|
||||
border: 1px solid var(--color-border-hint);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 3rem 1rem;
|
||||
align-items: center;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.empty-container > .inner {
|
||||
max-width: 32rem;
|
||||
min-height: 12rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<section>
|
||||
<div class="section-header">
|
||||
<div class="title">
|
||||
<h2>{title}</h2>
|
||||
<p>{subtitle}</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TransitionedHeight transitionHeightChanges>
|
||||
{#if empty}
|
||||
<div class="empty-container">
|
||||
<div class="inner">
|
||||
<slot name="empty" />
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div>
|
||||
<slot />
|
||||
</div>
|
||||
{/if}
|
||||
</TransitionedHeight>
|
||||
</section>
|
||||
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Command from "@app/components/Command.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
|
||||
export let disabled = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.popover {
|
||||
min-width: 16rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<Popover
|
||||
popoverPositionTop="2.5rem"
|
||||
popoverPositionRight="0"
|
||||
popoverBorderRadius="var(--border-radius-small)">
|
||||
<Button
|
||||
{disabled}
|
||||
variant="secondary"
|
||||
let:toggle
|
||||
slot="toggle"
|
||||
on:click={toggle}>
|
||||
<IconSmall name="plus" />
|
||||
New project
|
||||
</Button>
|
||||
|
||||
<div slot="popover" class="popover txt-small">
|
||||
Run the following command within an already-existing Git repository to
|
||||
create a new Radicle project.
|
||||
<Command fullWidth command="rad init" />
|
||||
</div>
|
||||
</Popover>
|
||||
@@ -0,0 +1,97 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
|
||||
import {
|
||||
prefferedSeeds as preferredSeedsStore,
|
||||
selectPreferredSeed,
|
||||
} from "@app/lib/seeds";
|
||||
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
import DropdownListItem from "@app/components/DropdownList/DropdownListItem.svelte";
|
||||
import Command from "@app/components/Command.svelte";
|
||||
|
||||
export let preferredSeed: BaseUrl;
|
||||
export let disabled = false;
|
||||
|
||||
$: stateOptions = $preferredSeedsStore?.seeds;
|
||||
|
||||
let expanded = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.popover {
|
||||
width: 16rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.divider {
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
margin: 0.5rem 0.25rem;
|
||||
background-color: var(--color-border-default);
|
||||
}
|
||||
|
||||
.add-seed-node-instructions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
color: var(--color-foreground-dim);
|
||||
}
|
||||
</style>
|
||||
|
||||
<Popover
|
||||
bind:expanded
|
||||
popoverPositionTop="2.5rem"
|
||||
popoverPositionRight="0"
|
||||
popoverPadding="0.25rem"
|
||||
popoverBorderRadius="var(--border-radius-small)">
|
||||
<Button
|
||||
variant="outline"
|
||||
slot="toggle"
|
||||
let:toggle
|
||||
on:click={toggle}
|
||||
title="Change peer"
|
||||
{disabled}>
|
||||
{preferredSeed.hostname}
|
||||
<IconSmall name={expanded ? "chevron-up" : "chevron-down"} />
|
||||
</Button>
|
||||
|
||||
<svelte:fragment slot="popover">
|
||||
<div class="popover">
|
||||
{#if stateOptions}
|
||||
<DropdownList items={stateOptions}>
|
||||
<DropdownListItem
|
||||
let:item
|
||||
on:click={() => {
|
||||
selectPreferredSeed(item);
|
||||
window.location.reload();
|
||||
}}
|
||||
slot="item"
|
||||
selected={item.hostname === preferredSeed.hostname}>
|
||||
<div class="label">
|
||||
{item.hostname}
|
||||
</div>
|
||||
</DropdownListItem>
|
||||
</DropdownList>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="divider" />
|
||||
<div class="add-seed-node-instructions txt-small">
|
||||
<div class="" style:font-weight="bold">Add a different seed node</div>
|
||||
<div class="">Update your preferred seeds in your radicle config.</div>
|
||||
<Command fullWidth command="rad self --config" />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Popover>
|
||||
+59
-35
@@ -1,17 +1,13 @@
|
||||
import type { LoadErrorRoute } from "@app/lib/router/definitions";
|
||||
import type { ProjectBaseUrl } from "@app/lib/projects";
|
||||
import type { WeeklyActivity } from "@app/lib/commit";
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
import type { ProjectWithListingData } from "@app/lib/projects";
|
||||
|
||||
import { get } from "svelte/store";
|
||||
|
||||
import type { LoadErrorRoute } from "@app/lib/router/definitions";
|
||||
import { getProjectsListingData } from "@app/lib/projects";
|
||||
import * as seeds from "@app/lib/seeds";
|
||||
import { api, httpdStore } from "@app/lib/httpd";
|
||||
import { config } from "@app/lib/config";
|
||||
import { getProjectsFromNodes } from "@app/lib/projects";
|
||||
import { loadProjectActivity } from "@app/lib/commit";
|
||||
|
||||
export interface ProjectBaseUrlActivity extends ProjectBaseUrl {
|
||||
activity: WeeklyActivity[];
|
||||
}
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
|
||||
export interface HomeRoute {
|
||||
resource: "home";
|
||||
@@ -19,35 +15,63 @@ export interface HomeRoute {
|
||||
|
||||
export interface HomeLoadedRoute {
|
||||
resource: "home";
|
||||
params: { projects: ProjectBaseUrlActivity[] };
|
||||
params: {
|
||||
nodeId: string | undefined;
|
||||
localProjects: ProjectWithListingData[] | "error";
|
||||
preferredSeedProjects: ProjectWithListingData[] | "error";
|
||||
preferredSeed: BaseUrl;
|
||||
};
|
||||
}
|
||||
|
||||
const fetchProjects = async (baseUrl: BaseUrl, show: "all" | "pinned") => {
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
return (await api.project.getAll({ perPage: 30, show })).map(project => ({
|
||||
project,
|
||||
baseUrl,
|
||||
}));
|
||||
};
|
||||
|
||||
function handleProjectLoadError(error: unknown): "error" {
|
||||
console.error(error);
|
||||
return "error";
|
||||
}
|
||||
|
||||
export async function loadHomeRoute(): Promise<
|
||||
HomeLoadedRoute | LoadErrorRoute
|
||||
> {
|
||||
let projects: ProjectBaseUrl[] = [];
|
||||
if (get(httpdStore).state !== "stopped") {
|
||||
projects = (await api.project.getAll({ perPage: 30, show: "all" })).map(
|
||||
project => ({
|
||||
project,
|
||||
baseUrl: api.baseUrl,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
projects = await getProjectsFromNodes(config.projects.pinned);
|
||||
}
|
||||
const results = await Promise.all(
|
||||
projects.map(async projectNode => {
|
||||
const activity = await loadProjectActivity(
|
||||
projectNode.project.id,
|
||||
projectNode.baseUrl,
|
||||
);
|
||||
return {
|
||||
...projectNode,
|
||||
activity,
|
||||
};
|
||||
}),
|
||||
);
|
||||
seeds.initialize();
|
||||
const preferredSeeds = await seeds.waitForLoad();
|
||||
|
||||
return { resource: "home", params: { projects: results } };
|
||||
const connectedToLocalNode = get(httpdStore).state !== "stopped";
|
||||
|
||||
const [localProjects, seedProjects] = await Promise.all([
|
||||
connectedToLocalNode
|
||||
? fetchProjects(api.baseUrl, "all").catch(handleProjectLoadError)
|
||||
: undefined,
|
||||
fetchProjects(preferredSeeds.selected, "pinned").catch(
|
||||
handleProjectLoadError,
|
||||
),
|
||||
]);
|
||||
|
||||
const projectsWithListingData = await Promise.all([
|
||||
localProjects !== "error"
|
||||
? await getProjectsListingData(localProjects ?? [])
|
||||
: ("error" as const),
|
||||
seedProjects !== "error"
|
||||
? await getProjectsListingData(seedProjects)
|
||||
: ("error" as const),
|
||||
]);
|
||||
|
||||
const nodeId = connectedToLocalNode ? (await api.getNode()).id : undefined;
|
||||
|
||||
return {
|
||||
resource: "home",
|
||||
params: {
|
||||
localProjects: projectsWithListingData[0],
|
||||
preferredSeedProjects: projectsWithListingData[1],
|
||||
preferredSeed: preferredSeeds.selected,
|
||||
nodeId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
+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 {
|
||||
|
||||
@@ -57,7 +57,10 @@
|
||||
alias={selectedPeer.alias}
|
||||
stylePopoverPositionLeft="-0.75rem" />
|
||||
{#if selectedPeer.delegate}
|
||||
<Badge size="tiny" variant="secondary">delegate</Badge>
|
||||
<Badge size="tiny" variant="primary">
|
||||
<IconSmall name="badge" />
|
||||
Delegate
|
||||
</Badge>
|
||||
{/if}
|
||||
{:else}
|
||||
Remotes
|
||||
@@ -74,13 +77,16 @@
|
||||
<DropdownListItem
|
||||
selected={item.selected}
|
||||
title={createTitle(item.remote)}>
|
||||
<Avatar nodeId={item.remote.id} />
|
||||
<div style:height="1rem"><Avatar nodeId={item.remote.id} /></div>
|
||||
<span style:font-family="var(--font-family-monospace)">
|
||||
{item.remote.alias || formatNodeId(item.remote.id)}
|
||||
</span>
|
||||
{#if item.remote.delegate}
|
||||
<div style:color="var(--color-fill-secondary)">
|
||||
<Badge size="tiny" variant="secondary">delegate</Badge>
|
||||
<Badge size="tiny" variant="primary">
|
||||
<IconSmall name="badge" />
|
||||
Delegate
|
||||
</Badge>
|
||||
</div>
|
||||
{/if}
|
||||
</DropdownListItem>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import type { BaseUrl, Project } from "@httpd-client";
|
||||
|
||||
import * as modal from "@app/lib/modal";
|
||||
import capitalize from "lodash/capitalize";
|
||||
import { httpdStore, api } from "@app/lib/httpd";
|
||||
import { twemoji } from "@app/lib/utils";
|
||||
|
||||
@@ -12,6 +11,7 @@
|
||||
import ErrorModal from "@app/modals/ErrorModal.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import SeedButton from "../Header/SeedButton.svelte";
|
||||
import Share from "@app/views/projects/Share.svelte";
|
||||
|
||||
@@ -114,8 +114,9 @@
|
||||
</Link>
|
||||
</span>
|
||||
{#if project.visibility && project.visibility.type === "private"}
|
||||
<Badge variant="yellowOutline" size="tiny">
|
||||
{capitalize(project.visibility.type)}
|
||||
<Badge variant="yellow" size="tiny">
|
||||
<IconSmall name="lock" />
|
||||
Private
|
||||
</Badge>
|
||||
{/if}
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user