From dbfa9862ddeb0e36b72a71a8dabce611662441a2 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Tue, 23 Aug 2022 23:36:32 +0200 Subject: [PATCH] Only have projects on home page Signed-off-by: Alexis Sellier --- cypress/e2e/home.spec.ts | 16 ++---- src/base/home/Index.svelte | 71 +++++++++++++------------ src/base/projects/Widget.svelte | 93 ++++++++++++++++++++------------- src/config.json | 44 ++++++++++++++++ src/config.ts | 2 + src/project.ts | 16 ++++++ 6 files changed, 164 insertions(+), 78 deletions(-) diff --git a/cypress/e2e/home.spec.ts b/cypress/e2e/home.spec.ts index eecdbeb1c..3822d4ac2 100644 --- a/cypress/e2e/home.spec.ts +++ b/cypress/e2e/home.spec.ts @@ -2,28 +2,22 @@ import { MockExtensionProvider } from "../support/e2e"; describe("Landing page", () => { - it("Loads user, orgs and seeds", () => { + it("Loads projects", () => { cy.intercept("https://willow.radicle.garden:8777/", { fixture: "projectHome.json" }); cy.intercept("https://willow.radicle.garden:8777/v1/peer", { fixture: "projectPeer.json" }); cy.intercept("https://pine.radicle.garden:8777/", { fixture: "projectHome.json" }); cy.intercept("https://pine.radicle.garden:8777/v1/peer", { fixture: "projectPeer.json" }); cy.intercept("https://maple.radicle.garden:8777/", { fixture: "projectHome.json" }); cy.intercept("https://maple.radicle.garden:8777/v1/peer", { fixture: "projectPeer.json" }); - cy.intercept("https://gateway.thegraph.com/api/1758a78ae257ad4906f9c638e4a68c19/subgraphs/id/0x2f0963e77ca6ac0c2dad1bf4147b6b40e0dd8728-0", { - "data": { "safe": null } - }); - cy.intercept("https://maple.radicle.garden:8777/v1/projects", { fixture: "projectList.json" }); - cy.intercept("https://pine.radicle.garden:8777/v1/projects", { fixture: "projectList.json" }); - cy.intercept("https://willow.radicle.garden:8777/v1/projects", { fixture: "projectList.json" }); + cy.intercept("https://maple.radicle.garden:8777/v1/projects/*", { fixture: "projectInfo.json" }); + cy.intercept({ pathname: "/v1/projects/*" }, { fixture: "projectInfo.json" }); cy.visit("/", { onBeforeLoad(win) { win.ethereum = new MockExtensionProvider("homestead", "0x3256a804085C24f3451cAb2C98a37e16DEEc5721"); }, }); - cy.get("div.card-label") + cy.get(".project .name") .first() - .should("have.text", "willow.radicle.garden") - .next() - .should("have.text", "1 project(s)"); + .should("have.text", "bright-forest-protocol"); }); }); diff --git a/src/base/home/Index.svelte b/src/base/home/Index.svelte index db7025b3a..15f17e2f1 100644 --- a/src/base/home/Index.svelte +++ b/src/base/home/Index.svelte @@ -1,12 +1,13 @@ -
+
{project.name} @@ -136,7 +152,11 @@ {#if project.head} - {project.head} + {#if compact} + {formatCommit(project.head)} + {:else} + {project.head} + {/if} {:else} ✗ No head {/if} @@ -144,36 +164,39 @@
-
-
- {project.urn} -
-
- - - - - - - - {#if anchor && project.head} - - {/if} - - - -
- {#await loadCommits() then points} -
- + + {#if !compact} +
+
+ {project.urn}
- {/await} -
+
+ + + + + + + + {#if anchor && project.head} + + {/if} + + + +
+ {#await loadCommits() then points} +
+ +
+ {/await} +
+ {/if}
diff --git a/src/config.json b/src/config.json index a1c769f13..c8a605147 100644 --- a/src/config.json +++ b/src/config.json @@ -99,6 +99,50 @@ "git": { "port": 443 } } }, + "projects": { + "pinned": [ + { + "name": "radicle-cli", + "urn": "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao", + "seed": "seed.alt-clients.radicle.xyz" + }, + { + "name": "radicle-interface", + "urn": "rad:git:hnrkjajuucc6zp5eknt3s9xykqsrus44cjimy", + "seed": "seed.alt-clients.radicle.xyz" + }, + { + "name": "radicle-client-services", + "urn": "rad:git:hnrkk9c4zt9thuxhwi1ukxqcrs5tmhbtcsony", + "seed": "seed.alt-clients.radicle.xyz" + }, + { + "name": "solmate", + "urn": "rad:git:hnrkbgczcfh9ycjtdfynmqyg478bqrso1hnty", + "seed": "willow.radicle.garden" + }, + { + "name": "openzeppelin-contracts", + "urn": "rad:git:hnrkbx9xzjg8tf9hj9uh5qdxwuyjddsxyaw6o", + "seed": "willow.radicle.garden" + }, + { + "name": "haskell-language-server", + "urn": "rad:git:hnrkf1jaje1e93rua64zgphg7zb14qo9zexgy", + "seed": "pine.radicle.garden" + }, + { + "name": "rx", + "urn": "rad:git:hnrk8aoks6w3tdbcwt9dqnor9aqy8tjha3k5o", + "seed": "maple.radicle.garden" + }, + { + "name": "py_ecc", + "urn": "rad:git:hnrkba67x8poqt4d9qgoc4au39ro9dx7pdhfo", + "seed": "maple.radicle.garden" + } + ] + }, "ipfs": { "gateway": "https://ipfs.io/ipfs/" }, "abi": { "registrar": [ diff --git a/src/config.ts b/src/config.ts index 90f87decc..9c10a7be9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,6 +35,7 @@ export class Config { reverseRegistrar: { address: string }; orgs: { subgraph: string; contractHash: string; pinned: string[] }; users: { pinned: string[] }; + projects: { pinned: { urn: string; name: string; seed: string }[] }; seeds: { pinned: Record }; gasLimits: { createOrg: number }; provider: ethers.providers.JsonRpcProvider; @@ -120,6 +121,7 @@ export class Config { this.provider = provider; this.signer = null; this.gasLimits = gasLimits; + this.projects = config.projects; this.abi = config.abi; this.ceramic = { client: ceramic, diff --git a/src/project.ts b/src/project.ts index 6195bd96b..675c7ca20 100644 --- a/src/project.ts +++ b/src/project.ts @@ -432,4 +432,20 @@ export class Project implements ProjectInfo { return new Project(urn, info, seed, peers, remote.heads, profile, anchors); } + + static async getMulti(projs: { urn: Urn; seed: string }[]): Promise<{ info: ProjectInfo; seed: Host }[]> { + const promises = []; + + for (const proj of projs) { + const seed = { host: proj.seed, port: null }; + promises.push(Project.getInfo(proj.urn, seed).then(info => { + return { info, seed }; + })); + } + const results = await Promise.allSettled(promises); + const isFulfilled = (input: PromiseSettledResult): + input is PromiseFulfilledResult => input.status === 'fulfilled'; + + return results.filter(isFulfilled).map(r => r.value); + } }