diff --git a/internal/tui/components/app/app.go b/internal/tui/components/app/app.go index 9bec7138..82c5c0ca 100644 --- a/internal/tui/components/app/app.go +++ b/internal/tui/components/app/app.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path" + "sort" "strings" "time" @@ -755,10 +756,15 @@ func (m Model) getCurrentPageCmd() tea.Cmd { return func() tea.Msg { // this does no async work, just constructs the task admin menu var rows []page.Row + var sortedAllocAdminActions []int for action := range nomad.AllocAdminActions { + sortedAllocAdminActions = append(sortedAllocAdminActions, int(action)) + } + sort.Ints(sortedAllocAdminActions) + for _, action := range sortedAllocAdminActions { rows = append(rows, page.Row{ - Key: nomad.AdminActionToKey(action), - Row: nomad.GetAllocAdminText(action, m.taskName, m.alloc.Name, m.alloc.ID), + Key: nomad.AdminActionToKey(nomad.AdminAction(action)), + Row: nomad.GetAllocAdminText(nomad.AdminAction(action), m.taskName, m.alloc.Name, m.alloc.ID), }) } return nomad.PageLoadedMsg{ @@ -785,10 +791,15 @@ func (m Model) getCurrentPageCmd() tea.Cmd { return func() tea.Msg { // this does no async work, just constructs the job admin menu var rows []page.Row + var sortedJobAdminActions []int for action := range nomad.JobAdminActions { + sortedJobAdminActions = append(sortedJobAdminActions, int(action)) + } + sort.Ints(sortedJobAdminActions) + for _, action := range sortedJobAdminActions { rows = append(rows, page.Row{ - Key: nomad.AdminActionToKey(action), - Row: nomad.GetJobAdminText(action, m.jobID), + Key: nomad.AdminActionToKey(nomad.AdminAction(action)), + Row: nomad.GetJobAdminText(nomad.AdminAction(action), m.jobID), }) } return nomad.PageLoadedMsg{ diff --git a/internal/tui/nomad/util.go b/internal/tui/nomad/util.go index adae6b0c..148c6667 100644 --- a/internal/tui/nomad/util.go +++ b/internal/tui/nomad/util.go @@ -16,6 +16,7 @@ const keySeparator = "|【=◈︿◈=】|" type AdminAction int8 // all admin actions, task or job +// the definition order of these is important, as it's used for sorting const ( RestartTaskAction AdminAction = iota RestartAllocAction