remove general folder in legacy api

This commit is contained in:
Ryan McKinley
2025-12-02 14:22:46 +03:00
parent 9d5659bfba
commit ff4f2b3926
2 changed files with 8 additions and 3 deletions
@@ -2174,13 +2174,18 @@ func (dr *DashboardServiceImpl) unstructuredToLegacyDashboardWithUsers(item *uns
dashVersion := obj.GetGeneration()
spec["version"] = dashVersion
folderUID := obj.GetFolder()
if folderUID == folder.GeneralFolderUID {
folderUID = "" // empty in legacy API
}
title, _, _ := unstructured.NestedString(spec, "title")
out := dashboards.Dashboard{
OrgID: orgID,
ID: obj.GetDeprecatedInternalID(), // nolint:staticcheck
UID: uid,
Slug: slugify.Slugify(title),
FolderUID: obj.GetFolder(),
FolderUID: folderUID,
Version: int(dashVersion),
Data: simplejson.NewFromAny(spec),
APIVersion: strings.TrimPrefix(item.GetAPIVersion(), dashboardv0.GROUP+"/"),
@@ -1089,13 +1089,13 @@ func TestIntegrationDashboardServicePermissions(t *testing.T) {
resp, err := postDashboard(t, grafanaListedAddr, "viewer", "viewer", dashboardPayload)
require.NoError(t, err)
assert.Equal(t, http.StatusForbidden, resp.StatusCode)
require.Equal(t, http.StatusForbidden, resp.StatusCode)
err = resp.Body.Close()
require.NoError(t, err)
resp, err = postDashboard(t, grafanaListedAddr, "editor", "editor", dashboardPayload)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
require.Equal(t, http.StatusOK, resp.StatusCode)
err = resp.Body.Close()
require.NoError(t, err)
})