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
- 0f6d1592Merge branch 'f18b-shell-session' into mainIdent
- 19868218|||PR ident#39 shell reads its session member instead of a cross-file emitmre
- 5d1b3fedMerge branch 'v61-day61' into mainIdent
- 83faeb15|||PR ident: vendor Hybriel day61mre
- b2572b34Merge branch 'v59-day59' into mainIdent
- 67cf016d|||PR ident: vendor Hybriel day59mre
- 600c043dMerge branch 'v58-day58' into mainIdent
- 365f8c80|||PR ident: vendor Hybriel day58mre
- 585126e5Merge branch 'f16-setf' into mainIdent
- 953bf03a|||PR ident setF mirror dropped (hybriel#370)mre
- a1419d9cMerge branch 'f15-navigate' into mainIdent
- 3b3e451f|||PR ident#36 navigate to the app instead of location.assignmre
- e36f4516Merge branch 'f14-online' into mainIdent
- 2c5eac91|||PR ident#38 online state without probe timermre
- bf1980f2Merge branch 'v56-day56' into mainIdent
- 62ae0adf|||PR ident: vendor Hybriel day56mre
- 0d18abc4Merge branch 'f13-avatar' into mainIdent
- 2a99730a|||PR ident#37 avatar in hlmre
- fa4ed25bMerge branch 'f11-upsert' into mainIdent
- 8f3d9bc9|||PR ident#42 keyed upsert and removemre