Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
hirenko-v authored Sep 19, 2024
1 parent 8c18bf6 commit aa5b2af
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions cmd/msg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ func (MsgExecutor) Execute(_ context.Context, in executor.ExecuteInput) (executo
if len(commandParts) > 2 && commandParts[1] == "selects" {
switch commandParts[2] {
case "first":
// First option is selected, respond appropriately
return executor.ExecuteOutput{
Message: api.NewCodeBlockMessage(fmt.Sprintf("You selected: %s", commandParts[3]), true),
}, nil
// User selected the first option, now show the second option
return showSecondSelect(), nil
case "second":
// Second option is selected, handle the final selection
// User selected the second option, respond accordingly
return executor.ExecuteOutput{
Message: api.NewCodeBlockMessage(fmt.Sprintf("You selected: %s", commandParts[3]), true),
}, nil
Expand All @@ -64,7 +62,7 @@ func (MsgExecutor) Execute(_ context.Context, in executor.ExecuteInput) (executo
}, nil
}

// initialMessages shows both selects side by side.
// initialMessages shows only the first select option.
func initialMessages() executor.ExecuteOutput {
cmdPrefix := func(cmd string) string {
return fmt.Sprintf("%s %s %s", api.MessageBotNamePlaceholder, pluginName, cmd)
Expand Down Expand Up @@ -97,6 +95,25 @@ func initialMessages() executor.ExecuteOutput {
},
},
},
},
OnlyVisibleForYou: true,
ReplaceOriginal: false,
},
}
}

// showSecondSelect displays the second select option after the first one is selected.
func showSecondSelect() executor.ExecuteOutput {
cmdPrefix := func(cmd string) string {
return fmt.Sprintf("%s %s %s", api.MessageBotNamePlaceholder, pluginName, cmd)
}

return executor.ExecuteOutput{
Message: api.Message{
BaseBody: api.Body{
Plaintext: "You've selected from the first dropdown. Now select from the second.",
},
Sections: []api.Section{
{
Selects: api.Selects{
ID: "select-id-2",
Expand All @@ -123,7 +140,7 @@ func initialMessages() executor.ExecuteOutput {
},
},
OnlyVisibleForYou: true,
ReplaceOriginal: false,
ReplaceOriginal: true,
},
}
}
Expand Down

0 comments on commit aa5b2af

Please sign in to comment.