Alerting: Add validation to slack contact point (#45618)
* add requiredifempty * rename field, fix logic * update mockdata * remove logs * update test * fix json expected payload in e2e tests * fix test * fix test again Co-authored-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
This commit is contained in:
co-authored by
Jean-Philippe Quémémer
parent
a68a570e92
commit
4ef58e595c
@@ -45,6 +45,7 @@ type NotifierOption struct {
|
||||
Required bool `json:"required"`
|
||||
ValidationRule string `json:"validationRule"`
|
||||
Secure bool `json:"secure"`
|
||||
DependsOn string `json:"dependsOn"`
|
||||
}
|
||||
|
||||
// InputType is the type of input that can be rendered in the frontend.
|
||||
|
||||
@@ -382,6 +382,8 @@ func GetAvailableNotifiers() []*alerting.NotifierPlugin {
|
||||
InputType: alerting.InputTypeText,
|
||||
Description: "Specify channel, private group, or IM channel (can be an encoded ID or a name) - required unless you provide a webhook",
|
||||
PropertyName: "recipient",
|
||||
Required: true,
|
||||
DependsOn: "secureSettings.url",
|
||||
},
|
||||
// Logically, this field should be required when not using a webhook, since the Slack API needs a token.
|
||||
// However, since the UI doesn't allow to say that a field is required or not depending on another field,
|
||||
@@ -394,6 +396,8 @@ func GetAvailableNotifiers() []*alerting.NotifierPlugin {
|
||||
Description: "Provide a Slack API token (starts with \"xoxb\") - required unless you provide a webhook",
|
||||
PropertyName: "token",
|
||||
Secure: true,
|
||||
Required: true,
|
||||
DependsOn: "secureSettings.url",
|
||||
},
|
||||
{
|
||||
Label: "Username",
|
||||
@@ -458,6 +462,8 @@ func GetAvailableNotifiers() []*alerting.NotifierPlugin {
|
||||
Placeholder: "Slack incoming webhook URL",
|
||||
PropertyName: "url",
|
||||
Secure: true,
|
||||
Required: true,
|
||||
DependsOn: "secureSettings.token",
|
||||
},
|
||||
{ // New in 8.4.
|
||||
Label: "Endpoint URL",
|
||||
|
||||
Reference in New Issue
Block a user