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:
parent
cdff30ac44
commit
31fb38723d
@ -10,8 +10,9 @@ type Folder struct {
|
||||
// Deprecated: use UID instead
|
||||
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
|
||||
UID string `json:"uid" xorm:"uid"`
|
||||
OrgID int64 `json:"orgId" xorm:"org_id"`
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url" xoem:"url"`
|
||||
URL string `json:"url" xorm:"url"`
|
||||
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
|
@ -145,8 +145,6 @@ func TestFoldersCreateAPIEndpoint(t *testing.T) {
|
||||
require.NoError(t, resp.Body.Close())
|
||||
|
||||
if tc.expectedCode == http.StatusOK {
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, int64(1), folder.ID)
|
||||
assert.Equal(t, "uid", folder.UID)
|
||||
assert.Equal(t, "Folder", folder.Title)
|
||||
}
|
||||
@ -250,8 +248,6 @@ func TestFoldersUpdateAPIEndpoint(t *testing.T) {
|
||||
require.NoError(t, resp.Body.Close())
|
||||
|
||||
if tc.expectedCode == http.StatusOK {
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, int64(1), folder.ID)
|
||||
assert.Equal(t, "uid", folder.UID)
|
||||
assert.Equal(t, "Folder upd", folder.Title)
|
||||
}
|
||||
@ -443,6 +439,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
||||
features *featuremgmt.FeatureManager
|
||||
expectedCode int
|
||||
expectedParentUIDs []string
|
||||
expectedParentOrgIDs []int64
|
||||
expectedParentTitles []string
|
||||
permissions []accesscontrol.Permission
|
||||
g *guardian.FakeDashboardGuardian
|
||||
@ -454,6 +451,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
||||
expectedCode: http.StatusOK,
|
||||
features: featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders),
|
||||
expectedParentUIDs: []string{"parent", "subfolder"},
|
||||
expectedParentOrgIDs: []int64{0, 0},
|
||||
expectedParentTitles: []string{"parent title", "subfolder title"},
|
||||
permissions: []accesscontrol.Permission{
|
||||
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
||||
@ -466,6 +464,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
||||
expectedCode: http.StatusOK,
|
||||
features: featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders),
|
||||
expectedParentUIDs: []string{REDACTED, REDACTED},
|
||||
expectedParentOrgIDs: []int64{0, 0},
|
||||
expectedParentTitles: []string{REDACTED, REDACTED},
|
||||
permissions: []accesscontrol.Permission{
|
||||
{Action: dashboards.ActionFoldersRead, Scope: dashboards.ScopeFoldersProvider.GetResourceScopeUID("uid")},
|
||||
@ -478,6 +477,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
||||
expectedCode: http.StatusOK,
|
||||
features: featuremgmt.WithFeatures(),
|
||||
expectedParentUIDs: []string{},
|
||||
expectedParentOrgIDs: []int64{0, 0},
|
||||
expectedParentTitles: []string{},
|
||||
permissions: []accesscontrol.Permission{
|
||||
{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++ {
|
||||
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)
|
||||
}
|
||||
require.NoError(t, resp.Body.Close())
|
||||
|
@ -328,6 +328,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
buf1 := &bytes.Buffer{}
|
||||
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
||||
Dashboard: dashboardDataOne,
|
||||
OrgID: 0,
|
||||
FolderUID: folder.UID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@ -358,7 +359,8 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
buf1 := &bytes.Buffer{}
|
||||
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
||||
Dashboard: dashboardDataOne,
|
||||
FolderID: folder.ID, // nolint:staticcheck
|
||||
OrgID: 0,
|
||||
FolderUID: folder.UID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
u := fmt.Sprintf("http://admin:admin@%s/api/dashboards/db", grafanaListedAddr)
|
||||
|
@ -14143,6 +14143,10 @@
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"orgId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"parentUid": {
|
||||
"description": "only used if nested folders are enabled",
|
||||
"type": "string"
|
||||
|
@ -5160,6 +5160,10 @@
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"orgId": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"parentUid": {
|
||||
"description": "only used if nested folders are enabled",
|
||||
"type": "string"
|
||||
|
Loading…
Reference in New Issue
Block a user