From bb6e5fc374343dd749773a7a106ab2ed7a2728a3 Mon Sep 17 00:00:00 2001 From: Orlando Romo Date: Mon, 24 Jul 2023 09:12:53 -0600 Subject: [PATCH] feat(ui): Remove footer left section when prompt confirmation shows --- ui/common/styles.go | 2 +- ui/components/issuessection/issuessection.go | 9 +++++---- ui/components/prompt/prompt.go | 4 ++++ ui/components/prssection/prssection.go | 10 ++++++---- ui/components/section/section.go | 5 ++--- ui/ui.go | 9 ++++++++- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/ui/common/styles.go b/ui/common/styles.go index eb7c0f2..e655c43 100644 --- a/ui/common/styles.go +++ b/ui/common/styles.go @@ -8,7 +8,7 @@ import ( ) var ( - SearchHeight = 4 + SearchHeight = 3 FooterHeight = 1 ExpandedHelpHeight = 11 InputBoxHeight = 8 diff --git a/ui/components/issuessection/issuessection.go b/ui/components/issuessection/issuessection.go index 7054952..9e0190a 100644 --- a/ui/components/issuessection/issuessection.go +++ b/ui/components/issuessection/issuessection.go @@ -72,7 +72,6 @@ func (m Model) Update(msg tea.Msg) (section.Section, tea.Cmd) { if m.IsPromptConfirmationFocused() { - var promptCmd tea.Cmd switch { case msg.Type == tea.KeyCtrlC, msg.Type == tea.KeyEsc: @@ -97,8 +96,7 @@ func (m Model) Update(msg tea.Msg) (section.Section, tea.Cmd) { return &m, tea.Batch(cmd, blinkCmd) } - m.PromptConfirmationBox, promptCmd = m.PromptConfirmationBox.Update(msg) - return &m, promptCmd + break } case UpdateIssueMsg: @@ -141,7 +139,10 @@ func (m Model) Update(msg tea.Msg) (section.Section, tea.Cmd) { search, searchCmd := m.SearchBar.Update(msg) m.SearchBar = search - return &m, tea.Batch(cmd, searchCmd) + + prompt, promptCmd := m.PromptConfirmationBox.Update(msg) + m.PromptConfirmationBox = prompt + return &m, tea.Batch(cmd, searchCmd, promptCmd) } func GetSectionColumns( diff --git a/ui/components/prompt/prompt.go b/ui/components/prompt/prompt.go index 3380271..df5c786 100644 --- a/ui/components/prompt/prompt.go +++ b/ui/components/prompt/prompt.go @@ -60,3 +60,7 @@ func (m *Model) SetPrompt(prompt string) { func (m *Model) Reset() { m.prompt.Reset() } + +func (m *Model) UpdateProgramContext(ctx *context.ProgramContext) { + m.ctx = ctx +} diff --git a/ui/components/prssection/prssection.go b/ui/components/prssection/prssection.go index 06dbdf9..4b6fce5 100644 --- a/ui/components/prssection/prssection.go +++ b/ui/components/prssection/prssection.go @@ -75,7 +75,6 @@ func (m Model) Update(msg tea.Msg) (section.Section, tea.Cmd) { } if m.IsPromptConfirmationFocused() { - var promptCmd tea.Cmd switch { case msg.Type == tea.KeyCtrlC, msg.Type == tea.KeyEsc: @@ -104,8 +103,8 @@ func (m Model) Update(msg tea.Msg) (section.Section, tea.Cmd) { return &m, tea.Batch(cmd, blinkCmd) } - m.PromptConfirmationBox, promptCmd = m.PromptConfirmationBox.Update(msg) - return &m, promptCmd + + break } switch { @@ -167,7 +166,10 @@ func (m Model) Update(msg tea.Msg) (section.Section, tea.Cmd) { search, searchCmd := m.SearchBar.Update(msg) m.SearchBar = search - return &m, tea.Batch(cmd, searchCmd) + + prompt, promptCmd := m.PromptConfirmationBox.Update(msg) + m.PromptConfirmationBox = prompt + return &m, tea.Batch(cmd, searchCmd, promptCmd) } func GetSectionColumns( diff --git a/ui/components/section/section.go b/ui/components/section/section.go index 1f44405..7cf34f7 100644 --- a/ui/components/section/section.go +++ b/ui/components/section/section.go @@ -313,7 +313,6 @@ func (m *Model) View() string { lipgloss.Left, search, m.GetMainContent(), - m.GetPromptConfirmation(), ), ) } @@ -346,7 +345,6 @@ func (m *Model) GetPagerContent() string { pager := m.Ctx.Styles.ListViewPort.PagerStyle.Copy().Render(pagerContent) return pager } - func (m *Model) GetPromptConfirmation() string { if m.IsPromptConfirmationShown { var prompt string @@ -369,9 +367,10 @@ func (m *Model) GetPromptConfirmation() string { case m.PromptConfirmationAction == "reopen" && m.Ctx.View == config.IssuesView: prompt = "Are you sure you want to reopen this issue? (Y/n) " } + m.PromptConfirmationBox.SetPrompt(prompt) - return m.PromptConfirmationBox.View() + return m.Ctx.Styles.ListViewPort.PagerStyle.Copy().Render(m.PromptConfirmationBox.View()) } return "" diff --git a/ui/ui.go b/ui/ui.go index d5bd920..b32cb1e 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -401,8 +401,15 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.footer, footerCmd = m.footer.Update(msg) if currSection != nil { - m.footer.SetLeftSection(currSection.GetPagerContent()) + if currSection.IsPromptConfirmationFocused() { + m.footer.SetLeftSection(currSection.GetPromptConfirmation()) + } + + if !currSection.IsPromptConfirmationFocused() { + m.footer.SetLeftSection(currSection.GetPagerContent()) + } } + sectionCmd := m.updateCurrentSection(msg) cmds = append( cmds,