gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf2d9f79ff2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemref2d9f79f/components/identitylist.hl

3.7 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. identities = []
  9. // 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)
  10. Style {
  11. identityMain {
  12. flex = '1 1 12rem'
  13. display = 'flex'
  14. flexWrap = 'wrap'
  15. alignItems = 'baseline'
  16. gap = '.2rem .5rem'
  17. minWidth = '0'
  18. }
  19. identityLabel {
  20. fontWeight = '700'
  21. color = 'var(--color-text-strong)'
  22. overflowWrap = 'anywhere'
  23. }
  24. identityShortId {
  25. fontFamily = 'ui-monospace, monospace'
  26. fontSize = '.875rem'
  27. color = 'var(--color-text-muted)'
  28. letterSpacing = '.08em'
  29. userSelect = 'all'
  30. }
  31. defaultBadge {
  32. padding = '0 .5rem'
  33. fontSize = '.875rem'
  34. fontWeight = '700'
  35. color = 'var(--color-accent-text)'
  36. background = 'var(--color-accent)'
  37. borderRadius = 'var(--radius-small)'
  38. }
  39. identityDetails {
  40. flexBasis = '100%'
  41. color = 'var(--color-text-muted)'
  42. fontSize = '.875rem'
  43. overflowWrap = 'anywhere'
  44. }
  45. identityActions {
  46. display = 'flex'
  47. flexWrap = 'wrap'
  48. gap = '.4rem'
  49. }
  50. // the avatar is a class the data chooses (a row has one only with a picture): quoted
  51. '#identities img.avatar, #chooselist img.avatar' {
  52. flex = '0 0 auto'
  53. width = '32px'
  54. height = '32px'
  55. objectFit = 'cover'
  56. borderRadius = '50%'
  57. background = 'var(--color-background-sunken)'
  58. }
  59. }
  60. View {
  61. section { id = "identitiessection"
  62. sectionHead {
  63. h1 { "Your identities" }
  64. button { id = "newidentity" type = "button" class = "small" "New identity" on click(e) { $parent.openNew() } }
  65. }
  66. ul { id = "identities"
  67. for (row of identities) {
  68. li { class = "identity"
  69. if (row.hasAvatar) { img { class = "avatar" src = row.avatar alt = "" width = "32" height = "32" } }
  70. identityMain {
  71. identityLabel { row.label }
  72. identityShortId { class = "shortid" row.shortId }
  73. if (row.isDefault) { defaultBadge { "default" } }
  74. identityDetails { row.details }
  75. }
  76. identityActions {
  77. a { class = "used" href = row.usedHref "Used in…" }
  78. button { type = "button" class = "quiet small edit" value = row.id "Edit" on click(e) { $parent.openEdit(e.target.value) } }
  79. if (row.canDelete) { button { type = "button" class = "quiet small danger delete" value = row.id "Delete" on click(e) { emit remove(e.target.value) } } }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. rowOf = (id) => {
  87. for (row of identities) { if ('' + row.id == '' + id) { return row } }
  88. return null
  89. }
  90. on remove(id) {
  91. $parent.status('', '')
  92. row = rowOf(id)
  93. if (row == null) { return null }
  94. if (!confirm('Delete the identity “' + row.label + '”?')) { return null }
  95. r = emit server dropIdentity('' + id)
  96. if (r == null) {
  97. $parent.status('the server did not answer — try again', '')
  98. return null
  99. }
  100. if (r.error != null) {
  101. $parent.status(r.error, '')
  102. return null
  103. }
  104. $parent.identitiesDeleted(r.identities, '' + id)
  105. }
  106. on server dropIdentity(id, session) {
  107. let me = accountOfSession(&session)
  108. if (me == null) { return { error = 'you are not signed in' } }
  109. r = deleteIdentity(me.id, id)
  110. if (r.error != null) { return r }
  111. return { deleted = r.deleted identities = identityRows(me.id) }
  112. }

Branches

Latest commits

  • f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
  • 8370b748ident#33: the app request box moves into home.hl's Stylemre
  • 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
  • 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
  • d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
  • ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre
  • 47e516afident#33 ident#34: the identity form's avatar rules move into identityform.hl; the preview and Remove button are hidden with the hidden attribute instead of built class strings (avatarPreviewClass, avatarRemoveClass gone)mre
  • 5cb5cf0eident#33: the code field's look moves into codestep.hl's Stylemre
  • f421cd60ident#33: the shell's own rules (user menu address, offline note, network probe) move into main.hl's Stylemre
  • c512fb96Merge branch 'f4-homesplit' into mainIdent
  • 07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre
  • 59e8fcc1ident#40.3: the app's identity choice is one component (components/chooseidentity.hl); its face chooseIdentity moves with itmre
  • e23efdfcident#40.3: the identity list is one component (components/identitylist.hl); its delete and face dropIdentity move with itmre
  • e24b59a6ident#40.3: the time zone is one component (components/timezone.hl); its face changeTimeZone moves with itmre
  • 8cbc5717ident#40.3: the email step is one component (components/emailstep.hl) placed by home.hl and embed.hlmre
  • 6fad3bd2Merge branch 'f3-codestep' into mainIdent
  • 51e387f2|||PR ident#40 the code step is one component (components/codestep.hl) placed by home.hl and embed.hl; its verify face, setCode, browserZone and verify call exist once (#40.2)mre
  • c28bddeeMerge branch 'f2-shell' into mainIdent
  • c3a40ff6|||PR ident#40 one shell for the app and /start (account part off on /start, #40.1); startshell.hl removed; unused signOut faces gone (#40.4)mre
  • 060f3870ident#40.4: use the shell sign-out faces in regression gatesmre