Skip to content

Commit 994e9e8

Browse files
mergify[bot]tthvo
andauthored
fix(dashboard): separate display from actual option value (#1024) (#1025)
Signed-off-by: Thuan Vo <[email protected]> (cherry picked from commit abd26e0) Co-authored-by: Thuan Vo <[email protected]>
1 parent 796d0a5 commit 994e9e8

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/app/Dashboard/AddCard.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,10 @@ interface PropsConfigFormProps {
467467
onChange: (config: object) => void;
468468
}
469469

470-
const PropsConfigForm = ({ onChange, ...props }: PropsConfigFormProps) => {
470+
const PropsConfigForm: React.FC<PropsConfigFormProps> = ({ onChange, ...props }) => {
471471
const { t } = useTranslation();
472472
const handleChange = React.useCallback(
473-
(k) => (e) => {
473+
(k: string) => (e: unknown) => {
474474
const copy = { ...props.config };
475475
copy[k] = e;
476476
onChange(copy);
@@ -479,7 +479,7 @@ const PropsConfigForm = ({ onChange, ...props }: PropsConfigFormProps) => {
479479
);
480480

481481
const handleNumeric = React.useCallback(
482-
(k) => (e) => {
482+
(k: string) => (e: React.FormEvent<HTMLInputElement>) => {
483483
const value = (e.target as HTMLInputElement).value;
484484
const copy = { ...props.config };
485485
copy[k] = value;
@@ -489,7 +489,7 @@ const PropsConfigForm = ({ onChange, ...props }: PropsConfigFormProps) => {
489489
);
490490

491491
const handleNumericStep = React.useCallback(
492-
(k, v) => (_) => {
492+
(k: string, v: number) => (_: React.MouseEvent) => {
493493
const copy = { ...props.config };
494494
copy[k] = props.config[k] + v;
495495
onChange(copy);
@@ -582,7 +582,7 @@ interface SelectControlProps {
582582
selectedConfig: string | SelectOptionObject;
583583
}
584584

585-
const SelectControl = ({ handleChange, control, selectedConfig }: SelectControlProps) => {
585+
const SelectControl: React.FC<SelectControlProps> = ({ handleChange, control, selectedConfig }) => {
586586
const addSubscription = useSubscriptions();
587587

588588
const [selectOpen, setSelectOpen] = React.useState(false);
@@ -638,10 +638,13 @@ const SelectControl = ({ handleChange, control, selectedConfig }: SelectControlP
638638
{errored
639639
? [<SelectOption key={0} value={`Load Error: ${options[0]}`} isPlaceholder isDisabled />]
640640
: options.map((choice, idx) => {
641-
if (control.extras && control.extras.displayMapper) {
642-
choice = control.extras.displayMapper(choice);
643-
}
644-
return <SelectOption key={idx + 1} value={choice} />;
641+
const display =
642+
control.extras && control.extras.displayMapper ? control.extras.displayMapper(choice) : choice;
643+
return (
644+
<SelectOption key={idx + 1} value={choice}>
645+
{display}
646+
</SelectOption>
647+
);
645648
})}
646649
</Select>
647650
);

src/app/Dashboard/Charts/mbean/MBeanMetricsChartCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ export const MBeanMetricsChartCardDescriptor: DashboardCardDescriptor = {
555555
name: 'CHART_CARD.PROP_CONTROLS.THEME.NAME',
556556
key: 'themeColor',
557557
values: ['blue', 'cyan', 'gold', 'gray', 'green', 'orange', 'purple'],
558-
defaultValue: 'Blue',
558+
defaultValue: 'blue',
559559
description: 'CHART_CARD.PROP_CONTROLS.THEME.DESCRIPTION',
560560
kind: 'select',
561561
extras: {

0 commit comments

Comments
 (0)