File tree Expand file tree Collapse file tree
graylog2-web-interface/src
views/components/time-range-picker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,28 +18,40 @@ import React from 'react';
1818import { Tabs as MantineTabs } from '@mantine/core' ;
1919import styled , { css } from 'styled-components' ;
2020
21- type TabsProps = {
22- children : React . ReactNode ;
21+ const StyledTab = styled ( MantineTabs . Tab ) `
22+ height: 40px;
23+ ` ;
24+
25+ const StyledPanel = styled ( MantineTabs . Panel ) (
26+ ( { theme } ) => css `
27+ padding : ${ theme . spacings . sm } ;
28+ ` ,
29+ ) ;
30+
31+ type Props = React . PropsWithChildren < {
2332 defaultValue ?: string ;
2433 value ?: string | null ;
2534 onChange ?: ( value : string | null ) => void ;
2635 variant ?: 'default' | 'outline' | 'pills' ;
2736 className ?: string ;
28- } ;
37+ } > ;
2938
30- const StyledTabsBase = styled ( MantineTabs ) (
31- ( ) => css `
32- .mantine-Tabs-tab {
33- height : 40px ;
34- }
35- ` ,
39+ const Tabs = ( {
40+ children = undefined ,
41+ defaultValue = undefined ,
42+ value = undefined ,
43+ onChange = undefined ,
44+ variant = 'outline' ,
45+ className,
46+ } : Props ) => (
47+ < MantineTabs defaultValue = { defaultValue } value = { value } onChange = { onChange } variant = { variant } className = { className } >
48+ { children }
49+ </ MantineTabs >
3650) ;
3751
38- const Tabs = ( { variant = 'outline' , ...props } : TabsProps ) => < StyledTabsBase variant = { variant } { ...props } /> ;
39-
4052Tabs . List = MantineTabs . List ;
41- Tabs . Tab = MantineTabs . Tab ;
42- Tabs . Panel = MantineTabs . Panel ;
53+ Tabs . Tab = StyledTab ;
54+ Tabs . Panel = StyledPanel ;
4355
4456/** @component */
4557export default Tabs ;
Original file line number Diff line number Diff line change @@ -142,24 +142,22 @@ const TimeRangeTabs = ({ limitDuration, validTypes }: Props) => {
142142 const defaultRanges = useMemo ( ( ) => createDefaultRanges ( formatTime ) , [ formatTime ] ) ;
143143
144144 const onSelect = useCallback (
145- ( nextTab : string | null ) => {
145+ ( nextTab : AbsoluteTimeRange [ 'type' ] | RelativeTimeRange [ 'type' ] | KeywordTimeRange [ 'type' ] | 'disabled' | null ) => {
146146 if ( ! nextTab || nextTab === 'disabled' ) return ;
147147
148- const typedNextTab = nextTab as AbsoluteTimeRange [ 'type' ] | RelativeTimeRange [ 'type' ] | KeywordTimeRange [ 'type' ] ;
149-
150148 setValues ( {
151149 timeRangeTabs : {
152150 ...timeRangeTabs ,
153- [ typedNextTab ] : newTabTimeRange ( {
151+ [ nextTab ] : newTabTimeRange ( {
154152 activeTab,
155- nextTab : typedNextTab ,
153+ nextTab,
156154 timeRangeTabs,
157155 formatTime,
158156 defaultRanges,
159157 userTimezone,
160158 } ) ,
161159 } ,
162- activeTab : typedNextTab ,
160+ activeTab : nextTab ,
163161 } ) ;
164162
165163 sendTelemetry ( TELEMETRY_EVENT_TYPE . SEARCH_TIMERANGE_PICKER_TAB_SELECTED , {
You can’t perform that action at this time.
0 commit comments