Skip to content

Commit 7074ea8

Browse files
committed
replace last button group occurence; remove from imports;
1 parent 3a74e7c commit 7074ea8

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
import { ButtonGroup } from '@redis-ui/components'
1+
import { ButtonGroup, ButtonGroupProps } from '@redis-ui/components'
22

33
export { ButtonGroup }
4+
5+
export type { ButtonGroupProps }

redisinsight/ui/src/packages/redistimeseries-app/src/components/Chart/ChartConfigForm.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react'
2-
import { EuiFieldText, EuiButtonGroup, EuiButtonGroupProps } from '@elastic/eui'
2+
import { EuiFieldText } from '@elastic/eui'
33
import { SwitchInput } from 'uiSrc/components/base/inputs'
44
import { FormFieldset } from 'uiSrc/components/base/forms/fieldset'
55
import { AxisScale, GraphMode, ChartConfigFormProps } from './interfaces'
@@ -9,7 +9,10 @@ import {
99
TITLE_MAX_LENGTH,
1010
} from './constants'
1111
import { RiAccordion } from 'uiSrc/components/base/display/accordion/RiAccordion'
12-
import { ButtonGroup } from 'uiSrc/components/base/forms/button-group/ButtonGroup'
12+
import {
13+
ButtonGroup,
14+
ButtonGroupProps,
15+
} from 'uiSrc/components/base/forms/button-group/ButtonGroup'
1316

1417
const NewEnumSelect = ({
1518
select,
@@ -178,6 +181,8 @@ const YAxisConfigForm = ({ value, onChange, label }: any) => (
178181
</div>
179182
)
180183

184+
const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1)
185+
181186
interface EnumSelectProps {
182187
enumType: any
183188
inputLabel: string
@@ -187,13 +192,18 @@ const EnumSelect = ({
187192
enumType,
188193
inputLabel,
189194
...props
190-
}: EnumSelectProps & EuiButtonGroupProps) => (
191-
<EuiButtonGroup
192-
legend="form-button"
193-
buttonSize="compressed"
194-
options={Object.values(enumType).map((v: string) => ({ id: v, label: v }))}
195-
onChange={(id) => props.onChange({ target: { value: id } } as any)}
196-
idSelected={props.value.toString()}
197-
isFullWidth
198-
/>
195+
}: EnumSelectProps & ButtonGroupProps) => (
196+
<ButtonGroup>
197+
{Object.values(enumType).map((v) => (
198+
<ButtonGroup.Button
199+
isSelected={props.value === v}
200+
key={String(v)}
201+
onClick={() =>
202+
props.onChange?.({ target: { value: String(v) } } as any)
203+
}
204+
>
205+
{capitalize(String(v))}
206+
</ButtonGroup.Button>
207+
))}
208+
</ButtonGroup>
199209
)

0 commit comments

Comments
 (0)