Public Dashboards: Disable email-sharing when there is no license (#80887)
* PublicDashboards: Disable email-shared dashboards when feature is disabled * fix pubdash creation when it was email-shared * add feature name const in OSS * update doc * Update service.go * fix test & linter * fix test * Update query_test.go * update tests * fix imports * fix doc linter issues * Update docs/sources/administration/enterprise-licensing/_index.md * fix after merge
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/licensing"
|
||||
"github.com/grafana/grafana/pkg/services/publicdashboards"
|
||||
. "github.com/grafana/grafana/pkg/services/publicdashboards/models"
|
||||
"github.com/grafana/grafana/pkg/services/publicdashboards/validation"
|
||||
@@ -28,6 +29,7 @@ type Api struct {
|
||||
accessControl accesscontrol.AccessControl
|
||||
cfg *setting.Cfg
|
||||
features featuremgmt.FeatureToggles
|
||||
license licensing.Licensing
|
||||
log log.Logger
|
||||
routeRegister routing.RouteRegister
|
||||
}
|
||||
@@ -39,6 +41,7 @@ func ProvideApi(
|
||||
features featuremgmt.FeatureToggles,
|
||||
md publicdashboards.Middleware,
|
||||
cfg *setting.Cfg,
|
||||
license licensing.Licensing,
|
||||
) *Api {
|
||||
api := &Api{
|
||||
PublicDashboardService: pd,
|
||||
@@ -46,6 +49,7 @@ func ProvideApi(
|
||||
accessControl: ac,
|
||||
cfg: cfg,
|
||||
features: features,
|
||||
license: license,
|
||||
log: log.New("publicdashboards.api"),
|
||||
routeRegister: rr,
|
||||
}
|
||||
@@ -158,8 +162,8 @@ func (api *Api) GetPublicDashboard(c *contextmodel.ReqContext) response.Response
|
||||
return response.Err(err)
|
||||
}
|
||||
|
||||
if pd == nil {
|
||||
response.Err(ErrPublicDashboardNotFound.Errorf("GetPublicDashboard: public dashboard not found"))
|
||||
if pd == nil || (!api.license.FeatureEnabled(FeaturePublicDashboardsEmailSharing) && pd.Share == EmailShareType) {
|
||||
return response.Err(ErrPublicDashboardNotFound.Errorf("GetPublicDashboard: public dashboard not found"))
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, pd)
|
||||
|
||||
Reference in New Issue
Block a user