diff --git a/forge-web/app/explore/page.tsx b/forge-web/app/explore/page.tsx new file mode 100644 index 000000000..357abc397 --- /dev/null +++ b/forge-web/app/explore/page.tsx @@ -0,0 +1,344 @@ +'use client' + +/** + * `/explore` (`ux-dx-spec.md` §5.11): recent repos, recently released, and, signed in, my + * repos, the repos I maintain or write to, my issues, my PRs, my stars, and what is assigned + * to me or mentions me. Every section reads an index that answers it; where none exists the + * section says so rather than implying it saw everything. + */ + +import Link from 'next/link' +import type { ReactNode } from 'react' +import { CircleDot, Compass, GitBranch, GitPullRequest, Info, Package, Star, UserCheck } from 'lucide-react' +import { AppShell } from '@/components/app-shell' +import { RepoCard } from '@/components/repo-card' +import { Button } from '@/components/ui/button' +import { ErrorState, Spinner } from '@/components/ui/states' +import { NotDeployedState, isV2Deployed } from '@/components/ui/network-badge' +import { useAuth } from '@/contexts/auth-context' +import { useAsync, type AsyncState } from '@/hooks/use-async' +import { repoHref } from '@/hooks/use-query-param' +import { useSdk } from '@/hooks/use-sdk' +import { useUiStore } from '@/hooks/use-ui-store' +import { NETWORKS } from '@/lib/constants' +import { listRecentRepos, listReposByOwner, resolveDpnsName, timeAgo, type DiscoveredRepo } from '@/lib/view' +import { + latestReleases, + listMyTargets, + listStarredRepoIds, + readReposByIds, + repoLite, + scanAssignedAndMentions, + type RepoLite, + type TargetRow, +} from '@/lib/view/mine' + +/** The trending note, verbatim from the spec. */ +const TRENDING = "Trending needs an indexer. Forge doesn't run one; you can" +/** "My repos" and "maintain or write to" read at most this many each (listReposByOwner's page). */ +const MY_REPOS_MAX = 50 +/** The assignment / mention scan looks at this many repos (one feed read each, 3 at a time). */ +const SCAN_REPOS_MAX = 20 +const INDEXER_DOCS = 'https://github.com/PastaPastaPasta/dash-forge/blob/master/docs/roadmap.md' + +export default function ExplorePage(): JSX.Element { + const { sdk, ready, network, error: sdkError } = useSdk() + const { identity } = useAuth() + const openLogin = useUiStore((s) => s.openLogin) + const forge = NETWORKS[network].v2 + const on = ready && sdk !== null && forge !== null + + const recent = useAsync(() => listRecentRepos(sdk!, { network, limit: 24 }), [ready, network], { enabled: on }) + const recentV2 = recent.data?.v2 ?? [] + const releases = useAsync(() => latestReleases(sdk!, forge!, recentV2.map(repoLite)), [recentV2.map((r) => r.key).join(',')], { + enabled: on && recent.data !== null, + }) + + const me = identity ?? '' + const signedIn = on && identity !== null + const mine = useAsync(() => listReposByOwner(sdk!, me, { network, limit: MY_REPOS_MAX }), [me, network], { enabled: signedIn }) + const issues = useAsync(() => listMyTargets(sdk!, forge!, me, 'issue'), [me, 'issues'], { enabled: signedIn }) + const pulls = useAsync(() => listMyTargets(sdk!, forge!, me, 'pull'), [me, 'pulls'], { enabled: signedIn }) + const stars = useAsync( + async () => { + const page = await listStarredRepoIds(sdk!, forge!, me) + const repos = await readReposByIds(sdk!, forge!, page.rows) + return { repos: page.rows.map((id) => repos.get(id)).filter((r): r is RepoLite => r !== undefined), more: page.more } + }, + [me, 'stars'], + { enabled: signedIn }, + ) + // Assigned / mentioned: no index, so scan the repos I own or belong to (the inbox's set). + const ownedV2 = mine.data?.owned.filter((r) => r.kind === 'v2') ?? [] + const memberOf = [...ownedV2, ...(mine.data?.member ?? [])] + const watched = memberOf.slice(0, SCAN_REPOS_MAX) + const scan = useAsync( + async () => scanAssignedAndMentions(sdk!, forge!, me, await resolveDpnsName(sdk!, me, network), watched.map(repoLite)), + [me, watched.map((r) => r.key).join(',')], + { enabled: signedIn && mine.data !== null }, + ) + + if (!isV2Deployed()) { + return ( + + + + ) + } + + return ( + +
+
+
+

+ Explore +

+

Read straight from {NETWORKS[network].key}, proof-checked. No server ranks or filters this.

+
+

+ + + {TRENDING} ( + + docs + + ). + +

+
+ + {sdkError ? : null} + + {signedIn ? ( +
+
}> + {() => ( + <> + + + + )} + {() => ownedV2.length === 0} +
+
+ {(d) => ( + <> + + + + )} + {(d) => d.member.length === 0} +
+
+ {(d) => } + {(d) => d.rows.length === 0} +
+
+ {(d) => } + {(d) => d.rows.length === 0} +
+
+ {(d) => } + {(d) => d.repos.length === 0} +
+
(d.failed > 0 ? `${d.failed} of ${d.reposScanned} repos could not be read; results cover the rest.` : null)} + > + {(d) => ( +
+ {d.assigned.length > 0 ? : null} + {d.mentioned.length > 0 ? : null} +
+ )} + {(d) => d.assigned.length + d.mentioned.length === 0} +
+
+ ) : on ? ( +
+ Sign in to see your repos, issues, pull requests and stars. + +
+ ) : null} + +
}> + {(d) => } + {(d) => d.v2.length === 0} +
+ +
(d.failed > 0 ? `${d.failed} of ${d.total} repos could not be read; their releases are not shown.` : null)} + > + {(d) => ( +
    + {d.rows.map((r) => ( +
  • + + + {r.repo.name} {r.tagName} + + {r.name && r.name !== r.tagName ? {r.name} : null} + {timeAgo(r.createdAt)} +
  • + ))} +
+ )} + {(d) => d.rows.length === 0} +
+
+
+ ) +} + +function NewRepoLink(): JSX.Element { + return ( + + Create a repository + + ) +} + +/** A titled section over one async read: spinner, error with retry, honest empty, or data. */ +function Section({ + title, + icon: Icon, + state, + empty, + emptyAction, + note, + partial, + children: [render, isEmpty], +}: { + title: string + icon: typeof Compass + state: AsyncState + empty: string + emptyAction?: ReactNode + note?: string + /** A "could not read all of it" line for the data, or null when it is complete. */ + partial?: (d: T) => string | null + children: [(d: T) => ReactNode, (d: T) => boolean] +}): JSX.Element { + const id = `explore-${title.toLowerCase().replace(/[^a-z]+/g, '-')}` + return ( +
+
+

+ {title} +

+ {state.loading ? : null} +
+ {note ?

{note}

: null} + {state.error ? ( + + ) : state.data !== null ? ( + <> + {partial?.(state.data) ? ( +

+ {partial(state.data)} +

+ ) : null} + {isEmpty(state.data) ? ( +
+ {empty} {emptyAction} +
+ ) : ( + render(state.data) + )} + + ) : null} +
+ ) +} + +/** "Showing the first N" when a capped read came back full. */ +function FirstN({ shown, cap, what, order }: { shown: number; cap: number; what: string; order: string }): JSX.Element | null { + if (shown < cap) return null + return ( +

+ Showing the first {cap} {what} ({order}); there may be more. +

+ ) +} + +function RepoGrid({ repos }: { repos: readonly DiscoveredRepo[] }): JSX.Element { + return ( +
+ {repos.map((r) => ( + + ))} +
+ ) +} + +function RepoLinks({ repos, more }: { repos: readonly RepoLite[]; more: boolean }): JSX.Element { + return ( +
+
    + {repos.map((r) => ( +
  • + + {r.name} + +
  • + ))} +
+ {more ?

Showing the first {repos.length} stars (index order); there may be more.

: null} +
+ ) +} + +function TargetList({ rows, more, label }: { rows: readonly TargetRow[]; more: boolean; label?: string }): JSX.Element { + return ( +
+ {label ?

{label}

: null} +
    + {rows.map((t) => { + const Icon = t.kind === 'issue' ? CircleDot : GitPullRequest + const addr = t.repo ? { owner: t.repo.ownerId, name: t.repo.name, repoId: t.repo.id } : null + return ( +
  • + + {t.kind === 'issue' ? 'Issue' : 'Pull request'} + {addr ? ( + + + {addr.name}#{t.number} + {' '} + {t.title} + + ) : ( + + #{t.number} {t.title} (repo not found) + + )} + {timeAgo(t.createdAt)} +
  • + ) + })} +
+ {more ? ( +

+ Read the first {rows.length} (in repo order, not by date); any past that are not shown. +

+ ) : null} +
+ ) +} diff --git a/forge-web/app/notifications/page.tsx b/forge-web/app/notifications/page.tsx new file mode 100644 index 000000000..282b56394 --- /dev/null +++ b/forge-web/app/notifications/page.tsx @@ -0,0 +1,212 @@ +'use client' + +/** + * `/notifications` — the local inbox (`ux-dx-spec.md` §5.10). Items are computed in this + * browser from the chain by the header's poller; this page lists them, marks them read, and + * says exactly what is watched. + */ + +import Link from 'next/link' +import { useState } from 'react' +import { Bell, CheckCheck, CircleDot, GitCommit, GitPullRequest, Info, MessageSquare, RefreshCw, ShieldCheck, Tag } from 'lucide-react' +import { AppShell } from '@/components/app-shell' +import { Author } from '@/components/author' +import { Button } from '@/components/ui/button' +import { EmptyState, ErrorState, Spinner } from '@/components/ui/states' +import { NotDeployedState, isV2Deployed } from '@/components/ui/network-badge' +import { useAuth } from '@/contexts/auth-context' +import { useInboxActions, useInboxStore } from '@/hooks/use-inbox' +import { repoHref } from '@/hooks/use-query-param' +import { useUiStore } from '@/hooks/use-ui-store' +import { INBOX_EMPTY, MAX_REPOS, MAX_THREADS, POLL_MS, type InboxItem } from '@/lib/view/inbox' +import { timeAgo } from '@/lib/view' +import { cn } from '@/lib/utils' + +const ICON: Readonly> = { + issue: CircleDot, + pull: GitPullRequest, + comment: MessageSquare, + state: Tag, + review: ShieldCheck, + push: GitCommit, +} + +function hrefOf(item: InboxItem): string { + const addr = { owner: item.repo.ownerId, name: item.repo.name, repoId: item.repo.id } + if (!item.target) return repoHref('/repo/commits', addr) + return repoHref(item.target.kind === 'issue' ? '/repo/issue' : '/repo/pull', addr, { number: String(item.target.number) }) +} + +export default function NotificationsPage(): JSX.Element { + const { identity } = useAuth() + const openLogin = useUiStore((s) => s.openLogin) + const { items, subs, prefs, polling, lastPoll, lastFeeds, error } = useInboxStore() + const { markRead, markAllRead, setPrefs, pollNow } = useInboxActions() + const [filter, setFilter] = useState<'unread' | 'all'>('unread') + const shown = filter === 'unread' ? items.filter((i) => !i.read) : items + const unread = items.filter((i) => !i.read).length + + if (!isV2Deployed()) { + return ( + + + + ) + } + if (!identity) { + return ( + +

Notifications

+ openLogin()}>Sign in} + /> +
+ ) + } + + return ( + +
+
+

Notifications

+
+ {polling ? : null} + + +
+
+ +

+ + + Local only: this tab checks the chain every {POLL_MS / 1000} s while it is open. There is no email, no push and no + sync to your other devices; each browser keeps its own read state. + +

+ +
+ {(['unread', 'all'] as const).map((f) => ( + + ))} +
+ + {error && items.length === 0 ? ( + + ) : shown.length === 0 ? ( +
+ 0 ? 'All caught up' : 'Nothing new'} + body={INBOX_EMPTY} + /> +
+ ) : ( +
    + {shown.map((item) => ( + void markRead([item.id])} /> + ))} +
+ )} + +
+

