Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions internal/devtui/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,37 @@ func TestStartStorefrontWatchRequest_OpensPicker(t *testing.T) {
_, ok := m.modal.(*salesChannelPicker)
assert.True(t, ok, "parent must open the sales-channel picker on the request")
}

func TestView_WindowTitlePerPhase(t *testing.T) {
cases := []struct {
phase phase
wantTitle string
}{
{phaseDashboard, "[project] · Overview"},
{phaseStarting, "[project] · Starting..."},
{phaseStopping, "[project] · Stopping"},
{phaseInstallPrompt, "[project] · Install"},
{phaseInstalling, "[project] · Installing..."},
{phaseMigrationWizard, "[project] · Setup"},
}

for _, tc := range cases {
m := newTestModel()
m.width = 120
m.height = 40
m.phase = tc.phase
if tc.phase == phaseMigrationWizard {
m.migrationWizard = newMigrationWizard("")
}
if tc.phase == phaseStarting || tc.phase == phaseStopping {
m.dockerSpinner = newBrandSpinner()
}
if tc.phase == phaseInstalling {
m.installProg.spinner = newBrandSpinner()
m.installProg.progress = newInstallProgress()
}

v := m.View()
assert.Equal(t, tc.wantTitle, v.WindowTitle, "phase %d", tc.phase)
}
}
18 changes: 17 additions & 1 deletion internal/devtui/model_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package devtui

import (
"fmt"
"path/filepath"
"strings"

tea "charm.land/bubbletea/v2"
Expand All @@ -17,12 +18,24 @@ func (m Model) View() tea.View {

v := tea.NewView("")
v.AltScreen = true
dir := "[" + filepath.Base(m.projectRoot) + "] · "

switch m.phase {
case phaseDashboard:
v.Content = m.renderDashboard()
case phaseStarting, phaseStopping, phaseInstallPrompt, phaseInstalling:
v.WindowTitle = dir + tabNames[m.activeTab]
case phaseStarting:
v.Content = m.renderPhase()
v.WindowTitle = dir + "Starting..."
case phaseStopping:
v.Content = m.renderPhase()
v.WindowTitle = dir + "Stopping"
case phaseInstallPrompt:
v.Content = m.renderPhase()
v.WindowTitle = dir + "Install"
case phaseInstalling:
v.Content = m.renderPhase()
v.WindowTitle = dir + "Installing..."
case phaseTask:
title := m.taskTitle
if !m.taskDone {
Expand All @@ -31,6 +44,9 @@ func (m Model) View() tea.View {
v.Content = m.renderDockerLogs(title, "")
case phaseMigrationWizard:
v.Content = m.renderMigrationWizard()
v.WindowTitle = dir + "Setup"
default:
v.WindowTitle = dir + "shopware-cli"
}

if m.modal != nil {
Expand Down
Loading