Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
canack committed Jan 7, 2025
1 parent 2dfbb32 commit 62e6851
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
4 changes: 3 additions & 1 deletion internal/terminal/handler/ghinformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type ModelInfo struct {
func SetupModelInfo(s *skeleton.Skeleton, githubUseCase gu.UseCase, version pkgversion.Version) *ModelInfo {
const releaseURL = "https://github.com/termkit/gama/releases"

modelStatus := SetupModelStatus(s)

return &ModelInfo{
// Initialize core dependencies
skeleton: s,
Expand All @@ -51,7 +53,7 @@ func SetupModelInfo(s *skeleton.Skeleton, githubUseCase gu.UseCase, version pkgv

// Initialize UI components
help: help.New(),
status: SetupModelStatus(s),
status: modelStatus,
keys: githubInformationKeys,

// Initialize application state
Expand Down
7 changes: 5 additions & 2 deletions internal/terminal/handler/ghrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type ModelGithubRepository struct {
// -----------------------------------------------------------------------------

func SetupModelGithubRepository(s *skeleton.Skeleton, githubUseCase gu.UseCase) *ModelGithubRepository {
modelStatus := SetupModelStatus(s)
tabOptions := NewOptions(s, modelStatus)

m := &ModelGithubRepository{
// Initialize core dependencies
skeleton: s,
Expand All @@ -62,9 +65,9 @@ func SetupModelGithubRepository(s *skeleton.Skeleton, githubUseCase gu.UseCase)
// Initialize UI components
help: help.New(),
Keys: githubRepositoryKeys,
status: SetupModelStatus(s),
status: modelStatus,
textInput: setupTextInput(),
modelTabOptions: NewOptions(s, SetupModelStatus(s)),
modelTabOptions: tabOptions,

// Initialize state
selectedRepository: NewSelectedRepository(),
Expand Down
4 changes: 3 additions & 1 deletion internal/terminal/handler/ghtrigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type ModelGithubTrigger struct {
// -----------------------------------------------------------------------------

func SetupModelGithubTrigger(s *skeleton.Skeleton, githubUseCase gu.UseCase) *ModelGithubTrigger {
modelStatus := SetupModelStatus(s)

m := &ModelGithubTrigger{
// Initialize core dependencies
skeleton: s,
Expand All @@ -77,7 +79,7 @@ func SetupModelGithubTrigger(s *skeleton.Skeleton, githubUseCase gu.UseCase) *Mo
// Initialize UI components
help: help.New(),
Keys: githubTriggerKeys,
status: SetupModelStatus(s),
status: modelStatus,
textInput: setupTriggerInput(),
tableTrigger: setupTriggerTable(),

Expand Down
12 changes: 5 additions & 7 deletions internal/terminal/handler/ghworkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type ModelGithubWorkflow struct {
// -----------------------------------------------------------------------------

func SetupModelGithubWorkflow(s *skeleton.Skeleton, githubUseCase gu.UseCase) *ModelGithubWorkflow {
modelStatus := SetupModelStatus(s)

m := &ModelGithubWorkflow{
// Initialize core dependencies
skeleton: s,
Expand All @@ -72,7 +74,7 @@ func SetupModelGithubWorkflow(s *skeleton.Skeleton, githubUseCase gu.UseCase) *M
// Initialize UI components
help: help.New(),
keys: githubWorkflowKeys,
status: SetupModelStatus(s),
status: modelStatus,
textInput: setupBranchInput(),

// Initialize state
Expand Down Expand Up @@ -148,10 +150,7 @@ func (m *ModelGithubWorkflow) Init() tea.Cmd {
}

func (m *ModelGithubWorkflow) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Check repository change and return command if exists
if cmd := m.handleRepositoryChange(); cmd != nil {
return m, cmd
}
m.handleRepositoryChange()

var cmds []tea.Cmd
var cmd tea.Cmd
Expand Down Expand Up @@ -182,7 +181,7 @@ func (m *ModelGithubWorkflow) View() string {
// Repository Change Handling
// -----------------------------------------------------------------------------

func (m *ModelGithubWorkflow) handleRepositoryChange() tea.Cmd {
func (m *ModelGithubWorkflow) handleRepositoryChange() {
if m.state.Repository.Current != m.selectedRepository.RepositoryName {
m.state.Ready = false
m.state.Repository.Current = m.selectedRepository.RepositoryName
Expand All @@ -191,7 +190,6 @@ func (m *ModelGithubWorkflow) handleRepositoryChange() tea.Cmd {
} else if !m.state.Repository.HasFlows {
m.skeleton.LockTab("trigger")
}
return nil
}

// -----------------------------------------------------------------------------
Expand Down
13 changes: 6 additions & 7 deletions internal/terminal/handler/ghworkflowhistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func SetupModelGithubWorkflowHistory(s *skeleton.Skeleton, githubUseCase gu.UseC
panic(fmt.Sprintf("failed to load config: %v", err))
}

modelStatus := SetupModelStatus(s)
tabOptions := NewOptions(s, modelStatus)
m := &ModelGithubWorkflowHistory{
// Initialize core dependencies
skeleton: s,
Expand All @@ -76,8 +78,8 @@ func SetupModelGithubWorkflowHistory(s *skeleton.Skeleton, githubUseCase gu.UseC
// Initialize UI components
Help: help.New(),
keys: githubWorkflowHistoryKeys,
status: SetupModelStatus(s),
modelTabOptions: NewOptions(s, SetupModelStatus(s)),
status: modelStatus,
modelTabOptions: tabOptions,

// Initialize state
selectedRepository: NewSelectedRepository(),
Expand Down Expand Up @@ -145,10 +147,7 @@ func (m *ModelGithubWorkflowHistory) Init() tea.Cmd {
}

func (m *ModelGithubWorkflowHistory) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Handle repository changes
if cmd := m.handleRepositoryChange(); cmd != nil {
return m, cmd
}
m.handleRepositoryChange()

cursor := m.tableWorkflowHistory.Cursor()
if m.workflows != nil && cursor >= 0 && cursor < len(m.workflows) {
Expand All @@ -174,7 +173,7 @@ func (m *ModelGithubWorkflowHistory) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

// Update UI components
if cmd = m.updateUIComponents(msg); cmd != nil {
cmds = append(cmds, cmd)
cmds = append(cmds, m.updateUIComponents(msg))
}

return m, tea.Batch(cmds...)
Expand Down

0 comments on commit 62e6851

Please sign in to comment.