What this browser watches

+ {subs ? ( +
    +
  • + {subs.repos.filter((r) => r.reason !== 'starred').length} repos you own or belong to: new issues and pull + requests{prefs?.pushes ? ', pushes' : ''}. +
  • +
  • + {subs.threads.length} issues and pull requests you opened or commented on: comments, state changes, and reviews + on your pull requests. +
  • + {prefs?.stars ?
  • {subs.repos.filter((r) => r.reason === 'starred').length} starred repos: new issues and pull requests.
  • : null} + {subs.droppedRepos > 0 ? ( +
  • + Capped at {MAX_REPOS} repos: {subs.droppedRepos} more are not watched. +
  • + ) : null} + {subs.droppedThreads > 0 ? ( +
  • + Capped at the {MAX_THREADS} threads you joined most recently: {subs.droppedThreads} older ones are not watched. +
  • + ) : null} + {subs.incomplete && subs.incomplete.length > 0 ? ( +
  • + Could not read all of: {subs.incomplete.join('; ')}. What they would add is not watched until the next check + succeeds. +
  • + ) : null} +
+ ) : ( +

Working out your repos and threads…

+ )} + {prefs ? ( +
+ + +
+ ) : null} +

+ {lastPoll ? `Last checked ${timeAgo(lastPoll)}` : 'Not checked yet'} + {lastFeeds ? ` · ${lastFeeds.read} of ${lastFeeds.total} feeds this round${lastFeeds.failed ? `, ${lastFeeds.failed} failed (retried next round)` : ''}` : ''} + . Your own actions never notify you. +

