Monorepo for Tangled tangled.org

appview/state: Move /knots & /spindles under /settings #660

merged opened by 5jiji.com targeting master from [deleted fork]: master

Closes https://tangled.org/@tangled.org/core/issues/248

I hope this go code is fine, because i have no damn clue how go works, so i just tried something and it worked If there is a better solution, i would like to know it!

NB: (I've checked if it compiled and worked, by removing commit '3ebdcd: knotserver: improve the logging situation', as for some reason, that commit is uncompilable (even your spindle is complaining))

Labels

None yet.

assignee

None yet.

Participants 3
AT URI
at://did:plc:uakrniojtddxh2juse64bgcm/sh.tangled.repo.pull/3m2z5niwb2y22
+216 -114
Interdiff #0 โ†’ #1
-10
appview/state/router.go
··· 161 161 162 162 r.Mount("/settings", s.SettingsRouter()) 163 163 r.Mount("/strings", s.StringsRouter(mw)) 164 - 165 - 166 - r.Mount("/knots", s.Redirect("/settings/knots")) 167 - r.Mount("/spindles", s.Redirect("/settings/spindles")) 168 164 169 165 r.Mount("/settings/knots", s.KnotsRouter()) 170 166 r.Mount("/settings/spindles", s.SpindlesRouter()) ··· 183 179 184 180 185 181 return r 186 - } 187 - 188 - func (s *State) Redirect(destination string) http.HandlerFunc { 189 - return func(w http.ResponseWriter, r *http.Request) { 190 - http.Redirect(w, r, destination, http.StatusFound) 191 - } 192 182 } 193 183 194 184 // Core serves tangled.org/core go-import meta tags, and redirects
+20 -4
appview/pages/templates/knots/dashboard.html
··· 1 - {{ define "title" }}{{ .Registration.Domain }} &middot; knots{{ end }} 1 + {{ define "title" }}{{ .Registration.Domain }} &middot; {{ .Tab }} settings{{ end }} 2 2 3 3 {{ define "content" }} 4 - <div class="px-6 py-4"> 4 + <div class="p-6"> 5 + <p class="text-xl font-bold dark:text-white">Settings</p> 6 + </div> 7 + <div class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 8 + <section class="w-full grid grid-cols-1 md:grid-cols-4 gap-6"> 9 + <div class="col-span-1"> 10 + {{ template "user/settings/fragments/sidebar" . }} 11 + </div> 12 + <div class="col-span-1 md:col-span-3 flex flex-col gap-6"> 13 + {{ template "knotDash" . }} 14 + </div> 15 + </section> 16 + </div> 17 + {{ end }} 18 + 19 + {{ define "knotDash" }} 20 + <div> 5 21 <div class="flex justify-between items-center"> 6 - <h1 class="text-xl font-bold dark:text-white">{{ .Registration.Domain }}</h1> 22 + <h2 class="text-sm pb-2 uppercase font-bold">{{ .Tab }} &middot; {{ .Registration.Domain }}</h2> 7 23 <div id="right-side" class="flex gap-2"> 8 24 {{ $style := "px-2 py-1 rounded flex items-center flex-shrink-0 gap-2" }} 9 25 {{ $isOwner := and .LoggedInUser (eq .LoggedInUser.Did .Registration.ByDid) }} ··· 35 51 </div> 36 52 37 53 {{ if .Members }} 38 - <section class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 54 + <section class="bg-white dark:bg-gray-800 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 39 55 <div class="flex flex-col gap-2"> 40 56 {{ block "member" . }} {{ end }} 41 57 </div>
appview/pages/templates/knots/fragments/addMemberModal.html

This file has not been changed.

appview/pages/templates/knots/fragments/knotListing.html

This file has not been changed.

