Fix #374 allow remove crumbs
parent
d7b933553c
commit
6b27c91168
|
|
@ -242,6 +242,8 @@ K9s uses aliases to navigate most K8s resources.
|
|||
enableMouse: false
|
||||
# Set to true to hide K9s header. Default false
|
||||
headless: false
|
||||
# Set to true to hide K9s footer. Default false
|
||||
crumbsless: false
|
||||
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
|
||||
readOnly: false
|
||||
# Toggles icons display as not all terminal support these chars.
|
||||
|
|
|
|||
|
|
@ -217,6 +217,12 @@ func initK9sFlags() {
|
|||
false,
|
||||
"Disable all commands that modify the cluster",
|
||||
)
|
||||
rootCmd.Flags().BoolVar(
|
||||
k9sFlags.Crumbsless,
|
||||
"crumbsless",
|
||||
false,
|
||||
"Turn K9s crumbs off",
|
||||
)
|
||||
}
|
||||
|
||||
func initK8sFlags() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ type Flags struct {
|
|||
Command *string
|
||||
AllNamespaces *bool
|
||||
ReadOnly *bool
|
||||
Crumbsless *bool
|
||||
}
|
||||
|
||||
// NewFlags returns new configuration flags.
|
||||
|
|
@ -30,6 +31,7 @@ func NewFlags() *Flags {
|
|||
Command: strPtr(DefaultCommand),
|
||||
AllNamespaces: boolPtr(false),
|
||||
ReadOnly: boolPtr(false),
|
||||
Crumbsless: boolPtr(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ type K9s struct {
|
|||
RefreshRate int `yaml:"refreshRate"`
|
||||
EnableMouse bool `yaml:"enableMouse"`
|
||||
Headless bool `yaml:"headless"`
|
||||
Crumbsless bool `yaml:"crumbsless"`
|
||||
ReadOnly bool `yaml:"readOnly"`
|
||||
NoIcons bool `yaml:"noIcons"`
|
||||
Logger *Logger `yaml:"logger"`
|
||||
|
|
@ -18,6 +19,7 @@ type K9s struct {
|
|||
Thresholds Threshold `yaml:"thresholds"`
|
||||
manualRefreshRate int
|
||||
manualHeadless *bool
|
||||
manualCrumbsless *bool
|
||||
manualReadOnly *bool
|
||||
manualCommand *string
|
||||
}
|
||||
|
|
@ -42,6 +44,11 @@ func (k *K9s) OverrideHeadless(b bool) {
|
|||
k.manualHeadless = &b
|
||||
}
|
||||
|
||||
// OverrideCrumbsless set the headlessness manually.
|
||||
func (k *K9s) OverrideCrumbsless(b bool) {
|
||||
k.manualCrumbsless = &b
|
||||
}
|
||||
|
||||
// OverrideReadOnly set the readonly mode manually.
|
||||
func (k *K9s) OverrideReadOnly(b bool) {
|
||||
k.manualReadOnly = &b
|
||||
|
|
@ -62,6 +69,16 @@ func (k *K9s) GetHeadless() bool {
|
|||
return h
|
||||
}
|
||||
|
||||
// GetCrumbsless returns crumbsless setting.
|
||||
func (k *K9s) GetCrumbsless() bool {
|
||||
h := k.Crumbsless
|
||||
if k.manualCrumbsless != nil && *k.manualCrumbsless {
|
||||
h = *k.manualCrumbsless
|
||||
}
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
// GetRefreshRate returns the current refresh rate.
|
||||
func (k *K9s) GetRefreshRate() int {
|
||||
rate := k.RefreshRate
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ type App struct {
|
|||
filterHistory *model.History
|
||||
conRetry int32
|
||||
showHeader bool
|
||||
showCrumbs bool
|
||||
}
|
||||
|
||||
// NewApp returns a K9s app instance.
|
||||
|
|
@ -129,12 +130,12 @@ func (a *App) layout(ctx context.Context, version string) {
|
|||
main := tview.NewFlex().SetDirection(tview.FlexRow)
|
||||
main.AddItem(a.statusIndicator(), 1, 1, false)
|
||||
main.AddItem(a.Content, 0, 10, true)
|
||||
main.AddItem(a.Crumbs(), 1, 1, false)
|
||||
main.AddItem(flash, 1, 1, false)
|
||||
|
||||
a.Main.AddPage("main", main, true, false)
|
||||
a.Main.AddPage("splash", ui.NewSplash(a.Styles, version), true, true)
|
||||
a.toggleHeader(!a.Config.K9s.GetHeadless())
|
||||
a.toggleCrumbs(!a.Config.K9s.GetCrumbsless())
|
||||
}
|
||||
|
||||
func (a *App) initSignals() {
|
||||
|
|
@ -186,6 +187,7 @@ func (a *App) keyboard(evt *tcell.EventKey) *tcell.EventKey {
|
|||
func (a *App) bindKeys() {
|
||||
a.AddActions(ui.KeyActions{
|
||||
tcell.KeyCtrlE: ui.NewSharedKeyAction("ToggleHeader", a.toggleHeaderCmd, false),
|
||||
tcell.KeyCtrlT: ui.NewSharedKeyAction("toggleCrumbs", a.toggleCrumbsCmd, false),
|
||||
ui.KeyHelp: ui.NewSharedKeyAction("Help", a.helpCmd, false),
|
||||
tcell.KeyCtrlA: ui.NewSharedKeyAction("Aliases", a.aliasCmd, false),
|
||||
tcell.KeyEnter: ui.NewKeyAction("Goto", a.gotoCmd, false),
|
||||
|
|
@ -212,6 +214,19 @@ func (a *App) toggleHeader(flag bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *App) toggleCrumbs(flag bool) {
|
||||
a.showCrumbs = flag
|
||||
flex, ok := a.Main.GetPrimitive("main").(*tview.Flex)
|
||||
if !ok {
|
||||
log.Fatal().Msg("Expecting valid flex view")
|
||||
}
|
||||
if a.showCrumbs {
|
||||
flex.AddItemAtIndex(2, a.Crumbs(), 1, 1, false)
|
||||
} else {
|
||||
flex.RemoveItemAtIndex(2)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) buildHeader() tview.Primitive {
|
||||
header := tview.NewFlex()
|
||||
header.SetBackgroundColor(a.Styles.BgColor())
|
||||
|
|
@ -498,6 +513,19 @@ func (a *App) toggleHeaderCmd(evt *tcell.EventKey) *tcell.EventKey {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *App) toggleCrumbsCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||
if a.Prompt().InCmdMode() {
|
||||
return evt
|
||||
}
|
||||
|
||||
a.QueueUpdateDraw(func() {
|
||||
a.showCrumbs = !a.showCrumbs
|
||||
a.toggleCrumbs(a.showCrumbs)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) gotoCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||
if a.CmdBuff().IsActive() && !a.CmdBuff().Empty() {
|
||||
if err := a.gotoResource(a.GetCmd(), "", true); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue