Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b3c32277
Unverified
Commit
b3c32277
authored
Feb 13, 2021
by
Torkel Ödegaard
Committed by
GitHub
Feb 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StatPanels: Fixes to palette color scheme is not cleared when loading panel (#31126)
parent
2dacc2c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
public/app/features/dashboard/state/PanelModel.ts
+4
-3
public/app/features/dashboard/state/getPanelOptionsWithDefaults.test.ts
+6
-0
public/app/features/dashboard/state/getPanelOptionsWithDefaults.ts
+17
-3
No files found.
public/app/features/dashboard/state/PanelModel.ts
View file @
b3c32277
...
...
@@ -313,11 +313,12 @@ export class PanelModel implements DataConfigSource {
this
.
fieldConfig
=
restoreCustomOverrideRules
(
this
.
fieldConfig
,
prevOptions
.
fieldConfig
);
}
applyPluginOptionDefaults
(
plugin
:
PanelPlugin
)
{
applyPluginOptionDefaults
(
plugin
:
PanelPlugin
,
isAfterPluginChange
:
boolean
)
{
const
options
=
getPanelOptionsWithDefaults
({
plugin
,
currentOptions
:
this
.
options
,
currentFieldConfig
:
this
.
fieldConfig
,
isAfterPluginChange
:
isAfterPluginChange
,
});
this
.
fieldConfig
=
options
.
fieldConfig
;
...
...
@@ -336,7 +337,7 @@ export class PanelModel implements DataConfigSource {
}
}
this
.
applyPluginOptionDefaults
(
plugin
);
this
.
applyPluginOptionDefaults
(
plugin
,
false
);
this
.
resendLastResult
();
}
...
...
@@ -389,7 +390,7 @@ export class PanelModel implements DataConfigSource {
// For some reason I need to rebind replace variables here, otherwise the viz repeater does not work
this
.
replaceVariables
=
this
.
replaceVariables
.
bind
(
this
);
this
.
applyPluginOptionDefaults
(
newPlugin
);
this
.
applyPluginOptionDefaults
(
newPlugin
,
true
);
if
(
newPlugin
.
onPanelMigration
)
{
this
.
pluginVersion
=
getPluginVersion
(
newPlugin
);
...
...
public/app/features/dashboard/state/getPanelOptionsWithDefaults.test.ts
View file @
b3c32277
...
...
@@ -79,6 +79,7 @@ describe('getPanelOptionsWithDefaults', () => {
defaults
:
{},
overrides
:
[],
},
isAfterPluginChange
:
false
,
});
expect
(
result
).
toMatchInlineSnapshot
(
`
...
...
@@ -129,6 +130,7 @@ describe('getPanelOptionsWithDefaults', () => {
},
overrides
:
[],
},
isAfterPluginChange
:
true
,
});
expect
(
result
).
toMatchInlineSnapshot
(
`
...
...
@@ -187,6 +189,7 @@ describe('getPanelOptionsWithDefaults', () => {
},
overrides
:
[],
},
isAfterPluginChange
:
true
,
});
expect
(
result
.
fieldConfig
.
defaults
.
color
!
.
mode
).
toBe
(
FieldColorModeId
.
PaletteClassic
);
...
...
@@ -223,6 +226,7 @@ describe('getPanelOptionsWithDefaults', () => {
},
},
},
isAfterPluginChange
:
true
,
});
expect
(
result
.
fieldConfig
.
defaults
.
color
!
.
mode
).
toBe
(
FieldColorModeId
.
Thresholds
);
});
...
...
@@ -357,6 +361,7 @@ interface ScenarioOptions {
standardOptions
?:
Partial
<
Record
<
FieldConfigProperty
,
StandardOptionConfig
>>
;
plugin
?:
PanelPlugin
;
options
?:
any
;
isAfterPluginChange
?:
boolean
;
}
function
runScenario
(
options
:
ScenarioOptions
)
{
...
...
@@ -386,5 +391,6 @@ function runScenario(options: ScenarioOptions) {
plugin
,
currentOptions
:
options
.
options
||
{},
currentFieldConfig
:
fieldConfig
,
isAfterPluginChange
:
!!
options
.
isAfterPluginChange
,
});
}
public/app/features/dashboard/state/getPanelOptionsWithDefaults.ts
View file @
b3c32277
...
...
@@ -17,6 +17,7 @@ export interface Props {
plugin
:
PanelPlugin
;
currentFieldConfig
:
FieldConfigSource
;
currentOptions
:
Record
<
string
,
any
>
;
isAfterPluginChange
:
boolean
;
}
export
interface
OptionDefaults
{
...
...
@@ -24,7 +25,12 @@ export interface OptionDefaults {
fieldConfig
:
FieldConfigSource
;
}
export
function
getPanelOptionsWithDefaults
({
plugin
,
currentOptions
,
currentFieldConfig
}:
Props
):
OptionDefaults
{
export
function
getPanelOptionsWithDefaults
({
plugin
,
currentOptions
,
currentFieldConfig
,
isAfterPluginChange
,
}:
Props
):
OptionDefaults
{
const
optionsWithDefaults
=
mergeWith
(
{},
plugin
.
defaults
,
...
...
@@ -37,7 +43,7 @@ export function getPanelOptionsWithDefaults({ plugin, currentOptions, currentFie
);
const
fieldConfigWithDefaults
=
applyFieldConfigDefaults
(
currentFieldConfig
,
plugin
);
const
fieldConfigWithOptimalColorMode
=
adaptFieldColorMode
(
plugin
,
fieldConfigWithDefaults
);
const
fieldConfigWithOptimalColorMode
=
adaptFieldColorMode
(
plugin
,
fieldConfigWithDefaults
,
isAfterPluginChange
);
return
{
options
:
optionsWithDefaults
,
fieldConfig
:
fieldConfigWithOptimalColorMode
};
}
...
...
@@ -119,7 +125,15 @@ function cleanProperties(obj: any, parentPath: string, fieldConfigRegistry: Fiel
}
}
function
adaptFieldColorMode
(
plugin
:
PanelPlugin
,
fieldConfig
:
FieldConfigSource
):
FieldConfigSource
{
function
adaptFieldColorMode
(
plugin
:
PanelPlugin
,
fieldConfig
:
FieldConfigSource
,
isAfterPluginChange
:
boolean
):
FieldConfigSource
{
if
(
!
isAfterPluginChange
)
{
return
fieldConfig
;
}
// adjust to prefered field color setting if needed
const
color
=
plugin
.
fieldConfigRegistry
.
getIfExists
(
FieldConfigProperty
.
Color
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment