287 lines
6.4 KiB
Go
287 lines
6.4 KiB
Go
package view
|
|
|
|
import (
|
|
"github.com/slack-go/slack"
|
|
"houston/common/util"
|
|
)
|
|
|
|
func NewIncidentBlock() map[string]interface{} {
|
|
payload := map[string]interface{}{
|
|
"blocks": []slack.Block{
|
|
slack.NewActionBlock("start_incident_button",
|
|
slack.NewButtonBlockElement(
|
|
string(util.StartIncident),
|
|
"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",
|
|
},
|
|
),
|
|
slack.NewButtonBlockElement(
|
|
"show_on_call_button",
|
|
"show_on_call_button_value",
|
|
&slack.TextBlockObject{
|
|
Type: slack.PlainTextType,
|
|
Text: "Show On-Call",
|
|
},
|
|
),
|
|
slack.NewButtonBlockElement(
|
|
"help_commands_button",
|
|
"help_commands_button_value",
|
|
&slack.TextBlockObject{
|
|
Type: slack.PlainTextType,
|
|
Text: "Help-Commands",
|
|
},
|
|
)),
|
|
},
|
|
}
|
|
|
|
return payload
|
|
}
|
|
|
|
func ExistingIncidentOptionsBlock() map[string]interface{} {
|
|
return map[string]interface{}{
|
|
"blocks": []slack.Block{
|
|
incidentSectionBlock(),
|
|
taskSectionBlock(),
|
|
tagsSectionBlock(),
|
|
onCallSectionBlock(),
|
|
botHelpSectionBlock(),
|
|
},
|
|
}
|
|
}
|
|
|
|
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 Incident Type",
|
|
},
|
|
Value: util.SetIncidentType,
|
|
},
|
|
{
|
|
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,
|
|
},
|
|
}
|
|
|
|
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 taskSectionBlock() *slack.SectionBlock {
|
|
textBlock := &slack.TextBlockObject{
|
|
Type: "mrkdwn",
|
|
Text: "Task",
|
|
}
|
|
|
|
optionBlockObjects := []*slack.OptionBlockObject{
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Add Task",
|
|
},
|
|
Value: "addTask",
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Assign Task",
|
|
},
|
|
Value: "assignTask",
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "View Your Tasks",
|
|
},
|
|
Value: "viewYourTasks",
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "View All Tasks",
|
|
},
|
|
Value: "viewAllTasks",
|
|
},
|
|
}
|
|
|
|
accessoryOption := &slack.Accessory{
|
|
SelectElement: &slack.SelectBlockElement{
|
|
Type: "static_select",
|
|
ActionID: "task",
|
|
Options: optionBlockObjects,
|
|
Placeholder: slack.NewTextBlockObject("plain_text", "Select Command", false, false),
|
|
},
|
|
}
|
|
return slack.NewSectionBlock(textBlock, nil, accessoryOption, slack.SectionBlockOptionBlockID("task"))
|
|
}
|
|
|
|
func tagsSectionBlock() *slack.SectionBlock {
|
|
textBlock := &slack.TextBlockObject{
|
|
Type: "mrkdwn",
|
|
Text: "Tags",
|
|
}
|
|
|
|
optionBlockObjects := []*slack.OptionBlockObject{
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Add Tag(s)",
|
|
},
|
|
Value: util.AddTags,
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Show Tags",
|
|
},
|
|
Value: util.ShowTags,
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Remove Tag",
|
|
},
|
|
Value: util.RemoveTag,
|
|
},
|
|
}
|
|
|
|
accessoryOption := &slack.Accessory{
|
|
SelectElement: &slack.SelectBlockElement{
|
|
Type: "static_select",
|
|
ActionID: "tags",
|
|
Options: optionBlockObjects,
|
|
Placeholder: slack.NewTextBlockObject("plain_text", "Select Command", false, false),
|
|
},
|
|
}
|
|
return slack.NewSectionBlock(textBlock, nil, accessoryOption, slack.SectionBlockOptionBlockID("tags"))
|
|
}
|
|
|
|
func onCallSectionBlock() *slack.SectionBlock {
|
|
textBlock := &slack.TextBlockObject{
|
|
Type: "mrkdwn",
|
|
Text: "On-Call",
|
|
}
|
|
|
|
optionBlockObjects := []*slack.OptionBlockObject{
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Show On-Call",
|
|
},
|
|
Value: "showOncall",
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Show Escalation Policy",
|
|
},
|
|
Value: "showEscalationPolicy",
|
|
},
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Trigger Alert",
|
|
},
|
|
Value: "triggerAlert",
|
|
},
|
|
}
|
|
|
|
accessoryOption := &slack.Accessory{
|
|
SelectElement: &slack.SelectBlockElement{
|
|
Type: "static_select",
|
|
ActionID: "on-call",
|
|
Options: optionBlockObjects,
|
|
Placeholder: slack.NewTextBlockObject("plain_text", "Select Command", false, false),
|
|
},
|
|
}
|
|
return slack.NewSectionBlock(textBlock, nil, accessoryOption, slack.SectionBlockOptionBlockID("on-call"))
|
|
}
|
|
|
|
func botHelpSectionBlock() *slack.SectionBlock {
|
|
textBlock := &slack.TextBlockObject{
|
|
Type: "mrkdwn",
|
|
Text: "Bot Help",
|
|
}
|
|
|
|
optionBlockObjects := []*slack.OptionBlockObject{
|
|
{
|
|
Text: &slack.TextBlockObject{
|
|
Type: "plain_text",
|
|
Text: "Help - Commands",
|
|
},
|
|
Value: "helpCommands",
|
|
},
|
|
}
|
|
|
|
accessoryOption := &slack.Accessory{
|
|
SelectElement: &slack.SelectBlockElement{
|
|
Type: "static_select",
|
|
ActionID: "bot-helps",
|
|
Options: optionBlockObjects,
|
|
Placeholder: slack.NewTextBlockObject("plain_text", "Select Command", false, false),
|
|
},
|
|
}
|
|
return slack.NewSectionBlock(textBlock, nil, accessoryOption, slack.SectionBlockOptionBlockID("bot-helps"))
|
|
}
|