This commit is contained in:
redlineo committed 2026-07-22 15:14:44 +03:00
1 parent 23c7133fa9
commit 8c1b93c14e
16 files changed
+1187 -295

No files matched your search

+76 -7
View File
@@ -32,9 +32,28 @@ const (
scrGroups
scrGroupHosts
scrHostNew
scrHostServices
scrServiceNew
scrExportSelect
scrExportConfirm
scrExportResult
scrConfigUpdateResult
scrAudit
scrQuitConfirm
scrConfirmAction
)
// confirmKind identifies which destructive action scrConfirmAction is
// guarding, so a single generic confirm screen can back every one of them
// instead of duplicating the "are you sure" plumbing per action.
type confirmKind int
const (
confirmNone confirmKind = iota
confirmLockUser
confirmDeleteUser
confirmDeleteHost
confirmDeleteService
)
var (
@@ -59,24 +78,31 @@ type Model struct {
usersList list.Model
userNewName textinput.Model
userNewComment textinput.Model
userNewFocus int
userNewGroupsSel map[string]bool
userNewGroupsOrder []string
userNewCursor int
userNewName textinput.Model
userNewComment textinput.Model
userNewFocus int
userNewGroupsSel map[string]bool
userNewGroupsOrder []string
userNewCursor int
userGroupsEditTarget string // non-empty: editing this existing user's groups instead of creating a new user
groupsList list.Model
groupNewName textinput.Model
awaitingGroup bool
selectedGroup string
hostsList list.Model
hostForm [4]textinput.Model // name, address, port, description
hostForm [2]textinput.Model // name, address
hostFormFocus int
selectedHost string
servicesList list.Model
serviceForm [3]textinput.Model // name, port, description
serviceFormFocus int
exportSel map[string]bool
exportOrder []string
exportCursor int
exportChosen []string // confirmed selection, pending scrExportConfirm -> runExport
exportRes []keymgr.BuildResult
exportPass string
exportErr string
@@ -84,6 +110,23 @@ type Model struct {
onlineSessions []audit.OnlineSession
recentEvents []audit.Event
quitReturnTo screen // screen to go back to if quit is cancelled
quitPending []string // usernames with no key issued yet, shown on scrQuitConfirm
// generic confirmation for destructive actions (lock/delete user,
// delete host/service) — see confirm.go. confirmTarget holds the
// username/host/service name being acted on; for host/service deletion
// the group (and host, for a service) context is the already-present
// selectedGroup/selectedHost fields above.
pendingConfirm confirmKind
confirmTarget string
confirmMessage string
confirmReturnTo screen
configUpdateUser string
configUpdateArchive string
configUpdatePass string
width, height int
}
@@ -100,6 +143,7 @@ func New(cfg config.Config, st *store.Store) Model {
m.usersList = emptyList("Пользователи")
m.groupsList = emptyList("Группы доступа")
m.hostsList = emptyList("Хосты")
m.servicesList = emptyList("Сервисы")
return m
}
@@ -153,6 +197,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.usersList.SetSize(listW, listH)
m.groupsList.SetSize(listW, listH)
m.hostsList.SetSize(listW, listH)
m.servicesList.SetSize(listW, listH)
return m, nil
case tea.KeyMsg:
if msg.String() == "ctrl+c" {
@@ -175,12 +220,24 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.updateGroupHosts(msg)
case scrHostNew:
return m.updateHostNew(msg)
case scrHostServices:
return m.updateHostServices(msg)
case scrServiceNew:
return m.updateServiceNew(msg)
case scrExportSelect:
return m.updateExportSelect(msg)
case scrExportConfirm:
return m.updateExportConfirm(msg)
case scrExportResult:
return m.updateExportResult(msg)
case scrConfigUpdateResult:
return m.updateConfigUpdateResult(msg)
case scrAudit:
return m.updateAudit(msg)
case scrQuitConfirm:
return m.updateQuitConfirm(msg)
case scrConfirmAction:
return m.updateConfirmAction(msg)
}
return m, nil
}
@@ -202,12 +259,24 @@ func (m Model) View() string {
body = m.viewGroupHosts()
case scrHostNew:
body = m.viewHostNew()
case scrHostServices:
body = m.viewHostServices()
case scrServiceNew:
body = m.viewServiceNew()
case scrExportSelect:
body = m.viewExportSelect()
case scrExportConfirm:
body = m.viewExportConfirm()
case scrExportResult:
body = m.viewExportResult()
case scrConfigUpdateResult:
body = m.viewConfigUpdateResult()
case scrAudit:
body = m.viewAudit()
case scrQuitConfirm:
body = m.viewQuitConfirm()
case scrConfirmAction:
body = m.viewConfirmAction()
}
footer := ""