Files
houston-be/internal/processor/action/view/incident_section.go
Shashank Shekhar 233c632d38 INFRA-2866 | Create and update incident with assigner and responder from slack (#394)
* INFRA-2866 | create incident modal with product

* INFRA-2866 | Update product flow

* INFRA-2866 | Resolving review comments

* INFRA-2866 | Adding default values for product, assigner and responder

* INFRA-2866 | bug fix in getting assigner and responder team

* INFRA-2866 | bug-fix: users in no team are not getting products

* INFRA-2866 | adding log lines

* INFRA-2866 | adding assigner team members into incident

* INFRA-2866 | updated help command response text

* INFRA-2866 | adding assigner team members by severity

* INFRA-2866 | updating product list for users with no product

* INFRA-2866 | assigner teams = (teamsOfUser ++ teamsOfSelectedProducts)

* INFRA-2866 | renamed assigner to reporting team

* INFRA-2866 | query to seed product as others for current open incidents without any product
2024-03-19 16:26:30 +05:30

164 lines
3.6 KiB
Go

package view
import (
"houston/common/util"
"github.com/slack-go/slack"
)
func NewIncidentBlock() map[string]interface{} {
payload := map[string]interface{}{
"blocks": []slack.Block{
slack.NewActionBlock("start_incident_button",
slack.NewButtonBlockElement(
util.SelectProduct,
"start_incident_button_value",
&slack.TextBlockObject{
Type: slack.PlainTextType,
Text: "Start incident",
},
),
slack.NewButtonBlockElement(
string(util.ShowIncidents),
"show_incidents_button_value",
&slack.TextBlockObject{
Type: slack.PlainTextType,
Text: "Show incidents",
},
),
getHelpCommandsButtonBlockElement()),
},
}
return payload
}
func IntegrateHoustonInChannelBlock() map[string]interface{} {
fields := []*slack.TextBlockObject{
slack.NewTextBlockObject("mrkdwn", "*please integrate houston in the channel*", false, false),
}
block := slack.NewSectionBlock(nil, fields, nil)
return map[string]interface{}{
"blocks": []slack.Block{
block,
},
}
}
func ExistingIncidentOptionsBlock() map[string]interface{} {
return map[string]interface{}{
"blocks": []slack.Block{
incidentSectionBlock(),
buttonsBlock(),
},
}
}
func incidentSectionBlock() *slack.SectionBlock {
textBlock := &slack.TextBlockObject{
Type: "mrkdwn",
Text: "Incident",
}
optionBlockObjects := []*slack.OptionBlockObject{
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Assign incident role",
},
Value: util.AssignIncidentRole,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Resolve incident",
},
Value: util.ResolveIncident,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Set incident status",
},
Value: util.SetIncidentStatus,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Set product",
},
Value: util.SetProduct,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Set responder team",
},
Value: util.SetResponderTeam,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Set incident severity",
},
Value: util.SetIncidentSeverity,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Set incident title",
},
Value: util.SetIncidentTitle,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Set incident description",
},
Value: util.SetIncidentDescription,
},
{
Text: &slack.TextBlockObject{
Type: "plain_text",
Text: "Mark incident as duplicate",
},
Value: util.MarkIncidentDuplicate,
},
}
accessoryOption := &slack.Accessory{
SelectElement: &slack.SelectBlockElement{
Type: "static_select",
ActionID: "incident",
Options: optionBlockObjects,
Placeholder: slack.NewTextBlockObject("plain_text", "Select command", false, false),
},
}
return slack.NewSectionBlock(textBlock, nil, accessoryOption, slack.SectionBlockOptionBlockID("incident"))
}
func buttonsBlock() *slack.ActionBlock {
return slack.NewActionBlock(util.ButtonsBlock, getFillRcaButtonBlockElement(), getHelpCommandsButtonBlockElement())
}
func getFillRcaButtonBlockElement() *slack.ButtonBlockElement {
return slack.NewButtonBlockElement(
util.SetRCADetails,
util.SetRCADetails,
&slack.TextBlockObject{
Type: slack.PlainTextType,
Text: "Fill RCA details",
},
)
}
func getHelpCommandsButtonBlockElement() *slack.ButtonBlockElement {
return slack.NewButtonBlockElement(
util.HelpCommand,
"help_commands_button_value",
&slack.TextBlockObject{
Type: slack.PlainTextType,
Text: "Help-commands",
},
)
}