K8s: Remove kubernetesClientDashboardsFolders feature flag (#108626)
This commit is contained in:
@@ -2,10 +2,8 @@ package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
@@ -25,7 +23,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrations"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/permissions"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
||||
"github.com/grafana/grafana/pkg/services/star"
|
||||
"github.com/grafana/grafana/pkg/services/store"
|
||||
"github.com/grafana/grafana/pkg/services/tag"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@@ -352,34 +349,6 @@ func (d *dashboardStore) UnprovisionDashboard(ctx context.Context, id int64) err
|
||||
})
|
||||
}
|
||||
|
||||
func (d *dashboardStore) DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *dashboards.DeleteOrphanedProvisionedDashboardsCommand) error {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.DeleteOrphanedProvisionedDashboards")
|
||||
defer span.End()
|
||||
|
||||
return d.store.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
var result []*dashboards.DashboardProvisioning
|
||||
|
||||
convertedReaderNames := make([]any, len(cmd.ReaderNames))
|
||||
for index, readerName := range cmd.ReaderNames {
|
||||
convertedReaderNames[index] = readerName
|
||||
}
|
||||
|
||||
err := sess.NotIn("name", convertedReaderNames...).Find(&result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, deleteDashCommand := range result {
|
||||
err := d.DeleteDashboard(ctx, &dashboards.DeleteDashboardCommand{ID: deleteDashCommand.DashboardID})
|
||||
if err != nil && !errors.Is(err, dashboards.ErrDashboardNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (d *dashboardStore) Count(ctx context.Context, scopeParams *quota.ScopeParameters) (*quota.Map, error) {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.Count")
|
||||
defer span.End()
|
||||
@@ -690,16 +659,6 @@ func (d *dashboardStore) CleanupAfterDelete(ctx context.Context, cmd *dashboards
|
||||
return err
|
||||
}
|
||||
|
||||
func (d *dashboardStore) DeleteAllDashboards(ctx context.Context, orgID int64) error {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.DeleteAllDashboards")
|
||||
defer span.End()
|
||||
|
||||
return d.store.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
|
||||
_, err := sess.Where("org_id = ?", orgID).Delete(&dashboards.Dashboard{})
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// FIXME: Remove me and handle nested deletions in the service with the DashboardPermissionsService
|
||||
func (d *dashboardStore) deleteResourcePermissions(sess *db.Session, orgID int64, resourceScope string) error {
|
||||
// retrieve all permissions for the resource scope and org id
|
||||
@@ -821,58 +780,6 @@ func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.Get
|
||||
return queryResult, err
|
||||
}
|
||||
|
||||
func (d *dashboardStore) GetDashboardUIDByID(ctx context.Context, query *dashboards.GetDashboardRefByIDQuery) (*dashboards.DashboardRef, error) {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.GetDashboardUIDByID")
|
||||
defer span.End()
|
||||
|
||||
us := &dashboards.DashboardRef{}
|
||||
err := d.store.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
var rawSQL = `SELECT uid, slug, folder_uid from dashboard WHERE Id=?`
|
||||
exists, err := sess.SQL(rawSQL, query.ID).Get(us)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return dashboards.ErrDashboardNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return us, nil
|
||||
}
|
||||
|
||||
func (d *dashboardStore) GetDashboards(ctx context.Context, query *dashboards.GetDashboardsQuery) ([]*dashboards.Dashboard, error) {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.GetDashboards")
|
||||
defer span.End()
|
||||
|
||||
var dashboards = make([]*dashboards.Dashboard, 0)
|
||||
err := d.store.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
if len(query.DashboardIDs) == 0 && len(query.DashboardUIDs) == 0 {
|
||||
return star.ErrCommandValidationFailed
|
||||
}
|
||||
|
||||
// remove soft deleted dashboards from the response
|
||||
sess.Where("deleted IS NULL")
|
||||
|
||||
if len(query.DashboardIDs) > 0 {
|
||||
sess.In("id", query.DashboardIDs)
|
||||
} else {
|
||||
sess.In("uid", query.DashboardUIDs)
|
||||
}
|
||||
if query.OrgID > 0 {
|
||||
sess.Where("org_id = ?", query.OrgID)
|
||||
}
|
||||
|
||||
err := sess.Find(&dashboards)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dashboards, nil
|
||||
}
|
||||
|
||||
func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.FindPersistedDashboardsQuery) ([]dashboards.DashboardSearchProjection, error) {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.FindDashboards")
|
||||
defer span.End()
|
||||
@@ -1025,39 +932,6 @@ func (d *dashboardStore) GetDashboardTags(ctx context.Context, query *dashboards
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// CountDashboardsInFolder returns a count of all dashboards associated with the
|
||||
// given parent folder ID.
|
||||
func (d *dashboardStore) CountDashboardsInFolders(
|
||||
ctx context.Context, req *dashboards.CountDashboardsInFolderRequest) (int64, error) {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.CountDashboardsInFolders")
|
||||
defer span.End()
|
||||
|
||||
if len(req.FolderUIDs) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
var count int64
|
||||
err := d.store.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
|
||||
s := strings.Builder{}
|
||||
args := make([]any, 0, 3)
|
||||
s.WriteString("SELECT COUNT(*) FROM dashboard WHERE ")
|
||||
if len(req.FolderUIDs) == 1 && req.FolderUIDs[0] == "" {
|
||||
s.WriteString("folder_uid IS NULL")
|
||||
} else {
|
||||
s.WriteString(fmt.Sprintf("folder_uid IN (%s)", strings.Repeat("?,", len(req.FolderUIDs)-1)+"?"))
|
||||
for _, folderUID := range req.FolderUIDs {
|
||||
args = append(args, folderUID)
|
||||
}
|
||||
}
|
||||
s.WriteString(" AND org_id = ? AND is_folder = ? AND deleted IS NULL")
|
||||
args = append(args, req.OrgID, d.store.GetDialect().BooleanValue(false))
|
||||
sql := s.String()
|
||||
_, err := sess.SQL(sql, args...).Get(&count)
|
||||
return err
|
||||
})
|
||||
return count, err
|
||||
}
|
||||
|
||||
func (d *dashboardStore) DeleteDashboardsInFolders(
|
||||
ctx context.Context, req *dashboards.DeleteDashboardsInFolderRequest) error {
|
||||
ctx, span := tracer.Start(ctx, "dashboards.database.DeleteDashboardsInFolders")
|
||||
|
||||
@@ -59,42 +59,6 @@ func TestIntegrationDashboardProvisioningTest(t *testing.T) {
|
||||
require.NotEqual(t, 0, dash.ID)
|
||||
dashId := dash.ID
|
||||
|
||||
t.Run("Deleting orphaned provisioned dashboards", func(t *testing.T) {
|
||||
saveCmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: 1,
|
||||
IsFolder: false,
|
||||
FolderUID: dash.UID,
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"id": nil,
|
||||
"title": "another_dashboard",
|
||||
}),
|
||||
}
|
||||
|
||||
provisioning := &dashboards.DashboardProvisioning{
|
||||
Name: "another_reader",
|
||||
ExternalID: "/var/grafana.json",
|
||||
Updated: now.Unix(),
|
||||
}
|
||||
|
||||
anotherDash, err := dashboardStore.SaveProvisionedDashboard(context.Background(), saveCmd, provisioning)
|
||||
require.Nil(t, err)
|
||||
|
||||
query := &dashboards.GetDashboardsQuery{DashboardIDs: []int64{anotherDash.ID}}
|
||||
queryResult, err := dashboardStore.GetDashboards(context.Background(), query)
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, queryResult)
|
||||
|
||||
deleteCmd := &dashboards.DeleteOrphanedProvisionedDashboardsCommand{ReaderNames: []string{"default"}}
|
||||
require.Nil(t, dashboardStore.DeleteOrphanedProvisionedDashboards(context.Background(), deleteCmd))
|
||||
|
||||
query = &dashboards.GetDashboardsQuery{DashboardIDs: []int64{dash.ID, anotherDash.ID}}
|
||||
queryResult, err = dashboardStore.GetDashboards(context.Background(), query)
|
||||
require.Nil(t, err)
|
||||
|
||||
require.Equal(t, 1, len(queryResult))
|
||||
require.Equal(t, dashId, queryResult[0].ID)
|
||||
})
|
||||
|
||||
t.Run("Can query for provisioned dashboards", func(t *testing.T) {
|
||||
rslt, err := dashboardStore.GetProvisionedDashboardData(context.Background(), "default")
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -10,27 +10,19 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/apiserver"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/services/folder/folderimpl"
|
||||
libmodel "github.com/grafana/grafana/pkg/services/libraryelements/model"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/search/model"
|
||||
"github.com/grafana/grafana/pkg/services/search/sort"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
||||
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlestest"
|
||||
"github.com/grafana/grafana/pkg/services/tag/tagimpl"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/storage/legacysql/dualwrite"
|
||||
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
@@ -185,15 +177,6 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
require.False(t, queryResult.IsFolder)
|
||||
})
|
||||
|
||||
t.Run("Should be able to get a dashboard UID by ID", func(t *testing.T) {
|
||||
setup()
|
||||
query := dashboards.GetDashboardRefByIDQuery{ID: savedDash.ID}
|
||||
queryResult, err := dashboardStore.GetDashboardUIDByID(context.Background(), &query)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, queryResult.UID, savedDash.UID)
|
||||
require.Equal(t, queryResult.FolderUID, savedFolder.UID)
|
||||
})
|
||||
|
||||
t.Run("Shouldn't be able to get a dashboard with just an OrgID", func(t *testing.T) {
|
||||
setup()
|
||||
query := dashboards.GetDashboardQuery{
|
||||
@@ -216,19 +199,6 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
require.Error(t, err, dashboards.ErrDashboardNotFound)
|
||||
})
|
||||
|
||||
t.Run("Should be able to get dashboards by IDs & UIDs", func(t *testing.T) {
|
||||
setup()
|
||||
query := dashboards.GetDashboardsQuery{DashboardIDs: []int64{savedDash.ID, savedDash2.ID}}
|
||||
queryResult, err := dashboardStore.GetDashboards(context.Background(), &query)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, len(queryResult), 2)
|
||||
|
||||
query = dashboards.GetDashboardsQuery{DashboardUIDs: []string{savedDash.UID, savedDash2.UID}}
|
||||
queryResult, err = dashboardStore.GetDashboards(context.Background(), &query)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, len(queryResult), 2)
|
||||
})
|
||||
|
||||
t.Run("Should be able to delete dashboard and associated tags", func(t *testing.T) {
|
||||
setup()
|
||||
dash := insertTestDashboard(t, dashboardStore, "delete me", 1, 0, "", false, "delete this")
|
||||
@@ -330,32 +300,6 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
require.Len(t, res, 0)
|
||||
})
|
||||
|
||||
t.Run("Should be able to delete all dashboards for an org", func(t *testing.T) {
|
||||
setup()
|
||||
dash1 := insertTestDashboard(t, dashboardStore, "delete me", 1, 0, "", false, "delete this")
|
||||
dash2 := insertTestDashboard(t, dashboardStore, "delete me2", 1, 0, "", false, "delete this2")
|
||||
dash3 := insertTestDashboard(t, dashboardStore, "dont delete me", 2, 0, "", false, "dont delete me")
|
||||
|
||||
err := dashboardStore.DeleteAllDashboards(context.Background(), 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
// no dashboards should exist for org 1
|
||||
queryResult, err := dashboardStore.GetDashboards(context.Background(), &dashboards.GetDashboardsQuery{
|
||||
OrgID: 1,
|
||||
DashboardUIDs: []string{dash1.UID, dash2.UID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, len(queryResult), 0)
|
||||
|
||||
// but we should still have one for org 2
|
||||
queryResult, err = dashboardStore.GetDashboards(context.Background(), &dashboards.GetDashboardsQuery{
|
||||
OrgID: 2,
|
||||
DashboardUIDs: []string{dash3.UID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, len(queryResult), 1)
|
||||
})
|
||||
|
||||
t.Run("Should be able to get all dashboards for an org", func(t *testing.T) {
|
||||
setup()
|
||||
dash1 := insertTestDashboard(t, dashboardStore, "org3test1", 3, 0, "", false, "org 1 test 1")
|
||||
@@ -679,22 +623,6 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
require.Equal(t, len(hit2.Tags), 1)
|
||||
})
|
||||
|
||||
t.Run("Can count dashboards by parent folder", func(t *testing.T) {
|
||||
setup()
|
||||
// setup() saves one dashboard in the general folder and two in the "savedFolder".
|
||||
count, err := dashboardStore.CountDashboardsInFolders(
|
||||
context.Background(),
|
||||
&dashboards.CountDashboardsInFolderRequest{FolderUIDs: []string{""}, OrgID: 1})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(1), count)
|
||||
|
||||
count, err = dashboardStore.CountDashboardsInFolders(
|
||||
context.Background(),
|
||||
&dashboards.CountDashboardsInFolderRequest{FolderUIDs: []string{savedFolder.UID}, OrgID: 1})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(2), count)
|
||||
})
|
||||
|
||||
t.Run("Can delete dashboards in folder", func(t *testing.T) {
|
||||
setup()
|
||||
folder := insertTestDashboard(t, dashboardStore, "dash folder", 1, 0, "", true, "prod", "webapp")
|
||||
@@ -703,10 +631,6 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
|
||||
err := dashboardStore.DeleteDashboardsInFolders(context.Background(), &dashboards.DeleteDashboardsInFolderRequest{OrgID: folder.OrgID, FolderUIDs: []string{folder.UID}})
|
||||
require.NoError(t, err)
|
||||
|
||||
count, err := dashboardStore.CountDashboardsInFolders(context.Background(), &dashboards.CountDashboardsInFolderRequest{FolderUIDs: []string{folder.UID}, OrgID: 1})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, count, int64(0))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -830,6 +754,59 @@ func TestIntegrationDashboard_Filter(t *testing.T) {
|
||||
assert.Equal(t, dashB.ID, results[0].ID)
|
||||
}
|
||||
|
||||
// has to be added to both the folder & the dashboard table
|
||||
func insertTestFolder(t *testing.T, dashboardStore dashboards.Store, sqlStore db.DB, title string, orgId int64, parentUID string, tags ...interface{}) *dashboards.Dashboard {
|
||||
t.Helper()
|
||||
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgId,
|
||||
FolderUID: parentUID,
|
||||
IsFolder: true,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
"id": nil,
|
||||
"title": title,
|
||||
"tags": tags,
|
||||
}),
|
||||
}
|
||||
dash, err := dashboardStore.SaveDashboard(context.Background(), cmd)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, dash)
|
||||
dash.Data.Set("id", dash.ID)
|
||||
dash.Data.Set("uid", dash.UID)
|
||||
|
||||
err = sqlStore.WithDbSession(context.Background(), func(sess *db.Session) error {
|
||||
type folder struct {
|
||||
ID int64 `xorm:"pk autoincr 'id'"`
|
||||
OrgID int64 `xorm:"org_id"`
|
||||
UID string `xorm:"uid"`
|
||||
ParentUID *string `xorm:"parent_uid"`
|
||||
Title string `xorm:"title"`
|
||||
Description string `xorm:"description"`
|
||||
Created time.Time `xorm:"created"`
|
||||
Updated time.Time `xorm:"updated"`
|
||||
}
|
||||
|
||||
f := &folder{
|
||||
OrgID: orgId,
|
||||
UID: dash.UID,
|
||||
Title: title,
|
||||
Description: "",
|
||||
Created: time.Now(),
|
||||
Updated: time.Now(),
|
||||
}
|
||||
|
||||
if parentUID != "" {
|
||||
f.ParentUID = &parentUID
|
||||
}
|
||||
|
||||
_, err := sess.Insert(f)
|
||||
return err
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
return dash
|
||||
}
|
||||
|
||||
func TestIntegrationFindDashboardsByTitle(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
@@ -844,13 +821,6 @@ func TestIntegrationFindDashboardsByTitle(t *testing.T) {
|
||||
orgID := int64(1)
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under general", orgID, 0, "", false, []string{"tag1", "tag2"})
|
||||
|
||||
ac := acimpl.ProvideAccessControl(features)
|
||||
folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore)
|
||||
fStore := folderimpl.ProvideStore(sqlStore)
|
||||
folderServiceWithFlagOn := folderimpl.ProvideService(
|
||||
fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore,
|
||||
nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest(), nil, dualwrite.ProvideTestService(), sort.ProvideService(), apiserver.WithoutRestConfig)
|
||||
|
||||
user := &user.SignedInUser{
|
||||
OrgID: 1,
|
||||
Permissions: map[int64]map[string][]string{
|
||||
@@ -863,23 +833,10 @@ func TestIntegrationFindDashboardsByTitle(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
f0, err := folderServiceWithFlagOn.Create(context.Background(), &folder.CreateFolderCommand{
|
||||
OrgID: orgID,
|
||||
Title: "f0",
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
f0 := insertTestFolder(t, dashboardStore, sqlStore, "f0", orgID, "")
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f0", orgID, 0, f0.UID, false, []string{"tag3"})
|
||||
|
||||
subfolder, err := folderServiceWithFlagOn.Create(context.Background(), &folder.CreateFolderCommand{
|
||||
OrgID: orgID,
|
||||
Title: "subfolder",
|
||||
ParentUID: f0.UID,
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
subfolder := insertTestFolder(t, dashboardStore, sqlStore, "subfolder", orgID, f0.UID)
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under subfolder", orgID, 0, subfolder.UID, false)
|
||||
|
||||
type res struct {
|
||||
@@ -981,14 +938,6 @@ func TestIntegrationFindDashboardsByFolder(t *testing.T) {
|
||||
orgID := int64(1)
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under general", orgID, 0, "", false)
|
||||
|
||||
ac := acimpl.ProvideAccessControl(features)
|
||||
folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore)
|
||||
fStore := folderimpl.ProvideStore(sqlStore)
|
||||
|
||||
folderServiceWithFlagOn := folderimpl.ProvideService(
|
||||
fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore,
|
||||
nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest(), nil, dualwrite.ProvideTestService(), sort.ProvideService(), apiserver.WithoutRestConfig)
|
||||
|
||||
user := &user.SignedInUser{
|
||||
OrgID: 1,
|
||||
Permissions: map[int64]map[string][]string{
|
||||
@@ -1001,31 +950,13 @@ func TestIntegrationFindDashboardsByFolder(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
f0, err := folderServiceWithFlagOn.Create(context.Background(), &folder.CreateFolderCommand{
|
||||
OrgID: orgID,
|
||||
Title: "f0",
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f0", orgID, f0.ID, f0.UID, false)
|
||||
f0 := insertTestFolder(t, dashboardStore, sqlStore, "f0", orgID, "")
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f0", orgID, 0, f0.UID, false)
|
||||
|
||||
f1, err := folderServiceWithFlagOn.Create(context.Background(), &folder.CreateFolderCommand{
|
||||
OrgID: orgID,
|
||||
Title: "f1",
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f1", orgID, f1.ID, f1.UID, false)
|
||||
f1 := insertTestFolder(t, dashboardStore, sqlStore, "f1", orgID, "")
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f1", orgID, 0, f1.UID, false)
|
||||
|
||||
subfolder, err := folderServiceWithFlagOn.Create(context.Background(), &folder.CreateFolderCommand{
|
||||
OrgID: orgID,
|
||||
Title: "subfolder",
|
||||
ParentUID: f0.UID,
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
subfolder := insertTestFolder(t, dashboardStore, sqlStore, "subfolder", orgID, f0.UID)
|
||||
|
||||
type res struct {
|
||||
title string
|
||||
|
||||
Reference in New Issue
Block a user