Public Dashboards: Add Public Tag to Dashboard Title (#52351)

Adds Public tag to dashboard title when it has an enabled public dashboard
This commit is contained in:
owensmallwood
2022-07-19 17:44:41 -06:00
committed by GitHub
parent acd85314b3
commit 3bc13e2335
13 changed files with 143 additions and 6 deletions
+13
View File
@@ -77,6 +77,18 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
if rsp != nil {
return rsp
}
var (
hasPublicDashboard bool
err error
)
if hs.Features.IsEnabled(featuremgmt.FlagPublicDashboards) {
hasPublicDashboard, err = hs.PublicDashboardsApi.PublicDashboardService.PublicDashboardEnabled(c.Req.Context(), dash.Uid)
if err != nil {
return response.Error(500, "Error while retrieving public dashboards", err)
}
}
// When dash contains only keys id, uid that means dashboard data is not valid and json decode failed.
if dash.Data != nil {
isEmptyData := true
@@ -139,6 +151,7 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
Url: dash.GetUrl(),
FolderTitle: "General",
AnnotationsPermissions: annotationPermissions,
PublicDashboardEnabled: hasPublicDashboard,
}
// lookup folder title
+4
View File
@@ -261,6 +261,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
AccessControl: accesscontrolmock.New(),
DashboardService: dashboardService,
dashboardVersionService: fakeDashboardVersionService,
Features: featuremgmt.WithFeatures(),
}
hs.CoremodelStaticRegistry, hs.CoremodelRegistry = setupDashboardCoremodel(t)
@@ -901,6 +902,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
SQLStore: mockSQLStore,
AccessControl: accesscontrolmock.New(),
DashboardService: dashboardService,
Features: featuremgmt.WithFeatures(),
}
hs.CoremodelStaticRegistry, hs.CoremodelRegistry = setupDashboardCoremodel(t)
hs.callGetDashboard(sc)
@@ -955,6 +957,7 @@ func getDashboardShouldReturn200WithConfig(t *testing.T, sc *scenarioContext, pr
folderPermissions, dashboardPermissions, ac,
),
DashboardService: dashboardService,
Features: featuremgmt.WithFeatures(),
}
hs.CoremodelStaticRegistry, hs.CoremodelRegistry = setupDashboardCoremodel(t)
@@ -1053,6 +1056,7 @@ func postDiffScenario(t *testing.T, desc string, url string, routePattern string
LibraryElementService: &mockLibraryElementService{},
SQLStore: sqlmock,
dashboardVersionService: fakeDashboardVersionService,
Features: featuremgmt.WithFeatures(),
}
hs.CoremodelStaticRegistry, hs.CoremodelRegistry = setupDashboardCoremodel(t)
+1
View File
@@ -34,6 +34,7 @@ type DashboardMeta struct {
ProvisionedExternalId string `json:"provisionedExternalId"`
AnnotationsPermissions *AnnotationPermission `json:"annotationsPermissions"`
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
PublicDashboardEnabled bool `json:"publicDashboardEnabled"`
}
type AnnotationPermission struct {
Dashboard AnnotationActions `json:"dashboard"`