+41 -10
appview/pages/templates/knots/index.html
··· 1 - {{ define "title" }}knots{{ end }} 1 + {{ define "title" }}{{ .Tab }} settings{{ end }} 2 2 3 3 {{ define "content" }} 4 - <div class="px-6 py-4 flex items-center justify-between gap-4 align-bottom"> 5 - <h1 class="text-xl font-bold dark:text-white">Knots</h1> 6 - <span class="flex items-center gap-1"> 7 - {{ i "book" "w-3 h-3" }} 8 - <a href="https://tangled.org/@tangled.org/core/blob/master/docs/knot-hosting.md">docs</a> 9 - </span> 10 - </div> 4 + <div class="p-6"> 5 + <p class="text-xl font-bold dark:text-white">Settings</p> 6 + </div> 7 + <div class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 8 + <section class="w-full grid grid-cols-1 md:grid-cols-4 gap-6"> 9 + <div class="col-span-1"> 10 + {{ template "user/settings/fragments/sidebar" . }} 11 + </div> 12 + <div class="col-span-1 md:col-span-3 flex flex-col gap-6"> 13 + {{ template "knotsList" . }} 14 + </div> 15 + </section> 16 + </div> 17 + {{ end }} 11 18 12 - <section class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 19 + {{ define "knotsList" }} 20 + <div class="grid grid-cols-1 md:grid-cols-3 gap-4 items-center"> 21 + <div class="col-span-1 md:col-span-2"> 22 + <h2 class="text-sm pb-2 uppercase font-bold">Knots</h2> 23 + {{ block "about" . }} {{ end }} 24 + </div> 25 + <div class="col-span-1 md:col-span-1 md:justify-self-end"> 26 + {{ template "docsButton" . }} 27 + </div> 28 + </div> 29 + 30 + <section> 13 31 <div class="flex flex-col gap-6"> 14 - {{ block "about" . }} {{ end }} 15 32 {{ block "list" . }} {{ end }} 16 33 {{ block "register" . }} {{ end }} 17 34 </div> ··· 83 100 84 101 85 102 </section> 103 + {{ end }} 104 + 105 + {{ define "docsButton" }} 106 + <a 107 + class="btn flex items-center gap-2" 108 + href="https://tangled.org/@tangled.org/core/blob/master/docs/spindle/hosting.md"> 109 + {{ i "book" "size-4" }} 110 + docs 111 + </a> 112 + <div 113 + id="add-email-modal" 114 + popover 115 + class="bg-white w-full md:w-96 dark:bg-gray-800 p-4 rounded border border-gray-200 dark:border-gray-700 drop-shadow dark:text-white backdrop:bg-gray-400/50 dark:backdrop:bg-gray-800/50"> 116 + </div> 86 117 {{ end }}
-3
appview/pages/templates/layouts/fragments/topbar.html
··· 65 65 <a href="/{{ $user }}">profile</a> 66 66 <a href="/{{ $user }}?tab=repos">repositories</a> 67 67 <a href="/{{ $user }}?tab=strings">strings</a> 68 - <a href="/settings/knots">knots</a> 69 - <a href="/settings/spindles">spindles</a> 70 68 <a href="/settings">settings</a> 71 69 <a href="#" 72 - hx-post="/logout" 73 70 hx-post="/logout"
appview/pages/templates/repo/fork.html

This file has not been changed.

appview/pages/templates/repo/new.html

This file has not been changed.

-25
docs/hacking.md
··· 140 140 hit verify. You can then configure each repository to use 141 141 this spindle and run CI jobs. 142 142 143 - 144 - 145 - 146 - 147 - 148 - 149 - 150 - 151 - 152 - 153 - 154 - 155 - 156 - 157 - 158 - 159 - 160 - 161 - ### running a spindle 162 - 163 - The above VM should already be running a spindle on 164 - `localhost:6555`. Head to http://localhost:3000/spindles and 165 - hit verify. You can then configure each repository to use 166 - this spindle and run CI jobs. 167 -
docs/knot-hosting.md

This patch was likely rebased, as context lines do not match.

docs/migrations.md

This patch was likely rebased, as context lines do not match.

