mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: Enable creation when dashboard has template variables (#64560)
This commit is contained in:
@@ -2,17 +2,12 @@ package validation
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
. "github.com/grafana/grafana/pkg/services/publicdashboards/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/legacydata"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
func ValidatePublicDashboard(dto *SavePublicDashboardDTO, dashboard *dashboards.Dashboard) error {
|
||||
if hasTemplateVariables(dashboard) {
|
||||
return ErrPublicDashboardHasTemplateVariables.Errorf("ValidateSavePublicDashboard: public dashboard has template variables")
|
||||
}
|
||||
|
||||
func ValidatePublicDashboard(dto *SavePublicDashboardDTO) error {
|
||||
// if it is empty we override it in the service with public for retro compatibility
|
||||
if dto.PublicDashboard.Share != "" && !IsValidShareType(dto.PublicDashboard.Share) {
|
||||
return ErrInvalidShareType.Errorf("ValidateSavePublicDashboard: invalid share type")
|
||||
@@ -21,12 +16,6 @@ func ValidatePublicDashboard(dto *SavePublicDashboardDTO, dashboard *dashboards.
|
||||
return nil
|
||||
}
|
||||
|
||||
func hasTemplateVariables(dashboard *dashboards.Dashboard) bool {
|
||||
templateVariables := dashboard.Data.Get("templating").Get("list").MustArray()
|
||||
|
||||
return len(templateVariables) > 0
|
||||
}
|
||||
|
||||
func ValidateQueryPublicDashboardRequest(req PublicDashboardQueryDTO, pd *PublicDashboard) error {
|
||||
if req.IntervalMs < 0 {
|
||||
return ErrInvalidInterval.Errorf("ValidateQueryPublicDashboardRequest: intervalMS should be greater than 0")
|
||||
|
||||
Reference in New Issue
Block a user