mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove FolderID from DTO Folder (#78420)
* Chore: Remove FolderID from DTO Folder * chore: add OrgID field to an instance of SaveDashboardCommand * chore: add another OrgID to pair with the FolderUID: * chore: add OrgId to Folder struct and expectedParentOrgIDs to testCase struct, unsure if last part is necessary * Fix folder test, add expected orgID * chore: regen specs --------- Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
This commit is contained in:
@@ -10,8 +10,9 @@ type Folder struct {
|
|||||||
// Deprecated: use UID instead
|
// Deprecated: use UID instead
|
||||||
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
|
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
|
||||||
UID string `json:"uid" xorm:"uid"`
|
UID string `json:"uid" xorm:"uid"`
|
||||||
|
OrgID int64 `json:"orgId" xorm:"org_id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
URL string `json:"url" xoem:"url"`
|
URL string `json:"url" xorm:"url"`
|
||||||
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
||||||
CanSave bool `json:"canSave"`
|
CanSave bool `json:"canSave"`
|
||||||
CanEdit bool `json:"canEdit"`
|
CanEdit bool `json:"canEdit"`
|
||||||
|
|||||||
@@ -145,8 +145,6 @@ func TestFoldersCreateAPIEndpoint(t *testing.T) {
|
|||||||
require.NoError(t, resp.Body.Close())
|
require.NoError(t, resp.Body.Close())
|
||||||
|
|
||||||
if tc.expectedCode == http.StatusOK {
|
if tc.expectedCode == http.StatusOK {
|
||||||
// nolint:staticcheck
|
|
||||||
assert.Equal(t, int64(1), folder.ID)
|
|
||||||
assert.Equal(t, "uid", folder.UID)
|
assert.Equal(t, "uid", folder.UID)
|
||||||
assert.Equal(t, "Folder", folder.Title)
|
assert.Equal(t, "Folder", folder.Title)
|
||||||
}
|
}
|
||||||
@@ -250,8 +248,6 @@ func TestFoldersUpdateAPIEndpoint(t *testing.T) {
|
|||||||
require.NoError(t, resp.Body.Close())
|
require.NoError(t, resp.Body.Close())
|
||||||
|
|
||||||
if tc.expectedCode == http.StatusOK {
|
if tc.expectedCode == http.StatusOK {
|
||||||
// nolint:staticcheck
|
|
||||||
assert.Equal(t, int64(1), folder.ID)
|
|
||||||
assert.Equal(t, "uid", folder.UID)
|
assert.Equal(t, "uid", folder.UID)
|
||||||
assert.Equal(t, "Folder upd", folder.Title)
|
assert.Equal(t, "Folder upd", folder.Title)
|
||||||
}
|
}
|
||||||
@@ -443,6 +439,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
|||||||
features *featuremgmt.FeatureManager
|
features *featuremgmt.FeatureManager
|
||||||
expectedCode int
|
expectedCode int
|
||||||
expectedParentUIDs []string
|
expectedParentUIDs []string
|
||||||
|
expectedParentOrgIDs []int64
|
||||||
expectedParentTitles []string
|
expectedParentTitles []string
|
||||||
permissions []accesscontrol.Permission
|
permissions []accesscontrol.Permission
|
||||||
g *guardian.FakeDashboardGuardian
|
g *guardian.FakeDashboardGuardian
|
||||||
@@ -454,6 +451,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
|||||||
expectedCode: http.StatusOK,
|
expectedCode: http.StatusOK,
|
||||||
features: featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders),
|
features: featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders),
|
||||||
expectedParentUIDs: []string{"parent", "subfolder"},
|
expectedParentUIDs: []string{"parent", "subfolder"},
|
||||||
|
expectedParentOrgIDs: []int64{0, 0},
|
||||||
expectedParentTitles: []string{"parent title", "subfolder title"},
|
expectedParentTitles: []string{"parent title", "subfolder title"},
|
||||||
permissions: []accesscontrol.Permission{
|
permissions: []accesscontrol.Permission{
|
||||||
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
||||||
@@ -466,6 +464,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
|||||||
expectedCode: http.StatusOK,
|
expectedCode: http.StatusOK,
|
||||||
features: featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders),
|
features: featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders),
|
||||||
expectedParentUIDs: []string{REDACTED, REDACTED},
|
expectedParentUIDs: []string{REDACTED, REDACTED},
|
||||||
|
expectedParentOrgIDs: []int64{0, 0},
|
||||||
expectedParentTitles: []string{REDACTED, REDACTED},
|
expectedParentTitles: []string{REDACTED, REDACTED},
|
||||||
permissions: []accesscontrol.Permission{
|
permissions: []accesscontrol.Permission{
|
||||||
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
||||||
@@ -478,6 +477,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
|||||||
expectedCode: http.StatusOK,
|
expectedCode: http.StatusOK,
|
||||||
features: featuremgmt.WithFeatures(),
|
features: featuremgmt.WithFeatures(),
|
||||||
expectedParentUIDs: []string{},
|
expectedParentUIDs: []string{},
|
||||||
|
expectedParentOrgIDs: []int64{0, 0},
|
||||||
expectedParentTitles: []string{},
|
expectedParentTitles: []string{},
|
||||||
permissions: []accesscontrol.Permission{
|
permissions: []accesscontrol.Permission{
|
||||||
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
||||||
@@ -516,6 +516,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
|||||||
|
|
||||||
for i := 0; i < len(tc.expectedParentUIDs); i++ {
|
for i := 0; i < len(tc.expectedParentUIDs); i++ {
|
||||||
assert.Equal(t, tc.expectedParentUIDs[i], folder.Parents[i].UID)
|
assert.Equal(t, tc.expectedParentUIDs[i], folder.Parents[i].UID)
|
||||||
|
assert.Equal(t, tc.expectedParentOrgIDs[i], folder.Parents[i].OrgID)
|
||||||
assert.Equal(t, tc.expectedParentTitles[i], folder.Parents[i].Title)
|
assert.Equal(t, tc.expectedParentTitles[i], folder.Parents[i].Title)
|
||||||
}
|
}
|
||||||
require.NoError(t, resp.Body.Close())
|
require.NoError(t, resp.Body.Close())
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ func TestIntegrationCreate(t *testing.T) {
|
|||||||
buf1 := &bytes.Buffer{}
|
buf1 := &bytes.Buffer{}
|
||||||
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
||||||
Dashboard: dashboardDataOne,
|
Dashboard: dashboardDataOne,
|
||||||
|
OrgID: 0,
|
||||||
FolderUID: folder.UID,
|
FolderUID: folder.UID,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -358,7 +359,8 @@ func TestIntegrationCreate(t *testing.T) {
|
|||||||
buf1 := &bytes.Buffer{}
|
buf1 := &bytes.Buffer{}
|
||||||
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
||||||
Dashboard: dashboardDataOne,
|
Dashboard: dashboardDataOne,
|
||||||
FolderID: folder.ID, // nolint:staticcheck
|
OrgID: 0,
|
||||||
|
FolderUID: folder.UID,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
u := fmt.Sprintf("http://admin:admin@%s/api/dashboards/db", grafanaListedAddr)
|
u := fmt.Sprintf("http://admin:admin@%s/api/dashboards/db", grafanaListedAddr)
|
||||||
|
|||||||
@@ -14143,6 +14143,10 @@
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64"
|
"format": "int64"
|
||||||
},
|
},
|
||||||
|
"orgId": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
"parentUid": {
|
"parentUid": {
|
||||||
"description": "only used if nested folders are enabled",
|
"description": "only used if nested folders are enabled",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@@ -5160,6 +5160,10 @@
|
|||||||
"format": "int64",
|
"format": "int64",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orgId": {
|
||||||
|
"format": "int64",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"parentUid": {
|
"parentUid": {
|
||||||
"description": "only used if nested folders are enabled",
|
"description": "only used if nested folders are enabled",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
Reference in New Issue
Block a user