+19 -3
appview/pages/templates/spindles/dashboard.html
··· 1 - {{ define "title" }}{{.Spindle.Instance}} &middot; spindles{{ end }} 1 + {{ define "title" }}{{.Spindle.Instance}} &middot; {{ .Tab }} settings{{ end }} 2 2 3 3 {{ define "content" }} 4 - <div class="px-6 py-4"> 4 + <div class="p-6"> 5 + <p class="text-xl font-bold dark:text-white">Settings</p> 6 + </div> 7 + <div class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 8 + <section class="w-full grid grid-cols-1 md:grid-cols-4 gap-6"> 9 + <div class="col-span-1"> 10 + {{ template "user/settings/fragments/sidebar" . }} 11 + </div> 12 + <div class="col-span-1 md:col-span-3 flex flex-col gap-6"> 13 + {{ template "spindleDash" . }} 14 + </div> 15 + </section> 16 + </div> 17 + {{ end }} 18 + 19 + {{ define "spindleDash" }} 20 + <div> 5 21 <div class="flex justify-between items-center"> 6 - <h1 class="text-xl font-bold dark:text-white">{{ .Spindle.Instance }}</h1> 22 + <h2 class="text-sm pb-2 uppercase font-bold">{{ .Tab }} &middot; {{ .Spindle.Instance }}</h2> 7 23 <div id="right-side" class="flex gap-2"> 8 24 {{ $style := "px-2 py-1 rounded flex items-center flex-shrink-0 gap-2" }} 9 25 {{ $isOwner := and .LoggedInUser (eq .LoggedInUser.Did .Spindle.Owner) }}
appview/pages/templates/spindles/fragments/addMemberModal.html

This file has not been changed.

appview/pages/templates/spindles/fragments/spindleListing.html

This file has not been changed.

