Skip to content

Commit

Permalink
Add WIP conversation tab pane for issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo385 committed Sep 2, 2024
1 parent 5d87055 commit c4d41de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lazy_github/ui/screens/primary.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from lazy_github.ui.widgets.actions import ActionsContainer
from lazy_github.ui.widgets.command_log import CommandLogSection
from lazy_github.ui.widgets.common import LazyGithubContainer
from lazy_github.ui.widgets.issues import IssueOverviewTabPane, IssuesContainer
from lazy_github.ui.widgets.issues import IssueConversationTabPane, IssueOverviewTabPane, IssuesContainer
from lazy_github.ui.widgets.pull_requests import (
PrConversationTabPane,
PrDiffTabPane,
Expand Down Expand Up @@ -175,6 +175,7 @@ async def on_issue_selected(self, message: IssueSelected) -> None:
tabbed_content = self.query_one("#selection_detail_tabs", TabbedContent)
await tabbed_content.clear_panes()
await tabbed_content.add_pane(IssueOverviewTabPane(message.issue))
await tabbed_content.add_pane(IssueConversationTabPane(self.client, message.issue))
tabbed_content.children[0].focus()


Expand Down
26 changes: 25 additions & 1 deletion lazy_github/ui/widgets/issues.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from typing import Dict

from textual import on
from textual import on, work
from textual.app import ComposeResult
from textual.containers import ScrollableContainer
from textual.coordinate import Coordinate
from textual.widgets import Label, Markdown, Rule, TabPane

from lazy_github.lib.github.client import GithubClient
from lazy_github.lib.github.issues import get_comments
from lazy_github.lib.messages import IssuesAndPullRequestsFetched, IssueSelected
from lazy_github.lib.string_utils import link
from lazy_github.models.github import Issue, IssueState
Expand Down Expand Up @@ -96,3 +98,25 @@ def compose(self) -> ComposeResult:

yield Rule()
yield Markdown(self.issue.body)


class IssueConversationTabPane(TabPane):
def __init__(self, client: GithubClient, issue: Issue) -> None:
super().__init__("Conversation", id="issue_conversation")
self.client = client
self.issue = issue

@property
def content(self) -> Markdown:
return self.query_one("#pr_conversation", Markdown)

def compose(self) -> ComposeResult:
yield Markdown(id="pr_conversation")

def on_mount(self) -> None:
self.fetch_issue_comments()

@work
async def fetch_issue_comments(self) -> None:
comments = await get_comments(self.client, self.issue)
self.content.update(str(comments))

0 comments on commit c4d41de

Please sign in to comment.