Skip to content

Commit

Permalink
Merge pull request #62 from termkit/feature/i47-fill-table-if-empty
Browse files Browse the repository at this point in the history
Feature #47 : Fill workflow with empty message if no workflow inputs
  • Loading branch information
canack committed Jun 26, 2024
2 parents 31cd0c4 + 516db5a commit 4b434b4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/terminal/handler/ghtrigger/ghtrigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ func (m *ModelGithubTrigger) syncWorkflowContent(ctx context.Context) {
if len(workflowContent.Workflow.KeyVals) == 0 &&
len(workflowContent.Workflow.Choices) == 0 &&
len(workflowContent.Workflow.Inputs) == 0 {
m.fillTableWithEmptyMessage()
m.modelError.SetDefaultMessage(fmt.Sprintf("[%s@%s] Workflow doesn't contain options but still triggerable",
m.SelectedRepository.RepositoryName, m.SelectedRepository.BranchName))
} else {
Expand All @@ -480,6 +481,19 @@ func (m *ModelGithubTrigger) syncWorkflowContent(ctx context.Context) {
go m.Update(m) // update model
}

func (m *ModelGithubTrigger) fillTableWithEmptyMessage() {
var rows []table.Row
for i := 0; i < 100; i++ {
idx := fmt.Sprintf("%d", i)
rows = append(rows, table.Row{
idx, "EMPTY", "EMPTY", "EMPTY", "No workflow input found",
})
}

m.tableTrigger.SetRows(rows)
m.tableTrigger.SetCursor(0)
}

func (m *ModelGithubTrigger) showInformationIfAnyEmptyValue() {
for _, row := range m.tableTrigger.Rows() {
if row[4] == "" {
Expand Down

0 comments on commit 4b434b4

Please sign in to comment.