Chore: Remove library panel thema (#112154)

This commit is contained in:
Ryan McKinley
2025-10-09 09:38:52 -03:00
committed by GitHub
parent 3658b1fce7
commit 7ceb4b90f6
35 changed files with 149 additions and 684 deletions
+9 -9
View File
@@ -8,13 +8,18 @@ import (
"net/http"
"strings"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
grafanaapiserver "github.com/grafana/grafana/pkg/services/apiserver"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
@@ -28,11 +33,6 @@ import (
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/errhttp"
"github.com/grafana/grafana/pkg/web"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
)
func (l *LibraryElementService) registerAPIEndpoints() {
@@ -340,7 +340,7 @@ func (l *LibraryElementService) getConnectionsHandler(c *contextmodel.ReqContext
ConnectionID: dashboard.ID, // nolint:staticcheck
ConnectionUID: dashboard.UID,
// returns the creation information of the library element, not the connection
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: element.Meta.CreatedBy.Id,
Name: element.Meta.CreatedBy.Name,
AvatarUrl: element.Meta.CreatedBy.AvatarUrl,
@@ -713,7 +713,7 @@ func (lk8s *libraryElementsK8sHandler) unstructuredToLegacyLibraryPanelDTO(c *co
}
for _, user := range users {
if user.UID == createdBy {
dto.Meta.CreatedBy = librarypanel.LibraryElementDTOMetaUser{
dto.Meta.CreatedBy = model.LibraryElementDTOMetaUser{
Id: user.ID,
Name: user.Login,
AvatarUrl: dtos.GetGravatarUrl(lk8s.cfg, user.Email),
@@ -721,7 +721,7 @@ func (lk8s *libraryElementsK8sHandler) unstructuredToLegacyLibraryPanelDTO(c *co
}
// not else because /api returns the same user for updated if it was never updated
if user.UID == updatedBy {
dto.Meta.UpdatedBy = librarypanel.LibraryElementDTOMetaUser{
dto.Meta.UpdatedBy = model.LibraryElementDTOMetaUser{
Id: user.ID,
Name: user.Login,
AvatarUrl: dtos.GetGravatarUrl(lk8s.cfg, user.Email),
+10 -11
View File
@@ -12,7 +12,6 @@ import (
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/featuremgmt"
@@ -200,12 +199,12 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
ConnectedDashboards: 0,
Created: element.Created,
Updated: element.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: element.CreatedBy,
Name: signedInUser.GetLogin(),
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, signedInUser.GetEmail()),
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: element.UpdatedBy,
Name: signedInUser.GetLogin(),
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, signedInUser.GetEmail()),
@@ -363,12 +362,12 @@ func (l *LibraryElementService) getLibraryElements(c context.Context, store db.D
ConnectedDashboards: libraryElement.ConnectedDashboards,
Created: libraryElement.Created,
Updated: libraryElement.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: libraryElement.CreatedBy,
Name: libraryElement.CreatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, libraryElement.CreatedByEmail),
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: libraryElement.UpdatedBy,
Name: libraryElement.UpdatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, libraryElement.UpdatedByEmail),
@@ -509,12 +508,12 @@ func (l *LibraryElementService) getAllLibraryElements(c context.Context, signedI
ConnectedDashboards: element.ConnectedDashboards,
Created: element.Created,
Updated: element.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: element.CreatedBy,
Name: element.CreatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.CreatedByEmail),
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: element.UpdatedBy,
Name: element.UpdatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.UpdatedByEmail),
@@ -670,12 +669,12 @@ func (l *LibraryElementService) patchLibraryElement(c context.Context, signedInU
ConnectedDashboards: elementInDB.ConnectedDashboards,
Created: libraryElement.Created,
Updated: libraryElement.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: elementInDB.CreatedBy,
Name: elementInDB.CreatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, elementInDB.CreatedByEmail),
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: libraryElement.UpdatedBy,
Name: signedInUser.GetLogin(),
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, signedInUser.GetEmail()),
@@ -761,12 +760,12 @@ func (l *LibraryElementService) getElementsForDashboardID(c context.Context, das
ConnectedDashboards: element.ConnectedDashboards,
Created: element.Created,
Updated: element.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: element.CreatedBy,
Name: element.CreatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.CreatedByEmail),
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: element.UpdatedBy,
Name: element.UpdatedByName,
AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.UpdatedByEmail),
@@ -6,7 +6,6 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/services/libraryelements/model"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util/testutil"
@@ -51,12 +50,12 @@ func TestIntegration_CreateLibraryElement(t *testing.T) {
ConnectedDashboards: 0,
Created: sc.initialResult.Result.Meta.Created,
Updated: sc.initialResult.Result.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
@@ -102,12 +101,12 @@ func TestIntegration_CreateLibraryElement(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Meta.Created,
Updated: result.Result.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
@@ -181,12 +180,12 @@ func TestIntegration_CreateLibraryElement(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Meta.Created,
Updated: result.Result.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
@@ -7,7 +7,6 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/services/folder"
"github.com/grafana/grafana/pkg/services/libraryelements/model"
"github.com/grafana/grafana/pkg/services/org"
@@ -84,12 +83,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -120,12 +119,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[1].Meta.Created,
Updated: result.Result.Elements[1].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -187,12 +186,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -223,12 +222,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[1].Meta.Created,
Updated: result.Result.Elements[1].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -312,12 +311,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -348,12 +347,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[1].Meta.Created,
Updated: result.Result.Elements[1].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -462,12 +461,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -562,12 +561,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -598,12 +597,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[1].Meta.Created,
Updated: result.Result.Elements[1].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -665,12 +664,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -732,12 +731,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -800,12 +799,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -878,12 +877,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -954,12 +953,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -990,12 +989,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[1].Meta.Created,
Updated: result.Result.Elements[1].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -1059,12 +1058,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) {
ConnectedDashboards: 0,
Created: result.Result.Elements[0].Meta.Created,
Updated: result.Result.Elements[0].Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/folder"
"github.com/grafana/grafana/pkg/services/libraryelements/model"
@@ -61,12 +60,12 @@ func TestIntegration_GetLibraryElement(t *testing.T) {
ConnectedDashboards: 0,
Created: res.Result.Meta.Created,
Updated: res.Result.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -161,12 +160,12 @@ func TestIntegration_GetLibraryElement(t *testing.T) {
ConnectedDashboards: 1,
Created: res.Result.Meta.Created,
Updated: res.Result.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
@@ -3,14 +3,12 @@ package libraryelements
import (
"testing"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/services/folder"
"github.com/grafana/grafana/pkg/services/libraryelements/model"
"github.com/grafana/grafana/pkg/util"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/services/folder"
"github.com/grafana/grafana/pkg/services/libraryelements/model"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util/testutil"
"github.com/grafana/grafana/pkg/web"
)
@@ -83,12 +81,12 @@ func TestIntegration_PatchLibraryElement(t *testing.T) {
ConnectedDashboards: 0,
Created: sc.initialResult.Result.Meta.Created,
Updated: result.Result.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: "signed_in_user",
AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b",
@@ -19,7 +19,6 @@ import (
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
@@ -118,7 +117,7 @@ func TestIntegration_GetLibraryPanelConnections(t *testing.T) {
ElementID: 1,
ConnectionID: 1,
Created: res.Result[0].Created,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
+15 -11
View File
@@ -4,8 +4,6 @@ import (
"encoding/json"
"errors"
"time"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
)
type LibraryConnectionKind int
@@ -99,8 +97,8 @@ type LibraryElementDTOMeta struct {
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
CreatedBy librarypanel.LibraryElementDTOMetaUser `json:"createdBy"`
UpdatedBy librarypanel.LibraryElementDTOMetaUser `json:"updatedBy"`
CreatedBy LibraryElementDTOMetaUser `json:"createdBy"`
UpdatedBy LibraryElementDTOMetaUser `json:"updatedBy"`
}
// libraryElementConnection is the model for library element connections.
@@ -126,16 +124,22 @@ type LibraryElementConnectionWithMeta struct {
CreatedByEmail string
}
type LibraryElementDTOMetaUser struct {
Id int64 `json:"id"`
Name string `json:"name"`
AvatarUrl string `json:"avatarUrl"`
}
// LibraryElementConnectionDTO is the frontend DTO for element connections.
type LibraryElementConnectionDTO struct {
// Deprecated: this field will be removed in the future
ID int64 `json:"id"`
Kind int64 `json:"kind"`
ElementID int64 `json:"elementId"`
ConnectionID int64 `json:"connectionId"`
ConnectionUID string `json:"connectionUid"`
Created time.Time `json:"created"`
CreatedBy librarypanel.LibraryElementDTOMetaUser `json:"createdBy"`
ID int64 `json:"id"`
Kind int64 `json:"kind"`
ElementID int64 `json:"elementId"`
ConnectionID int64 `json:"connectionId"`
ConnectionUID string `json:"connectionUid"`
Created time.Time `json:"created"`
CreatedBy LibraryElementDTOMetaUser `json:"createdBy"`
}
var (
@@ -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/tracing"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/featuremgmt"
@@ -656,12 +655,12 @@ func toLibraryElement(t *testing.T, res model.LibraryElementDTO) libraryElement
ConnectedDashboards: res.Meta.ConnectedDashboards,
Created: res.Meta.Created,
Updated: res.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: res.Meta.CreatedBy.Id,
Name: res.Meta.CreatedBy.Name,
AvatarUrl: res.Meta.CreatedBy.AvatarUrl,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: res.Meta.UpdatedBy.Id,
Name: res.Meta.UpdatedBy.Name,
AvatarUrl: res.Meta.UpdatedBy.AvatarUrl,
@@ -694,12 +693,12 @@ func getExpected(t *testing.T, res model.LibraryElementDTO, UID string, name str
ConnectedDashboards: 0,
Created: res.Meta.Created,
Updated: res.Meta.Updated,
CreatedBy: librarypanel.LibraryElementDTOMetaUser{
CreatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,
},
UpdatedBy: librarypanel.LibraryElementDTOMetaUser{
UpdatedBy: model.LibraryElementDTOMetaUser{
Id: 1,
Name: userInDbName,
AvatarUrl: userInDbAvatar,