Skip to content

Commit 9b13608

Browse files
committed
[EuiTimeWindowButtons] Rename to add Eui prefix
1 parent 3742248 commit 9b13608

File tree

4 files changed

+46
-29
lines changed

4 files changed

+46
-29
lines changed

packages/eui/src/components/date_picker/super_date_picker/__snapshots__/time_window_buttons.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`TimeWindowButtons renders 1`] = `
3+
exports[`EuiTimeWindowButtons renders 1`] = `
44
<div
5-
class="euiSuperDatePicker__timeWindowButtons emotion-euiButtonGroup__buttons-m-TimeWindowButtons"
5+
class="euiSuperDatePicker__timeWindowButtons emotion-euiButtonGroup__buttons-m-EuiTimeWindowButtons"
66
data-test-subj="timeWindowButtons"
77
>
88
<span

packages/eui/src/components/date_picker/super_date_picker/super_date_picker.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import {
4040
import { TimeOptions, RenderI18nTimeOptions } from './time_options';
4141
import { PrettyDuration, showPrettyDuration } from './pretty_duration';
4242
import {
43-
TimeWindowButtons,
44-
type TimeWindowButtonsConfig,
43+
EuiTimeWindowButtons,
44+
type EuiTimeWindowButtonsConfig,
4545
} from './time_window_buttons';
4646
import { AsyncInterval } from './async_interval';
4747

@@ -211,7 +211,7 @@ export type EuiSuperDatePickerProps = CommonProps & {
211211
* Set to true to display buttons for time shifting and zooming out,
212212
* next to the top-level control.
213213
*/
214-
showTimeWindowButtons?: boolean | TimeWindowButtonsConfig;
214+
showTimeWindowButtons?: boolean | EuiTimeWindowButtonsConfig;
215215

216216
/**
217217
* Hides the actual input reducing to just the quick select button.
@@ -758,7 +758,7 @@ export class EuiSuperDatePickerInternal extends Component<
758758
typeof showTimeWindowButtons === 'boolean' ? {} : showTimeWindowButtons;
759759

760760
return (
761-
<TimeWindowButtons
761+
<EuiTimeWindowButtons
762762
applyTime={this.applyQuickTime}
763763
start={start}
764764
end={end}

packages/eui/src/components/date_picker/super_date_picker/time_window_buttons.test.tsx

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ import userEvent from '@testing-library/user-event';
1313
import { render, renderHook, renderHookAct } from '../../../test/rtl';
1414

1515
import {
16-
TimeWindowButtons,
17-
useTimeWindow,
16+
EuiTimeWindowButtons,
17+
useEuiTimeWindow,
1818
ZOOM_FACTOR_DEFAULT,
1919
} from './time_window_buttons';
2020

21-
describe('TimeWindowButtons: useTimeWindow hook', () => {
21+
describe('EuiTimeWindowButtons: useEuiTimeWindow hook', () => {
2222
describe('displayInterval', () => {
2323
it('handles relative times', () => {
2424
const applyTime = jest.fn();
2525
const start = 'now-15m';
2626
const end = 'now';
2727

28-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
28+
const { result } = renderHook(() =>
29+
useEuiTimeWindow(start, end, applyTime)
30+
);
2931

3032
expect(result.current.displayInterval).toBe('15 minutes');
3133
});
@@ -35,7 +37,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
3537
const start = '2025-10-29T16:00:00.000Z';
3638
const end = '2025-10-29T16:15:00.000Z';
3739

38-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
40+
const { result } = renderHook(() =>
41+
useEuiTimeWindow(start, end, applyTime)
42+
);
3943

4044
expect(result.current.displayInterval).toBe('15 minutes');
4145
});
@@ -45,8 +49,10 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
4549
const start = undefined;
4650
const end = '2025-10-29T16:15:00.000Z';
4751

48-
// @ts-expect-error - intentionally testing with undefined start value
49-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
52+
const { result } = renderHook(() =>
53+
// @ts-expect-error - intentionally testing with undefined start value
54+
useEuiTimeWindow(start, end, applyTime)
55+
);
5056

5157
expect(result.current.displayInterval).toBe('');
5258
expect(result.current.isInvalid).toBeTruthy();
@@ -57,7 +63,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
5763
const start = '2025-10-29T16:00:00.000Z';
5864
const end = 'not a date';
5965

60-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
66+
const { result } = renderHook(() =>
67+
useEuiTimeWindow(start, end, applyTime)
68+
);
6169

6270
expect(result.current.displayInterval).toBe('');
6371
expect(result.current.isInvalid).toBeTruthy();
@@ -68,7 +76,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
6876
const start = '2025-10-27T16:00:01.000Z';
6977
const end = '2025-10-29T16:12:00.000Z';
7078

71-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
79+
const { result } = renderHook(() =>
80+
useEuiTimeWindow(start, end, applyTime)
81+
);
7282

7383
expect(result.current.displayInterval).toBe('~2 days');
7484
});
@@ -80,7 +90,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
8090
const start = '2025-10-30T10:00:00.000Z';
8191
const end = '2025-10-30T11:00:00.000Z';
8292

83-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
93+
const { result } = renderHook(() =>
94+
useEuiTimeWindow(start, end, applyTime)
95+
);
8496

8597
renderHookAct(() => {
8698
result.current.stepForward();
@@ -99,7 +111,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
99111
const start = '2025-10-30T10:00:00.000Z';
100112
const end = '2025-10-30T11:00:00.000Z';
101113

102-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
114+
const { result } = renderHook(() =>
115+
useEuiTimeWindow(start, end, applyTime)
116+
);
103117

104118
renderHookAct(() => {
105119
result.current.stepBackward();
@@ -124,7 +138,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
124138
);
125139
const shiftedEnd = moment(end).add(ZOOM_FACTOR_DEFAULT / 2, 'hours');
126140

127-
const { result } = renderHook(() => useTimeWindow(start, end, applyTime));
141+
const { result } = renderHook(() =>
142+
useEuiTimeWindow(start, end, applyTime)
143+
);
128144

129145
renderHookAct(() => {
130146
result.current.expandWindow();
@@ -149,7 +165,9 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
149165
const shiftedEnd = moment(end).add(customZoomFactor / 2, 'hours');
150166

151167
const { result } = renderHook(() =>
152-
useTimeWindow(start, end, applyTime, { zoomFactor: customZoomFactor })
168+
useEuiTimeWindow(start, end, applyTime, {
169+
zoomFactor: customZoomFactor,
170+
})
153171
);
154172

155173
renderHookAct(() => {
@@ -164,13 +182,13 @@ describe('TimeWindowButtons: useTimeWindow hook', () => {
164182
});
165183
});
166184

167-
describe('TimeWindowButtons', () => {
185+
describe('EuiTimeWindowButtons', () => {
168186
it('renders', () => {
169187
const start = 'now-15m';
170188
const end = 'now';
171189

172190
const { container } = render(
173-
<TimeWindowButtons start={start} end={end} applyTime={() => {}} />
191+
<EuiTimeWindowButtons start={start} end={end} applyTime={() => {}} />
174192
);
175193

176194
expect(container.firstChild).toMatchSnapshot();
@@ -184,7 +202,7 @@ describe('TimeWindowButtons', () => {
184202
const end = 'now';
185203

186204
const { getByTestSubject, findByText } = render(
187-
<TimeWindowButtons start={start} end={end} applyTime={apply} />
205+
<EuiTimeWindowButtons start={start} end={end} applyTime={apply} />
188206
);
189207

190208
act(() => {

packages/eui/src/components/date_picker/super_date_picker/time_window_buttons.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { useEuiI18n } from '../../i18n';
2121

2222
export const ZOOM_FACTOR_DEFAULT = 0.5;
2323

24-
export interface TimeWindowButtonsConfig {
24+
export interface EuiTimeWindowButtonsConfig {
2525
/**
2626
* Show button for zooming out
2727
* @default true
@@ -40,20 +40,19 @@ export interface TimeWindowButtonsConfig {
4040
zoomFactor?: number | string;
4141
}
4242

43-
export type TimeWindowButtonsProps = TimeWindowButtonsConfig & {
43+
export type EuiTimeWindowButtonsProps = EuiTimeWindowButtonsConfig & {
4444
applyTime: ApplyTime;
4545
start: ShortDate;
4646
end: ShortDate;
4747
compressed?: boolean;
4848
isDisabled?: boolean;
4949
};
5050

51-
// TODO rename to add eui prefix e.g. EuiTimeWindowButtons
5251
/**
5352
* Button group with time window controls for shifting the time window
5453
* forwards and backwards, and zooming out.
5554
*/
56-
export const TimeWindowButtons: React.FC<TimeWindowButtonsProps> = ({
55+
export const EuiTimeWindowButtons: React.FC<EuiTimeWindowButtonsProps> = ({
5756
applyTime,
5857
start,
5958
end,
@@ -74,7 +73,7 @@ export const TimeWindowButtons: React.FC<TimeWindowButtonsProps> = ({
7473
stepForward,
7574
stepBackward,
7675
expandWindow,
77-
} = useTimeWindow(start, end, applyTime, { zoomFactor });
76+
} = useEuiTimeWindow(start, end, applyTime, { zoomFactor });
7877

7978
const invalidShiftDescription = useEuiI18n(
8079
'euiTimeWindowButtons.invalidShiftLabel',
@@ -188,11 +187,11 @@ export const TimeWindowButtons: React.FC<TimeWindowButtonsProps> = ({
188187
/**
189188
* Partly adapted from date_picker/super_date_picker/quick_select_popover/quick_select.tsx
190189
*/
191-
export function useTimeWindow(
190+
export function useEuiTimeWindow(
192191
start: ShortDate,
193192
end: ShortDate,
194193
apply: ApplyTime,
195-
options?: { zoomFactor?: TimeWindowButtonsConfig['zoomFactor'] }
194+
options?: { zoomFactor?: EuiTimeWindowButtonsConfig['zoomFactor'] }
196195
) {
197196
const min = dateMath.parse(start);
198197
const max = dateMath.parse(end, { roundUp: true });

0 commit comments

Comments
 (0)