+90 -59
appview/pages/templates/spindles/index.html
··· 1 - {{ define "title" }}spindles{{ end }} 1 + {{ define "title" }}{{ .Tab }} settings{{ end }} 2 2 3 3 {{ define "content" }} 4 - <div class="px-6 py-4 flex items-center justify-between gap-4 align-bottom"> 5 - <h1 class="text-xl font-bold dark:text-white">Spindles</h1> 6 - <span class="flex items-center gap-1"> 7 - {{ i "book" "w-3 h-3" }} 8 - <a href="https://tangled.org/@tangled.org/core/blob/master/docs/spindle/hosting.md">docs</a> 9 - </span> 4 + <div class="p-6"> 5 + <p class="text-xl font-bold dark:text-white">Settings</p> 6 + </div> 7 + <div class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 8 + <section class="w-full grid grid-cols-1 md:grid-cols-4 gap-6"> 9 + <div class="col-span-1"> 10 + {{ template "user/settings/fragments/sidebar" . }} 11 + </div> 12 + <div class="col-span-1 md:col-span-3 flex flex-col gap-6"> 13 + {{ template "spindleList" . }} 14 + </div> 15 + </section> 16 + </div> 17 + {{ end }} 18 + 19 + {{ define "spindleList" }} 20 + <div class="grid grid-cols-1 md:grid-cols-3 gap-4 items-center"> 21 + <div class="col-span-1 md:col-span-2"> 22 + <h2 class="text-sm pb-2 uppercase font-bold">Spindle</h2> 23 + {{ block "about" . }} {{ end }} 24 + </div> 25 + <div class="col-span-1 md:col-span-1 md:justify-self-end"> 26 + {{ template "docsButton" . }} 27 + </div> 10 28 </div> 11 29 12 - <section class="bg-white dark:bg-gray-800 p-6 rounded relative w-full mx-auto drop-shadow-sm dark:text-white"> 30 + <section> 13 31 <div class="flex flex-col gap-6"> 14 - {{ block "about" . }} {{ end }} 15 32 {{ block "list" . }} {{ end }} 16 33 {{ block "register" . }} {{ end }} 17 34 </div> ··· 20 37 21 38 {{ define "about" }} 22 39 <section class="rounded flex items-center gap-2"> 23 - <p class="text-gray-500 dark:text-gray-400"> 24 - Spindles are small CI runners. 25 - </p> 40 + <p class="text-gray-500 dark:text-gray-400"> 41 + Spindles are small CI runners. 42 + </p> 26 43 </section> 27 44 {{ end }} 28 45 29 46 {{ define "list" }} 30 - <section class="rounded w-full flex flex-col gap-2"> 31 - <h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">your spindles</h2> 32 - <div class="flex flex-col rounded border border-gray-200 dark:border-gray-700 w-full"> 33 - {{ range $spindle := .Spindles }} 34 - {{ template "spindles/fragments/spindleListing" . }} 35 - {{ else }} 36 - <div class="flex items-center justify-center p-2 border-b border-gray-200 dark:border-gray-700 text-gray-500"> 37 - no spindles registered yet 38 - </div> 39 - {{ end }} 47 + <section class="rounded w-full flex flex-col gap-2"> 48 + <h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">your spindles</h2> 49 + <div class="flex flex-col rounded border border-gray-200 dark:border-gray-700 w-full"> 50 + {{ range $spindle := .Spindles }} 51 + {{ template "spindles/fragments/spindleListing" . }} 52 + {{ else }} 53 + <div class="flex items-center justify-center p-2 border-b border-gray-200 dark:border-gray-700 text-gray-500"> 54 + no spindles registered yet 40 55 </div> 41 - <div id="operation-error" class="text-red-500 dark:text-red-400"></div> 42 - </section> 56 + {{ end }} 57 + </div> 58 + <div id="operation-error" class="text-red-500 dark:text-red-400"></div> 59 + </section> 43 60 {{ end }} 44 61 45 62 {{ define "register" }} 46 - <section class="rounded w-full lg:w-fit flex flex-col gap-2"> 47 - <h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">register a spindle</h2> 48 - <p class="mb-2 dark:text-gray-300">Enter the hostname of your spindle to get started.</p> 49 - <form 50 - hx-post="/settings/spindles/register" 51 - class="max-w-2xl mb-2 space-y-4" 52 - hx-indicator="#register-button" 53 - hx-swap="none" 54 - > 55 - <div class="flex gap-2"> 56 - <input 57 - type="text" 58 - id="instance" 59 - name="instance" 60 - placeholder="spindle.example.com" 61 - required 62 - class="flex-1 w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400 px-3 py-2 border rounded" 63 - > 64 - <button 65 - type="submit" 66 - id="register-button" 67 - class="btn rounded flex items-center py-2 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 group" 68 - > 69 - <span class="inline-flex items-center gap-2"> 70 - {{ i "plus" "w-4 h-4" }} 71 - register 72 - </span> 73 - <span class="pl-2 hidden group-[.htmx-request]:inline"> 74 - {{ i "loader-circle" "w-4 h-4 animate-spin" }} 75 - </span> 76 - </button> 77 - </div> 63 + <section class="rounded w-full lg:w-fit flex flex-col gap-2"> 64 + <h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">register a spindle</h2> 65 + <p class="mb-2 dark:text-gray-300">Enter the hostname of your spindle to get started.</p> 66 + <form 67 + hx-post="/settings/spindles/register" 68 + class="max-w-2xl mb-2 space-y-4" 69 + hx-indicator="#register-button" 70 + hx-swap="none" 71 + > 72 + <div class="flex gap-2"> 73 + <input 74 + type="text" 75 + id="instance" 76 + name="instance" 77 + placeholder="spindle.example.com" 78 + required 79 + class="flex-1 w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400 px-3 py-2 border rounded" 80 + > 81 + <button 82 + type="submit" 83 + id="register-button" 84 + class="btn rounded flex items-center py-2 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600 group" 85 + > 86 + <span class="inline-flex items-center gap-2"> 87 + {{ i "plus" "w-4 h-4" }} 88 + register 89 + </span> 90 + <span class="pl-2 hidden group-[.htmx-request]:inline"> 91 + {{ i "loader-circle" "w-4 h-4 animate-spin" }} 92 + </span> 93 + </button> 94 + </div> 78 95 79 - <div id="register-error" class="dark:text-red-400"></div> 80 - </form> 96 + <div id="register-error" class="dark:text-red-400"></div> 97 + </form> 81 98 82 - </section> 99 + </section> 100 + {{ end }} 101 + 102 + {{ define "docsButton" }} 103 + <a 104 + class="btn flex items-center gap-2" 105 + href="https://tangled.org/@tangled.org/core/blob/master/docs/spindle/hosting.md"> 106 + {{ i "book" "size-4" }} 107 + docs 108 + </a> 109 + <div 110 + id="add-email-modal" 111 + popover 112 + class="bg-white w-full md:w-96 dark:bg-gray-800 p-4 rounded border border-gray-200 dark:border-gray-700 drop-shadow dark:text-white backdrop:bg-gray-400/50 dark:backdrop:bg-gray-800/50"> 113 + </div> 83 114 {{ end }}
+17
appview/knots/knots.go
··· 38 38 Knotstream *eventconsumer.Consumer 39 39 } 40 40 41 + type tab = map[string]any 42 + 43 + var ( 44 + knotsTabs []tab = []tab{ 45 + {"Name": "profile", "Icon": "user"}, 46 + {"Name": "keys", "Icon": "key"}, 47 + {"Name": "emails", "Icon": "mail"}, 48 + {"Name": "notifications", "Icon": "bell"}, 49 + {"Name": "knots", "Icon": "volleyball"}, 50 + {"Name": "spindles", "Icon": "spool"}, 51 + } 52 + ) 53 + 41 54 func (k *Knots) Router() http.Handler { 42 55 r := chi.NewRouter() 43 56 ··· 69 82 k.Pages.Knots(w, pages.KnotsParams{ 70 83 LoggedInUser: user, 71 84 Registrations: registrations, 85 + Tabs: knotsTabs, 86 + Tab: "knots", 72 87 }) 73 88 } 74 89 ··· 131 146 Members: members, 132 147 Repos: repoMap, 133 148 IsOwner: true, 149 + Tabs: knotsTabs, 150 + Tab: "knots", 134 151 }) 135 152 } 136 153
+10
appview/pages/pages.go
··· 410 410 type KnotsParams struct { 411 411 LoggedInUser *oauth.User 412 412 Registrations []models.Registration 413 + Tabs []map[string]any 414 + Tab string 413 415 } 414 416 415 417 func (p *Pages) Knots(w io.Writer, params KnotsParams) error { ··· 422 424 Members []string 423 425 Repos map[string][]models.Repo 424 426 IsOwner bool 427 + Tabs []map[string]any 428 + Tab string 425 429 } 426 430 427 431 func (p *Pages) Knot(w io.Writer, params KnotParams) error { ··· 439 443 type SpindlesParams struct { 440 444 LoggedInUser *oauth.User 441 445 Spindles []models.Spindle 446 + Tabs []map[string]any 447 + Tab string 442 448 } 443 449 444 450 func (p *Pages) Spindles(w io.Writer, params SpindlesParams) error { ··· 447 453 448 454 type SpindleListingParams struct { 449 455 models.Spindle 456 + Tabs []map[string]any 457 + Tab string 450 458 } 451 459 452 460 func (p *Pages) SpindleListing(w io.Writer, params SpindleListingParams) error { ··· 458 466 Spindle models.Spindle 459 467 Members []string 460 468 Repos map[string][]models.Repo 469 + Tabs []map[string]any 470 + Tab string 461 471 } 462 472 463 473 func (p *Pages) SpindleDashboard(w io.Writer, params SpindleDashboardParams) error {
+2
appview/settings/settings.go
··· 43 43 {"Name": "keys", "Icon": "key"}, 44 44 {"Name": "emails", "Icon": "mail"}, 45 45 {"Name": "notifications", "Icon": "bell"}, 46 + {"Name": "knots", "Icon": "volleyball"}, 47 + {"Name": "spindles", "Icon": "spool"}, 46 48 } 47 49 ) 48 50
+17
appview/spindles/spindles.go
··· 37 37 Logger *slog.Logger 38 38 } 39 39 40 + type tab = map[string]any 41 + 42 + var ( 43 + spindlesTabs []tab = []tab{ 44 + {"Name": "profile", "Icon": "user"}, 45 + {"Name": "keys", "Icon": "key"}, 46 + {"Name": "emails", "Icon": "mail"}, 47 + {"Name": "notifications", "Icon": "bell"}, 48 + {"Name": "knots", "Icon": "volleyball"}, 49 + {"Name": "spindles", "Icon": "spool"}, 50 + } 51 + ) 52 + 40 53 func (s *Spindles) Router() http.Handler { 41 54 r := chi.NewRouter() 42 55 ··· 68 81 s.Pages.Spindles(w, pages.SpindlesParams{ 69 82 LoggedInUser: user, 70 83 Spindles: all, 84 + Tabs: spindlesTabs, 85 + Tab: "spindles", 71 86 }) 72 87 } 73 88 ··· 126 141 Spindle: spindle, 127 142 Members: members, 128 143 Repos: repoMap, 144 + Tabs: spindlesTabs, 145 + Tab: "spindles", 129 146 }) 130 147 } 131 148

