Chore: Deprecate FolderID from Dashboard (#77823)

* Chore: Deprecate FolderID from Dashboard

* chore: add two missing nolint comments
This commit is contained in:
Kat Yang
2023-11-15 10:28:50 -05:00
committed by GitHub
parent 0214b25663
commit 3a2e96b0db
28 changed files with 92 additions and 27 deletions
@@ -330,6 +330,7 @@ func getExistingDashboardByIDOrUIDForUpdate(sess *db.Session, dash *dashboards.D
}
}
// nolint:staticcheck
if dash.FolderID > 0 {
var existingFolder dashboards.Dashboard
folderExists, err := sess.Where("org_id=? AND id=? AND is_folder=?", dash.OrgID, dash.FolderID,
@@ -364,6 +365,7 @@ func getExistingDashboardByIDOrUIDForUpdate(sess *db.Session, dash *dashboards.D
return isParentFolderChanged, dashboards.ErrDashboardTypeMismatch
}
// nolint:staticcheck
if !dash.IsFolder && dash.FolderID != existing.FolderID {
isParentFolderChanged = true
}
@@ -389,6 +391,7 @@ func getExistingDashboardByIDOrUIDForUpdate(sess *db.Session, dash *dashboards.D
func getExistingDashboardByTitleAndFolder(sess *db.Session, dash *dashboards.Dashboard, dialect migrator.Dialect, overwrite,
isParentFolderChanged bool) (bool, error) {
var existing dashboards.Dashboard
// nolint:staticcheck
exists, err := sess.Where("org_id=? AND title=? AND (is_folder=? OR folder_id=?)", dash.OrgID, dash.Title,
dialect.BooleanStr(true), dash.FolderID).Get(&existing)
if err != nil {
@@ -403,6 +406,7 @@ func getExistingDashboardByTitleAndFolder(sess *db.Session, dash *dashboards.Das
return isParentFolderChanged, dashboards.ErrDashboardFolderWithSameNameAsDashboard
}
// nolint:staticcheck
if !dash.IsFolder && (dash.FolderID != existing.FolderID || dash.ID == 0) {
isParentFolderChanged = true
}
@@ -897,6 +901,7 @@ func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.Get
}
// nolint:staticcheck
if query.FolderID != nil {
// nolint:staticcheck
dashboard.FolderID = *query.FolderID
mustCols = append(mustCols, "folder_id")
}