From bd3fb911a8666085caff8d5e56e18322c81849b3 Mon Sep 17 00:00:00 2001 From: eti Date: Wed, 29 Jul 2026 19:52:07 +0200 Subject: [PATCH] web/components: tailor the empty repo state to ssh key presence the four-step 'generate a key, add it to settings, set your remote, push' walk through is only useful to an owner without a key on their account. owners who already have one now get the quick-setup commands instead, in the shape github and codeberg use: create-and-push, or push an existing repository. key presence comes from sh.tangled.publicKey.countKeys, fetched lazily and only for the owner; a failed lookup falls back to the key-generation instructions since those are the safe ones to show. the new hasSshKey prop overrides the lookup so both variants are storyable without a backend. Signed-off-by: eti --- .../components/repo/EmptyRepo.stories.svelte | 7 +- web/src/lib/components/repo/EmptyRepo.svelte | 122 ++++++++++++++---- 2 files changed, 106 insertions(+), 23 deletions(-) diff --git a/web/src/lib/components/repo/EmptyRepo.stories.svelte b/web/src/lib/components/repo/EmptyRepo.stories.svelte index a4439408..275f4c55 100644 --- a/web/src/lib/components/repo/EmptyRepo.stories.svelte +++ b/web/src/lib/components/repo/EmptyRepo.stories.svelte @@ -26,7 +26,12 @@ - + + + + + + diff --git a/web/src/lib/components/repo/EmptyRepo.svelte b/web/src/lib/components/repo/EmptyRepo.svelte index 5879e878..2a9e309b 100644 --- a/web/src/lib/components/repo/EmptyRepo.svelte +++ b/web/src/lib/components/repo/EmptyRepo.svelte @@ -1,13 +1,20 @@ {#snippet bullet(n: number)} @@ -28,29 +68,67 @@ {/snippet} +{#snippet codeBlock(lines: string[])} +
{lines.join(
+			"\n"
+		)}
+{/snippet} + {#if isOwner} -
-
-

This is an empty repository. To get started:

-

- {@render bullet(1)}First, generate a new - SSH key pair. -

-

- {@render bullet(2)}Then add the public key from the - keys page in your settings. -

-

- {@render bullet(3)}Configure your remote to - {remote} -

-

{@render bullet(4)}Push!

+ {#if keyStatus === "checking"} + + {:else if keyStatus === "has-key"} +
+
+

This is an empty repository.

+
+

…create a new repository on the command line

+ {@render codeBlock([ + `echo "# ${repo.name}" >> README.md`, + "git init", + "git add README.md", + 'git commit -m "initial commit"', + `git branch -M ${repo.defaultBranch}`, + `git remote add origin ${remote}`, + `git push -u origin ${repo.defaultBranch}` + ])} +
+
+

+ …or push an existing repository from the command line +

+ {@render codeBlock([ + `git remote add origin ${remote}`, + `git branch -M ${repo.defaultBranch}`, + `git push -u origin ${repo.defaultBranch}` + ])} +
+
+
+ {:else} +
+
+

This is an empty repository. To get started:

+

+ {@render bullet(1)}First, generate a new + SSH key pair. +

+

+ {@render bullet(2)}Then add the public key from the + keys page in your settings. +

+

+ {@render bullet(3)}Configure your remote to + {remote} +

+

{@render bullet(4)}Push!

+
-
+ {/if} {:else}

This is an empty repository.

{/if} -- 2.51.2