|
|
@@ -4,8 +4,6 @@ import { SingleStatPanel } from './SingleStatPanel';
|
|
|
import cloneDeep from 'lodash/cloneDeep';
|
|
|
import { SingleStatEditor } from './SingleStatEditor';
|
|
|
|
|
|
-export const reactPanel = new ReactPanelPlugin<SingleStatOptions>(SingleStatPanel);
|
|
|
-
|
|
|
const optionsToKeep = ['valueOptions', 'stat', 'maxValue', 'maxValue', 'thresholds', 'valueMappings'];
|
|
|
|
|
|
export const singleStatBaseOptionsCheck = (
|
|
|
@@ -23,17 +21,22 @@ export const singleStatBaseOptionsCheck = (
|
|
|
return options;
|
|
|
};
|
|
|
|
|
|
-export const singleStatMigrationCheck = (options: Partial<SingleStatBaseOptions>) => {
|
|
|
- // 6.1 renamed some stats, This makes sure they are up to date
|
|
|
- // avg -> mean, current -> last, total -> sum
|
|
|
- const { valueOptions } = options;
|
|
|
- if (valueOptions && valueOptions.stat) {
|
|
|
- valueOptions.stat = getStatsCalculators([valueOptions.stat]).map(s => s.id)[0];
|
|
|
+export const singleStatMigrationCheck = (exiting: any, oldVersion?: string) => {
|
|
|
+ const options = exiting as Partial<SingleStatOptions>;
|
|
|
+ if (options.valueOptions) {
|
|
|
+ // 6.1 renamed some stats, This makes sure they are up to date
|
|
|
+ // avg -> mean, current -> last, total -> sum
|
|
|
+
|
|
|
+ const { valueOptions } = options;
|
|
|
+ if (valueOptions && valueOptions.stat) {
|
|
|
+ valueOptions.stat = getStatsCalculators([valueOptions.stat]).map(s => s.id)[0];
|
|
|
+ }
|
|
|
}
|
|
|
return options;
|
|
|
};
|
|
|
|
|
|
-reactPanel.setEditor(SingleStatEditor);
|
|
|
-reactPanel.setDefaults(defaults);
|
|
|
-reactPanel.setPanelTypeChangedHook(singleStatBaseOptionsCheck);
|
|
|
-reactPanel.setPanelMigrationHook(singleStatMigrationCheck);
|
|
|
+export const reactPanel = new ReactPanelPlugin<SingleStatOptions>(SingleStatPanel, defaults);
|
|
|
+
|
|
|
+reactPanel.editor = SingleStatEditor;
|
|
|
+reactPanel.onPanelTypeChanged = singleStatBaseOptionsCheck;
|
|
|
+reactPanel.onPanelMigration = singleStatMigrationCheck;
|