fix: simplify dashboard and disable unauthorized actions
hermetic-ci / test (push) Canceled after 0s
hermetic-ci / test (push) Canceled after 0s
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
|
||||
"proxyctl/internal/app"
|
||||
"proxyctl/internal/target"
|
||||
)
|
||||
|
||||
type dashboardRenderState struct {
|
||||
@@ -149,55 +148,18 @@ func (p terminalPresentation) targetDetails(item app.TargetSnapshot, progress ap
|
||||
|
||||
var details strings.Builder
|
||||
details.WriteString(p.theme.section.Render(item.Description.Name))
|
||||
fmt.Fprintf(&details, "\nState: %s\nEvidence: %s", state, evidence)
|
||||
fmt.Fprintf(&details, "\nAction: %s", targetActionLabel(item.PrimaryAction.Kind))
|
||||
if !item.PrimaryAction.Available && item.PrimaryAction.DisabledReason != "" {
|
||||
fmt.Fprintf(&details, "\nAction unavailable: %s", item.PrimaryAction.DisabledReason)
|
||||
}
|
||||
switch item.PrimaryAction.Kind {
|
||||
case app.ApplyProfileTargetAction:
|
||||
details.WriteString("\nApply Profile means proxyctl will begin managing this configuration while preserving restorable state.")
|
||||
case app.ResolveDriftTargetAction:
|
||||
details.WriteString("\nResolve opens Drift Resolution without choosing a recovery direction for you.")
|
||||
fmt.Fprintf(&details, "\n%s\n%s", state, evidence)
|
||||
action := targetActionLabel(item.PrimaryAction.Kind)
|
||||
if item.PrimaryAction.Available {
|
||||
fmt.Fprintf(&details, "\n\nSpace: %s", action)
|
||||
} else if item.PrimaryAction.DisabledReason != "" {
|
||||
fmt.Fprintf(&details, "\n\nUnavailable: %s", item.PrimaryAction.DisabledReason)
|
||||
}
|
||||
if item.DetectionPhase == app.TargetDetectionFailed && item.DetectionErr != nil {
|
||||
fmt.Fprintf(&details, "\nCheck error: %s", item.DetectionErr)
|
||||
}
|
||||
facts := []struct {
|
||||
label string
|
||||
value string
|
||||
}{
|
||||
{"Affects", item.Description.Scope},
|
||||
{"Permissions", item.Description.Permissions},
|
||||
{"Ownership & restoration", item.Description.Ownership},
|
||||
{"Restart risk", item.Description.RestartRisk},
|
||||
}
|
||||
for _, fact := range facts {
|
||||
if fact.value != "" {
|
||||
fmt.Fprintf(&details, "\n%s: %s", fact.label, fact.value)
|
||||
}
|
||||
fmt.Fprintf(&details, "\nCheck failed: %s", item.DetectionErr)
|
||||
}
|
||||
if item.Description.Summary != "" {
|
||||
fmt.Fprintf(&details, "\n\n%s", item.Description.Summary)
|
||||
}
|
||||
if item.Description.Details != "" {
|
||||
fmt.Fprintf(&details, "\n\n%s", item.Description.Details)
|
||||
}
|
||||
return protectRenderedText(details.String())
|
||||
}
|
||||
|
||||
func (p terminalPresentation) stateCountSummary(snapshot app.Snapshot) string {
|
||||
counts := countAvailableTargetStates(snapshot)
|
||||
summary := fmt.Sprintf("%s %d %s %d %s %d %s %d",
|
||||
p.theme.renderTargetState(target.Enabled, false), counts.enabled,
|
||||
p.theme.renderTargetState(target.Disabled, false), counts.disabled,
|
||||
p.theme.renderTargetState(target.External, false), counts.external,
|
||||
p.theme.renderTargetState(target.Drifted, false), counts.drifted)
|
||||
if counts.checking > 0 {
|
||||
summary += fmt.Sprintf(" %s %d", p.theme.checking.Render("… Checking"), counts.checking)
|
||||
}
|
||||
if counts.failed > 0 {
|
||||
summary += fmt.Sprintf(" %s %d", p.theme.checkFailed.Render("! Check failed"), counts.failed)
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user