Skip to content

Commit

Permalink
feat(ui): Remove footer left section when prompt confirmation shows
Browse files Browse the repository at this point in the history
  • Loading branch information
orlandorode97 authored and dlvhdr committed Jul 24, 2023
1 parent 144d589 commit bb6e5fc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/common/styles.go
Expand Up @@ -8,7 +8,7 @@ import (
)

var (
SearchHeight = 4
SearchHeight = 3
FooterHeight = 1
ExpandedHelpHeight = 11
InputBoxHeight = 8
Expand Down
9 changes: 5 additions & 4 deletions ui/components/issuessection/issuessection.go
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions ui/components/prompt/prompt.go
Expand Up @@ -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
}
10 changes: 6 additions & 4 deletions ui/components/prssection/prssection.go
Expand Up @@ -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:
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 2 additions & 3 deletions ui/components/section/section.go
Expand Up @@ -313,7 +313,6 @@ func (m *Model) View() string {
lipgloss.Left,
search,
m.GetMainContent(),
m.GetPromptConfirmation(),
),
)
}
Expand Down Expand Up @@ -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
Expand All @@ -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 ""
Expand Down
9 changes: 8 additions & 1 deletion ui/ui.go
Expand Up @@ -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,
Expand Down

0 comments on commit bb6e5fc

Please sign in to comment.