History

3 rounds 7 comments
sign up or login to add to the discussion
9 commits
expand
bfa487d3
appview/state: Moved /knots & /spindle to /settings
07a7776b
appview/pages, docs: Update knots links
69207de2
appview/pages, docs: Update spindle links
ff1993a3
appview/pages: Remove links from dropdown
09cebe3c
appview/state: Remove Redirects
8df0b723
appview/{pages,knots}: Update knots page to be more settings like
efee07c6
appview/{pages,spindle}: Update knots page to be more settings like
8ccee251
appview/{knots,settings,spindle}: Added icons for knots & spindle
eee39bb4
appview/{knots,pages,state}: formating
expand 3 comments

Resubmitted to format the code properly!

Generally lgtm! Can you squash the commits into single commit?

nvm I'll merge this PR and squash manually. Thank you for your contribution!

pull request successfully merged
8 commits
expand
d0c19d4c
appview/state: Moved /knots & /spindle to /settings
572cf29a
appview/pages, docs: Update knots links
1e0f64f1
appview/pages, docs: Update spindle links
4d0f3209
appview/pages: Remove links from dropdown
cc9f5e64
appview/state: Remove Redirects
3a38512d
appview/{pages,knots}: Update knots page to be more settings like
37debd08
appview/{pages,spindle}: Update knots page to be more settings like
6206b22b
appview/{knots,settings,spindle}: Added icons for knots & spindle
expand 1 comment

