-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(app): add Go Back and Last View #2799
base: master
Are you sure you want to change the base?
Conversation
be13aa3
to
f6bff90
Compare
Features from these requests not included are:
This PR implements the most powerful parts of the feature requests. Better navigation and richer history could be added later while keeping this functionality intact. Supersedes #1090 |
Tested the feature locally and I have some questions:
Is this intended? I assume these "views" are somehow different from the generic Object views (Pod, StatefulSet, Deployment, ...)? In general I really like this feature! Especially |
I think that's a good idea, just to make it clear what to expect from the feature 👍 |
I updated the README. |
Thanks! One tiny remark: Your commit changed all My 2ct would be to revert these style-changes so only the new documentation is added, but I guess @derailed has the final call here :) |
7fbfca2
to
c29dd8e
Compare
Go Back walks back through the history until at the oldest saved view Last View switches between the current and previous views like how "cd -" works
c29dd8e
to
8652c78
Compare
@KevinGimbel those formatting changes were not intentional, I've changed my settings so it doesn't happen again. While I was at it, I squashed my commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyzbit Nice work! Good concept. Just a few items to clean up and simplify.
@@ -355,6 +355,8 @@ K9s uses aliases to navigate most K8s resources. | |||
| To view and switch to another Kubernetes context (Pod view) | `:`ctx⏎ | | | |||
| To view and switch directly to another Kubernetes context (Last used view) | `:`ctx context-name⏎ | | | |||
| To view and switch to another Kubernetes namespace | `:`ns⏎ | | | |||
| To switch between the last active view/command (like how "cd -" works) | `-` | Navigation that adds breadcrumbs to the bottom are not commands | | |||
| To go back through previous views/commands | `b` | Same as above | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 'b' is already in use in some views aka to run benchmarks ;(
Perhaps we can use '-' as the last 2 cmd toggle as you have here but then useuse '<' and '>' to nav the command history?
@@ -691,6 +693,54 @@ func (a *App) helpCmd(evt *tcell.EventKey) *tcell.EventKey { | |||
return nil | |||
} | |||
|
|||
// previousView returns to the view prior to the current one in the history | |||
func (a *App) previousView(evt *tcell.EventKey) *tcell.EventKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should really be named previousCmd to avoid confusion
return evt | ||
} | ||
cmds := a.cmdHistory.List() | ||
if !(len(cmds) > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A dialog here feels a bit heavy, I think best to use a flash for this instance.
Also not keen on !(len(cmds) > 1. This is len(cmds) <=1 return.
But... as noted below better to defer these calls to cmdHistory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally all these should be on cmdHistory apis. ie the logic for toggle last view and fwd/backwd should be methods on the history and not view logic imho i.ie toggleLastCmd, prevCmd, nextCmd, etc..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally if we surfaced a cmdHistory view all the necessary apis would be already there.
} | ||
|
||
// lastView switches between the last view and this one a la `cd -` | ||
func (a *App) lastView(evt *tcell.EventKey) *tcell.EventKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above these are commands and not views since sub-views are not part of the cmd history.
if len(n) > 1 { | ||
// only one argument is expected | ||
return false | ||
} else if len(n) == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are done here no need for the else clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not keen on the vararg with only one option. Best to leave Pop as such and introduce PopN(n int)
Thank you for the great feedback. I'm working on addressing the comments; some planned changes:
|
Go Back walks back through the history until at the oldest saved view
Last View switches between the current and previous views like how "cd -" works