68 lines
2.3 KiB
Go
68 lines
2.3 KiB
Go
package houston
|
|
|
|
import (
|
|
"houston/entity"
|
|
|
|
"github.com/slack-go/slack"
|
|
)
|
|
|
|
func GenerateModalForIncidentAssign(channel slack.Channel) slack.ModalViewRequest {
|
|
|
|
titleText := slack.NewTextBlockObject("plain_text", "Houston", false, false)
|
|
closeText := slack.NewTextBlockObject("plain_text", "Close", false, false)
|
|
submitText := slack.NewTextBlockObject("plain_text", "Submit", false, false)
|
|
headerText := slack.NewTextBlockObject("mrkdwn", ":information_source: Incident roles are customizable by your organization. While a user can be assigned multiple roles, a role cannot be assigned to multiple users.", false, false)
|
|
headerSection := slack.NewSectionBlock(headerText, nil, nil)
|
|
|
|
optionBlockObjects := []*slack.OptionBlockObject{
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: string(entity.RESPONDER),
|
|
},
|
|
Value: string(entity.RESPONDER),
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: string(entity.SERVICE_OWNER),
|
|
},
|
|
Value: string(entity.SERVICE_OWNER),
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: string(entity.RETROSPECTIVE),
|
|
},
|
|
Value: string(entity.RETROSPECTIVE),
|
|
},
|
|
}
|
|
|
|
rolePlaceholder := slack.NewTextBlockObject("plain_text", "Select a role", false, false)
|
|
roleTypeOption := slack.NewOptionsSelectBlockElement(slack.OptTypeStatic, rolePlaceholder, "role_type", optionBlockObjects...)
|
|
roleTypeText := slack.NewTextBlockObject(slack.PlainTextType, "Roles", false, false)
|
|
roleBlock := slack.NewInputBlock("role_type", roleTypeText, nil, roleTypeOption)
|
|
|
|
userPlaceholder := slack.NewTextBlockObject("plain_text", "Select people", false, false)
|
|
userTypeOption := slack.NewOptionsSelectBlockElement(slack.OptTypeUser, userPlaceholder, "users_select")
|
|
userTypeText := slack.NewTextBlockObject(slack.PlainTextType, "Users", false, false)
|
|
userBlock := slack.NewInputBlock("user_type", userTypeText, nil, userTypeOption)
|
|
blocks := slack.Blocks{
|
|
BlockSet: []slack.Block{
|
|
headerSection,
|
|
roleBlock,
|
|
userBlock,
|
|
},
|
|
}
|
|
return slack.ModalViewRequest{
|
|
Type: slack.ViewType("modal"),
|
|
Title: titleText,
|
|
Close: closeText,
|
|
Submit: submitText,
|
|
Blocks: blocks,
|
|
PrivateMetadata: channel.ID,
|
|
CallbackID: "assignIncidentRole",
|
|
}
|
|
|
|
}
|