mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add FolderUID for library elements (#83819)
* Revert "Revert "Add FolderUID for library elements" (#83776)"
This reverts commit 0dfdb2ae47
.
* Fix bug, dashboard id and library element fodler_id are the corresponding values
Dashboard table hold both dahboards and tables
This commit is contained in:
parent
2e7cc68394
commit
5c4a2de59b
@ -1035,7 +1035,7 @@ func (m *mockLibraryPanelService) ConnectLibraryPanelsForDashboard(c context.Con
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockLibraryPanelService) ImportLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error {
|
func (m *mockLibraryPanelService) ImportLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
|
|||||||
|
|
||||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.DashboardImport).Inc()
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.DashboardImport).Inc()
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
err = s.libraryPanelService.ImportLibraryPanelsForDashboard(ctx, req.User, libraryElements, generatedDash.Get("panels").MustArray(), req.FolderId)
|
err = s.libraryPanelService.ImportLibraryPanelsForDashboard(ctx, req.User, libraryElements, generatedDash.Get("panels").MustArray(), req.FolderId, req.FolderUid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func TestImportDashboardService(t *testing.T) {
|
|||||||
importLibraryPanelsForDashboard := false
|
importLibraryPanelsForDashboard := false
|
||||||
connectLibraryPanelsForDashboardCalled := false
|
connectLibraryPanelsForDashboardCalled := false
|
||||||
libraryPanelService := &libraryPanelServiceMock{
|
libraryPanelService := &libraryPanelServiceMock{
|
||||||
importLibraryPanelsForDashboardFunc: func(ctx context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error {
|
importLibraryPanelsForDashboardFunc: func(ctx context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error {
|
||||||
importLibraryPanelsForDashboard = true
|
importLibraryPanelsForDashboard = true
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -76,8 +76,7 @@ func TestImportDashboardService(t *testing.T) {
|
|||||||
{Name: "*", Type: "datasource", Value: "prom"},
|
{Name: "*", Type: "datasource", Value: "prom"},
|
||||||
},
|
},
|
||||||
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
||||||
// FolderId: 5,
|
FolderUid: "folderUID",
|
||||||
FolderUid: "123",
|
|
||||||
}
|
}
|
||||||
resp, err := s.ImportDashboard(context.Background(), req)
|
resp, err := s.ImportDashboard(context.Background(), req)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -91,7 +90,7 @@ func TestImportDashboardService(t *testing.T) {
|
|||||||
require.Equal(t, int64(3), importDashboardArg.OrgID)
|
require.Equal(t, int64(3), importDashboardArg.OrgID)
|
||||||
require.Equal(t, int64(2), userID)
|
require.Equal(t, int64(2), userID)
|
||||||
require.Equal(t, "prometheus", importDashboardArg.Dashboard.PluginID)
|
require.Equal(t, "prometheus", importDashboardArg.Dashboard.PluginID)
|
||||||
require.Equal(t, "123", importDashboardArg.Dashboard.FolderUID)
|
require.Equal(t, "folderUID", importDashboardArg.Dashboard.FolderUID)
|
||||||
|
|
||||||
panel := importDashboardArg.Dashboard.Data.Get("panels").GetIndex(0)
|
panel := importDashboardArg.Dashboard.Data.Get("panels").GetIndex(0)
|
||||||
require.Equal(t, "prom", panel.Get("datasource").MustString())
|
require.Equal(t, "prom", panel.Get("datasource").MustString())
|
||||||
@ -143,7 +142,7 @@ func TestImportDashboardService(t *testing.T) {
|
|||||||
{Name: "*", Type: "datasource", Value: "prom"},
|
{Name: "*", Type: "datasource", Value: "prom"},
|
||||||
},
|
},
|
||||||
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
User: &user.SignedInUser{UserID: 2, OrgRole: org.RoleAdmin, OrgID: 3},
|
||||||
FolderUid: "123",
|
FolderUid: "folderUID",
|
||||||
}
|
}
|
||||||
resp, err := s.ImportDashboard(context.Background(), req)
|
resp, err := s.ImportDashboard(context.Background(), req)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -157,7 +156,7 @@ func TestImportDashboardService(t *testing.T) {
|
|||||||
require.Equal(t, int64(3), importDashboardArg.OrgID)
|
require.Equal(t, int64(3), importDashboardArg.OrgID)
|
||||||
require.Equal(t, int64(2), userID)
|
require.Equal(t, int64(2), userID)
|
||||||
require.Equal(t, "", importDashboardArg.Dashboard.PluginID)
|
require.Equal(t, "", importDashboardArg.Dashboard.PluginID)
|
||||||
require.Equal(t, "123", importDashboardArg.Dashboard.FolderUID)
|
require.Equal(t, "folderUID", importDashboardArg.Dashboard.FolderUID)
|
||||||
|
|
||||||
panel := importDashboardArg.Dashboard.Data.Get("panels").GetIndex(0)
|
panel := importDashboardArg.Dashboard.Data.Get("panels").GetIndex(0)
|
||||||
require.Equal(t, "prom", panel.Get("datasource").MustString())
|
require.Equal(t, "prom", panel.Get("datasource").MustString())
|
||||||
@ -211,7 +210,7 @@ func (s *dashboardServiceMock) ImportDashboard(ctx context.Context, dto *dashboa
|
|||||||
type libraryPanelServiceMock struct {
|
type libraryPanelServiceMock struct {
|
||||||
librarypanels.Service
|
librarypanels.Service
|
||||||
connectLibraryPanelsForDashboardFunc func(c context.Context, signedInUser identity.Requester, dash *dashboards.Dashboard) error
|
connectLibraryPanelsForDashboardFunc func(c context.Context, signedInUser identity.Requester, dash *dashboards.Dashboard) error
|
||||||
importLibraryPanelsForDashboardFunc func(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error
|
importLibraryPanelsForDashboardFunc func(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ librarypanels.Service = (*libraryPanelServiceMock)(nil)
|
var _ librarypanels.Service = (*libraryPanelServiceMock)(nil)
|
||||||
@ -224,9 +223,9 @@ func (s *libraryPanelServiceMock) ConnectLibraryPanelsForDashboard(ctx context.C
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *libraryPanelServiceMock) ImportLibraryPanelsForDashboard(ctx context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error {
|
func (s *libraryPanelServiceMock) ImportLibraryPanelsForDashboard(ctx context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error {
|
||||||
if s.importLibraryPanelsForDashboardFunc != nil {
|
if s.importLibraryPanelsForDashboardFunc != nil {
|
||||||
return s.importLibraryPanelsForDashboardFunc(ctx, signedInUser, libraryPanels, panels, folderID)
|
return s.importLibraryPanelsForDashboardFunc(ctx, signedInUser, libraryPanels, panels, folderID, folderUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -448,10 +448,12 @@ func TestIntegrationNestedFolderService(t *testing.T) {
|
|||||||
|
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
libraryElementCmd.FolderID = parent.ID
|
libraryElementCmd.FolderID = parent.ID
|
||||||
|
libraryElementCmd.FolderUID = &parent.UID
|
||||||
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
libraryElementCmd.FolderID = subfolder.ID
|
libraryElementCmd.FolderID = subfolder.ID
|
||||||
|
libraryElementCmd.FolderUID = &subfolder.UID
|
||||||
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -528,10 +530,12 @@ func TestIntegrationNestedFolderService(t *testing.T) {
|
|||||||
|
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
libraryElementCmd.FolderID = parent.ID
|
libraryElementCmd.FolderID = parent.ID
|
||||||
|
libraryElementCmd.FolderUID = &parent.UID
|
||||||
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
libraryElementCmd.FolderID = subfolder.ID
|
libraryElementCmd.FolderID = subfolder.ID
|
||||||
|
libraryElementCmd.FolderUID = &subfolder.UID
|
||||||
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
_, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -667,11 +671,13 @@ func TestIntegrationNestedFolderService(t *testing.T) {
|
|||||||
_ = createRule(t, alertStore, subfolder.UID, "sub alert")
|
_ = createRule(t, alertStore, subfolder.UID, "sub alert")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
libraryElementCmd.FolderID = subfolder.ID
|
libraryElementCmd.FolderID = subfolder.ID
|
||||||
|
libraryElementCmd.FolderUID = &subPanel.FolderUID
|
||||||
subPanel, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
subPanel, err = lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
libraryElementCmd.FolderID = parent.ID
|
libraryElementCmd.FolderID = parent.ID
|
||||||
|
libraryElementCmd.FolderUID = &parent.UID
|
||||||
parentPanel, err := lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
parentPanel, err := lps.LibraryElementService.CreateElement(context.Background(), &signedInUser, libraryElementCmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -149,9 +149,15 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||||
|
// folderUID *string will be changed to string
|
||||||
|
var folderUID string
|
||||||
|
if cmd.FolderUID != nil {
|
||||||
|
folderUID = *cmd.FolderUID
|
||||||
|
}
|
||||||
element := model.LibraryElement{
|
element := model.LibraryElement{
|
||||||
OrgID: signedInUser.GetOrgID(),
|
OrgID: signedInUser.GetOrgID(),
|
||||||
FolderID: cmd.FolderID, // nolint:staticcheck
|
FolderID: cmd.FolderID, // nolint:staticcheck
|
||||||
|
FolderUID: folderUID,
|
||||||
UID: createUID,
|
UID: createUID,
|
||||||
Name: cmd.Name,
|
Name: cmd.Name,
|
||||||
Model: updatedModel,
|
Model: updatedModel,
|
||||||
|
@ -15,7 +15,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to create a library panel that already exists, it should fail",
|
scenarioWithPanel(t, "When an admin tries to create a library panel that already exists, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 400, resp.Status())
|
require.Equal(t, 400, resp.Status())
|
||||||
@ -28,6 +28,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: sc.initialResult.Result.UID,
|
UID: sc.initialResult.Result.UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -68,7 +69,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
testScenario(t, "When an admin tries to create a library panel that does not exists using an nonexistent UID, it should succeed",
|
testScenario(t, "When an admin tries to create a library panel that does not exists using an nonexistent UID, it should succeed",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Nonexistent UID")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Nonexistent UID")
|
||||||
command.UID = util.GenerateShortUID()
|
command.UID = util.GenerateShortUID()
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
@ -78,6 +79,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: command.UID,
|
UID: command.UID,
|
||||||
Name: "Nonexistent UID",
|
Name: "Nonexistent UID",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -118,7 +120,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to create a library panel that does not exists using an existent UID, it should fail",
|
scenarioWithPanel(t, "When an admin tries to create a library panel that does not exists using an existent UID, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Existing UID")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Existing UID")
|
||||||
command.UID = sc.initialResult.Result.UID
|
command.UID = sc.initialResult.Result.UID
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
@ -128,7 +130,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to create a library panel that does not exists using an invalid UID, it should fail",
|
scenarioWithPanel(t, "When an admin tries to create a library panel that does not exists using an invalid UID, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Invalid UID")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Invalid UID")
|
||||||
command.UID = "Testing an invalid UID"
|
command.UID = "Testing an invalid UID"
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
@ -138,7 +140,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to create a library panel that does not exists using an UID that is too long, it should fail",
|
scenarioWithPanel(t, "When an admin tries to create a library panel that does not exists using an UID that is too long, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Invalid UID")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Invalid UID")
|
||||||
command.UID = "j6T00KRZzj6T00KRZzj6T00KRZzj6T00KRZzj6T00K"
|
command.UID = "j6T00KRZzj6T00KRZzj6T00KRZzj6T00KRZzj6T00K"
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
@ -147,7 +149,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
|
|
||||||
testScenario(t, "When an admin tries to create a library panel where name and panel title differ, it should not update panel title",
|
testScenario(t, "When an admin tries to create a library panel where name and panel title differ, it should not update panel title",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
command := getCreatePanelCommand(1, "Library Panel Name")
|
command := getCreatePanelCommand(1, sc.folder.UID, "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
var result = validateAndUnMarshalResponse(t, resp)
|
var result = validateAndUnMarshalResponse(t, resp)
|
||||||
@ -156,6 +158,7 @@ func TestCreateLibraryElement(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.UID,
|
UID: result.Result.UID,
|
||||||
Name: "Library Panel Name",
|
Name: "Library Panel Name",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
|
@ -74,7 +74,7 @@ func TestDeleteLibraryElement(t *testing.T) {
|
|||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID, sc.folder.UID)
|
||||||
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all panel elements and both panels and variables exist, it should only return panels",
|
scenarioWithPanel(t, "When an admin tries to get all panel elements and both panels and variables exist, it should only return panels",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateVariableCommand(sc.folder.ID, "query0")
|
command := getCreateVariableCommand(sc.folder.ID, sc.folder.UID, "query0")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -64,6 +64,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -106,7 +107,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all variable elements and both panels and variables exist, it should only return panels",
|
scenarioWithPanel(t, "When an admin tries to get all variable elements and both panels and variables exist, it should only return panels",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateVariableCommand(sc.folder.ID, "query0")
|
command := getCreateVariableCommand(sc.folder.ID, sc.folder.UID, "query0")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -131,6 +132,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "query0",
|
Name: "query0",
|
||||||
Kind: int64(model.VariableElement),
|
Kind: int64(model.VariableElement),
|
||||||
@ -172,7 +174,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist, it should succeed",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist, it should succeed",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -193,6 +195,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -228,6 +231,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[1].UID,
|
UID: result.Result.Elements[1].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -270,7 +274,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and sort desc is set, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and sort desc is set, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -294,6 +298,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -329,6 +334,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[1].UID,
|
UID: result.Result.Elements[1].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -371,7 +377,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and typeFilter is set to existing types, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and typeFilter is set to existing types, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateCommandWithModel(sc.folder.ID, "Gauge - Library Panel", model.PanelElement, []byte(`
|
command := getCreateCommandWithModel(sc.folder.ID, sc.folder.UID, "Gauge - Library Panel", model.PanelElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@ -385,7 +391,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
|
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command = getCreateCommandWithModel(sc.folder.ID, "BarGauge - Library Panel", model.PanelElement, []byte(`
|
command = getCreateCommandWithModel(sc.folder.ID, sc.folder.UID, "BarGauge - Library Panel", model.PanelElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@ -417,6 +423,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 3,
|
ID: 3,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "BarGauge - Library Panel",
|
Name: "BarGauge - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -452,6 +459,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[1].UID,
|
UID: result.Result.Elements[1].UID,
|
||||||
Name: "Gauge - Library Panel",
|
Name: "Gauge - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -494,7 +502,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and typeFilter is set to a nonexistent type, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and typeFilter is set to a nonexistent type, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateCommandWithModel(sc.folder.ID, "Gauge - Library Panel", model.PanelElement, []byte(`
|
command := getCreateCommandWithModel(sc.folder.ID, sc.folder.UID, "Gauge - Library Panel", model.PanelElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@ -529,25 +537,24 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and folderFilter is set to existing folders, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and folderFilterUIDs is set to existing folders, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
newFolder := createFolder(t, sc, "NewFolder")
|
newFolder := createFolder(t, sc, "NewFolder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(newFolder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(newFolder.ID, newFolder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
// nolint:staticcheck
|
folderFilterUID := newFolder.UID
|
||||||
folderFilter := strconv.FormatInt(newFolder.ID, 10)
|
|
||||||
|
|
||||||
err := sc.reqContext.Req.ParseForm()
|
err := sc.reqContext.Req.ParseForm()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sc.reqContext.Req.Form.Add("folderFilter", folderFilter)
|
sc.reqContext.Req.Form.Add("folderFilterUIDs", folderFilterUID)
|
||||||
resp = sc.service.getAllHandler(sc.reqContext)
|
resp = sc.service.getAllHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
|
|
||||||
var result libraryElementsSearch
|
var result libraryElementsSearch
|
||||||
err = json.Unmarshal(resp.Body(), &result)
|
err = json.Unmarshal(resp.Body(), &result)
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var expected = libraryElementsSearch{
|
var expected = libraryElementsSearch{
|
||||||
Result: libraryElementsSearchResult{
|
Result: libraryElementsSearchResult{
|
||||||
@ -559,6 +566,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: newFolder.ID, // nolint:staticcheck
|
FolderID: newFolder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: newFolder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -602,15 +610,15 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
newFolder := createFolder(t, sc, "NewFolder")
|
newFolder := createFolder(t, sc, "NewFolder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(newFolder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(newFolder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
folderFilter := "2020,2021"
|
folderFilterUIDs := "2020,2021"
|
||||||
|
|
||||||
err := sc.reqContext.Req.ParseForm()
|
err := sc.reqContext.Req.ParseForm()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sc.reqContext.Req.Form.Add("folderFilter", folderFilter)
|
sc.reqContext.Req.Form.Add("folderFilterUIDs", folderFilterUIDs)
|
||||||
resp = sc.service.getAllHandler(sc.reqContext)
|
resp = sc.service.getAllHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
|
|
||||||
@ -633,7 +641,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and folderFilter is set to General folder, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and folderFilter is set to General folder, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -658,6 +666,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -693,6 +702,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[1].UID,
|
UID: result.Result.Elements[1].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -735,7 +745,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and excludeUID is set, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and excludeUID is set, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -759,6 +769,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -801,7 +812,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -825,6 +836,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -867,7 +879,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 2, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 2, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -892,6 +904,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -934,7 +947,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and searchString exists in the description, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and searchString exists in the description, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateCommandWithModel(sc.folder.ID, "Text - Library Panel2", model.PanelElement, []byte(`
|
command := getCreateCommandWithModel(sc.folder.ID, sc.folder.UID, "Text - Library Panel2", model.PanelElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@ -968,6 +981,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -1010,7 +1024,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and searchString exists in both name and description, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and searchString exists in both name and description, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateCommandWithModel(sc.folder.ID, "Some Other", model.PanelElement, []byte(`
|
command := getCreateCommandWithModel(sc.folder.ID, sc.folder.UID, "Some Other", model.PanelElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@ -1042,6 +1056,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Some Other",
|
Name: "Some Other",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -1077,6 +1092,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[1].UID,
|
UID: result.Result.Elements[1].UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -1119,7 +1135,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 1 and searchString is panel2, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 1 and searchString is panel2, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -1145,6 +1161,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
ID: 2,
|
ID: 2,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: result.Result.Elements[0].UID,
|
UID: result.Result.Elements[0].UID,
|
||||||
Name: "Text - Library Panel2",
|
Name: "Text - Library Panel2",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -1187,7 +1204,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 3 and searchString is panel, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 3 and searchString is panel, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -1219,7 +1236,7 @@ func TestGetAllLibraryElements(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 3 and searchString does not exist, it should succeed and the result should be correct",
|
scenarioWithPanel(t, "When an admin tries to get all library panels and two exist and perPage is 1 and page is 3 and searchString does not exist, it should succeed and the result should be correct",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel2")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel2")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
|
@ -35,6 +35,7 @@ func TestGetLibraryElement(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: res.Result.UID,
|
UID: res.Result.UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -123,7 +124,7 @@ func TestGetLibraryElement(t *testing.T) {
|
|||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID, sc.folder.UID)
|
||||||
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -133,6 +134,7 @@ func TestGetLibraryElement(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: sc.folder.UID,
|
||||||
UID: res.Result.UID,
|
UID: res.Result.UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
|
@ -27,6 +27,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
newFolder := createFolder(t, sc, "NewFolder")
|
newFolder := createFolder(t, sc, "NewFolder")
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: newFolder.ID, // nolint:staticcheck
|
FolderID: newFolder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: &newFolder.UID,
|
||||||
Name: "Panel - New name",
|
Name: "Panel - New name",
|
||||||
Model: []byte(`
|
Model: []byte(`
|
||||||
{
|
{
|
||||||
@ -50,6 +51,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
ID: 1,
|
ID: 1,
|
||||||
OrgID: 1,
|
OrgID: 1,
|
||||||
FolderID: newFolder.ID, // nolint:staticcheck
|
FolderID: newFolder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: newFolder.UID,
|
||||||
UID: sc.initialResult.Result.UID,
|
UID: sc.initialResult.Result.UID,
|
||||||
Name: "Panel - New name",
|
Name: "Panel - New name",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
@ -92,6 +94,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
newFolder := createFolder(t, sc, "NewFolder")
|
newFolder := createFolder(t, sc, "NewFolder")
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: newFolder.ID, // nolint:staticcheck
|
FolderID: newFolder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: &newFolder.UID,
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
Version: 1,
|
Version: 1,
|
||||||
}
|
}
|
||||||
@ -102,6 +105,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
var result = validateAndUnMarshalResponse(t, resp)
|
var result = validateAndUnMarshalResponse(t, resp)
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
sc.initialResult.Result.FolderID = newFolder.ID
|
sc.initialResult.Result.FolderID = newFolder.ID
|
||||||
|
sc.initialResult.Result.FolderUID = newFolder.UID
|
||||||
sc.initialResult.Result.Meta.CreatedBy.Name = userInDbName
|
sc.initialResult.Result.Meta.CreatedBy.Name = userInDbName
|
||||||
sc.initialResult.Result.Meta.CreatedBy.AvatarUrl = userInDbAvatar
|
sc.initialResult.Result.Meta.CreatedBy.AvatarUrl = userInDbAvatar
|
||||||
sc.initialResult.Result.Meta.Updated = result.Result.Meta.Updated
|
sc.initialResult.Result.Meta.Updated = result.Result.Meta.Updated
|
||||||
@ -177,6 +181,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: -1, // nolint:staticcheck
|
FolderID: -1, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
UID: "j6T00KRZzj6T00KRZzj6T00KRZzj6T00KRZzj6T00K",
|
UID: "j6T00KRZzj6T00KRZzj6T00KRZzj6T00KRZzj6T00K",
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
Version: 1,
|
Version: 1,
|
||||||
@ -190,13 +195,14 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with an existing UID, it should fail",
|
scenarioWithPanel(t, "When an admin tries to patch a library panel with an existing UID, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Existing UID")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Existing UID")
|
||||||
command.UID = util.GenerateShortUID()
|
command.UID = util.GenerateShortUID()
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: -1, // nolint:staticcheck
|
FolderID: -1, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
UID: command.UID,
|
UID: command.UID,
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
Version: 1,
|
Version: 1,
|
||||||
@ -312,7 +318,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with a name that already exists, it should fail",
|
scenarioWithPanel(t, "When an admin tries to patch a library panel with a name that already exists, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Another Panel")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Another Panel")
|
||||||
sc.ctx.Req.Body = mockRequestBody(command)
|
sc.ctx.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
var result = validateAndUnMarshalResponse(t, resp)
|
var result = validateAndUnMarshalResponse(t, resp)
|
||||||
@ -331,12 +337,13 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
newFolder := createFolder(t, sc, "NewFolder")
|
newFolder := createFolder(t, sc, "NewFolder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(newFolder.ID, "Text - Library Panel")
|
command := getCreatePanelCommand(newFolder.ID, newFolder.UID, "Text - Library Panel")
|
||||||
sc.ctx.Req.Body = mockRequestBody(command)
|
sc.ctx.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
var result = validateAndUnMarshalResponse(t, resp)
|
var result = validateAndUnMarshalResponse(t, resp)
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: 1, // nolint:staticcheck
|
FolderID: 1, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
Version: 1,
|
Version: 1,
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
}
|
}
|
||||||
@ -350,6 +357,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
Version: 1,
|
Version: 1,
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
}
|
}
|
||||||
@ -357,13 +365,14 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
|
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
|
||||||
sc.ctx.Req.Body = mockRequestBody(cmd)
|
sc.ctx.Req.Body = mockRequestBody(cmd)
|
||||||
resp := sc.service.patchHandler(sc.reqContext)
|
resp := sc.service.patchHandler(sc.reqContext)
|
||||||
require.Equal(t, 404, resp.Status())
|
require.Equal(t, 400, resp.Status())
|
||||||
})
|
})
|
||||||
|
|
||||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with an old version number, it should fail",
|
scenarioWithPanel(t, "When an admin tries to patch a library panel with an old version number, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
Version: 1,
|
Version: 1,
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
}
|
}
|
||||||
@ -380,6 +389,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := model.PatchLibraryElementCommand{
|
cmd := model.PatchLibraryElementCommand{
|
||||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
Version: 1,
|
Version: 1,
|
||||||
Kind: int64(model.VariableElement),
|
Kind: int64(model.VariableElement),
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
sc.reqContext.SignedInUser.OrgRole = testCase.role
|
sc.reqContext.SignedInUser.OrgRole = testCase.role
|
||||||
|
|
||||||
command := getCreatePanelCommand(0, "Library Panel Name")
|
command := getCreatePanelCommand(0, "", "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, testCase.status, resp.Status())
|
require.Equal(t, testCase.status, resp.Status())
|
||||||
@ -40,7 +40,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
folder := createFolder(t, sc, "Folder")
|
folder := createFolder(t, sc, "Folder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(folder.ID, "Library Panel Name")
|
command := getCreatePanelCommand(folder.ID, folder.UID, "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -57,7 +57,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
testScenario(t, fmt.Sprintf("When %s tries to patch a library panel by moving it from the General folder, it should return correct status", testCase.role),
|
testScenario(t, fmt.Sprintf("When %s tries to patch a library panel by moving it from the General folder, it should return correct status", testCase.role),
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
folder := createFolder(t, sc, "Folder")
|
folder := createFolder(t, sc, "Folder")
|
||||||
command := getCreatePanelCommand(0, "Library Panel Name")
|
command := getCreatePanelCommand(0, "", "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -73,7 +73,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
|
|
||||||
testScenario(t, fmt.Sprintf("When %s tries to delete a library panel in the General folder, it should return correct status", testCase.role),
|
testScenario(t, fmt.Sprintf("When %s tries to delete a library panel in the General folder, it should return correct status", testCase.role),
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := getCreatePanelCommand(0, "Library Panel Name")
|
cmd := getCreatePanelCommand(0, "", "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -86,7 +86,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
|
|
||||||
testScenario(t, fmt.Sprintf("When %s tries to get a library panel from General folder, it should return correct response", testCase.role),
|
testScenario(t, fmt.Sprintf("When %s tries to get a library panel from General folder, it should return correct response", testCase.role),
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := getCreatePanelCommand(0, "Library Panel in General Folder")
|
cmd := getCreatePanelCommand(0, "", "Library Panel in General Folder")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -96,6 +96,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
result.Result.Meta.UpdatedBy.AvatarUrl = userInDbAvatar
|
result.Result.Meta.UpdatedBy.AvatarUrl = userInDbAvatar
|
||||||
result.Result.Meta.FolderName = "General"
|
result.Result.Meta.FolderName = "General"
|
||||||
result.Result.Meta.FolderUID = ""
|
result.Result.Meta.FolderUID = ""
|
||||||
|
result.Result.FolderUID = "general"
|
||||||
sc.reqContext.SignedInUser.OrgRole = testCase.role
|
sc.reqContext.SignedInUser.OrgRole = testCase.role
|
||||||
|
|
||||||
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": result.Result.UID})
|
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": result.Result.UID})
|
||||||
@ -111,7 +112,7 @@ func TestLibraryElementPermissionsGeneralFolder(t *testing.T) {
|
|||||||
|
|
||||||
testScenario(t, fmt.Sprintf("When %s tries to get all library panels from General folder, it should return correct response", testCase.role),
|
testScenario(t, fmt.Sprintf("When %s tries to get all library panels from General folder, it should return correct response", testCase.role),
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := getCreatePanelCommand(0, "Library Panel in General Folder")
|
cmd := getCreatePanelCommand(0, "", "Library Panel in General Folder")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -183,7 +184,7 @@ func TestLibraryElementCreatePermissions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(folder.ID, "Library Panel Name")
|
command := getCreatePanelCommand(folder.ID, folder.UID, "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, testCase.status, resp.Status())
|
require.Equal(t, testCase.status, resp.Status())
|
||||||
@ -236,7 +237,7 @@ func TestLibraryElementPatchPermissions(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
fromFolder := createFolder(t, sc, "FromFolder")
|
fromFolder := createFolder(t, sc, "FromFolder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(fromFolder.ID, "Library Panel Name")
|
command := getCreatePanelCommand(fromFolder.ID, fromFolder.UID, "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -248,7 +249,7 @@ func TestLibraryElementPatchPermissions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
cmd := model.PatchLibraryElementCommand{FolderID: toFolder.ID, Version: 1, Kind: int64(model.PanelElement)}
|
cmd := model.PatchLibraryElementCommand{FolderID: toFolder.ID, FolderUID: &toFolder.UID, Version: 1, Kind: int64(model.PanelElement)}
|
||||||
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": result.Result.UID})
|
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": result.Result.UID})
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp = sc.service.patchHandler(sc.reqContext)
|
resp = sc.service.patchHandler(sc.reqContext)
|
||||||
@ -298,7 +299,7 @@ func TestLibraryElementDeletePermissions(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
folder := createFolder(t, sc, "Folder")
|
folder := createFolder(t, sc, "Folder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(folder.ID, "Library Panel Name")
|
command := getCreatePanelCommand(folder.ID, folder.UID, "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -317,27 +318,29 @@ func TestLibraryElementDeletePermissions(t *testing.T) {
|
|||||||
func TestLibraryElementsWithMissingFolders(t *testing.T) {
|
func TestLibraryElementsWithMissingFolders(t *testing.T) {
|
||||||
testScenario(t, "When a user tries to create a library panel in a folder that doesn't exist, it should fail",
|
testScenario(t, "When a user tries to create a library panel in a folder that doesn't exist, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
command := getCreatePanelCommand(-100, "Library Panel Name")
|
command := getCreatePanelCommand(0, "badFolderUID", "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 404, resp.Status())
|
fmt.Println(string(resp.Body()))
|
||||||
|
require.Equal(t, 400, resp.Status())
|
||||||
})
|
})
|
||||||
|
|
||||||
testScenario(t, "When a user tries to patch a library panel by moving it to a folder that doesn't exist, it should fail",
|
testScenario(t, "When a user tries to patch a library panel by moving it to a folder that doesn't exist, it should fail",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
folder := createFolder(t, sc, "Folder")
|
folder := createFolder(t, sc, "Folder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(folder.ID, "Library Panel Name")
|
command := getCreatePanelCommand(folder.ID, folder.UID, "Library Panel Name")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
|
|
||||||
|
folderUID := "badFolderUID"
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
cmd := model.PatchLibraryElementCommand{FolderID: -100, Version: 1, Kind: int64(model.PanelElement)}
|
cmd := model.PatchLibraryElementCommand{FolderID: -100, FolderUID: &folderUID, Version: 1, Kind: int64(model.PanelElement)}
|
||||||
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": result.Result.UID})
|
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": result.Result.UID})
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp = sc.service.patchHandler(sc.reqContext)
|
resp = sc.service.patchHandler(sc.reqContext)
|
||||||
require.Equal(t, 404, resp.Status())
|
require.Equal(t, 400, resp.Status())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +370,7 @@ func TestLibraryElementsGetPermissions(t *testing.T) {
|
|||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
folder := createFolder(t, sc, "Folder")
|
folder := createFolder(t, sc, "Folder")
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
cmd := getCreatePanelCommand(folder.ID, "Library Panel")
|
cmd := getCreatePanelCommand(folder.ID, folder.UID, "Library Panel")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
@ -418,7 +421,7 @@ func TestLibraryElementsGetAllPermissions(t *testing.T) {
|
|||||||
for i := 1; i <= 2; i++ {
|
for i := 1; i <= 2; i++ {
|
||||||
folder := createFolder(t, sc, fmt.Sprintf("Folder%d", i))
|
folder := createFolder(t, sc, fmt.Sprintf("Folder%d", i))
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
cmd := getCreatePanelCommand(folder.ID, fmt.Sprintf("Library Panel %d", i))
|
cmd := getCreatePanelCommand(folder.ID, folder.UID, fmt.Sprintf("Library Panel %d", i))
|
||||||
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
sc.reqContext.Req.Body = mockRequestBody(cmd)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
result := validateAndUnMarshalResponse(t, resp)
|
result := validateAndUnMarshalResponse(t, resp)
|
||||||
|
@ -88,7 +88,7 @@ func TestDeleteLibraryPanelsInFolder(t *testing.T) {
|
|||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID, sc.folder.UID)
|
||||||
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ func TestDeleteLibraryPanelsInFolder(t *testing.T) {
|
|||||||
scenarioWithPanel(t, "When an admin tries to delete a folder that contains disconnected elements, it should delete all disconnected elements too",
|
scenarioWithPanel(t, "When an admin tries to delete a folder that contains disconnected elements, it should delete all disconnected elements too",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreateVariableCommand(sc.folder.ID, "query0")
|
command := getCreateVariableCommand(sc.folder.ID, sc.folder.UID, "query0")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
require.Equal(t, 200, resp.Status())
|
require.Equal(t, 200, resp.Status())
|
||||||
@ -163,7 +163,7 @@ func TestGetLibraryPanelConnections(t *testing.T) {
|
|||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID, sc.folder.UID)
|
||||||
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
err := sc.service.ConnectElementsToDashboard(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -202,6 +202,7 @@ type libraryElement struct {
|
|||||||
OrgID int64 `json:"orgId"`
|
OrgID int64 `json:"orgId"`
|
||||||
// Deprecated: use FolderUID instead
|
// Deprecated: use FolderUID instead
|
||||||
FolderID int64 `json:"folderId"`
|
FolderID int64 `json:"folderId"`
|
||||||
|
FolderUID string `json:"folderUid"`
|
||||||
UID string `json:"uid"`
|
UID string `json:"uid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Kind int64 `json:"kind"`
|
Kind int64 `json:"kind"`
|
||||||
@ -231,8 +232,8 @@ type libraryElementsSearchResult struct {
|
|||||||
PerPage int `json:"perPage"`
|
PerPage int `json:"perPage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCreatePanelCommand(folderID int64, name string) model.CreateLibraryElementCommand {
|
func getCreatePanelCommand(folderID int64, folderUID string, name string) model.CreateLibraryElementCommand {
|
||||||
command := getCreateCommandWithModel(folderID, name, model.PanelElement, []byte(`
|
command := getCreateCommandWithModel(folderID, folderUID, name, model.PanelElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@ -245,8 +246,8 @@ func getCreatePanelCommand(folderID int64, name string) model.CreateLibraryEleme
|
|||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCreateVariableCommand(folderID int64, name string) model.CreateLibraryElementCommand {
|
func getCreateVariableCommand(folderID int64, folderUID, name string) model.CreateLibraryElementCommand {
|
||||||
command := getCreateCommandWithModel(folderID, name, model.VariableElement, []byte(`
|
command := getCreateCommandWithModel(folderID, folderUID, name, model.VariableElement, []byte(`
|
||||||
{
|
{
|
||||||
"datasource": "${DS_GDEV-TESTDATA}",
|
"datasource": "${DS_GDEV-TESTDATA}",
|
||||||
"name": "query0",
|
"name": "query0",
|
||||||
@ -258,9 +259,9 @@ func getCreateVariableCommand(folderID int64, name string) model.CreateLibraryEl
|
|||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCreateCommandWithModel(folderID int64, name string, kind model.LibraryElementKind, byteModel []byte) model.CreateLibraryElementCommand {
|
func getCreateCommandWithModel(folderID int64, folderUID, name string, kind model.LibraryElementKind, byteModel []byte) model.CreateLibraryElementCommand {
|
||||||
command := model.CreateLibraryElementCommand{
|
command := model.CreateLibraryElementCommand{
|
||||||
FolderID: folderID, // nolint:staticcheck
|
FolderUID: &folderUID,
|
||||||
Name: name,
|
Name: name,
|
||||||
Model: byteModel,
|
Model: byteModel,
|
||||||
Kind: int64(kind),
|
Kind: int64(kind),
|
||||||
@ -280,9 +281,10 @@ type scenarioContext struct {
|
|||||||
log log.Logger
|
log log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDashboard(t *testing.T, sqlStore db.DB, user user.SignedInUser, dash *dashboards.Dashboard, folderID int64) *dashboards.Dashboard {
|
func createDashboard(t *testing.T, sqlStore db.DB, user user.SignedInUser, dash *dashboards.Dashboard, folderID int64, folderUID string) *dashboards.Dashboard {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
dash.FolderID = folderID
|
dash.FolderID = folderID
|
||||||
|
dash.FolderUID = folderUID
|
||||||
dashItem := &dashboards.SaveDashboardDTO{
|
dashItem := &dashboards.SaveDashboardDTO{
|
||||||
Dashboard: dash,
|
Dashboard: dash,
|
||||||
Message: "",
|
Message: "",
|
||||||
@ -396,7 +398,7 @@ func scenarioWithPanel(t *testing.T, desc string, fn func(t *testing.T, sc scena
|
|||||||
|
|
||||||
testScenario(t, desc, func(t *testing.T, sc scenarioContext) {
|
testScenario(t, desc, func(t *testing.T, sc scenarioContext) {
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
command := getCreatePanelCommand(sc.folder.ID, "Text - Library Panel")
|
command := getCreatePanelCommand(sc.folder.ID, sc.folder.UID, "Text - Library Panel")
|
||||||
sc.reqContext.Req.Body = mockRequestBody(command)
|
sc.reqContext.Req.Body = mockRequestBody(command)
|
||||||
resp := sc.service.createHandler(sc.reqContext)
|
resp := sc.service.createHandler(sc.reqContext)
|
||||||
sc.initialResult = validateAndUnMarshalResponse(t, resp)
|
sc.initialResult = validateAndUnMarshalResponse(t, resp)
|
||||||
|
@ -20,6 +20,7 @@ type LibraryElement struct {
|
|||||||
OrgID int64 `xorm:"org_id"`
|
OrgID int64 `xorm:"org_id"`
|
||||||
// Deprecated: use FolderUID instead
|
// Deprecated: use FolderUID instead
|
||||||
FolderID int64 `xorm:"folder_id"`
|
FolderID int64 `xorm:"folder_id"`
|
||||||
|
FolderUID string `xorm:"folder_uid"`
|
||||||
UID string `xorm:"uid"`
|
UID string `xorm:"uid"`
|
||||||
Name string
|
Name string
|
||||||
Kind int64
|
Kind int64
|
||||||
@ -41,6 +42,7 @@ type LibraryElementWithMeta struct {
|
|||||||
OrgID int64 `xorm:"org_id"`
|
OrgID int64 `xorm:"org_id"`
|
||||||
// Deprecated: use FolderUID instead
|
// Deprecated: use FolderUID instead
|
||||||
FolderID int64 `xorm:"folder_id"`
|
FolderID int64 `xorm:"folder_id"`
|
||||||
|
FolderUID string `xorm:"folder_uid"`
|
||||||
UID string `xorm:"uid"`
|
UID string `xorm:"uid"`
|
||||||
Name string
|
Name string
|
||||||
Kind int64
|
Kind int64
|
||||||
@ -53,7 +55,6 @@ type LibraryElementWithMeta struct {
|
|||||||
Updated time.Time
|
Updated time.Time
|
||||||
|
|
||||||
FolderName string
|
FolderName string
|
||||||
FolderUID string `xorm:"folder_uid"`
|
|
||||||
ConnectedDashboards int64
|
ConnectedDashboards int64
|
||||||
CreatedBy int64
|
CreatedBy int64
|
||||||
UpdatedBy int64
|
UpdatedBy int64
|
||||||
@ -224,6 +225,7 @@ type SearchLibraryElementsQuery struct {
|
|||||||
Kind int
|
Kind int
|
||||||
TypeFilter string
|
TypeFilter string
|
||||||
ExcludeUID string
|
ExcludeUID string
|
||||||
|
// Deprecated: use FolderFilterUIDs instead
|
||||||
FolderFilter string
|
FolderFilter string
|
||||||
FolderFilterUIDs string
|
FolderFilterUIDs string
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ type FolderFilter struct {
|
|||||||
func parseFolderFilter(query model.SearchLibraryElementsQuery) FolderFilter {
|
func parseFolderFilter(query model.SearchLibraryElementsQuery) FolderFilter {
|
||||||
folderIDs := make([]string, 0)
|
folderIDs := make([]string, 0)
|
||||||
folderUIDs := make([]string, 0)
|
folderUIDs := make([]string, 0)
|
||||||
|
// nolint:staticcheck
|
||||||
hasFolderFilter := len(strings.TrimSpace(query.FolderFilter)) > 0
|
hasFolderFilter := len(strings.TrimSpace(query.FolderFilter)) > 0
|
||||||
hasFolderFilterUID := len(strings.TrimSpace(query.FolderFilterUIDs)) > 0
|
hasFolderFilterUID := len(strings.TrimSpace(query.FolderFilterUIDs)) > 0
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ func parseFolderFilter(query model.SearchLibraryElementsQuery) FolderFilter {
|
|||||||
|
|
||||||
if hasFolderFilter {
|
if hasFolderFilter {
|
||||||
result.includeGeneralFolder = false
|
result.includeGeneralFolder = false
|
||||||
|
// nolint:staticcheck
|
||||||
folderIDs = strings.Split(query.FolderFilter, ",")
|
folderIDs = strings.Split(query.FolderFilter, ",")
|
||||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
|
@ -42,7 +42,7 @@ func ProvideService(cfg *setting.Cfg, sqlStore db.DB, routeRegister routing.Rout
|
|||||||
// Service is a service for operating on library panels.
|
// Service is a service for operating on library panels.
|
||||||
type Service interface {
|
type Service interface {
|
||||||
ConnectLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, dash *dashboards.Dashboard) error
|
ConnectLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, dash *dashboards.Dashboard) error
|
||||||
ImportLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error
|
ImportLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type LibraryInfo struct {
|
type LibraryInfo struct {
|
||||||
@ -117,11 +117,11 @@ func connectLibraryPanelsRecursively(c context.Context, panels []any, libraryPan
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImportLibraryPanelsForDashboard loops through all panels in dashboard JSON and creates any missing library panels in the database.
|
// ImportLibraryPanelsForDashboard loops through all panels in dashboard JSON and creates any missing library panels in the database.
|
||||||
func (lps *LibraryPanelService) ImportLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error {
|
func (lps *LibraryPanelService) ImportLibraryPanelsForDashboard(c context.Context, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error {
|
||||||
return importLibraryPanelsRecursively(c, lps.LibraryElementService, signedInUser, libraryPanels, panels, folderID)
|
return importLibraryPanelsRecursively(c, lps.LibraryElementService, signedInUser, libraryPanels, panels, folderID, folderUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func importLibraryPanelsRecursively(c context.Context, service libraryelements.Service, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64) error {
|
func importLibraryPanelsRecursively(c context.Context, service libraryelements.Service, signedInUser identity.Requester, libraryPanels *simplejson.Json, panels []any, folderID int64, folderUID string) error {
|
||||||
for _, panel := range panels {
|
for _, panel := range panels {
|
||||||
panelAsJSON := simplejson.NewFromAny(panel)
|
panelAsJSON := simplejson.NewFromAny(panel)
|
||||||
libraryPanel := panelAsJSON.Get("libraryPanel")
|
libraryPanel := panelAsJSON.Get("libraryPanel")
|
||||||
@ -132,7 +132,7 @@ func importLibraryPanelsRecursively(c context.Context, service libraryelements.S
|
|||||||
|
|
||||||
// we have a row
|
// we have a row
|
||||||
if panelType == "row" {
|
if panelType == "row" {
|
||||||
err := importLibraryPanelsRecursively(c, service, signedInUser, libraryPanels, panelAsJSON.Get("panels").MustArray(), folderID)
|
err := importLibraryPanelsRecursively(c, service, signedInUser, libraryPanels, panelAsJSON.Get("panels").MustArray(), folderID, folderUID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -169,6 +169,7 @@ func importLibraryPanelsRecursively(c context.Context, service libraryelements.S
|
|||||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryPanels).Inc()
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryPanels).Inc()
|
||||||
var cmd = model.CreateLibraryElementCommand{
|
var cmd = model.CreateLibraryElementCommand{
|
||||||
FolderID: folderID, // nolint:staticcheck
|
FolderID: folderID, // nolint:staticcheck
|
||||||
|
FolderUID: &folderUID,
|
||||||
Name: name,
|
Name: name,
|
||||||
Model: Model,
|
Model: Model,
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
|
@ -85,8 +85,7 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
Title: "Testing ConnectLibraryPanelsForDashboard",
|
Title: "Testing ConnectLibraryPanelsForDashboard",
|
||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash)
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
|
||||||
|
|
||||||
err := sc.service.ConnectLibraryPanelsForDashboard(sc.ctx, sc.user, dashInDB)
|
err := sc.service.ConnectLibraryPanelsForDashboard(sc.ctx, sc.user, dashInDB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -100,7 +99,6 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
scenarioWithLibraryPanel(t, "When an admin tries to store a dashboard with library panels inside and outside of rows, it should connect all",
|
scenarioWithLibraryPanel(t, "When an admin tries to store a dashboard with library panels inside and outside of rows, it should connect all",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
cmd := model.CreateLibraryElementCommand{
|
cmd := model.CreateLibraryElementCommand{
|
||||||
FolderID: sc.initialResult.Result.FolderID, // nolint:staticcheck
|
|
||||||
Name: "Outside row",
|
Name: "Outside row",
|
||||||
Model: []byte(`
|
Model: []byte(`
|
||||||
{
|
{
|
||||||
@ -112,6 +110,7 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
}
|
}
|
||||||
outsidePanel, err := sc.elementService.CreateElement(sc.ctx, sc.user, cmd)
|
outsidePanel, err := sc.elementService.CreateElement(sc.ctx, sc.user, cmd)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -184,8 +183,7 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
Title: "Testing ConnectLibraryPanelsForDashboard",
|
Title: "Testing ConnectLibraryPanelsForDashboard",
|
||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash)
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
|
||||||
|
|
||||||
err = sc.service.ConnectLibraryPanelsForDashboard(sc.ctx, sc.user, dashInDB)
|
err = sc.service.ConnectLibraryPanelsForDashboard(sc.ctx, sc.user, dashInDB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -231,8 +229,7 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
Title: "Testing ConnectLibraryPanelsForDashboard",
|
Title: "Testing ConnectLibraryPanelsForDashboard",
|
||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash)
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
|
||||||
|
|
||||||
err := sc.service.ConnectLibraryPanelsForDashboard(sc.ctx, sc.user, dashInDB)
|
err := sc.service.ConnectLibraryPanelsForDashboard(sc.ctx, sc.user, dashInDB)
|
||||||
require.EqualError(t, err, errLibraryPanelHeaderUIDMissing.Error())
|
require.EqualError(t, err, errLibraryPanelHeaderUIDMissing.Error())
|
||||||
@ -241,7 +238,6 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
scenarioWithLibraryPanel(t, "When an admin tries to store a dashboard with unused/removed library panels, it should disconnect unused/removed library panels",
|
scenarioWithLibraryPanel(t, "When an admin tries to store a dashboard with unused/removed library panels, it should disconnect unused/removed library panels",
|
||||||
func(t *testing.T, sc scenarioContext) {
|
func(t *testing.T, sc scenarioContext) {
|
||||||
unused, err := sc.elementService.CreateElement(sc.ctx, sc.user, model.CreateLibraryElementCommand{
|
unused, err := sc.elementService.CreateElement(sc.ctx, sc.user, model.CreateLibraryElementCommand{
|
||||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
|
||||||
Name: "Unused Libray Panel",
|
Name: "Unused Libray Panel",
|
||||||
Model: []byte(`
|
Model: []byte(`
|
||||||
{
|
{
|
||||||
@ -253,6 +249,7 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
Kind: int64(model.PanelElement),
|
Kind: int64(model.PanelElement),
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
dashJSON := map[string]any{
|
dashJSON := map[string]any{
|
||||||
@ -288,8 +285,7 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
Title: "Testing ConnectLibraryPanelsForDashboard",
|
Title: "Testing ConnectLibraryPanelsForDashboard",
|
||||||
Data: simplejson.NewFromAny(dashJSON),
|
Data: simplejson.NewFromAny(dashJSON),
|
||||||
}
|
}
|
||||||
// nolint:staticcheck
|
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash)
|
||||||
dashInDB := createDashboard(t, sc.sqlStore, sc.user, &dash, sc.folder.ID)
|
|
||||||
err = sc.elementService.ConnectElementsToDashboard(sc.ctx, sc.user, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
err = sc.elementService.ConnectElementsToDashboard(sc.ctx, sc.user, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -398,7 +394,7 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
|
|
||||||
require.EqualError(t, err, model.ErrLibraryElementNotFound.Error())
|
require.EqualError(t, err, model.ErrLibraryElementNotFound.Error())
|
||||||
|
|
||||||
err = sc.service.ImportLibraryPanelsForDashboard(sc.ctx, sc.user, simplejson.NewFromAny(libraryElements), panels, 0)
|
err = sc.service.ImportLibraryPanelsForDashboard(sc.ctx, sc.user, simplejson.NewFromAny(libraryElements), panels, 0, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
element, err := sc.elementService.GetElement(sc.ctx, sc.user,
|
element, err := sc.elementService.GetElement(sc.ctx, sc.user,
|
||||||
@ -439,14 +435,14 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
err = sc.service.ImportLibraryPanelsForDashboard(sc.ctx, sc.user, simplejson.New(), panels, sc.folder.ID)
|
err = sc.service.ImportLibraryPanelsForDashboard(sc.ctx, sc.user, simplejson.New(), panels, sc.folder.ID, sc.folder.UID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
element, err := sc.elementService.GetElement(sc.ctx, sc.user,
|
element, err := sc.elementService.GetElement(sc.ctx, sc.user,
|
||||||
model.GetLibraryElementCommand{UID: existingUID, FolderName: dashboards.RootFolderName})
|
model.GetLibraryElementCommand{UID: existingUID, FolderName: dashboards.RootFolderName})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var expected = getExpected(t, element, existingUID, existingName, sc.initialResult.Result.Model)
|
var expected = getExpected(t, element, existingUID, existingName, sc.initialResult.Result.Model)
|
||||||
expected.FolderID = sc.initialResult.Result.FolderID
|
expected.FolderUID = sc.initialResult.Result.FolderUID
|
||||||
expected.Description = sc.initialResult.Result.Description
|
expected.Description = sc.initialResult.Result.Description
|
||||||
expected.Meta.FolderUID = sc.folder.UID
|
expected.Meta.FolderUID = sc.folder.UID
|
||||||
expected.Meta.FolderName = sc.folder.Title
|
expected.Meta.FolderName = sc.folder.Title
|
||||||
@ -555,7 +551,7 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
_, err = sc.elementService.GetElement(sc.ctx, sc.user, model.GetLibraryElementCommand{UID: insideUID, FolderName: dashboards.RootFolderName})
|
_, err = sc.elementService.GetElement(sc.ctx, sc.user, model.GetLibraryElementCommand{UID: insideUID, FolderName: dashboards.RootFolderName})
|
||||||
require.EqualError(t, err, model.ErrLibraryElementNotFound.Error())
|
require.EqualError(t, err, model.ErrLibraryElementNotFound.Error())
|
||||||
|
|
||||||
err = sc.service.ImportLibraryPanelsForDashboard(sc.ctx, sc.user, simplejson.NewFromAny(libraryElements), panels, 0)
|
err = sc.service.ImportLibraryPanelsForDashboard(sc.ctx, sc.user, simplejson.NewFromAny(libraryElements), panels, 0, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
element, err := sc.elementService.GetElement(sc.ctx, sc.user, model.GetLibraryElementCommand{UID: outsideUID, FolderName: dashboards.RootFolderName})
|
element, err := sc.elementService.GetElement(sc.ctx, sc.user, model.GetLibraryElementCommand{UID: outsideUID, FolderName: dashboards.RootFolderName})
|
||||||
@ -579,7 +575,9 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
|||||||
type libraryPanel struct {
|
type libraryPanel struct {
|
||||||
ID int64
|
ID int64
|
||||||
OrgID int64
|
OrgID int64
|
||||||
|
// Deprecated: use FolderUID instead
|
||||||
FolderID int64
|
FolderID int64
|
||||||
|
FolderUID string
|
||||||
UID string
|
UID string
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
@ -615,6 +613,7 @@ type libraryElement struct {
|
|||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
OrgID int64 `json:"orgId"`
|
OrgID int64 `json:"orgId"`
|
||||||
FolderID int64 `json:"folderId"`
|
FolderID int64 `json:"folderId"`
|
||||||
|
FolderUID string `json:"folderUid"`
|
||||||
UID string `json:"uid"`
|
UID string `json:"uid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Kind int64 `json:"kind"`
|
Kind int64 `json:"kind"`
|
||||||
@ -648,7 +647,6 @@ func toLibraryElement(t *testing.T, res model.LibraryElementDTO) libraryElement
|
|||||||
return libraryElement{
|
return libraryElement{
|
||||||
ID: res.ID,
|
ID: res.ID,
|
||||||
OrgID: res.OrgID,
|
OrgID: res.OrgID,
|
||||||
FolderID: res.FolderID, // nolint:staticcheck
|
|
||||||
UID: res.UID,
|
UID: res.UID,
|
||||||
Name: res.Name,
|
Name: res.Name,
|
||||||
Type: res.Type,
|
Type: res.Type,
|
||||||
@ -714,9 +712,7 @@ func getExpected(t *testing.T, res model.LibraryElementDTO, UID string, name str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDashboard(t *testing.T, sqlStore db.DB, user *user.SignedInUser, dash *dashboards.Dashboard, folderID int64) *dashboards.Dashboard {
|
func createDashboard(t *testing.T, sqlStore db.DB, user *user.SignedInUser, dash *dashboards.Dashboard) *dashboards.Dashboard {
|
||||||
// nolint:staticcheck
|
|
||||||
dash.FolderID = folderID
|
|
||||||
dashItem := &dashboards.SaveDashboardDTO{
|
dashItem := &dashboards.SaveDashboardDTO{
|
||||||
Dashboard: dash,
|
Dashboard: dash,
|
||||||
Message: "",
|
Message: "",
|
||||||
@ -773,6 +769,7 @@ func scenarioWithLibraryPanel(t *testing.T, desc string, fn func(t *testing.T, s
|
|||||||
testScenario(t, desc, func(t *testing.T, sc scenarioContext) {
|
testScenario(t, desc, func(t *testing.T, sc scenarioContext) {
|
||||||
command := model.CreateLibraryElementCommand{
|
command := model.CreateLibraryElementCommand{
|
||||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||||
|
FolderUID: &sc.folder.UID,
|
||||||
Name: "Text - Library Panel",
|
Name: "Text - Library Panel",
|
||||||
Model: []byte(`
|
Model: []byte(`
|
||||||
{
|
{
|
||||||
@ -795,7 +792,7 @@ func scenarioWithLibraryPanel(t *testing.T, desc string, fn func(t *testing.T, s
|
|||||||
Result: libraryPanel{
|
Result: libraryPanel{
|
||||||
ID: resp.ID,
|
ID: resp.ID,
|
||||||
OrgID: resp.OrgID,
|
OrgID: resp.OrgID,
|
||||||
FolderID: resp.FolderID, // nolint:staticcheck
|
FolderUID: resp.FolderUID,
|
||||||
UID: resp.UID,
|
UID: resp.UID,
|
||||||
Name: resp.Name,
|
Name: resp.Name,
|
||||||
Type: resp.Type,
|
Type: resp.Type,
|
||||||
|
@ -61,4 +61,26 @@ func addLibraryElementsMigrations(mg *migrator.Migrator) {
|
|||||||
|
|
||||||
mg.AddMigration("alter library_element model to mediumtext", migrator.NewRawSQLMigration("").
|
mg.AddMigration("alter library_element model to mediumtext", migrator.NewRawSQLMigration("").
|
||||||
Mysql("ALTER TABLE library_element MODIFY model MEDIUMTEXT NOT NULL;"))
|
Mysql("ALTER TABLE library_element MODIFY model MEDIUMTEXT NOT NULL;"))
|
||||||
|
|
||||||
|
q := `UPDATE library_element
|
||||||
|
SET folder_uid = dashboard.uid
|
||||||
|
FROM dashboard
|
||||||
|
WHERE library_element.folder_id = dashboard.id AND library_element.org_id = dashboard.org_id`
|
||||||
|
|
||||||
|
if mg.Dialect.DriverName() == migrator.MySQL {
|
||||||
|
q = `UPDATE library_element
|
||||||
|
SET folder_uid = (
|
||||||
|
SELECT dashboard.uid
|
||||||
|
FROM dashboard
|
||||||
|
WHERE library_element.folder_id = dashboard.id AND library_element.org_id = dashboard.org_id
|
||||||
|
)`
|
||||||
|
}
|
||||||
|
|
||||||
|
mg.AddMigration("add library_element folder uid", migrator.NewAddColumnMigration(libraryElementsV1, &migrator.Column{
|
||||||
|
Name: "folder_uid", Type: migrator.DB_NVarchar, Length: 40, Nullable: true,
|
||||||
|
}))
|
||||||
|
|
||||||
|
mg.AddMigration("populate library_element folder_uid", migrator.NewRawSQLMigration(q))
|
||||||
|
|
||||||
|
mg.AddMigration("add index library_element org_id-folder_uid-name-kind", migrator.NewAddIndexMigration(libraryElementsV1, &migrator.Index{Cols: []string{"org_id", "folder_uid", "name", "kind"}, Type: migrator.UniqueIndex}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user