Dashboard Migrations: v25 & v24; migrate angular table (#108826)
* Dashboard Migrations: V31 LabelsToFields-Merge Migration * Dashboard Migrations: V32 No-op migration * simplify * Refactor to reduce nesting * Dashboard Migrations: V30 value mappings and tooltip options * Do not automigrate since graph is migrated in v27 * Refactor to reduce nesting * Add test case for invalid mapping * migrate to v29 * wip * Fix tests * fix output * wip * fix min version issue * fix wire * ignore gauge logic as it never get's executed * add panel migration to test * improvements * update * cleanup * address mappings inconsistencies * cleanup * fix lint issues * add cfg when initializing * v27 migration * migrate to v26 * preallocate array * remove logic for grafana-singlestat because it's shared with stat logic; improve error handling and testing * fix go lint * don't preallocate; cleanup comments * cleanup * wip * run internal provider function when getting a single panel * clean up; add tests * add tests for panel plugin service * remove obsolete mock for getting panel plugin * add tests for the whole pipeline * fix test and lint * fix test * Fix missing scenarios --------- Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
co-authored by
Ivan Ortega
parent
3920b25aee
commit
6ca8c6c6da
@@ -0,0 +1,89 @@
|
||||
package schemaversion
|
||||
|
||||
var notPersistedProperties = []string{
|
||||
"events",
|
||||
"isViewing",
|
||||
"isEditing",
|
||||
"isInView",
|
||||
"hasRefreshed",
|
||||
"cachedPluginOptions",
|
||||
"plugin",
|
||||
"queryRunner",
|
||||
"replaceVariables",
|
||||
"configRev",
|
||||
"hasSavedPanelEditChange",
|
||||
"getDisplayTitle",
|
||||
"dataSupport",
|
||||
"key",
|
||||
"isNew",
|
||||
"refreshWhenInView",
|
||||
}
|
||||
|
||||
var mustKeepProperties = []string{
|
||||
"id",
|
||||
"gridPos",
|
||||
"type",
|
||||
"title",
|
||||
"scopedVars",
|
||||
"repeat",
|
||||
"repeatPanelId",
|
||||
"repeatDirection",
|
||||
"repeatedByRow",
|
||||
"minSpan",
|
||||
"collapsed",
|
||||
"panels",
|
||||
"targets",
|
||||
"datasource",
|
||||
"timeFrom",
|
||||
"timeShift",
|
||||
"hideTimeOverride",
|
||||
"description",
|
||||
"links",
|
||||
"fullscreen",
|
||||
"isEditing",
|
||||
"isViewing",
|
||||
"hasRefreshed",
|
||||
"events",
|
||||
"cacheTimeout",
|
||||
"queryCachingTTL",
|
||||
"cachedPluginOptions",
|
||||
"transparent",
|
||||
"pluginVersion",
|
||||
"queryRunner",
|
||||
"transformations",
|
||||
"fieldConfig",
|
||||
"maxDataPoints",
|
||||
"interval",
|
||||
"replaceVariables",
|
||||
"libraryPanel",
|
||||
"getDisplayTitle",
|
||||
"configRev",
|
||||
"key",
|
||||
}
|
||||
|
||||
// getOptionsToRemember returns a map of panel properties that should be remembered
|
||||
// during panel type changes, excluding notPersistedProperties and mustKeepProperties
|
||||
func getOptionsToRemember(panel map[string]interface{}) map[string]interface{} {
|
||||
// Create sets for faster lookup
|
||||
notPersistedSet := make(map[string]bool)
|
||||
for _, prop := range notPersistedProperties {
|
||||
notPersistedSet[prop] = true
|
||||
}
|
||||
|
||||
mustKeepSet := make(map[string]bool)
|
||||
for _, prop := range mustKeepProperties {
|
||||
mustKeepSet[prop] = true
|
||||
}
|
||||
|
||||
// Filter the panel properties
|
||||
result := make(map[string]interface{})
|
||||
for key, value := range panel {
|
||||
// Skip properties that are in notPersistedProperties or mustKeepProperties
|
||||
if notPersistedSet[key] || mustKeepSet[key] {
|
||||
continue
|
||||
}
|
||||
result[key] = value
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user