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

Start showing a list of PRs #25

Merged
merged 5 commits into from
Jan 25, 2025
Merged

Conversation

heathhenley
Copy link
Collaborator

@heathhenley heathhenley commented Jan 25, 2025

Query for recent PRs and show in a list. Mostly copied the implementation for issues, there's a lot that could be DRY'd out right now as they have basically the same fields - but I think that they might not be so similar after starting to pull more information so I didn't merge them. Not sure if this is anywhere near how you would set it up but let me know what you think, happy to iterate on it.

It looks like this:

image

@heathhenley heathhenley requested a review from chshersh January 25, 2025 04:47
Copy link
Owner

@chshersh chshersh left a comment

Choose a reason for hiding this comment

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

Amazing stuff, @heathhenley!

Great idea to copy-paste the implementation with minimal DRY. That's actually was my plan as well: to copy-paste issues and abstract later. Things are in flux still, so it makes sense to keep them decoupled.

There're some similarities between issues and PRs but refactoring always can be done later.


I'm actually working on prettifying issues right now. I'll open a PR with my changes, so it'll be easier to resolve conflicts. You don't need to copy my new changes in this PR, this is also can be done later 🙂

lib/gh/gh.ml Outdated Show resolved Hide resolved
lib/gh/client.ml Show resolved Hide resolved
lib/gh/gh.mli Outdated Show resolved Hide resolved
lib/pretty/style.ml Show resolved Hide resolved
lib/tui/view.ml Outdated
Comment on lines 38 to 58
let pr_section (pr_tab : Model.pull_requests_tab) =
let open Pretty.Doc in
let fmt_state = function
| None -> str ""
| Some Gh.Pr.Merged -> fmt Style.pr_merged "\u{e725}"
| Some Gh.Pr.Open -> fmt Style.pr_open "\u{ea64}"
| Some Gh.Pr.Closed -> fmt Style.pr_closed "\u{ebda}"
in
let fmt_pr (pr : Gh.Pr.t) =
Pretty.Doc.(
horizontal
[
fmt_state pr.state;
str " ";
fmt Style.secondary (Printf.sprintf "#%d " pr.number);
str pr.title;
str " by ";
fmt Style.bold (Printf.sprintf "@%s" pr.author);
])
in
pr_tab.pull_requests |> Lazy.force |> List.map fmt_pr |> Pretty.Doc.vertical
Copy link
Owner

Choose a reason for hiding this comment

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

This amazing!

One comment: We're starting to get lots of new view components. Having them inside a single view.ml file won't scale.

I just quickly implemented issues inside here. But I think a better approach would be to have 3 modules inside the widget/ directory:

  1. code.ml
  2. issue.ml
  3. pr.ml

I'll move code and issue but let's start with pr in this PR (no pun intended).

Just have a single exposed section function from the Pr module, so the call site will look like Pr.section

Copy link
Collaborator Author

@heathhenley heathhenley Jan 25, 2025

Choose a reason for hiding this comment

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

That makes sense, I took a shot at it here: 71427e6 now here after rebase: ebdad51

@chshersh chshersh added component: UI Issues related to changing UI component: GH Issues related to GitHub API and interaction with it labels Jan 25, 2025
@chshersh chshersh added the type: feature New feature request label Jan 25, 2025
@heathhenley
Copy link
Collaborator Author

FYI about to force push a rebase with conflicts fixed...

Comment on lines +1 to +20
module Pr = Pr
module Generic = Generic

(** Print the about info into a pretty doc **)
val about_doc : Model.t -> Pretty.Doc.t

(** Draw the code tab *)
val code_tab : is_selected:bool -> Pretty.Doc.t

(** Draw the issues tab *)
val issues_tab : is_selected:bool -> Pretty.Doc.t

(** Draw the pull requests tab *)
val pull_requests_tab : is_selected:bool -> Pretty.Doc.t

(** Draw the working directory **)
val pwd : string -> Fs.zipper -> Pretty.Doc.t

(** Draw the file view **)
val file_view : Fs.zipper -> Pretty.Doc.t
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for creating this file!

It'll make future refactorings easier 🙂

Copy link
Owner

@chshersh chshersh left a comment

Choose a reason for hiding this comment

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

Great stuff!

I really appreciate your work on this project! 🙏🏻

@chshersh chshersh merged commit 0486bcc into chshersh:main Jan 25, 2025
3 checks passed
@heathhenley heathhenley deleted the dev_hh_parse_prs branch January 25, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: GH Issues related to GitHub API and interaction with it component: UI Issues related to changing UI type: feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants