gitoria
All repositories: gitoria
7.6 KB
// components/settings.hl — THE SETTINGS of a repo (gitoria#18): `/settings` on <slug>.<domain>. For now one section,// "Tickets": connect the repo to a tickets.worldapi.org project (the owner clicks "Tickets: connect", tickets asks which// project, and brings them back — lib/api.hl /settings/connect and /settings/connected; lib/tickets.hl). Anyone sees// whether the repo is connected; only the owner sees the buttons. Rendered on the server from the request's host.// (The main branch is switched on the code page.)parent './repo.hl'import { siteName } from '../project.hl'import { slugOfRequest } from '../lib/orgs.hl'import { userOfSession, userIdOfSession } from '../lib/users.hl'import { titleSlug, repoAt, ownsRepo, setTicketsConnection, setRepoPriv, membersOf, changeMember } from '../lib/repos.hl'import { px } from '../lib/util.hl'import { pageTitle } from '../lib/repos-helpers.hl'import { ticketsUrl } from '../lib/tickets-helpers.hl'host = nullorepo = ''session = nullslug = slugOfRequest(host, orepo)repo = repoAt(slug, session)hasRepo = repo != nullpre = px(slug)connectHref = pre + '/settings/connect'isOwner = repo != null && ownsRepo(slug, session)connected = repo != null && repo.ticketsOnnotConnected = repo != null && !repo.ticketsOnprojectTitle = repo != null ? repo.ticketsTitle : ''projectHref = repo != null && repo.ticketsOn ? ticketsUrl + '/projects/' + repo.ticketsProject : ''connectNote = session != null && session.data != null && session.data.connectNote != null ? session.data.connectNote : ''hasConnectNote = connectNote != ''notOwnerHint = repo != null && !isOwnersettingsError = ''forgetClass = repo != null && repo.ticketsOn ? 'quiet' : 'nomerge'__title = pageTitle(siteName, titleSlug(host, orepo, session), 'Settings')// VISIBILITY AND MEMBERS (GO34): the owner makes the repo private / public and keeps the member list (people who see a private repo and may push)isPrivate = repo != null && repo.isPrivateownPriv = repo != null && repo.isPrivate && !repo.inOrgprivText = repo == null ? '' : (repo.isPrivate ? 'This repository is private: only its owner and its members can see it.' : 'This repository is public: everybody can read it.')privButton = repo != null && repo.isPrivate ? 'Make public' : 'Make private'listed = isOwner ? membersOf('r', slug, userIdOfSession(session)) : nullmembers = listed != null && listed.members != null ? listed.members : []noMembers = isOwner && members.length == 0memberName = ''memberError = ''View {repoPage {if (hasRepo) {repoSettings { id = "settings"section { id = "visibility"h2 { "Visibility" }p { id = "privtext" privText }if (isOwner) { button { id = "togglepriv" type = "button" privButton on click(e) { emit togglePriv() } } }if (isOwner) {h2 { "Members" }p { class = "muted" "Members see this repository even when it is private, and may push to it. Add somebody by the display name they chose." }if (noMembers) { p { id = "nomembers" class = "empty" "No members yet." } }ul { id = "members"for (m of members) {li { span { class = "slug" m.name } button { class = "quiet" type = "button" "Remove" on click(e) { emit removeMember(m.name) } } }}}form { id = "memberform"on submit(e) {e.preventDefault()emit addMember(e)}label { "Display name"input { id = "membername" name = "membername" required = "required" maxlength = "60" autocomplete = "off" }}button { id = "memberadd" type = "submit" "Add member" }p { id = "membererror" class = "message" memberError }}}}section { id = "ticketsettings"h2 { "Tickets" }if (hasConnectNote) { p { id = "connectnote" class = "message" connectNote } }if (connected) {p { id = "connectedto" "Connected to the tickets project " a { id = "projectlink" href = projectHref projectTitle } "." }}if (notConnected) { p { id = "notconnected" class = "muted" "This repository is not connected to a tickets project yet." } }if (isOwner) {p {a { id = "connecttickets" class = "button" href = connectHref "Tickets: connect" }}button { id = "disconnecttickets" class = forgetClass type = "button" "Forget the connection" on click(e) { emit disconnect() } }p { class = "muted" "Connecting asks tickets which project (you must be its admin there). Tickets can also disconnect gitoria from its side." }}if (notOwnerHint) { p { id = "ownerhint" class = "muted" "Only the owner of this repository can connect it." } }p { id = "settingserror" class = "message" settingsError }}}}}}on togglePriv() {memberError = ''r = emit server gitoriaSetPrivate(slug, !isPrivate)if (r == null || r.error != null) {memberError = r != null ? r.error : 'could not change the visibility'return null}isPrivate = r.repo.isPrivateprivText = isPrivate ? 'This repository is private: only its owner and its members can see it.' : 'This repository is public: everybody can read it.'privButton = isPrivate ? 'Make public' : 'Make private'}on addMember(e) {memberError = ''r = emit server gitoriaChangeMember(slug, e.target.elements.membername.value, true)if (r == null || r.error != null) {memberError = r != null ? r.error : 'could not add the member'return null}members = r.membersnoMembers = members.length == 0e.target.elements.membername.value = ''}on removeMember(name) {memberError = ''r = emit server gitoriaChangeMember(slug, name, false)if (r == null || r.error != null) {memberError = r != null ? r.error : 'could not remove the member'return null}members = r.membersnoMembers = members.length == 0}on server gitoriaSetPrivate(slugOf, priv, session) {return setRepoPriv(userIdOfSession(session), slugOf, priv)}on server gitoriaChangeMember(slugOf, name, add, session) {return changeMember(userIdOfSession(session), 'r', slugOf, name, add)}on disconnect() {settingsError = ''r = emit server gitoriaDisconnectTickets(slug)if (r == null || r.error != null) {settingsError = r != null ? r.error : 'could not disconnect'return null}connected = falsenotConnected = trueforgetClass = 'nomerge'projectTitle = ''projectHref = ''}on server gitoriaDisconnectTickets(slugOf, session) {if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not disconnect' } }if (userOfSession(session) == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can change this' } }r = setTicketsConnection(slugOf, '', '', '', '')if (r.error != null) { return { error = r.error } }return { ok = true }}Style {repoSettings {display = 'grid'gap = '1rem'minWidth = '0''> *' {margin = '0'}}#ticketsettings {display = 'grid'gap = '.75rem'justifyItems = 'start''> *' {margin = '0'}}'#disconnecttickets.nomerge' {display = 'none'}#connecttickets {color = 'var(--color-accent-text)'background = 'var(--color-accent)'}#members {listStyle = 'none'margin = '0'padding = '0'display = 'grid'gap = '.25rem'maxWidth = '32rem'li {display = 'flex'alignItems = 'center'justifyContent = 'space-between'gap = '.75rem'minHeight = '2.75rem'padding = '0 .5rem 0 1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}}#memberform {display = 'grid'gap = '.75rem'margin = '.75rem 0 1.5rem'maxWidth = '32rem'}#togglepriv {justifySelf = 'start'}#visibility {display = 'grid'gap = '.75rem'margin = '0 0 1.5rem'}}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 9364fb16gitoria#40: ssh pushes call /__git/pushed before and after (ensurePulls, notifyPush, syncPulls); gate over the sshd imagemre
- 2ef23df0gitoria#40: the browser gate reads the title without the #Nmre
- b9137ff0gitoria#40: pull requests are stored with a number, refs/pull/N/head, syncPulls and pullObject; /pulls shows #Nmre
- 06d622daown image tag gitoria-runtime:debian12 for gitoria and standby (shared tag lost git)mre
- 20caa33agitoria#37: media queries in the language's @media block (minWidth = '60rem') in list, codebrowser and repomre
- c4175e6dgitoria: a startup error prints its message before exit 1 (hybriel#247)mre
- c50d17efKeep function-route not-found style in shared stylesheetmre
- e42d78d3Preserve ticket state CSS and document function-route style gapmre
- c6b7154eWIP gitoria#26: move styles into nested component blocksmre
- 77a2c31cgitoria#31: plain declarations instead of needless let in lib/ and tools/ (103 let removed, 137 kept because reassigned); no other changemre
- 4b98ab62gitoria: an ident access key (idt_) works as the git password; read key clones only, bad key 401, ident down 503 (ident#27); gate tests/ident-access-gitoria.mjs in deploy.shmre
- 1185f686gitoria#36: a failed return from tickets shows a note on the settings page and leaves one log line per outcome; no code is exchangedmre
- 5d2c385agitoria: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 71+5 failing → 76 passed; deploy.sh runs tests/private.mjs toomre
- 241ef3f9deploy.sh: rebuild the sshd image before up -d (GO34c)mre
- 821cdbb1gitoria#34b: styles, create-repo tool, docs, push/ssh gates sign in through the selector, shots scriptmre
- a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
- 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
- 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
- 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
- a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre