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
@@ -171,3 +171,21 @@ func (d *PublicDashboardStoreImpl) UpdatePublicDashboardConfig(ctx context.Conte
return err
}
func (d *PublicDashboardStoreImpl) PublicDashboardEnabled(ctx context.Context, dashboardUid string) (bool, error) {
hasPublicDashboard := false
err := d.sqlStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
sql := "SELECT COUNT(*) FROM dashboard_public WHERE dashboard_uid=? AND is_enabled=true"
result, err := dbSession.SQL(sql, dashboardUid).Count()
if err != nil {
return err
}
hasPublicDashboard = result > 0
return err
})
return hasPublicDashboard, err
}