add:partial functionality
This commit is contained in:
13
internal/pages/file_action.go
Normal file
13
internal/pages/file_action.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package pages
|
||||
|
||||
type FileActionPageMsg struct {
|
||||
ServerName string
|
||||
Filename string
|
||||
}
|
||||
|
||||
func FileActionItems() []MenuItem {
|
||||
return []MenuItem{
|
||||
{Label: "Get", Key: "get"},
|
||||
{Label: "Delete", Key: "delete"},
|
||||
}
|
||||
}
|
||||
13
internal/pages/server_actions.go
Normal file
13
internal/pages/server_actions.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package pages
|
||||
|
||||
type ServerActionsPageMsg struct {
|
||||
ServerName string
|
||||
}
|
||||
|
||||
func ServerActionItems() []MenuItem {
|
||||
return []MenuItem{
|
||||
{Label: "Send", Key: "send"},
|
||||
{Label: "Get", Key: "get"},
|
||||
{Label: "Clean", Key: "clean"},
|
||||
}
|
||||
}
|
||||
53
internal/services/commands.go
Normal file
53
internal/services/commands.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
const defaultPort = "22"
|
||||
const defaultStoragePath = "~/.filepass_storage"
|
||||
|
||||
func serverPort(s Server) string {
|
||||
if s.Port == "" {
|
||||
return defaultPort
|
||||
}
|
||||
return s.Port
|
||||
}
|
||||
|
||||
// SSHCmd returns an exec.Cmd for running a single command on the server.
|
||||
func SSHCmd(s Server, remoteCmd string) *exec.Cmd {
|
||||
return exec.Command(
|
||||
"ssh",
|
||||
"-i", s.PrivateKey,
|
||||
"-p", serverPort(s),
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "BatchMode=yes",
|
||||
s.User+"@"+s.Host,
|
||||
remoteCmd,
|
||||
)
|
||||
}
|
||||
|
||||
// RsyncCmd returns an exec.Cmd for an rsync transfer.
|
||||
// src and dst follow standard rsync syntax (local path or user@host:path).
|
||||
func RsyncCmd(s Server, src, dst string) *exec.Cmd {
|
||||
sshFlag := "ssh -i " + s.PrivateKey + " -p " + serverPort(s) +
|
||||
" -o StrictHostKeyChecking=no -o BatchMode=yes"
|
||||
return exec.Command(
|
||||
"rsync",
|
||||
"-avz",
|
||||
"--partial",
|
||||
"-e", sshFlag,
|
||||
src,
|
||||
dst,
|
||||
)
|
||||
}
|
||||
|
||||
// RemotePath returns the full remote path for a filename inside storage.
|
||||
func RemotePath(s Server, filename string) string {
|
||||
return s.User + "@" + s.Host + ":" + defaultStoragePath + "/" + filename
|
||||
}
|
||||
|
||||
// RemoteStorageRoot returns the remote storage root for rsync operations.
|
||||
func RemoteStorageRoot(s Server) string {
|
||||
return s.User + "@" + s.Host + ":" + defaultStoragePath + "/"
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package services
|
||||
|
||||
import "fmt"
|
||||
|
||||
type ServicesStore struct {
|
||||
Config *ConfigService
|
||||
}
|
||||
@@ -11,3 +13,11 @@ func NewServicesStore() (*ServicesStore, error) {
|
||||
}
|
||||
return &ServicesStore{Config: cfg}, nil
|
||||
}
|
||||
|
||||
func (s *ServicesStore) NewStorageService(serverName string) (*StorageService, error) {
|
||||
srv, ok := s.Config.servers[serverName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("server %q not found", serverName)
|
||||
}
|
||||
return NewStorageService(srv), nil
|
||||
}
|
||||
|
||||
52
internal/services/storage.go
Normal file
52
internal/services/storage.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// StorageService executes file operations against a single server's storage.
|
||||
type StorageService struct {
|
||||
server Server
|
||||
}
|
||||
|
||||
func NewStorageService(s Server) *StorageService {
|
||||
return &StorageService{server: s}
|
||||
}
|
||||
|
||||
// Check returns the list of files currently in the remote storage directory.
|
||||
func (s *StorageService) Check() ([]string, error) {
|
||||
cmd := SSHCmd(s.server,
|
||||
"find "+defaultStoragePath+" -type f -printf '%f\n' 2>/dev/null",
|
||||
)
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("check failed: %w", err)
|
||||
}
|
||||
raw := strings.TrimSpace(string(out))
|
||||
if raw == "" {
|
||||
return []string{}, nil
|
||||
}
|
||||
return strings.Split(raw, "\n"), nil
|
||||
}
|
||||
|
||||
// Send transfers one or more local files to the remote storage.
|
||||
// Multiple files are archived into a temp tarball first.
|
||||
func (s *StorageService) Send(localPaths []string) error {
|
||||
// TODO: implement
|
||||
return fmt.Errorf("send: not yet implemented")
|
||||
}
|
||||
|
||||
// Get downloads one or more files from remote storage to destDir.
|
||||
// Multiple files are archived server-side, transferred, then extracted.
|
||||
func (s *StorageService) Get(remoteFiles []string, destDir string) error {
|
||||
// TODO: implement
|
||||
return fmt.Errorf("get: not yet implemented")
|
||||
}
|
||||
|
||||
// Clean removes specific files from remote storage.
|
||||
// Pass a nil or empty slice to remove all files.
|
||||
func (s *StorageService) Clean(remoteFiles []string) error {
|
||||
// TODO: implement
|
||||
return fmt.Errorf("clean: not yet implemented")
|
||||
}
|
||||
@@ -117,6 +117,35 @@ var (
|
||||
serverRowNameActiveStyle = lipgloss.NewStyle().
|
||||
Bold(true).
|
||||
Foreground(lipgloss.Color("75"))
|
||||
|
||||
// Storage file list
|
||||
StorageFileSectionStyle = lipgloss.NewStyle().
|
||||
BorderTop(true).
|
||||
BorderStyle(lipgloss.NormalBorder()).
|
||||
BorderForeground(lipgloss.Color("237")).
|
||||
MarginTop(1).
|
||||
PaddingTop(1).
|
||||
Width(44)
|
||||
|
||||
StorageEmptyStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("243")).
|
||||
Italic(true)
|
||||
|
||||
fileItemInactive = lipgloss.NewStyle().
|
||||
PaddingLeft(4).
|
||||
Foreground(lipgloss.Color("252")).
|
||||
Width(44)
|
||||
|
||||
fileItemActive = lipgloss.NewStyle().
|
||||
PaddingLeft(2).
|
||||
Foreground(lipgloss.Color("75")).
|
||||
Bold(true).
|
||||
Width(44).
|
||||
SetString("▸ ")
|
||||
|
||||
FilenameLabelStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("243")).
|
||||
MarginBottom(1)
|
||||
)
|
||||
|
||||
func MenuItemStyle(active, disabled bool) lipgloss.Style {
|
||||
@@ -150,6 +179,14 @@ func ButtonStyle(focused, enabled bool) lipgloss.Style {
|
||||
}
|
||||
}
|
||||
|
||||
// FileItemStyle returns the style for a file list row.
|
||||
func FileItemStyle(active bool) lipgloss.Style {
|
||||
if active {
|
||||
return fileItemActive
|
||||
}
|
||||
return fileItemInactive
|
||||
}
|
||||
|
||||
// ServerRowStyle renders a single-line server list entry showing only the server name.
|
||||
func ServerRowStyle(active bool, name string) string {
|
||||
if active {
|
||||
|
||||
@@ -12,23 +12,34 @@ const (
|
||||
pageConfig
|
||||
pageAddServer
|
||||
pageSelectServer
|
||||
pageServerActions
|
||||
pageFileAction
|
||||
)
|
||||
|
||||
type TUIInterface struct {
|
||||
Services *services.ServicesStore
|
||||
Page page
|
||||
MenuItems []pages.MenuItem
|
||||
Selected int
|
||||
Servers map[string]services.Server
|
||||
ServerNames []string // sorted, stable order for list rendering
|
||||
NoServers bool
|
||||
InitErr error
|
||||
FlashMsg string
|
||||
Form addServerForm
|
||||
FormErr string // inline field error (e.g. duplicate name)
|
||||
Quitting bool
|
||||
WindowWidth int
|
||||
WindowHeight int
|
||||
Services *services.ServicesStore
|
||||
Page page
|
||||
MenuItems []pages.MenuItem
|
||||
Selected int
|
||||
Servers map[string]services.Server
|
||||
ServerNames []string // sorted, stable order for list rendering
|
||||
NoServers bool
|
||||
InitErr error
|
||||
FlashMsg string
|
||||
Form addServerForm
|
||||
FormErr string // inline field error (e.g. duplicate name)
|
||||
Quitting bool
|
||||
WindowWidth int
|
||||
WindowHeight int
|
||||
// server actions page
|
||||
ActiveServer string
|
||||
StorageFiles []string
|
||||
StorageLoading bool
|
||||
StorageErr error
|
||||
FileSelected int // cursor within StorageFiles
|
||||
FileFocused bool // true = ↑↓ drives file list, false = action menu
|
||||
// file action page
|
||||
ActiveFile string
|
||||
}
|
||||
|
||||
func NewTUIInterface(store *services.ServicesStore) TUIInterface {
|
||||
|
||||
@@ -23,6 +23,22 @@ type serverAddedMsg struct {
|
||||
|
||||
type clearFlashMsg struct{}
|
||||
|
||||
type storageFilesMsg struct {
|
||||
files []string
|
||||
err error
|
||||
}
|
||||
|
||||
func checkStorageCmd(store *services.ServicesStore, serverName string) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
storage, err := store.NewStorageService(serverName)
|
||||
if err != nil {
|
||||
return storageFilesMsg{err: err}
|
||||
}
|
||||
files, err := storage.Check()
|
||||
return storageFilesMsg{files: files, err: err}
|
||||
}
|
||||
}
|
||||
|
||||
func clearFlashAfter(d time.Duration) tea.Cmd {
|
||||
return tea.Tick(d, func(time.Time) tea.Msg {
|
||||
return clearFlashMsg{}
|
||||
@@ -82,6 +98,32 @@ func (m TUIInterface) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.Selected = 0
|
||||
return m, nil
|
||||
|
||||
case pages.ServerActionsPageMsg:
|
||||
m.Page = pageServerActions
|
||||
m.ActiveServer = msg.ServerName
|
||||
m.MenuItems = pages.ServerActionItems()
|
||||
m.Selected = 0
|
||||
m.FileSelected = 0
|
||||
m.FileFocused = false
|
||||
m.StorageFiles = nil
|
||||
m.StorageErr = nil
|
||||
m.StorageLoading = true
|
||||
return m, checkStorageCmd(m.Services, msg.ServerName)
|
||||
|
||||
case pages.FileActionPageMsg:
|
||||
m.Page = pageFileAction
|
||||
m.ActiveFile = msg.Filename
|
||||
m.MenuItems = pages.FileActionItems()
|
||||
m.Selected = 0
|
||||
return m, nil
|
||||
|
||||
case storageFilesMsg:
|
||||
m.StorageLoading = false
|
||||
m.StorageFiles = msg.files
|
||||
m.StorageErr = msg.err
|
||||
m.FileSelected = 0
|
||||
return m, nil
|
||||
|
||||
case configLoadedMsg:
|
||||
if msg.err != nil {
|
||||
m.InitErr = msg.err
|
||||
@@ -112,14 +154,18 @@ func (m TUIInterface) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
|
||||
case tea.KeyPressMsg:
|
||||
// add server form has its own key handling
|
||||
if m.Page == pageAddServer {
|
||||
return m.updateAddServer(msg)
|
||||
}
|
||||
// server list has its own key handling
|
||||
if m.Page == pageSelectServer {
|
||||
return m.updateSelectServer(msg)
|
||||
}
|
||||
if m.Page == pageServerActions {
|
||||
return m.updateServerActions(msg)
|
||||
}
|
||||
if m.Page == pageFileAction {
|
||||
return m.updateFileAction(msg)
|
||||
}
|
||||
|
||||
switch msg.String() {
|
||||
case "up", "k":
|
||||
@@ -169,6 +215,122 @@ func (m TUIInterface) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m TUIInterface) updateServerActions(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "tab":
|
||||
// toggle focus between action menu and file list
|
||||
if len(m.StorageFiles) > 0 {
|
||||
m.FileFocused = !m.FileFocused
|
||||
}
|
||||
|
||||
case "up", "k":
|
||||
if m.FileFocused {
|
||||
if m.FileSelected > 0 {
|
||||
m.FileSelected--
|
||||
}
|
||||
} else {
|
||||
if m.Selected > 0 {
|
||||
m.Selected--
|
||||
}
|
||||
}
|
||||
|
||||
case "down", "j":
|
||||
if m.FileFocused {
|
||||
if m.FileSelected < len(m.StorageFiles)-1 {
|
||||
m.FileSelected++
|
||||
}
|
||||
} else {
|
||||
if m.Selected < len(m.MenuItems)-1 {
|
||||
m.Selected++
|
||||
}
|
||||
}
|
||||
|
||||
case "enter":
|
||||
if m.FileFocused && len(m.StorageFiles) > 0 {
|
||||
file := m.StorageFiles[m.FileSelected]
|
||||
server := m.ActiveServer
|
||||
return m, func() tea.Msg {
|
||||
return pages.FileActionPageMsg{ServerName: server, Filename: file}
|
||||
}
|
||||
}
|
||||
switch m.MenuItems[m.Selected].Key {
|
||||
case "send":
|
||||
// TODO: navigate to send page
|
||||
case "get":
|
||||
// TODO: navigate to get page (bulk)
|
||||
case "clean":
|
||||
// TODO: navigate to clean page (bulk)
|
||||
}
|
||||
|
||||
case "ctrl+c":
|
||||
m.Quitting = true
|
||||
return m, tea.Quit
|
||||
|
||||
case "esc":
|
||||
return m, func() tea.Msg { return pages.SelectServerPageMsg{} }
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m TUIInterface) updateFileAction(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "up", "k":
|
||||
if m.Selected > 0 {
|
||||
m.Selected--
|
||||
}
|
||||
case "down", "j":
|
||||
if m.Selected < len(m.MenuItems)-1 {
|
||||
m.Selected++
|
||||
}
|
||||
case "enter":
|
||||
server := m.ActiveServer
|
||||
file := m.ActiveFile
|
||||
switch m.MenuItems[m.Selected].Key {
|
||||
case "get":
|
||||
_ = server
|
||||
_ = file
|
||||
// TODO: implement get
|
||||
case "delete":
|
||||
_ = server
|
||||
_ = file
|
||||
// TODO: implement delete
|
||||
}
|
||||
case "ctrl+c":
|
||||
m.Quitting = true
|
||||
return m, tea.Quit
|
||||
case "esc":
|
||||
server := m.ActiveServer
|
||||
return m, func() tea.Msg { return pages.ServerActionsPageMsg{ServerName: server} }
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m TUIInterface) updateSelectServer(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
last := len(m.ServerNames) - 1
|
||||
switch msg.String() {
|
||||
case "up", "k":
|
||||
if m.Selected > 0 {
|
||||
m.Selected--
|
||||
}
|
||||
case "down", "j":
|
||||
if m.Selected < last {
|
||||
m.Selected++
|
||||
}
|
||||
case "enter":
|
||||
if m.Selected >= 0 && m.Selected < len(m.ServerNames) {
|
||||
name := m.ServerNames[m.Selected]
|
||||
return m, func() tea.Msg { return pages.ServerActionsPageMsg{ServerName: name} }
|
||||
}
|
||||
case "ctrl+c":
|
||||
m.Quitting = true
|
||||
return m, tea.Quit
|
||||
case "esc":
|
||||
return m, func() tea.Msg { return pages.HomePageMsg{} }
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m TUIInterface) updateAddServer(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
f := m.Form
|
||||
|
||||
@@ -182,16 +344,13 @@ func (m TUIInterface) updateAddServer(msg tea.KeyPressMsg) (tea.Model, tea.Cmd)
|
||||
return m, nil
|
||||
|
||||
case "enter":
|
||||
// on an input field, advance to next
|
||||
if f.focused < fieldSave {
|
||||
m.Form = f.focusNext()
|
||||
return m, nil
|
||||
}
|
||||
// on save button
|
||||
if f.focused == fieldSave {
|
||||
return m.submitAddServer()
|
||||
}
|
||||
// on back button
|
||||
if f.focused == fieldBack {
|
||||
return m, func() tea.Msg { return pages.ConfigPageMsg{} }
|
||||
}
|
||||
@@ -201,7 +360,6 @@ func (m TUIInterface) updateAddServer(msg tea.KeyPressMsg) (tea.Model, tea.Cmd)
|
||||
return m, tea.Quit
|
||||
|
||||
case "ctrl+v":
|
||||
// OSC52 clipboard read; result arrives as tea.ClipboardMsg
|
||||
if f.focused < len(f.inputs) {
|
||||
return m, tea.ReadClipboard
|
||||
}
|
||||
@@ -211,11 +369,9 @@ func (m TUIInterface) updateAddServer(msg tea.KeyPressMsg) (tea.Model, tea.Cmd)
|
||||
return m, func() tea.Msg { return pages.ConfigPageMsg{} }
|
||||
}
|
||||
|
||||
// route keystrokes to the focused input
|
||||
if f.focused < len(f.inputs) {
|
||||
var cmd tea.Cmd
|
||||
f.inputs[f.focused], cmd = f.inputs[f.focused].Update(msg)
|
||||
// clear duplicate-name error when user edits the name field
|
||||
if f.focused == fieldName {
|
||||
m.FormErr = ""
|
||||
}
|
||||
@@ -240,28 +396,6 @@ func (m TUIInterface) updateAddServerPaste(text string) (tea.Model, tea.Cmd) {
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
func (m TUIInterface) updateSelectServer(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
last := len(m.ServerNames) - 1
|
||||
switch msg.String() {
|
||||
case "up", "k":
|
||||
if m.Selected > 0 {
|
||||
m.Selected--
|
||||
}
|
||||
case "down", "j":
|
||||
if m.Selected < last {
|
||||
m.Selected++
|
||||
}
|
||||
case "enter":
|
||||
// TODO: connect to selected server
|
||||
case "ctrl+c":
|
||||
m.Quitting = true
|
||||
return m, tea.Quit
|
||||
case "esc":
|
||||
return m, func() tea.Msg { return pages.HomePageMsg{} }
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m TUIInterface) submitAddServer() (tea.Model, tea.Cmd) {
|
||||
f := m.Form
|
||||
name := strings.TrimSpace(f.inputs[fieldName].Value())
|
||||
|
||||
@@ -25,6 +25,13 @@ func (m TUIInterface) subtitle() string {
|
||||
return "Add Server"
|
||||
case pageSelectServer:
|
||||
return "Select Server"
|
||||
case pageServerActions:
|
||||
if m.ActiveServer != "" {
|
||||
return m.ActiveServer
|
||||
}
|
||||
return "Server"
|
||||
case pageFileAction:
|
||||
return m.ActiveFile
|
||||
default:
|
||||
return "Secure file transfer"
|
||||
}
|
||||
@@ -50,6 +57,10 @@ func (m TUIInterface) View() tea.View {
|
||||
body = m.viewAddServer()
|
||||
case pageSelectServer:
|
||||
body = m.viewSelectServer()
|
||||
case pageServerActions:
|
||||
body = m.viewServerActions()
|
||||
case pageFileAction:
|
||||
body = m.viewFileAction()
|
||||
default:
|
||||
body = m.viewMenu()
|
||||
}
|
||||
@@ -79,6 +90,20 @@ func (m TUIInterface) View() tea.View {
|
||||
footerHint("enter", "connect") +
|
||||
footerSep() +
|
||||
footerHint("esc", "back")
|
||||
case pageServerActions:
|
||||
footerStr = footerHint("tab", "switch pane") +
|
||||
footerSep() +
|
||||
footerHint("↑↓", "navigate") +
|
||||
footerSep() +
|
||||
footerHint("enter", "select") +
|
||||
footerSep() +
|
||||
footerHint("esc", "back")
|
||||
case pageFileAction:
|
||||
footerStr = footerHint("↑↓", "navigate") +
|
||||
footerSep() +
|
||||
footerHint("enter", "confirm") +
|
||||
footerSep() +
|
||||
footerHint("esc", "back")
|
||||
default:
|
||||
footerStr = footerHint("↑↓", "navigate") +
|
||||
footerSep() +
|
||||
@@ -130,6 +155,49 @@ func (m TUIInterface) viewMenu() string {
|
||||
return menu
|
||||
}
|
||||
|
||||
func (m TUIInterface) viewServerActions() string {
|
||||
// action menu — single column, unfocused when file pane is active
|
||||
var actionRows []string
|
||||
for i, item := range m.MenuItems {
|
||||
active := !m.FileFocused && i == m.Selected
|
||||
actionRows = append(actionRows, styles.MenuItemStyle(active, false).Render(item.Label))
|
||||
}
|
||||
actions := lipgloss.JoinVertical(lipgloss.Left, actionRows...)
|
||||
|
||||
// file list section below, separated by a top border
|
||||
var fileRows []string
|
||||
switch {
|
||||
case m.StorageLoading:
|
||||
fileRows = append(fileRows, styles.StatusWarnStyle.Render(" loading…"))
|
||||
case m.StorageErr != nil:
|
||||
fileRows = append(fileRows, styles.StatusErrStyle.Render("✗ "+m.StorageErr.Error()))
|
||||
case len(m.StorageFiles) == 0:
|
||||
fileRows = append(fileRows, styles.StorageEmptyStyle.Render(" no files in storage"))
|
||||
default:
|
||||
for i, f := range m.StorageFiles {
|
||||
active := m.FileFocused && i == m.FileSelected
|
||||
fileRows = append(fileRows, styles.FileItemStyle(active).Render(f))
|
||||
}
|
||||
}
|
||||
fileList := lipgloss.JoinVertical(lipgloss.Left, fileRows...)
|
||||
fileSection := styles.StorageFileSectionStyle.Render(fileList)
|
||||
|
||||
return lipgloss.JoinVertical(lipgloss.Left, actions, fileSection)
|
||||
}
|
||||
|
||||
func (m TUIInterface) viewFileAction() string {
|
||||
// filename shown as a dim label above the menu
|
||||
filenameLabel := styles.FilenameLabelStyle.Render(m.ActiveFile)
|
||||
|
||||
var menuRows []string
|
||||
for i, item := range m.MenuItems {
|
||||
menuRows = append(menuRows, styles.MenuItemStyle(i == m.Selected, false).Render(item.Label))
|
||||
}
|
||||
menu := lipgloss.JoinVertical(lipgloss.Left, menuRows...)
|
||||
|
||||
return lipgloss.JoinVertical(lipgloss.Left, filenameLabel, menu)
|
||||
}
|
||||
|
||||
func (m TUIInterface) viewSelectServer() string {
|
||||
if len(m.ServerNames) == 0 {
|
||||
return styles.StatusWarnStyle.Render("⚠ No servers configured.")
|
||||
@@ -155,16 +223,13 @@ func (m TUIInterface) viewAddServer() string {
|
||||
}
|
||||
form := lipgloss.JoinVertical(lipgloss.Left, rows...)
|
||||
|
||||
// required legend
|
||||
legend := styles.FieldLegendStyle.Render("* required")
|
||||
|
||||
// form error (duplicate name, etc.)
|
||||
var errLine string
|
||||
if m.FormErr != "" {
|
||||
errLine = styles.StatusErrStyle.Render(m.FormErr)
|
||||
}
|
||||
|
||||
// save / back buttons
|
||||
saveBtn := styles.ButtonStyle(f.focused == fieldSave, f.canSave()).Render("Save")
|
||||
backBtn := styles.ButtonStyle(f.focused == fieldBack, true).Render("Back")
|
||||
buttons := lipgloss.JoinHorizontal(lipgloss.Top, saveBtn, " ", backBtn)
|
||||
|
||||
Reference in New Issue
Block a user