Skip to content

Commit c1d1e62

Browse files
authored
FE: Topics: Add more retain options (#1264)
Signed-off-by: Bob Du <[email protected]>
1 parent d48b947 commit c1d1e62

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

e2e-tests/src/main/java/io/kafbat/ui/screens/topics/enums/TimeToRetain.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
@Getter
66
public enum TimeToRetain {
77

8+
BTN_1_HOUR("1 hour", "3600000"),
9+
BTN_3_HOURS("3 hours", "10800000"),
10+
BTN_6_HOURS("6 hours", "21600000"),
811
BTN_12_HOURS("12 hours", "43200000"),
912
BTN_1_DAY("1 day", "86400000"),
1013
BTN_2_DAYS("2 days", "172800000"),

frontend/src/components/Topics/shared/Form/TimeToRetainBtns.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { MILLISECONDS_IN_DAY } from 'lib/constants';
2+
import { MILLISECONDS_IN_DAY, MILLISECONDS_IN_HOUR } from 'lib/constants';
33
import styled from 'styled-components';
44

55
import TimeToRetainBtn from './TimeToRetainBtn';
@@ -17,10 +17,25 @@ const TimeToRetainBtnsWrapper = styled.div`
1717

1818
const TimeToRetainBtns: React.FC<Props> = ({ name }) => (
1919
<TimeToRetainBtnsWrapper>
20+
<TimeToRetainBtn
21+
text="1 hour"
22+
inputName={name}
23+
value={MILLISECONDS_IN_HOUR}
24+
/>
25+
<TimeToRetainBtn
26+
text="3 hours"
27+
inputName={name}
28+
value={MILLISECONDS_IN_HOUR * 3}
29+
/>
30+
<TimeToRetainBtn
31+
text="6 hours"
32+
inputName={name}
33+
value={MILLISECONDS_IN_HOUR * 6}
34+
/>
2035
<TimeToRetainBtn
2136
text="12 hours"
2237
inputName={name}
23-
value={MILLISECONDS_IN_DAY / 2}
38+
value={MILLISECONDS_IN_HOUR * 12}
2439
/>
2540
<TimeToRetainBtn
2641
text="1 day"

frontend/src/components/Topics/shared/Form/__tests__/TimeToRetainBtns.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ describe('TimeToRetainBtns', () => {
2727

2828
it('should test the normal view rendering of the component', () => {
2929
SetUpComponent();
30-
expect(screen.getAllByRole('button')).toHaveLength(5);
30+
expect(screen.getAllByRole('button')).toHaveLength(8);
3131
});
3232
});

frontend/src/components/Topics/shared/Form/__tests__/TopicForm.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ describe('TopicForm', () => {
4747
'spinbutton',
4848
'Time to retain data (in ms)'
4949
);
50+
expectByRoleAndNameToBeInDocument('button', '1 hour');
51+
expectByRoleAndNameToBeInDocument('button', '3 hours');
52+
expectByRoleAndNameToBeInDocument('button', '6 hours');
5053
expectByRoleAndNameToBeInDocument('button', '12 hours');
54+
expectByRoleAndNameToBeInDocument('button', '1 day');
5155
expectByRoleAndNameToBeInDocument('button', '2 days');
5256
expectByRoleAndNameToBeInDocument('button', '7 days');
5357
expectByRoleAndNameToBeInDocument('button', '4 weeks');

frontend/src/lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const TOPIC_CUSTOM_PARAMS: Record<string, string> = {
4949

5050
export const MILLISECONDS_IN_WEEK = 604_800_000;
5151
export const MILLISECONDS_IN_DAY = 86_400_000;
52+
export const MILLISECONDS_IN_HOUR = 3_600_000;
5253
export const MILLISECONDS_IN_SECOND = 1_000;
5354

5455
export const NOT_SET = -1;

0 commit comments

Comments
 (0)