Chore: Move dashboard models to dashboard pkg (#61458)

* Copy dashboard models to dashboard pkg

* Use some models from current pkg instead of models

* Adjust api pkg

* Adjust pkg services

* Fix lint
This commit is contained in:
idafurjes
2023-01-16 16:33:55 +01:00
committed by GitHub
parent 07bbc0716c
commit 7c2522c477
83 changed files with 1770 additions and 1444 deletions
@@ -14,7 +14,6 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/annotations"
"github.com/grafana/grafana/pkg/services/dashboards"
@@ -61,9 +60,9 @@ func TestIntegrationAnnotations(t *testing.T) {
dashboardStore, err := dashboardstore.ProvideDashboardStore(sql, sql.Cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sql, sql.Cfg), quotaService)
require.NoError(t, err)
testDashboard1 := models.SaveDashboardCommand{
UserId: 1,
OrgId: 1,
testDashboard1 := dashboards.SaveDashboardCommand{
UserID: 1,
OrgID: 1,
Dashboard: simplejson.NewFromAny(map[string]interface{}{
"title": "Dashboard 1",
}),
@@ -72,9 +71,9 @@ func TestIntegrationAnnotations(t *testing.T) {
dashboard, err := dashboardStore.SaveDashboard(context.Background(), testDashboard1)
require.NoError(t, err)
testDashboard2 := models.SaveDashboardCommand{
UserId: 1,
OrgId: 1,
testDashboard2 := dashboards.SaveDashboardCommand{
UserID: 1,
OrgID: 1,
Dashboard: simplejson.NewFromAny(map[string]interface{}{
"title": "Dashboard 2",
}),
@@ -85,7 +84,7 @@ func TestIntegrationAnnotations(t *testing.T) {
annotation := &annotations.Item{
OrgId: 1,
UserId: 1,
DashboardId: dashboard.Id,
DashboardId: dashboard.ID,
Text: "hello",
Type: "alert",
Epoch: 10,
@@ -100,7 +99,7 @@ func TestIntegrationAnnotations(t *testing.T) {
annotation2 := &annotations.Item{
OrgId: 1,
UserId: 1,
DashboardId: dashboard2.Id,
DashboardId: dashboard2.ID,
Text: "hello",
Type: "alert",
Epoch: 21, // Should swap epoch & epochEnd
@@ -139,7 +138,7 @@ func TestIntegrationAnnotations(t *testing.T) {
t.Run("Can query for annotation by dashboard id", func(t *testing.T) {
items, err := repo.Get(context.Background(), &annotations.ItemQuery{
OrgId: 1,
DashboardId: dashboard.Id,
DashboardId: dashboard.ID,
From: 0,
To: 15,
SignedInUser: testUser,
@@ -417,7 +416,7 @@ func TestIntegrationAnnotations(t *testing.T) {
annotation3 := &annotations.Item{
OrgId: 1,
UserId: 1,
DashboardId: dashboard2.Id,
DashboardId: dashboard2.ID,
Text: "toBeDeletedWithPanelId",
Type: "alert",
Epoch: 11,
@@ -501,9 +500,9 @@ func TestIntegrationAnnotationListingWithRBAC(t *testing.T) {
dashboardStore, err := dashboardstore.ProvideDashboardStore(sql, sql.Cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sql, sql.Cfg), quotaService)
require.NoError(t, err)
testDashboard1 := models.SaveDashboardCommand{
UserId: 1,
OrgId: 1,
testDashboard1 := dashboards.SaveDashboardCommand{
UserID: 1,
OrgID: 1,
IsFolder: false,
Dashboard: simplejson.NewFromAny(map[string]interface{}{
"title": "Dashboard 1",
@@ -511,11 +510,11 @@ func TestIntegrationAnnotationListingWithRBAC(t *testing.T) {
}
dashboard, err := dashboardStore.SaveDashboard(context.Background(), testDashboard1)
require.NoError(t, err)
dash1UID := dashboard.Uid
dash1UID := dashboard.UID
testDashboard2 := models.SaveDashboardCommand{
UserId: 1,
OrgId: 1,
testDashboard2 := dashboards.SaveDashboardCommand{
UserID: 1,
OrgID: 1,
Dashboard: simplejson.NewFromAny(map[string]interface{}{
"title": "Dashboard 2",
}),