fix: bad ux
This commit is contained in:
parent
a70ed5a372
commit
5a425b8c60
15 changed files with 791 additions and 463 deletions
67
internal/ui/pages/domaindetails/model.go
Normal file
67
internal/ui/pages/domaindetails/model.go
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
package domaindetails
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.juancwu.dev/juancwu/porkbacon/internal/porkbun"
|
||||
"git.juancwu.dev/juancwu/porkbacon/internal/ui/messages"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
domain *porkbun.Domain
|
||||
}
|
||||
|
||||
func New() Model {
|
||||
return Model{}
|
||||
}
|
||||
|
||||
func (m Model) Init() tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case messages.DomainSelectedMsg:
|
||||
m.domain = msg.Domain
|
||||
case tea.KeyMsg:
|
||||
if msg.String() == "esc" {
|
||||
return m, func() tea.Msg {
|
||||
return messages.SwitchPageMsg{Page: messages.PageDomainMenu}
|
||||
}
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m Model) View() string {
|
||||
if m.domain == nil {
|
||||
return "No domain selected"
|
||||
}
|
||||
return renderDomain(m.domain)
|
||||
}
|
||||
|
||||
func renderDomain(item *porkbun.Domain) string {
|
||||
var b strings.Builder
|
||||
b.WriteString(fmt.Sprintf("Domain Details: %s\n\n", item.Domain))
|
||||
b.WriteString("Status: " + item.Status + "\n")
|
||||
b.WriteString("Create Date: " + item.CreateDate + "\n")
|
||||
b.WriteString("Expire Date: " + item.ExpireDate + "\n")
|
||||
b.WriteString(fmt.Sprintln("Security Lock:", item.SecurityLock))
|
||||
b.WriteString(fmt.Sprintln("Whois Privacy:", item.WhoIsPrivacy))
|
||||
b.WriteString(fmt.Sprintln("Auto Renew:", item.AutoRenew))
|
||||
b.WriteString(fmt.Sprintln("Not Local:", item.NotLocal))
|
||||
if len(item.Labels) > 0 {
|
||||
b.WriteString("Labels:\n")
|
||||
}
|
||||
for i, label := range item.Labels {
|
||||
b.WriteString("=> " + label.Title)
|
||||
if i < len(item.Labels)-1 {
|
||||
b.WriteString("\n")
|
||||
}
|
||||
}
|
||||
|
||||
b.WriteString("\n\n(Press Esc to go back)")
|
||||
return b.String()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue