More work

This commit is contained in:
2026-02-18 19:08:29 -06:00
parent 009d5701d2
commit 4066197ec1
3 changed files with 57 additions and 21 deletions

View File

@@ -421,7 +421,12 @@ func (s *ScreenHome) cliSendStatus(args ...string) bool {
}
func (s *ScreenHome) updatePdsListing() {
s.pdsListing.SetTitle(fmt.Sprintf("─ %s (%s)", s.activePds.AtId.String(), s.activePds.Did.String()))
isAuth := s.r.Auth.HasAuth(s.activePds.Did)
auth := '🔒'
if isAuth {
auth = '🔓'
}
s.pdsListing.SetTitle(fmt.Sprintf("%c %s (%s)", auth, s.activePds.AtId.String(), s.activePds.Did.String()))
s.pdsListing.Clear()
nsidList := s.activePds.NSIDStringList()
var tree []*wd.TreeNode
@@ -472,6 +477,15 @@ func (s *ScreenHome) selectPdsListingEntry(tn *wd.TreeNode) bool {
}
func (s *ScreenHome) changePdsList(tn *wd.TreeNode) bool {
auth := s.r.Auth.HasAuth(s.activePds.Did)
if auth {
if tn.Depth() == 0 {
s.pdsListing.SetHintText("(A)dd New Record")
} else {
s.pdsListing.SetHintText("(A)dd New Record; (D)elete Record")
}
}
upd := s.updateJsonView(tn)
upd = s.updateStatusPathBlock(tn)
return upd
@@ -483,6 +497,7 @@ func (s *ScreenHome) updateStatusPathBlock(tn *wd.TreeNode) bool {
func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
// TODO: Update JSON View
auth := s.r.Auth.HasAuth(s.activePds.Did)
if tn.Depth() == 0 {
nsid, err := syntax.ParseNSID(tn.Value())
if err != nil {
@@ -491,9 +506,13 @@ func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
}
recordIds := s.activePds.GetRecordIdsFor(nsid)
s.jsonContent.SetValue(recordIds)
s.jsonContent.SetEditable(false)
// We don't set the jsonContent to editable, but allow creation of
// new objects
return true
} else {
s.jsonContent.SetValue(s.activePds.Records[tn.Value()])
s.jsonContent.SetEditable(auth)
}
return true
}
@@ -593,32 +612,34 @@ func (s *ScreenHome) deleteCurrentRecord() bool {
if len(tnPath) != 2 {
return false
}
//tnLabelPath := tn.GetLabelPath()
tnLabelPath := tn.GetLabelPath()
nsid, err := syntax.ParseNSID(tnPath[0])
if err != nil {
s.Log("error parsing NSID from %s: %w", tnPath[0], err)
return false
}
rkey := tnPath[1]
if err := s.r.DeleteRecord(s.activePds.Did, nsid, rkey); err != nil {
s.Log("error deleting record: %w", err)
}
/*
s.alert.SetTitle("Confirm Deletion")
s.alert.SetMessage(fmt.Sprintf("Are you sure you want to delete this record?\n%s %s\nThis cannot be undone.", tnLabelPath[0], tnLabelPath[1]))
s.alert.SetVisible(true)
s.alert.SetActive(true)
s.alert.SetOkPressed(func() bool {
s.r.DeleteRecord(s.activePds.Did, nsid, rkey)
s.alert.SetVisible(false)
s.alert.SetActive(false)
return true
})
s.alert.SetCancelPressed(func() bool {
s.alert.SetVisible(false)
s.alert.SetActive(false)
return true
})
if err := s.r.DeleteRecord(s.activePds.Did, nsid, rkey); err != nil {
s.Log("error deleting record: %w", err)
}
*/
s.alert.SetTitle("Confirm Deletion")
s.alert.SetMessage(fmt.Sprintf("Are you sure you want to delete this record?\n%s: %s\nThis cannot be undone.", tnLabelPath[0], tnLabelPath[1]))
s.alert.SetVisible(true)
s.alert.SetActive(true)
s.alert.SetOkPressed(func() bool {
s.r.DeleteRecord(s.activePds.Did, nsid, rkey)
s.alert.SetVisible(false)
s.alert.SetActive(false)
return true
})
s.alert.SetCancelPressed(func() bool {
s.alert.SetVisible(false)
s.alert.SetActive(false)
return true
})
s.alert.SetPos(w.Coord{X: s.w / 4, Y: s.h / 4})
s.alert.HandleResize(w.Coord{X: s.w / 4, Y: s.h / 4}.ResizeEvent())
return true
}