From a43ac33ddc95a49faa1b8090b3d165bbb38262d6 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 2 Feb 2022 23:12:38 +0100 Subject: [PATCH] Refactor org and user routes Signed-off-by: Sebastian Martinez --- src/Address.svelte | 15 +- src/App.svelte | 8 +- src/Cards.svelte | 8 +- src/NotFound.svelte | 21 ++ src/Profile.svelte | 391 +++++++++++++++++++++++++++++ src/Redirect.svelte | 10 + src/base/orgs/Create.svelte | 2 +- src/base/orgs/Routes.svelte | 7 +- src/base/orgs/View.svelte | 369 --------------------------- src/base/orgs/View/Projects.svelte | 112 ++++++--- src/base/projects/Browser.svelte | 8 +- src/base/projects/Commit.svelte | 8 +- src/base/projects/History.svelte | 8 +- src/base/projects/Routes.svelte | 21 +- src/base/projects/View.svelte | 52 +--- src/base/projects/Widget.svelte | 6 +- src/base/resolver/Query.svelte | 12 +- src/base/seeds/View.svelte | 17 +- src/base/users/Routes.svelte | 10 +- src/base/users/View.svelte | 260 ------------------- src/error.ts | 10 + src/profile.ts | 44 +++- src/project.ts | 18 +- vite.config.ts | 1 - 24 files changed, 619 insertions(+), 799 deletions(-) create mode 100644 src/NotFound.svelte create mode 100644 src/Profile.svelte create mode 100644 src/Redirect.svelte delete mode 100644 src/base/orgs/View.svelte delete mode 100644 src/base/users/View.svelte diff --git a/src/Address.svelte b/src/Address.svelte index 09285dcc1..573719d0e 100644 --- a/src/Address.svelte +++ b/src/Address.svelte @@ -21,9 +21,14 @@ const nameOrAddress = profile?.name || address; onMount(async () => { - identifyAddress(address, config).then((t: AddressType) => addressType = t); - if (resolve && !profile) { - Profile.get(address, ProfileType.Minimal, config).then(p => profile = p); + if (!profile) { + identifyAddress(address, config).then((t: AddressType) => addressType = t); + if (resolve) { + Profile.get(address, ProfileType.Minimal, config).then(p => profile = p); + } + } else { + // If there is a profile we can use the profile.type to avoid identifying it again. + addressType = profile.type; } }); $: addressLabel = profile?.name ? compact ? parseEnsLabel(profile.name, config) : profile.name : checksumAddress; @@ -54,7 +59,7 @@ {/if} {#if addressType === AddressType.Org} - {addressLabel} + {addressLabel} org {:else if addressType === AddressType.Safe} {addressLabel} @@ -63,7 +68,7 @@ {addressLabel} contract {:else if addressType === AddressType.EOA} - {addressLabel} + {addressLabel} {:else} {addressLabel} {/if} diff --git a/src/App.svelte b/src/App.svelte index e20dc8673..02ba3deb9 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -11,6 +11,7 @@ import Seeds from '@app/base/seeds/Routes.svelte'; import Faucet from '@app/base/faucet/Routes.svelte'; import Projects from '@app/base/projects/Routes.svelte'; + import Profile from '@app/Profile.svelte'; import Resolver from '@app/base/resolver/Routes.svelte'; import Header from '@app/Header.svelte'; import Loading from '@app/Loading.svelte'; @@ -89,9 +90,12 @@ - - + + + + + {:catch err} diff --git a/src/Cards.svelte b/src/Cards.svelte index 4325776d4..f3cebb51c 100644 --- a/src/Cards.svelte +++ b/src/Cards.svelte @@ -38,18 +38,18 @@
{#each orgs as org} {#await Profile.get(org.name ?? org.address, ProfileType.Minimal, config)} - + {:then profile} {#if orgMembers[profile.address]?.length} - + {:else} - + {/if} {/await} {/each} {#each profiles as profile} - + {/each} {#if !orgs.length && !profiles.length} diff --git a/src/NotFound.svelte b/src/NotFound.svelte new file mode 100644 index 000000000..92ac62780 --- /dev/null +++ b/src/NotFound.svelte @@ -0,0 +1,21 @@ + + + + 🏜️ + +

{title}

+

{subtitle}

+
+ + + +
diff --git a/src/Profile.svelte b/src/Profile.svelte new file mode 100644 index 000000000..32aada937 --- /dev/null +++ b/src/Profile.svelte @@ -0,0 +1,391 @@ + + + + + + {addressOrName} + + +{#await Profile.get(addressOrName, ProfileType.Full, config)} +
+ +
+{:then profile} +
+
+
+ +
+
+ + + {profile.name ? utils.formatName(profile.name, config) : profile.address} + + + {profile.name ? utils.formatName(profile.name, config) : utils.formatAddress(profile.address)} + + {#if profile.name && profile.org} + org + {/if} + + +
+
+ +
+ +
Address
+
+
+
+ + {#if profile.org} +
Owner
+
+
+
+ {#await account && profile.org.isMember(account, config) then isMember} + {#if isOwner(profile.org) || isMember} + + {/if} + {/await} +
+ + {#await getOrgTreasury(profile.org) then tokens} + {#if tokens && tokens.length > 0} +
Treasury
+
+ {#each tokens as token} + {` ${utils.formatBalance(token.balance, token.decimals)} ${token.symbol} `} + {/each} +
+
+ {/if} + {/await} + {:else} + + {#if profile.anchorsAccount} +
Anchors
+
+
+
+ {/if} + {/if} + + {#if profile.seed && profile.seed.valid} +
Seed
+ + {/if} + +
Profile
+ {#if profile.org} + {#if utils.isAddressEqual(profile.address, profile.org.address)} +
+ {#if profile.name} + {profile.name} + {:else} + Not set + {/if} +
+
+ {#await isOrgAuthorized(profile.org)} + + {:then authorized} + {#if authorized} + + {/if} + {/await} +
+ {/if} + + {#await profile.org.getSafe(config) then safe} + {#if safe} +
Quorum
+
+ {safe.threshold} of {safe.owners.length} +
+
+ {/if} + {/await} + {:else} + +
+ {#if profile.name} + {profile.name} + {:else} + Not set + {/if} +
+
+ {#if isUserAuthorized(profile.address)} + + {/if} +
+ {/if} +
+ + {#if profile.org} + {#await profile.org.getMembers(config)} + + {:then members} + {#if members.length > 0} +
+ + {#await Profile.getMulti(members, config)} + + {:then members} + {#each members as profile} +
+
+ + + +
+
+
+
+
+ {/each} + {/await} +
+ {/if} + {:catch err} + + Error: failed to load org members: {err.message}. + + {/await} + {:else} + {#await Org.getOrgsByMember(profile.address, config)} + + {:then orgs} + {#if orgs.length > 0} +
+ {#each orgs as org} +
+ + {#await Profile.get(org.address, ProfileType.Minimal, config)} + + {:then profile} +
+ + + +
+
+
+
+ {/await} +
+ {/each} +
+ {/if} + {:catch err} + + Error: failed to load orgs: {err.message}. + + {/await} + {/if} + +
+ + setNameForm = null} /> + transferOwnerForm = null} /> +{:catch err} + {#if err instanceof NotFoundError} + + {:else} + + {/if} +{/await} diff --git a/src/Redirect.svelte b/src/Redirect.svelte new file mode 100644 index 000000000..f946e5bd2 --- /dev/null +++ b/src/Redirect.svelte @@ -0,0 +1,10 @@ + diff --git a/src/base/orgs/Create.svelte b/src/base/orgs/Create.svelte index 282eb1b80..4bb73d91d 100644 --- a/src/base/orgs/Create.svelte +++ b/src/base/orgs/Create.svelte @@ -135,7 +135,7 @@ - diff --git a/src/base/orgs/Routes.svelte b/src/base/orgs/Routes.svelte index c85ab6d2c..b06d718c2 100644 --- a/src/base/orgs/Routes.svelte +++ b/src/base/orgs/Routes.svelte @@ -1,9 +1,8 @@ @@ -12,6 +11,6 @@ - - + + diff --git a/src/base/orgs/View.svelte b/src/base/orgs/View.svelte deleted file mode 100644 index 222c83444..000000000 --- a/src/base/orgs/View.svelte +++ /dev/null @@ -1,369 +0,0 @@ - - - - - - {utils.formatOrg(addressOrName, config)} - - -{#await Org.get(addressOrName, config)} -
- -
-{:then org} - {#if org} -
- {#await Profile.get(org.name ?? org.address, ProfileType.Full, config)} -
- -
- {:then profile} -
-
- -
-
- - - {profile.name ? formatName(profile.name, config) : profile.address} - - - {profile.name ? formatName(profile.name, config) : formatAddress(profile.address)} - - {#if profile.name && profile.address === org.owner} - org - {/if} - - -
-
- -
- -
Address
-
-
-
- -
Owner
-
-
-
- {#if isOwner(org) || (account && org.isMember(account, config))} - - {/if} -
- {#await getOrgTreasury(org) then tokens} - {#if tokens && tokens.length > 0} -
Treasury
-
- {#each tokens as token} - {` ${utils.formatBalance(token.balance, token.decimals)} ${token.symbol} `} - {/each} -
-
- {/if} - {/await} - - {#if profile.seed?.valid} -
Seed
- - {:else if !profile.seed?.valid} -
Seed
-
✗ Seed configuration is invalid
-
- {/if} - -
Profile
- - {#if utils.isAddressEqual(profile.address, org.address)} -
- {#if profile.name} - {profile.name} - {:else} - Not set - {/if} -
-
- {#await isAuthorized(org)} - - {:then authorized} - {#if authorized} - - {/if} - {/await} -
- {:else} -
- Using owner's profile. -
-
- {#await isAuthorized(org) then authorized} - {#if authorized} - - {/if} - {/await} -
- {/if} - - {#await org.getSafe(config) then safe} - {#if safe} -
Quorum
-
- {safe.threshold} of {safe.owners.length} -
-
- {/if} - {/await} -
- - {#await org.getMembers(config)} - - {:then members} - {#if members.length > 0} -
- {#await Profile.getMulti(members, config)} - - {:then members} - {#each members as profile} -
-
- - - -
-
-
-
-
- {/each} - {/await} -
- {/if} - {:catch err} - - Error: failed to load org members: {err.message}. - - {/await} - - - {:catch err} - - Error: {err.message}. - - {/await} -
- {:else} - - 🏜️ - -

{addressOrName}

-

Sorry, there is no Org at this address.

- {#if utils.isAddress(addressOrName)} -

- View in explorer - ↗ -

- {/if} -
- - - -
- {/if} - setNameForm = null} /> - transferOwnerForm = null} /> -{:catch err} - -{/await} diff --git a/src/base/orgs/View/Projects.svelte b/src/base/orgs/View/Projects.svelte index 57d06d6b0..993c8bc97 100644 --- a/src/base/orgs/View/Projects.svelte +++ b/src/base/orgs/View/Projects.svelte @@ -1,14 +1,15 @@ @@ -40,36 +43,65 @@
- {#await getProjects()} - - {:then projects} - {#each projects as project} -
- {#if "safeTxHash" in project} - - - commit {formatCommit(project.anchor.stateHash)} - commit {project.anchor.stateHash} - - - {#if org.safe && account} - updateRecords()} {account} {config} /> - {/if} - - - {:else} - - - commit {formatCommit(project.anchor.stateHash)} - commit {project.anchor.stateHash} - - - {/if} -
- {/each} - {:catch err} - - Error: failed to load projects: {err.message}. - - {/await} + {#if profile.org} + {#await getProjects()} + + {:then projects} + {#each projects as project} +
+ {#if "safeTxHash" in project} + + + commit {formatCommit(project.anchor.stateHash)} + commit {project.anchor.stateHash} + + + {#if profile.org.safe && account} + updateRecords()} {account} {config} /> + {/if} + + + {:else} + + + commit {formatCommit(project.anchor.stateHash)} + commit {project.anchor.stateHash} + + + {/if} +
+ {/each} + {:catch err} + + Error: failed to load anchored projects: {err.message}. + + {/await} + {:else} +
+ {#if profile.anchorsAccount} + {#await Org.get(profile.anchorsAccount, config)} + + {:then org} + {#if org} + {#await org.getProjects(config) then projects} + {#each projects as project} +
+ + + commit {formatCommit(project.anchor.stateHash)} + commit {project.anchor.stateHash} + + +
+ {/each} + {:catch err} + + Error: failed to load projects: {err.message}. + + {/await} + {/if} + {/await} + {/if} +
+ {/if}
diff --git a/src/base/projects/Browser.svelte b/src/base/projects/Browser.svelte index 62f06361e..8f2364a6c 100644 --- a/src/base/projects/Browser.svelte +++ b/src/base/projects/Browser.svelte @@ -23,7 +23,7 @@ export let revision: string; export let path: string; - let { urn, org, user, seed, peer, project, config, branches } = source; + let { urn, addressOrName, seed, peer, project, config, branches } = source; // This is reactive to respond to path changes that don't originate from this // component, eg. when using the browser's "back" button. @@ -70,10 +70,8 @@ // Replaces path with current path if none passed. if (path === undefined) path = state.path; - if (org) { - navigate(proj.path({ peer, urn, org, revision, path })); - } else if (user) { - navigate(proj.path({ peer, urn, user, revision, path })); + if (addressOrName) { + navigate(proj.path({ peer, urn, addressOrName, revision, path })); } else if (seed) { navigate(proj.path({ peer, urn, seed, revision, path })); } else { diff --git a/src/base/projects/Commit.svelte b/src/base/projects/Commit.svelte index 50cad34a6..808866c26 100644 --- a/src/base/projects/Commit.svelte +++ b/src/base/projects/Commit.svelte @@ -10,16 +10,14 @@ export let locator: string; export let source: any; - const { org, user, peer, seed } = source; + const { addressOrName, peer, seed } = source; const navigateCommit = (path: string, content?: proj.ProjectContent) => { // Replaces path with current path if none passed. if (path === undefined) path = "/"; - if (org) { - navigate(proj.path({ content, peer, urn, org, revision, path })); - } else if (user) { - navigate(proj.path({ content, peer, urn, user, revision, path })); + if (addressOrName) { + navigate(proj.path({ content, peer, urn, addressOrName, revision, path })); } else if (seed) { navigate(proj.path({ content, peer, urn, seed, revision, path })); } else { diff --git a/src/base/projects/History.svelte b/src/base/projects/History.svelte index 8a0a9477f..9a211321f 100644 --- a/src/base/projects/History.svelte +++ b/src/base/projects/History.svelte @@ -12,7 +12,7 @@ export let revision: string; export let path: string; - let { urn, user, seed, org, peer, config, project, branches } = source; + let { urn, seed, addressOrName, peer, config, project, branches } = source; // Bind content to commit history to trigger updates in parent components. $: [revision_,] = splitPrefixFromPath(locator, branches, project.head); @@ -23,10 +23,8 @@ // Replaces path with current path if none passed. if (path === undefined) path = "/"; - if (org) { - navigate(proj.path({ content, peer, urn, org, revision, path })); - } else if (user) { - navigate(proj.path({ content, peer, urn, user, revision, path })); + if (addressOrName) { + navigate(proj.path({ content, peer, urn, addressOrName, revision, path })); } else if (seed) { navigate(proj.path({ content, peer, urn, seed, revision, path })); } else { diff --git a/src/base/projects/Routes.svelte b/src/base/projects/Routes.svelte index c46c2b9be..aa4b8bdb8 100644 --- a/src/base/projects/Routes.svelte +++ b/src/base/projects/Routes.svelte @@ -2,6 +2,7 @@ import { Route } from "svelte-routing"; import View from '@app/base/projects/View.svelte'; import type { Config } from '@app/config'; + import Redirect from "@app/Redirect.svelte"; export let config: Config; @@ -9,22 +10,24 @@ - + - + - - - - + + + - + + + + - - + + diff --git a/src/base/projects/View.svelte b/src/base/projects/View.svelte index c0bc86e63..e365eb266 100644 --- a/src/base/projects/View.svelte +++ b/src/base/projects/View.svelte @@ -3,7 +3,6 @@ import type { Config } from '@app/config'; import * as proj from '@app/project'; import Loading from '@app/Loading.svelte'; - import Modal from '@app/Modal.svelte'; import Avatar from '@app/Avatar.svelte'; import { Profile, ProfileType } from '@app/profile'; import type { Info } from '@app/project'; @@ -14,27 +13,25 @@ import Header from '@app/base/projects/Header.svelte'; import ProjectContentRoutes from '@app/base/projects/ProjectContentRoutes.svelte'; + import NotFound from '@app/NotFound.svelte'; export let id: string; // Project name or URN. - export let org = ""; - export let user = ""; + export let addressOrName = ""; export let seed = ""; export let peer = ""; export let config: Config; - let parentName = formatOrg(org || user, config); + let parentName = formatOrg(addressOrName, config); let pageTitle = parentName ? `${parentName}/${id}` : id; let projectInfo: Info | null = null; let revision: string; let content: proj.ProjectContent; let path: string; - let getProject = new Promise<{ profile?: Profile; seed?: Seed } | null>(resolve => { - if (org) { - Profile.get(org, ProfileType.Project, config).then(p => resolve({ profile: p })); - } else if (user) { - Profile.get(user, ProfileType.Project, config).then(p => resolve({ profile: p })); + let getProject = new Promise<{ profile?: Profile | null; seed?: Seed } | null>((resolve, reject) => { + if (addressOrName) { + Profile.get(addressOrName, ProfileType.Project, config).then(p => resolve({ profile: p })).catch(err => reject(err.message)); } else if (seed) { - Seed.get(config.withSeed({ host: seed })).then(s => resolve({ seed: s })); + Seed.get(config.withSeed({ host: seed })).then(s => resolve({ seed: s })).catch(err => reject(err.message)); } else { resolve(null); } @@ -44,16 +41,12 @@ const cfg = seedInstance && seedInstance.valid ? config.withSeed(seedInstance) : config; const info = await proj.getInfo(id, cfg); const urn = isRadicleId(id) ? id : info.meta.urn; - const anchors = await getAllAnchors(config, urn, profile?.anchorsAccount ?? org); - + const anchors = await getAllAnchors(config, urn, profile?.anchorsAccount ?? addressOrName); let branches = Array([info.meta.defaultBranch, info.head]) as [string, string][]; let peers: proj.Peer[] = []; projectInfo = info; - // Replace project name with URN, in URL bar. - navigate(proj.path({ peer, urn, org, revision, path, seed }), { replace: true }); - // Checks for delegates returned from seed node, as feature check of the seed node if (info.meta.delegates) { // Check for selected peer to override available branches. @@ -63,15 +56,9 @@ } peers = await proj.getPeers(urn, cfg); } - return { urn, org, user, seed, peer, project: info, branches, peers, config: cfg, profile, anchors }; + return { urn, addressOrName, seed, peer, project: info, branches, peers, config: cfg, profile, anchors }; }); - const parentUrl = (profile: Profile) => { - return org - ? `/orgs/${profile.nameOrAddress}` - : `/users/${profile.nameOrAddress}`; - }; - $: if (projectInfo) { const baseName = parentName ? `${parentName}/${projectInfo.meta.name}` @@ -85,7 +72,7 @@ } function updateRouteParams({ detail: newParams }: { detail: { urn: string; path: string; revision: string; peer: string; content: proj.ProjectContent } }) { - let newLocation = proj.path({ user, org, seed, urn: newParams.urn, content: newParams.content, peer: newParams.peer, revision: newParams.revision, path: newParams.path }); + let newLocation = proj.path({ addressOrName, seed, urn: newParams.urn, content: newParams.content, peer: newParams.peer, revision: newParams.revision, path: newParams.path }); if (newLocation !== window.location.pathname) { navigate(newLocation); } @@ -94,8 +81,6 @@ if (path !== newParams.path) path = newParams.path; if (peer !== newParams.peer) peer = newParams.peer; } - - const back = () => window.history.back(); - - - {addressOrName} - - -{#await Profile.get(addressOrName, ProfileType.Full, config)} - -{:then profile} -
-
-
- -
-
- -
- - -
-
-
- -
Address
-
-
-
- - {#if profile.anchorsAccount} -
Anchors
-
-
-
- {/if} - - {#if profile.seed && profile.seed.valid} - {#if profile.seed.id && profile.seed.host} -
Seed
- - {/if} - {/if} - -
Profile
-
- {#if profile.name} - {profile.name} - {:else} - Not set - {/if} -
-
- {#if isAuthorized(profile.address)} - - {/if} -
-
- {#await Org.getOrgsByMember(profile.address, config)} - - {:then orgs} - {#if orgs.length > 0} -
- {#each orgs as org} -
- {#await Profile.get(org.address, ProfileType.Minimal, config)} - - {:then profile} -
- - - -
-
-
-
- {/await} -
- {/each} -
- {/if} - {:catch err} - - Error: failed to load orgs: {err.message}. - - {/await} -
- {#if profile.anchorsAccount} - {#await Org.get(profile.anchorsAccount, config)} - - {:then org} - {#if org} - {#await org.getProjects(config) then projects} - {#each projects as project} -
- - - commit {formatCommit(project.anchor.stateHash)} - commit {project.anchor.stateHash} - - -
- {/each} - {:catch err} - - Error: failed to load projects: {err.message}. - - {/await} - {/if} - {/await} - {/if} -
-
- setNameForm = null} /> -{:catch err} - -{/await} diff --git a/src/error.ts b/src/error.ts index f93d463f1..0a93a2d05 100644 --- a/src/error.ts +++ b/src/error.ts @@ -24,6 +24,16 @@ export class Unreachable extends Error { } } +export class NotFoundError extends Error { + constructor(message?: string) { + if (message) { + super(`not found: ${message}`); + } else { + super(`not found`); + } + } +} + class AssertionError extends Error { constructor(message?: string) { if (message) { diff --git a/src/profile.ts b/src/profile.ts index 311a25126..ae02f9da5 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -1,15 +1,19 @@ import type { EnsProfile } from "@app/base/registrations/registrar"; import type { BasicProfile } from '@datamodels/identity-profile-basic'; import { - isAddress, formatCAIP10Address, formatIpfsFile, resolveEnsProfile, resolveIdxProfile, parseUsername, parseEnsLabel + isAddress, formatCAIP10Address, formatIpfsFile, resolveEnsProfile, resolveIdxProfile, parseUsername, parseEnsLabel, AddressType, identifyAddress } from "@app/utils"; import type { Config } from "@app/config"; import type { Seed, InvalidSeed } from "@app/base/seeds/Seed"; +import { Org } from "@app/base/orgs/Org"; +import { NotFoundError } from "@app/error"; export interface IProfile { address: string; + type: AddressType; ens?: EnsProfile; idx?: BasicProfile; + org?: Org; } export enum ProfileType { @@ -30,6 +34,16 @@ export class Profile { return this.profile.ens?.address ?? this.profile.address; } + // Get the address type + get type(): AddressType { + return this.profile.type; + } + + // Get the org instance + get org(): Org | undefined { + return this.profile.org; + } + // Get the ENS profile get ens(): EnsProfile | undefined { return this.profile.ens; @@ -121,13 +135,23 @@ export class Profile { profileType: ProfileType, config: Config ): Promise { + let type = AddressType.EOA; + let org: Org | null = null; const ens = await resolveEnsProfile(addressOrName, profileType, config); if (ens) { if (ens.address) { + type = await identifyAddress(ens.address, config); + + if (type === AddressType.Org) { + org = await Org.get(ens.address, config); + } + return { address: ens.address.toLowerCase(), - ens: { ...ens, address: ens.address.toLowerCase() } + type, + ens: { ...ens, address: ens.address.toLowerCase() }, + org: org ?? undefined }; } throw new Error(`No address set for ${addressOrName}`); @@ -135,20 +159,30 @@ export class Profile { } else if (isAddress(addressOrName)) { const address = addressOrName.toLowerCase(); + type = await identifyAddress(addressOrName, config); + if (type === AddressType.Org) { + org = await Org.get(addressOrName, config); + } + try { const idx = await resolveIdxProfile( formatCAIP10Address(address, "eip155", config.network.chainId), config ); - return { address, idx: idx ?? undefined }; + return { + address, + type, + idx: idx ?? undefined, + org: org ?? undefined + }; } catch (e: any) { // Look for the No DID found for error by the resolveIdxProfile fn and send it to console.debug if (e.message.match("No DID found for")) console.debug(e.message); else console.error(e); - return { address }; + return { address, type, org: org ?? undefined }; } } - throw new Error(`Name ${addressOrName} was not found`); + throw new NotFoundError(`Not able to resolve profile for ${addressOrName}`); } static async getMulti(addressesOrNames: string[], config: Config): Promise { diff --git a/src/project.ts b/src/project.ts index 340c33d34..9c92dc4c6 100644 --- a/src/project.ts +++ b/src/project.ts @@ -22,8 +22,7 @@ export interface Project { // Params to render correctly source code related views export interface Source { urn: string; - org: string; - user: string; + addressOrName: string; peer: string; config: Config; project: Info; @@ -31,7 +30,7 @@ export interface Source { anchors: string[]; seed: string; branches: [string, string][]; - profile?: Profile; + profile?: Profile | null; } export interface PendingProject extends Project { @@ -155,8 +154,7 @@ export async function getReadme( export function path( opts: { urn: string; - org?: string; - user?: string; + addressOrName?: string; seed?: string; peer?: string; content?: ProjectContent; @@ -164,17 +162,15 @@ export function path( path?: string; } ): string { - const { urn, org, user, seed, peer, content, revision, path } = opts; + const { urn, addressOrName, seed, peer, content, revision, path } = opts; const result = []; - if (org) { - result.push("orgs", org); - } else if (user) { - result.push("users", user); + if (addressOrName) { + result.push(addressOrName); } else if (seed) { result.push("seeds", seed); } - result.push("projects", urn); + result.push(urn); if (peer) { result.push("remotes", peer); diff --git a/vite.config.ts b/vite.config.ts index 30a7cb18a..97f39144d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,3 @@ -/// import path from 'path'; import { UserConfig } from 'vite'; import { svelte } from '@sveltejs/vite-plugin-svelte';