mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Alerting: Fix width of Adapative Cards in Teams notifications (#53996)
This commit is contained in:
parent
2caaa7fba2
commit
e163a976fa
@ -69,10 +69,10 @@ type AdaptiveCardsAttachment struct {
|
||||
// AdapativeCard repesents an Adaptive Card.
|
||||
// https://adaptivecards.io/explorer/AdaptiveCard.html
|
||||
type AdaptiveCard struct {
|
||||
Body []AdaptiveCardItem `json:"body"`
|
||||
Schema string `json:"$schema"`
|
||||
Type string `json:"type"`
|
||||
Version string `json:"version"`
|
||||
Body []AdaptiveCardItem
|
||||
Schema string
|
||||
Type string
|
||||
Version string
|
||||
}
|
||||
|
||||
// NewAdaptiveCard returns a prepared Adaptive Card.
|
||||
@ -85,6 +85,22 @@ func NewAdaptiveCard() AdaptiveCard {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AdaptiveCard) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Body []AdaptiveCardItem `json:"body"`
|
||||
Schema string `json:"$schema"`
|
||||
Type string `json:"type"`
|
||||
Version string `json:"version"`
|
||||
MsTeams map[string]interface{} `json:"msTeams,omitempty"`
|
||||
}{
|
||||
Body: c.Body,
|
||||
Schema: c.Schema,
|
||||
Type: c.Type,
|
||||
Version: c.Version,
|
||||
MsTeams: map[string]interface{}{"width": "Full"},
|
||||
})
|
||||
}
|
||||
|
||||
// AppendItem appends an item, such as text or an image, to the Adaptive Card.
|
||||
func (c *AdaptiveCard) AppendItem(i AdaptiveCardItem) {
|
||||
c.Body = append(c.Body, i)
|
||||
|
@ -70,6 +70,9 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
}},
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4",
|
||||
"msTeams": map[string]interface{}{
|
||||
"width": "Full",
|
||||
},
|
||||
},
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
}},
|
||||
@ -123,6 +126,9 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
}},
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4",
|
||||
"msTeams": map[string]interface{}{
|
||||
"width": "Full",
|
||||
},
|
||||
},
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
}},
|
||||
@ -176,6 +182,9 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
}},
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4",
|
||||
"msTeams": map[string]interface{}{
|
||||
"width": "Full",
|
||||
},
|
||||
},
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
}},
|
||||
@ -228,6 +237,9 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
}},
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4",
|
||||
"msTeams": map[string]interface{}{
|
||||
"width": "Full",
|
||||
},
|
||||
},
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
}},
|
||||
|
@ -2224,7 +2224,10 @@ var expNonEmailNotifications = map[string][]string{
|
||||
}
|
||||
],
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4"
|
||||
"version": "1.4",
|
||||
"msTeams": {
|
||||
"width": "Full"
|
||||
}
|
||||
},
|
||||
"contentType": "application/vnd.microsoft.card.adaptive"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user