Skip to content
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

Add a sort option popup to branch list view #2146

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

UUGTech
Copy link
Contributor

@UUGTech UUGTech commented Mar 22, 2024

This Pull Request fixes/closes #2129, #2024

It changes the following:

  • show last commit date and last commit author on branchlist popup.
  • make it possible to sort by branch name, last commit date, and last commit author.

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog
Screenshot 2024-03-22 at 19 48 35
Screen.Recording.2024-03-22.at.19.46.23.mov

src/strings.rs Outdated Show resolved Hide resolved
@UUGTech UUGTech marked this pull request as ready for review March 22, 2024 13:38
@extrawurst
Copy link
Owner

Thanks for taking a go at this!

If you look at other popups like the options or search-in-log popup you will notice that the way we do these is: using the navigation cursors to pick an option instead of adding a bunch of new key bindings for each option uniquely. if you could convert this on to the same that would be awesome

@UUGTech
Copy link
Contributor Author

UUGTech commented Mar 25, 2024

Thank you for pointing that out.
Now, it works with navigation keys 😄

Screen.Recording.2024-03-25.at.13.26.57.mov

@UUGTech UUGTech marked this pull request as draft March 25, 2024 04:34
@UUGTech UUGTech marked this pull request as ready for review March 25, 2024 04:38
@@ -587,6 +706,15 @@ impl BranchListPopup {
.take(height)
.enumerate()
{
let date_local = Local
.timestamp_opt(displaybranch.top_commit_time, 0)
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to change this from an unwrap to an unwrap_or to protect from panics just incase

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this even possible to pass CI?
checkout main.rs: #![deny(clippy::unwrap_used)]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wtf MappedLocalTime: https://docs.rs/chrono/latest/chrono/offset/type.MappedLocalTime.html

lets do earliest and then unwrap the Option with unwrap_or_else

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also debating whether to store this DateTime<Local> instead inside of BranchInfo which should be fine as it is just twice as big as the i64 that we we do not have to do this mess everytime the screen renders

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but at the least the unwrap needs to go

Comment on lines +724 to +728
let date_text = displaybranch
.top_commit_time_local
.map_or("????-??-?? ".to_string(), |time| {
time.date_naive().to_string() + " "
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure how to deal with None case.

Comment on lines +99 to +101
pub top_commit_time: i64,
///
pub top_commit_time_local: Option<DateTime<Local>>,
Copy link
Contributor Author

@UUGTech UUGTech Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added top_commit_time_local inside of BranchInfo.
But this could be None. I thought we should keep top_commit_time: i64 here. (top_commit_time is used for sorting) What do you think?

Comment on lines +107 to +108
// TODO: clean up
#[allow(clippy::too_many_lines)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any idea to minimize this for now..

@UUGTech
Copy link
Contributor Author

UUGTech commented Apr 14, 2024

@extrawurst Sorry for the delay 🙇‍♂️
I updated according to your feedback and left some comments.

Copy link
Owner

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when sorting it should also keep the selection: right now it only keeps the same index selected which will mostly be a different branch when sorting changes.

the popup list entries should also not use a focused (bold) style, make it more in line with other popups (search, fuzzy find)

@UUGTech
Copy link
Contributor Author

UUGTech commented Apr 14, 2024

@extrawurst
Thank you for your review.

when sorting it should also keep the selection: right now it only keeps the same index selected which will mostly be a different branch when sorting changes.

Easier way to find new branch is required in #2129, also I think sorting is that kind of feature.
I thought keeping the selection makes it difficult. 🤔
I myself am not strongly attached to it, so If you still prefer to keep the selection, then I will do so.

the popup list entries should also not use a focused (bold) style, make it more in line with other popups (search, fuzzy find)

Thank you. I'll fix this.

@extrawurst extrawurst added this to the v0.27 milestone Apr 14, 2024
@extrawurst
Copy link
Owner

I myself am not strongly attached to it, so If you still prefer to keep the selection, then I will do so.

yes please. the use case you describe is better fixed by providing quick scroll-to-top/bottom shortcuts like we also have in the commit log list view

@UUGTech
Copy link
Contributor Author

UUGTech commented Apr 24, 2024

Other popups are in a bold style
Screenshot 2024-04-24 at 21 51 50

Which is better?
not bold:
Screenshot 2024-04-24 at 21 51 34
bold:
Screenshot 2024-04-24 at 21 58 47

Currently, branch_sort popup is in bold style. This is same with other popups.
If they should not be bold, I will fix all popups.

@UUGTech
Copy link
Contributor Author

UUGTech commented Apr 24, 2024

the use case you describe is better fixed by providing quick scroll-to-top/bottom shortcuts like we also have in the commit log list view.

I made an issue for this.

@UUGTech UUGTech requested a review from extrawurst April 24, 2024 13:27
@extrawurst
Copy link
Owner

Other popups are in a bold style Screenshot 2024-04-24 at 21 51 50

Which is better? not bold: Screenshot 2024-04-24 at 21 51 34 bold: Screenshot 2024-04-24 at 21 58 47

Currently, branch_sort popup is in bold style. This is same with other popups. If they should not be bold, I will fix all popups.

Let’s go non bold and make only the selection bold

@UUGTech
Copy link
Contributor Author

UUGTech commented May 1, 2024

updated the style of these popups

branch-sort popup

Screen.Recording.2024-05-01.at.12.24.21.mov

logs-search popup

Screen.Recording.2024-05-01.at.12.25.00.mov

fuzzy-find popup

Screenshot 2024-05-01 at 12 25 34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow sorting by last branch commit
3 participants