ident
All repositories: gitoria
3.6 KB
// components/identitylist.hl — THE ACCOUNT'S IDENTITIES (ident#40.3), placed by components/home.hl on `/`: the list with "Used in…", Edit// and Delete, and the New identity button. The host passes in the rows (identities, lib/identities.hl identityRows). This component owns// the delete (face dropIdentity); the form is the host's other component (identityform.hl), so New and Edit go up:// $parent.openNew() and $parent.openEdit(id). The host shows the messages: $parent.status(message, notice), and takes the new rows with// $parent.identitiesDeleted(rows, id).import { accountOfSession } from '../lib/accounts.hl'import { identityRows, deleteIdentity } from '../lib/identities.hl'import { avatarLook, chipLook } from './styles.hl'identities = []// the identity row's parts: also used by the app's identity choice (chooseidentity.hl, embed.hl), the identity page (identity.hl) and, for identityActions, the apps list (apps.hl)Style {identityMain {flex = '1 1 12rem'display = 'flex'flexWrap = 'wrap'alignItems = 'baseline'gap = '.2rem .5rem'minWidth = '0'}identityLabel {fontWeight = '700'color = 'var(--color-text-strong)'overflowWrap = 'anywhere'}identityShortId {fontFamily = 'ui-monospace, monospace'fontSize = '.875rem'color = 'var(--color-text-muted)'letterSpacing = '.08em'userSelect = 'all'}defaultBadge {padding = '0 .5rem'fontSize = '.875rem'fontWeight = '700'color = 'var(--color-accent-text)'background = 'var(--color-accent)'borderRadius = 'var(--radius-small)'}identityDetails {flexBasis = '100%'color = 'var(--color-text-muted)'fontSize = '.875rem'overflowWrap = 'anywhere'}identityActions {display = 'flex'flexWrap = 'wrap'gap = '.4rem'}pAvatar = avatarLookpChip = chipLook'#identities img' {width = '32px'height = '32px'}}View {section { id = "identitiessection"sectionHead {h1 { "Your identities" }button { id = "newidentity" type = "button" class = "small" "New identity" on click(e) { $parent.openNew() } }}ul { id = "identities"for (row of identities) {li {if (row.hasAvatar) { img { Style.pAvatar src = row.avatar alt = "" width = "32" height = "32" } }identityMain {identityLabel { row.label }identityShortId { row.shortId }if (row.isDefault) { defaultBadge { "default" } }identityDetails { row.details }}identityActions {a { Style.pChip href = row.usedHref "Used in…" }button { type = "button" class = "quiet small" name = "edit" value = row.id "Edit" on click(e) { $parent.openEdit(e.target.value) } }if (row.canDelete) { button { type = "button" class = "quiet small danger" name = "delete" value = row.id "Delete" on click(e) { emit remove(e.target.value) } } }}}}}}}rowOf = (id) => {for (row of identities) { if ('' + row.id == '' + id) { return row } }return null}on remove(id) {$parent.status('', '')row = rowOf(id)if (row == null) { return null }if (!confirm('Delete the identity “' + row.label + '”?')) { return null }r = emit server dropIdentity('' + id)if (r == null) {$parent.status('the server did not answer — try again', '')return null}if (r.error != null) {$parent.status(r.error, '')return null}$parent.identitiesDeleted(r.identities, '' + id)}on server dropIdentity(id, session) {let me = accountOfSession(&session)if (me == null) { return { error = 'you are not signed in' } }r = deleteIdentity(me.id, id)if (r.error != null) { return r }return { deleted = r.deleted identities = identityRows(me.id) }}
Branches
Latest commits
- e56d8273|||PR ident#34 part 4: access and inbox fixed classesmre
- df7696dbident#34: tests: access ticks selector quoting fixmre
- 7215903eident#34: access: the unstyled classes all, app, tick, apptick, plus are dropped; the gate finds the app ticks by input[name=app]mre
- 69b0a0ceident#34: access: the pick buttons use Style.pickCard instead of class pickmre
- dc702419Merge branch 'f9-choose' into mainIdent
- 8caec771|||PR ident#34 restore .choose hookmre
- 0dbff960Merge branch 'f8-shared' into mainIdent
- d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
- 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
- eb039073ident#34: tests: signin and migration find the choice without the classmre
- 4b94a594ident#34: tests: fix selector of the identity choicemre
- bebc88e4ident#34: main.hl drops the unstyled classes inboxlink and whomre
- b4e7ad04ident#34: the identity choice link/button has no class (rule on #chooselist a)mre
- 3c33d6eaident#34: the connection link in inbox has no class (rule on #conns a)mre
- dc97ec0dident#34: the Notif. chip and the Used in link share chipLook (Style.pChip) instead of the classes chip/used/notifmre
- 378bd432ident#34: the identity picture look is a static in styles.hl (Style.pAvatar); sizes stay with each listmre
- 1cf79e7eident#34: the wide page column is a static in styles.hl (Style.pWide), not the class "wide"mre
- ddc7d135Merge branch 'f7-hooks' into mainIdent
- eee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmre
- ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre