Skip to content

Commit

Permalink
Added defaultsToFullScreen flag for Live/Details view,logs (#2516)
Browse files Browse the repository at this point in the history
* Added fullScreen flag for LiveView, updated readme.md

* Added fullScreenLView default value for tests

* Extended DefaultsToFullScreen to include logView and DetailsView
  • Loading branch information
eiachh authored Feb 3, 2024
1 parent a1e9485 commit 3c20f0d
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 31 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,27 @@ K9s uses aliases to navigate most K8s resources.
refreshRate: 2
# Number of retries once the connection to the api-server is lost. Default 15.
maxConnRetry: 5
# Enable mouse support. Default false
enableMouse: true
# Set to true to hide K9s header. Default false
headless: false
# Set to true to hide K9s crumbs. Default false
crumbsless: false
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
readOnly: false
# Toggles whether k9s should exit when CTRL-C is pressed. When set to true, you will need to exist k9s via the :quit command. Default is false.
noExitOnCtrlC: false
#UI settings
ui:
# Enable mouse support. Default false
enableMouse: false
# Set to true to hide K9s header. Default false
headless: false
# Set to true to hide the K9S logo Default false
logoless: false
# Set to true to hide K9s crumbs. Default false
crumbsless: false
noIcons: false
# Toggles reactive UI. This option provide for watching on disk artifacts changes and update the UI live Defaults to false.
reactive: false
# By default all contexts wil use the dracula skin unless explicitly overridden in the context config file.
skin: dracula # => assumes the file skins/dracula.yaml is present in the $XDG_DATA_HOME/k9s/skins directory
# Allows to set certain views default fullscreen mode. (yaml, helm history, describe, value_extender, details, logs) Default false
defaultsToFullScreen: false
# Toggles icons display as not all terminal support these chars.
noIcons: false
# Toggles whether k9s should check for the latest revision from the Github repository releases. Default is false.
Expand All @@ -409,8 +420,6 @@ K9s uses aliases to navigate most K8s resources.
buffer: 500
# Represents how far to go back in the log timeline in seconds. Setting to -1 will tail logs. Default is -1.
sinceSeconds: 300 # => tail the last 5 mins.
# Go full screen while displaying logs. Default false
fullScreenLogs: false
# Toggles log line wrap. Default false
textWrap: false
# Toggles log line timestamp info. Default false
Expand Down Expand Up @@ -912,6 +921,7 @@ k9s:
reactive: false
# By default all contexts wil use the dracula skin unless explicitly overridden in the context config file.
skin: dracula # => assumes the file skins/dracula.yaml is present in the $XDG_DATA_HOME/k9s/skins directory
defaultsToFullScreen: false
skipLatestRevCheck: false
disablePodCounting: false
shellPod:
Expand All @@ -929,7 +939,6 @@ k9s:
tail: 100
buffer: 5000
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
4 changes: 2 additions & 2 deletions internal/config/json/schemas/k9s.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"crumbsless": {"type": "boolean"},
"noIcons": {"type": "boolean"},
"reactive": {"type": "boolean"},
"skin": {"type": "string"}
"skin": {"type": "string"},
"defaultsToFullScreen": {"type": "boolean"}
}
},
"shellPod": {
Expand Down Expand Up @@ -101,7 +102,6 @@
"tail": {"type": "integer"},
"buffer": {"type": "integer"},
"sinceSeconds": {"type": "integer"},
"fullScreen": {"type": "boolean"},
"textWrap": {"type": "boolean"},
"showTime": {"type": "boolean"}
}
Expand Down
1 change: 0 additions & 1 deletion internal/config/json/testdata/k9s/cool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ k9s:
tail: 100
buffer: 5000
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
1 change: 0 additions & 1 deletion internal/config/json/testdata/k9s/toast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ k9s:
tail: 100
buffer: 5000
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
1 change: 0 additions & 1 deletion internal/config/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type Logger struct {
TailCount int64 `json:"tail" yaml:"tail"`
BufferSize int `json:"buffer" yaml:"buffer"`
SinceSeconds int64 `json:"sinceSeconds" yaml:"sinceSeconds"`
FullScreen bool `json:"fullScreen" yaml:"fullScreen"`
TextWrap bool `json:"textWrap" yaml:"textWrap"`
ShowTime bool `json:"showTime" yaml:"showTime"`
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/testdata/configs/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ k9s:
crumbsless: false
reactive: false
noIcons: false
defaultsToFullScreen: false
skipLatestRevCheck: false
disablePodCounting: false
shellPod:
Expand All @@ -29,7 +30,6 @@ k9s:
tail: 100
buffer: 5000
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
2 changes: 1 addition & 1 deletion internal/config/testdata/configs/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ k9s:
crumbsless: false
reactive: false
noIcons: false
defaultsToFullScreen: false
skipLatestRevCheck: false
disablePodCounting: false
shellPod:
Expand All @@ -29,7 +30,6 @@ k9s:
tail: 500
buffer: 800
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
2 changes: 1 addition & 1 deletion internal/config/testdata/configs/k9s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ k9s:
crumbsless: false
reactive: false
noIcons: false
defaultsToFullScreen: false
skipLatestRevCheck: false
disablePodCounting: false
shellPod:
Expand All @@ -29,7 +30,6 @@ k9s:
tail: 200
buffer: 2000
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
1 change: 0 additions & 1 deletion internal/config/testdata/configs/k9s_toast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ k9s:
tail: 200
buffer: 2000
sinceSeconds: -1
fullScreen: false
textWrap: false
showTime: false
thresholds:
Expand Down
3 changes: 3 additions & 0 deletions internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ type UI struct {
// Skin reference the general k9s skin name.
// Can be overridden per context.
Skin string `json:"skin" yaml:"skin,omitempty"`

// DefaultsToFullScreen toggles fullscreen on views like logs, yaml, details.
DefaultsToFullScreen bool `json:"defaultsToFullScreen" yaml:"defaultsToFullScreen"`
}
17 changes: 11 additions & 6 deletions internal/view/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (d *Details) Init(_ context.Context) error {

d.app.Styles.AddListener(d)
d.StylesChanged(d.app.Styles)
d.setFullScreen(d.app.Config.K9s.UI.DefaultsToFullScreen)

d.app.Prompt().SetModel(d.cmdBuff)
d.cmdBuff.AddListener(d)
Expand Down Expand Up @@ -226,16 +227,20 @@ func (d *Details) toggleFullScreenCmd(evt *tcell.EventKey) *tcell.EventKey {
return evt
}

d.fullScreen = !d.fullScreen
d.SetFullScreen(d.fullScreen)
d.Box.SetBorder(!d.fullScreen)
if d.fullScreen {
d.setFullScreen(!d.fullScreen)

return nil
}

func (d *Details) setFullScreen(isFullScreen bool) {
d.fullScreen = isFullScreen
d.SetFullScreen(isFullScreen)
d.Box.SetBorder(!isFullScreen)
if isFullScreen {
d.Box.SetBorderPadding(0, 0, 0, 0)
} else {
d.Box.SetBorderPadding(0, 0, 1, 1)
}

return nil
}

func (d *Details) prevCmd(evt *tcell.EventKey) *tcell.EventKey {
Expand Down
17 changes: 11 additions & 6 deletions internal/view/live_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (v *LiveView) Init(_ context.Context) error {

v.app.Styles.AddListener(v)
v.StylesChanged(v.app.Styles)
v.setFullScreen(v.app.Config.K9s.UI.DefaultsToFullScreen)

v.app.Prompt().SetModel(v.cmdBuff)
v.cmdBuff.AddListener(v)
Expand Down Expand Up @@ -286,16 +287,20 @@ func (v *LiveView) toggleFullScreenCmd(evt *tcell.EventKey) *tcell.EventKey {
return evt
}

v.fullScreen = !v.fullScreen
v.SetFullScreen(v.fullScreen)
v.Box.SetBorder(!v.fullScreen)
if v.fullScreen {
v.setFullScreen(!v.fullScreen)

return nil
}

func (v *LiveView) setFullScreen(isFullScreen bool) {
v.fullScreen = isFullScreen
v.SetFullScreen(isFullScreen)
v.Box.SetBorder(!isFullScreen)
if isFullScreen {
v.Box.SetBorderPadding(0, 0, 0, 0)
} else {
v.Box.SetBorderPadding(0, 0, 1, 1)
}

return nil
}

func (v *LiveView) nextCmd(evt *tcell.EventKey) *tcell.EventKey {
Expand Down
2 changes: 1 addition & 1 deletion internal/view/log_indicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewLogIndicator(cfg *config.Config, styles *config.Styles, allContainers bo
TextView: tview.NewTextView(),
indicator: make([]byte, 0, 100),
scrollStatus: 1,
fullScreen: cfg.K9s.Logger.FullScreen,
fullScreen: cfg.K9s.UI.DefaultsToFullScreen,
textWrap: cfg.K9s.Logger.TextWrap,
showTime: cfg.K9s.Logger.ShowTime,
shouldDisplayAllContainers: allContainers,
Expand Down

0 comments on commit 3c20f0d

Please sign in to comment.