Skip to content

Commit

Permalink
Add dialog submit bindings to new issue modal
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo385 committed Dec 25, 2024
1 parent 2b512f6 commit fda1829
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lazy_github/ui/screens/new_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@


class NewIssueContainer(Container):
BINDINGS = [LazyGithubBindings.SUBMIT_DIALOG]

DEFAULT_CSS = """
#button_holder {
align: center middle;
Expand Down Expand Up @@ -50,8 +52,7 @@ def compose(self) -> ComposeResult:
def cancel_new_issue(self, _: Button) -> None:
self.app.pop_screen()

@on(Button.Pressed, "#save_new_issue")
async def submit_new_issue(self, _: Button) -> None:
async def create_issue(self) -> None:
assert LazyGithubContext.current_repo is not None, "Unexpectedly missing current repo from application context!"

title = self.query_one("#new_issue_title", Input).value
Expand All @@ -68,6 +69,13 @@ async def submit_new_issue(self, _: Button) -> None:
self.notify(f"Successfully created issue #{new_issue.number}")
self.post_message(IssueCreated(new_issue))

async def action_submit(self) -> None:
await self.create_issue()

@on(Button.Pressed, "#save_new_issue")
async def handle_save_new_issue_button(self, _: Button) -> None:
await self.create_issue()


class NewIssueModal(ModalScreen[Issue | None]):
BINDINGS = [LazyGithubBindings.CLOSE_DIALOG]
Expand Down

0 comments on commit fda1829

Please sign in to comment.