Skip to content

Commit

Permalink
Improve the consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
canack committed Mar 13, 2024
1 parent cff6c62 commit 52fde5c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions internal/terminal/handler/ghtrigger/ghtrigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (m *ModelGithubTrigger) switchBetweenInputAndTable() {
m.textInput.SetCursor(len(m.textInput.Value()))
}

func (m *ModelGithubTrigger) inputController(ctx context.Context) {
func (m *ModelGithubTrigger) inputController(_ context.Context) {
if m.workflowContent == nil {
return
}
Expand Down Expand Up @@ -254,13 +254,14 @@ func (m *ModelGithubTrigger) inputController(ctx context.Context) {

for i, choice := range m.workflowContent.Choices {
var selectedRow = m.tableTrigger.SelectedRow()
if len(selectedRow) == 0 {
var rows = m.tableTrigger.Rows()

if len(selectedRow) == 0 || len(rows) == 0 {
return
}
if fmt.Sprintf("%d", choice.ID) == selectedRow[0] {
m.workflowContent.Choices[i].SetValue(m.optionValues[m.optionCursor])

rows := m.tableTrigger.Rows()
for i, row := range rows {
if row[0] == selectedRow[0] {
rows[i][4] = m.optionValues[m.optionCursor]
Expand All @@ -274,13 +275,13 @@ func (m *ModelGithubTrigger) inputController(ctx context.Context) {
if m.workflowContent.Boolean != nil {
for i, boolean := range m.workflowContent.Boolean {
var selectedRow = m.tableTrigger.SelectedRow()
if len(selectedRow) == 0 {
var rows = m.tableTrigger.Rows()
if len(selectedRow) == 0 || len(rows) == 0 {
return
}
if fmt.Sprintf("%d", boolean.ID) == selectedRow[0] {
m.workflowContent.Boolean[i].SetValue(m.optionValues[m.optionCursor])

rows := m.tableTrigger.Rows()
for i, row := range rows {
if row[0] == selectedRow[0] {
rows[i][4] = m.optionValues[m.optionCursor]
Expand All @@ -298,15 +299,16 @@ func (m *ModelGithubTrigger) inputController(ctx context.Context) {
}

var selectedRow = m.tableTrigger.SelectedRow()
if len(selectedRow) == 0 {
var rows = m.tableTrigger.Rows()
if len(selectedRow) == 0 || len(rows) == 0 {
return
}

for i, input := range m.workflowContent.Inputs {
if fmt.Sprintf("%d", input.ID) == selectedRow[0] {
m.textInput.Placeholder = input.Default
m.workflowContent.Inputs[i].SetValue(m.textInput.Value())

rows := m.tableTrigger.Rows()
for i, row := range rows {
if row[0] == selectedRow[0] {
rows[i][4] = m.textInput.Value()
Expand All @@ -322,7 +324,6 @@ func (m *ModelGithubTrigger) inputController(ctx context.Context) {
m.textInput.Placeholder = keyVal.Default
m.workflowContent.KeyVals[i].SetValue(m.textInput.Value())

rows := m.tableTrigger.Rows()
for i, row := range rows {
if row[0] == selectedRow[0] {
rows[i][4] = m.textInput.Value()
Expand Down

0 comments on commit 52fde5c

Please sign in to comment.