Skip to content

Commit 9e7551c

Browse files
authored
Merge branch 'main' into feat/disable-releaseinfo
2 parents ede6682 + 43bd3b0 commit 9e7551c

File tree

9 files changed

+1025
-443
lines changed

9 files changed

+1025
-443
lines changed

api/src/main/java/io/kafbat/ui/service/metrics/RawMetric.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.prometheus.metrics.core.metrics.Gauge;
44
import io.prometheus.metrics.model.snapshots.MetricSnapshot;
5+
import io.prometheus.metrics.model.snapshots.PrometheusNaming;
56
import java.math.BigDecimal;
67
import java.util.Arrays;
78
import java.util.Collection;
@@ -26,13 +27,19 @@ static RawMetric create(String name, Map<String, String> labels, BigDecimal valu
2627
static Stream<MetricSnapshot> groupIntoSnapshot(Collection<RawMetric> rawMetrics) {
2728
Map<String, Gauge> map = new LinkedHashMap<>();
2829
for (RawMetric m : rawMetrics) {
29-
var lbls = m.labels().keySet().toArray(String[]::new);
30-
var lblVals = Arrays.stream(lbls).map(l -> m.labels().get(l)).toArray(String[]::new);
30+
var lbls = m.labels().keySet()
31+
.stream()
32+
.map(PrometheusNaming::sanitizeLabelName)
33+
.toArray(String[]::new);
34+
var lblVals = Arrays.stream(lbls)
35+
.map(l -> m.labels().get(l))
36+
.toArray(String[]::new);
37+
var sanitizedName = PrometheusNaming.sanitizeMetricName(m.name());
3138
var gauge = map.computeIfAbsent(
32-
m.name(),
39+
sanitizedName,
3340
n -> Gauge.builder()
34-
.name(m.name())
35-
.help(m.name())
41+
.name(sanitizedName)
42+
.help(sanitizedName)
3643
.labelNames(lbls)
3744
.build()
3845
);

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/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"devDependencies": {
5656
"@jest/types": "29.6.3",
57-
"@openapitools/openapi-generator-cli": "2.13.4",
57+
"@openapitools/openapi-generator-cli": "2.22.0",
5858
"@swc/core": "1.3.107",
5959
"@swc/jest": "0.2.36",
6060
"@testing-library/dom": "10.0.0",
@@ -88,7 +88,7 @@
8888
"eslint-plugin-react-hooks": "4.6.0",
8989
"fetch-mock": "9.11.0",
9090
"jest": "29.7.0",
91-
"jest-environment-jsdom": "29.7.0",
91+
"jest-environment-jsdom": "30.0.5",
9292
"jest-sonar-reporter": "2.0.0",
9393
"jest-styled-components": "7.1.1",
9494
"jest-watch-typeahead": "2.2.2",

frontend/pnpm-lock.yaml

Lines changed: 958 additions & 428 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/components/Topics/Topic/Messages/Filters/__tests__/Filters.spec.tsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Filters, {
33
FiltersProps,
44
} from 'components/Topics/Topic/Messages/Filters/Filters';
55
import { render, WithRoute } from 'lib/testHelpers';
6-
import { screen } from '@testing-library/react';
6+
import { act, screen } from '@testing-library/react';
77
import userEvent from '@testing-library/user-event';
88
import { clusterTopicPath } from 'lib/paths';
99
import { useTopicDetails } from 'lib/hooks/api/topics';
@@ -119,10 +119,6 @@ describe('Filters component', () => {
119119
await selectDropdownAndCheckInput('From offset', 'Offset');
120120
});
121121

122-
it('offset input To offset option', async () => {
123-
await selectDropdownAndCheckInput('To offset', 'Offset');
124-
});
125-
126122
it('timestamp input since time', async () => {
127123
await selectDropdownAndCheckInput('Since time', 'Select timestamp');
128124
});
@@ -132,6 +128,32 @@ describe('Filters component', () => {
132128
});
133129
});
134130

131+
describe('change from and to offset filter', () => {
132+
const inputValue = 'Hello World!';
133+
134+
it('saves filter value', async () => {
135+
await act(() => renderComponent());
136+
137+
const seekTypeSelect = getSeekTypeSelect();
138+
const option = screen.getAllByRole('option');
139+
140+
await userEvent.click(seekTypeSelect);
141+
await userEvent.selectOptions(seekTypeSelect, ['From offset']);
142+
143+
expect(option[0]).toHaveTextContent('From offset');
144+
const timestampInput = screen.getByPlaceholderText('Offset');
145+
expect(timestampInput).toHaveValue('');
146+
await userEvent.type(timestampInput, inputValue);
147+
148+
expect(timestampInput).toHaveValue(inputValue);
149+
150+
await userEvent.click(seekTypeSelect);
151+
await userEvent.selectOptions(seekTypeSelect, ['To offset']);
152+
153+
expect(timestampInput).toHaveValue(inputValue);
154+
});
155+
});
156+
135157
describe('checks the input values when data comes from the url', () => {
136158
const renderAndCheckSelectType = (
137159
mode: PollingMode,

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)