gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain0f6d1592Merge branch 'f18b-shell-session' into mainIdentmain/components/identitylist.hl

3.6 KB

  1. // components/identitylist.hl — THE ACCOUNT'S IDENTITIES (ident#40.3), placed by components/home.hl on `/`: the list with "Used in…", Edit
  2. // and Delete, and the New identity button. The host passes in the rows (identities, lib/identities.hl identityRows). This component owns
  3. // the delete (face dropIdentity); the form is the host's other component (identityform.hl), so New and Edit go up:
  4. // $parent.openNew() and $parent.openEdit(id). The host shows the messages: $parent.status(message, notice), and takes the new rows with
  5. // $parent.identitiesDeleted(rows, id).
  6. import { accountOfSession } from '../lib/accounts.hl'
  7. import { identityRows, deleteIdentity } from '../lib/identities.hl'
  8. import { avatarLook, chipLook } from './styles.hl'
  9. identities = []
  10. // 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)
  11. Style {
  12. identityMain {
  13. flex = '1 1 12rem'
  14. display = 'flex'
  15. flexWrap = 'wrap'
  16. alignItems = 'baseline'
  17. gap = '.2rem .5rem'
  18. minWidth = '0'
  19. }
  20. identityLabel {
  21. fontWeight = '700'
  22. color = 'var(--color-text-strong)'
  23. overflowWrap = 'anywhere'
  24. }
  25. identityShortId {
  26. fontFamily = 'ui-monospace, monospace'
  27. fontSize = '.875rem'
  28. color = 'var(--color-text-muted)'
  29. letterSpacing = '.08em'
  30. userSelect = 'all'
  31. }
  32. defaultBadge {
  33. padding = '0 .5rem'
  34. fontSize = '.875rem'
  35. fontWeight = '700'
  36. color = 'var(--color-accent-text)'
  37. background = 'var(--color-accent)'
  38. borderRadius = 'var(--radius-small)'
  39. }
  40. identityDetails {
  41. flexBasis = '100%'
  42. color = 'var(--color-text-muted)'
  43. fontSize = '.875rem'
  44. overflowWrap = 'anywhere'
  45. }
  46. identityActions {
  47. display = 'flex'
  48. flexWrap = 'wrap'
  49. gap = '.4rem'
  50. }
  51. pAvatar = avatarLook
  52. pChip = chipLook
  53. '#identities img' {
  54. width = '32px'
  55. height = '32px'
  56. }
  57. }
  58. View {
  59. section { id = "identitiessection"
  60. sectionHead {
  61. h1 { "Your identities" }
  62. button { id = "newidentity" type = "button" class = "small" "New identity" on click(e) { $parent.openNew() } }
  63. }
  64. ul { id = "identities"
  65. for (row of identities) {
  66. li {
  67. if (row.hasAvatar) { img { Style.pAvatar src = row.avatar alt = "" width = "32" height = "32" } }
  68. identityMain {
  69. identityLabel { row.label }
  70. identityShortId { row.shortId }
  71. if (row.isDefault) { defaultBadge { "default" } }
  72. identityDetails { row.details }
  73. }
  74. identityActions {
  75. a { Style.pChip href = row.usedHref "Used in…" }
  76. button { type = "button" class = "quiet small" name = "edit" value = row.id "Edit" on click(e) { $parent.openEdit(e.target.value) } }
  77. if (row.canDelete) { button { type = "button" class = "quiet small danger" name = "delete" value = row.id "Delete" on click(e) { emit remove(e.target.value) } } }
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84. rowOf = (id) => {
  85. for (row of identities) { if ('' + row.id == '' + id) { return row } }
  86. return null
  87. }
  88. on remove(id) {
  89. $parent.status('', '')
  90. row = rowOf(id)
  91. if (row == null) { return null }
  92. if (!confirm('Delete the identity “' + row.label + '”?')) { return null }
  93. r = emit server dropIdentity('' + id)
  94. if (r == null) {
  95. $parent.status('the server did not answer — try again', '')
  96. return null
  97. }
  98. if (r.error != null) {
  99. $parent.status(r.error, '')
  100. return null
  101. }
  102. $parent.identitiesDeleted(r.identities, '' + id)
  103. }
  104. on server dropIdentity(id, session) {
  105. let me = accountOfSession(&session)
  106. if (me == null) { return { error = 'you are not signed in' } }
  107. r = deleteIdentity(me.id, id)
  108. if (r.error != null) { return r }
  109. return { deleted = r.deleted identities = identityRows(me.id) }
  110. }

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