From 26b352b8b780586355a84ac7acced8c4b09144ee Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 23 Sep 2024 17:42:05 +0200 Subject: [PATCH] improve comments and names of reportsConstants --- .../reports/chartColorsPicker.component.tsx | 16 ++++---- .../reports/chartTypePicker.component.tsx | 4 +- .../reports/reportViewItem.component.tsx | 10 ++--- jsapp/js/components/reports/reports.tsx | 2 +- .../js/components/reports/reportsConstants.ts | 39 ++++++++++++------- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/jsapp/js/components/reports/chartColorsPicker.component.tsx b/jsapp/js/components/reports/chartColorsPicker.component.tsx index 315a536414..a111a768b4 100644 --- a/jsapp/js/components/reports/chartColorsPicker.component.tsx +++ b/jsapp/js/components/reports/chartColorsPicker.component.tsx @@ -1,7 +1,7 @@ import React from 'react'; import bem from 'js/bem'; -import {REPORT_COLOR_SETS} from './reportsConstants'; -import type {ReportStyle, ReportColorSet} from './reportsConstants'; +import {CHART_COLOR_SETS} from './reportsConstants'; +import type {ReportStyle, ChartColorSet} from './reportsConstants'; interface ChartColorsPickerProps { onChange: (params: {default: boolean}, value: {report_colors: string[]}) => void; @@ -10,9 +10,9 @@ interface ChartColorsPickerProps { export default function ChartColorsPicker(props: ChartColorsPickerProps) { function defaultReportColorsChange(value: number) { - let newColors = REPORT_COLOR_SETS[0].colors; - if (REPORT_COLOR_SETS[value]?.colors) { - newColors = REPORT_COLOR_SETS[value].colors; + let newColors = CHART_COLOR_SETS[0].colors; + if (CHART_COLOR_SETS[value]?.colors) { + newColors = CHART_COLOR_SETS[value].colors; } props.onChange({default: true}, {report_colors: newColors}); @@ -20,7 +20,7 @@ export default function ChartColorsPicker(props: ChartColorsPickerProps) { // Not sure why this is called "is default", and not simply "is active". This // needs some more investigation. - function isDefaultValue(set: ReportColorSet, index: number) { + function isDefaultValue(set: ChartColorSet, index: number) { if (props.defaultStyle.report_colors === undefined && index === 0) { return true; } @@ -33,7 +33,7 @@ export default function ChartColorsPicker(props: ChartColorsPickerProps) { return ( - {REPORT_COLOR_SETS.map((set, index) => ( + {CHART_COLOR_SETS.map((set, index) => (