+
+
+
+ ) +} + +function InboxRow({ item, onRead }: { item: InboxItem; onRead: () => void }): JSX.Element { + const Icon = ICON[item.kind] + return ( +
  • + +
    + + {item.repo.name} + {item.target ? ( + <> + {' '} + #{item.target.number}{' '} + {item.target.title} + + ) : null} + +
    + + {item.what} + · {timeAgo(item.at)} + {item.read ? null : new} +
    +
    + {item.read ? null : ( + + )} +
  • + ) +} diff --git a/forge-web/app/page.tsx b/forge-web/app/page.tsx index 0570dfa39..a143d7b35 100644 --- a/forge-web/app/page.tsx +++ b/forge-web/app/page.tsx @@ -8,7 +8,7 @@ */ import Link from 'next/link' -import { GitBranch, Lock, Plus, Search } from 'lucide-react' +import { Compass, GitBranch, Lock, Plus, Search } from 'lucide-react' import type { ReactNode } from 'react' import { AppShell } from '@/components/app-shell' import { RepoCard } from '@/components/repo-card' @@ -56,6 +56,11 @@ export default function LandingPage(): JSX.Element { New repo + + + -
    +

    Recent repos

    - {feed.loading ? : null} +
    + {feed.loading ? : null} + {v2 ? ( + + Explore more + + ) : null} +
    {!deployed ? ( diff --git a/forge-web/components/app-footer.tsx b/forge-web/components/app-footer.tsx index 7ee7b1774..b93a3ac24 100644 --- a/forge-web/components/app-footer.tsx +++ b/forge-web/components/app-footer.tsx @@ -15,6 +15,9 @@ export function AppFooter(): JSX.Element { Discover + + Explore + New repo diff --git a/forge-web/components/app-header.tsx b/forge-web/components/app-header.tsx index ffbd4c902..9a8b45d68 100644 --- a/forge-web/components/app-header.tsx +++ b/forge-web/components/app-header.tsx @@ -1,71 +1,66 @@ 'use client' /** - * App header — the persistent foundry chrome: wordmark, global repo jump, network badge (every - * network except mainnet), theme toggle, and the auth surface (sign-in trigger, or balance + - * identity + logout when signed in). + * App header (`ux-dx-spec.md` §5.2): wordmark · network badge (every network except mainnet) · + * jump box (`owner/name`, `@name`, `#n` in a repo) · New ▾ (Repository, Mirror a GitHub repo) · + * notifications bell with the unread count · identity pill. Below `sm` the jump box moves to a + * second row so the bar fits 360 px. */ import Link from 'next/link' -import { useRouter } from 'next/navigation' -import { useEffect, useRef, useState } from 'react' -import { Hammer, LogOut, Search, Wallet } from 'lucide-react' +import { usePathname, useRouter, useSearchParams } from 'next/navigation' +import { Suspense, useEffect, useRef, useState, type ReactNode } from 'react' +import { Bell, ChevronDown, Compass, GitFork, Hammer, LogOut, Plus, Search, Wallet } from 'lucide-react' import { useAuth } from '@/contexts/auth-context' import { useUiStore } from '@/hooks/use-ui-store' +import { useUnreadCount } from '@/hooks/use-inbox' +import { addressFromParams, repoHref } from '@/hooks/use-query-param' import { Button } from '@/components/ui/button' import { IdentityPill } from '@/components/ui/identity-pill' import { ThemeToggle } from '@/components/theme-toggle' import { NetworkBadge } from '@/components/ui/network-badge' -import { creditsToDash } from '@/lib/sdk' +import { ACTIVE_NETWORK, DEFAULT_NETWORK } from '@/lib/constants' +import { resolveAnyRepo } from '@/lib/repo' +import { creditsToDash, ensureSdk } from '@/lib/sdk' +import { errorMessage } from '@/lib/utils' +import { numberTargets, parseJump } from '@/lib/view/jump' import { balanceToDash, dashToUsd } from '@/lib/view/format' import { FundsPill } from '@/components/funds-pill' +/** The mirror guide (the `/mirror` wizard does not exist yet). */ +export const MIRROR_GUIDE_URL = 'https://github.com/PastaPastaPasta/dash-forge/blob/master/docs/guides/mirror-a-github-repo.md' + export function AppHeader(): JSX.Element { const openLogin = useUiStore((s) => s.openLogin) const { identity, balance, logout } = useAuth() - const router = useRouter() - const [query, setQuery] = useState('') - - const onSearch = (e: React.FormEvent): void => { - e.preventDefault() - const q = query.trim() - if (!q) return - // Accept "owner/name" jump (owner: identity id or DPNS name); otherwise treat it as an - // owner profile lookup (`alice`, `@alice`, or an identity id). - if (q.includes('/')) { - const [owner, name] = q.split('/') - router.push(`/repo?owner=${encodeURIComponent(owner ?? '')}&name=${encodeURIComponent(name ?? '')}`) - } else { - router.push(`/u?name=${encodeURIComponent(q.replace(/^@/, ''))}`) - } - } return (
    -
    - +
    + - - Dash Forge - + Dash Forge -
    - - setQuery(e.target.value)} - placeholder="Jump to owner/name…" - aria-label="Jump to a repo or profile" - className="h-8 w-full rounded-md border border-anvil-300 bg-white pl-8 pr-2 text-dense placeholder:text-anvil-400 focus-visible:border-forge-400 dark:border-anvil-700 dark:bg-anvil-900" - /> - - -
    +
    + + + +
    + +
    + + Explore + + + {identity ? : null} {identity ? ( <> @@ -79,76 +74,279 @@ export function AppHeader(): JSX.Element { )}
    +
    + + + +
    ) } -function AccountMenu({ - identity, - balance, - onLogout, -}: { - identity: string - balance: string | null - onLogout: (forget?: boolean) => void -}): JSX.Element { +/** + * The jump box. `#n` resolves against the repo the page shows (from its query string): issue + * first, then PR; both existing opens a choice. `owner/name#n` does the same for that repo. + */ +function JumpBox({ compact = false }: { compact?: boolean }): JSX.Element { + const router = useRouter() + const pathname = usePathname() + const params = useSearchParams() + const [query, setQuery] = useState('') + const [note, setNote] = useState(null) + const [busy, setBusy] = useState(false) + // Only the newest #n lookup may act: a slow one must not navigate after the query changed. + const request = useRef(0) + const here = addressFromParams(params) + const inRepo = pathname.startsWith('/repo') && here.owner !== '' && here.name !== '' + const id = compact ? 'jump-compact' : 'jump' + + const goNumber = async (addr: typeof here, n: number): Promise => { + const mine = ++request.current + const current = (): boolean => request.current === mine + setBusy(true) + setNote(null) + try { + const sdk = await ensureSdk(DEFAULT_NETWORK) + const resolved = await resolveAnyRepo(sdk, { network: DEFAULT_NETWORK, ...addr }) + if (!current()) return + if (resolved === null) { + setNote(`No repo ${addr.owner}/${addr.name} here.`) + return + } + const found = await numberTargets(sdk, resolved.repo, n) + if (!current()) return + const issue = repoHref('/repo/issue', addr, { number: String(n) }) + const pull = repoHref('/repo/pull', addr, { number: String(n) }) + if (found.issue && found.pull) { + setNote( + + #{n} is both:{' '} + setNote(null)}>issue #{n} ·{' '} + setNote(null)}>PR #{n} + , + ) + } else if (found.issue || found.pull) { + setQuery('') + router.push(found.issue ? issue : pull) + } else { + setNote(`No issue or PR #${n} in ${addr.name}.`) + } + } catch (e) { + if (current()) setNote(errorMessage(e)) + } finally { + if (current()) setBusy(false) + } + } + + const onSubmit = (e: React.FormEvent): void => { + e.preventDefault() + const jump = parseJump(query, inRepo) + if (jump === null) return + switch (jump.kind) { + case 'invalid': + setNote(jump.message) + return + case 'number': + void goNumber(here, jump.number) + return + case 'repo': + if (jump.number !== undefined) { + void goNumber({ owner: jump.owner, name: jump.name }, jump.number) + return + } + setQuery('') + setNote(null) + router.push(repoHref('/repo', { owner: jump.owner, name: jump.name })) + return + case 'profile': + setQuery('') + setNote(null) + router.push(`/u?name=${encodeURIComponent(jump.name)}`) + } + } + + return ( +
    + + + { + setQuery(e.target.value) + setNote(null) + // Typing supersedes a lookup still in flight. + request.current++ + setBusy(false) + }} + placeholder={inRepo ? 'owner/name, @name or #n' : 'owner/name or @name'} + aria-describedby={note ? `${id}-note` : undefined} + aria-busy={busy} + className="h-8 w-full rounded-md border border-anvil-300 bg-white pl-8 pr-2 text-dense placeholder:text-anvil-500 focus-visible:border-forge-400 dark:border-anvil-700 dark:bg-anvil-900 dark:placeholder:text-anvil-400" + /> + {note ? ( +

    + {note} +

    + ) : null} + + ) +} + +/** + * A disclosure popover (button with `aria-expanded` + a panel of plain links): closes on an + * outside click, on Escape (focus returns to the trigger), and when focus leaves it (Tab). + */ +function usePopover(): { open: boolean; setOpen: (v: boolean) => void; ref: React.RefObject; trigger: React.RefObject } { const [open, setOpen] = useState(false) const ref = useRef(null) - + const trigger = useRef(null) useEffect(() => { if (!open) return const onDoc = (e: MouseEvent): void => { if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false) } + const onKey = (e: KeyboardEvent): void => { + if (e.key === 'Escape') { + setOpen(false) + trigger.current?.focus() + } + } + const onFocus = (e: FocusEvent): void => { + if (ref.current && e.target instanceof Node && !ref.current.contains(e.target)) setOpen(false) + } document.addEventListener('mousedown', onDoc) - return () => document.removeEventListener('mousedown', onDoc) + document.addEventListener('keydown', onKey) + document.addEventListener('focusin', onFocus) + return () => { + document.removeEventListener('mousedown', onDoc) + document.removeEventListener('keydown', onKey) + document.removeEventListener('focusin', onFocus) + } }, [open]) + return { open, setOpen, ref, trigger } +} +const MENU_ITEM = 'flex w-full items-start gap-2 rounded-md px-3 py-2 text-left text-dense hover:bg-anvil-100 focus-visible:bg-anvil-100 dark:hover:bg-anvil-800 dark:focus-visible:bg-anvil-800' + +function NewMenu(): JSX.Element | null { + const { open, setOpen, ref, trigger } = usePopover() + // No "New" on a network without Forge (spec §6.3: no New repo button in that state). + if (ACTIVE_NETWORK.v2 === null && ACTIVE_NETWORK.registryContractId === null) return null + return ( +
    + + {open ? ( + + ) : null} +
    + ) +} + +function NotificationsBell(): JSX.Element { + const unread = useUnreadCount() + const label = unread === 0 ? 'Notifications, none unread' : `Notifications, ${unread} unread` + return ( + + + {unread > 0 ? ( + + {unread > 99 ? '99+' : unread} + + ) : null} + + ) +} + +function AccountMenu({ + identity, + balance, + onLogout, +}: { + identity: string + balance: string | null + onLogout: (forget?: boolean) => void +}): JSX.Element { + const { open, setOpen, ref, trigger } = usePopover() const credits = balance ? Number(balance) : 0 const dash = balanceToDash(balance ?? '0') return (
    {open ? ( -
    +
    Balance
    {dash} DASH
    -
    +
    {credits.toLocaleString()} credits · ≈ {dashToUsd(creditsToDash(credits))}
    - setOpen(false)} - > + setOpen(false)}> + Notifications + + setOpen(false)}> + Explore + + setOpen(false)}> Settings & spend - setOpen(false)} - > + setOpen(false)}> Your profile + )} + +
    +
    + ) : done ? ( +
    +

    + Key limits updated on chain. +

    +
    +
    +
    Before
    +
    Now (read back from the chain)
    +
    Budget
    +
    {dash(done.before?.total ?? null)}
    +
    {dash(done.after.total)}
    +
    Left
    +
    {dash(done.before?.remaining ?? null)}
    +
    {dash(done.after.remaining)}
    +
    Expires
    +
    {done.before?.expiresAt ? formatDate(done.before.expiresAt) : '—'}
    +
    {done.after.expiresAt ? formatDate(done.after.expiresAt) : 'never'}
    +
    +

    Your master key was used for this one update and was not stored.

    + +
    + ) : ( +
    { + e.preventDefault() + void submit() + }} + > +

    + Adds budget to the key this browser already signs with, so nothing here has to be re-imported. Your master key + signs this one update and is not stored. The fee comes from your identity balance. +

    + + setAmount(e.target.value)} className="font-mono" autoComplete="off" aria-invalid={amountError !== null} /> + + {amountError ?

    {amountError}

    : null} +
    + + {extend ? ( + + setExpiry(e.target.value)} aria-invalid={expiryError !== null} /> + + ) : null} + {expiryError ?

    {expiryError}

    : null} +
    + +
    + + Master key, used once + +
    + {(['file', 'mnemonic'] as const).map((m) => ( + + ))} +
    + {mode === 'file' ? ( + <> + + { + const f = e.target.files?.[0] + if (f) void onFile(f) + e.target.value = '' + }} + /> + + ) : ( + +