Hello there, finally could resubmit my patch (as i couldn't do that for some reason), so to update on what i updated:

  • Moved the knots & spindle pages to the settings page
    • I know that i currently have duplicated information, for the icons to be showed, but i have no clue on how to share that information (i still don't know go very much)
    • I tried making the knots & spindle pages fit in, but i have no idea if that's good enough or not
  • Removed the knots & spindle shortcuts from the user dropdown
    • Did not add them on the repo create page & spindle pages, as i don't really know how you'd like them to be set as

And i think that's about it! I may have forgotten a bit of what i did, as it's now been a while since i wrote all the stuff for the patch, as i couldn't resubmit, but i think i touched on all main points.

3 commits
expand
6ccadcfa
appview/state: Moved /knots & /spindle to /settings
c021c3c5
appview/pages, docs: Update knots links
6d7337ce
appview/pages, docs: Update spindle links
expand 3 comments

thanks for the contribution! some high level thoughts on this work:

  • the original intent of the issue (it is not the clearest about this unfortunately) is to move the knots and spindles pages to be new tabs under the settings page
  • the code here seems to move the routers, which is a good chunk of this work, we also want to make UI changes here to completely move the pages
  • i personally do not think the redirect is necessary, we can move the router directly under settings, without using a redirect

For the second point, does it mean that the links from the user submenu (when you click on your account in the topbar) will be removed, or will stay?

yes, we will remove the links from there. other areas of the UI can be later improved to indicate the existence of selfhosting (the new repo page can contain a link to selfhosted knots, the pipelienes page can have a link to spindles and selfhosting docs etc.)