Skip to content

Commit b3fdb9e

Browse files
author
Mukul Tayal
committed
restrict negative values as input in custom log filter
1 parent 81076eb commit b3fdb9e

File tree

1 file changed

+4
-6
lines changed
  • src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/CustomLogsModal

1 file changed

+4
-6
lines changed

src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/CustomLogsModal/CustomLogsModal.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export const InputForSelectedOption = ({
5151
const handleFocusChange = ({ focused: isFocused }) => {
5252
setFocused(isFocused)
5353
}
54-
const minValue = filterTypeRadio === CUSTOM_LOGS_FILTER.DURATION ? 0 : -1
5554

5655
const setUntilTimeOptionsWithExcluded = () => {
5756
const nearestOption = getNearestTimeOptionBeforeNow()
@@ -96,8 +95,8 @@ export const InputForSelectedOption = ({
9695
let errorString
9796
if (e.target.value === '') {
9897
errorString = 'This field is required'
99-
} else if (e.target.value === '0') {
100-
errorString = 'Value cannot be 0'
98+
} else if (Number(e.target.value) < 0) {
99+
errorString = 'Value must be greater than 0'
101100
} else if (customLogFilterOptions[filterTypeRadio].error) {
102101
errorString = ''
103102
}
@@ -109,10 +108,9 @@ export const InputForSelectedOption = ({
109108

110109
const handleInputChange = (e) => {
111110
checkInputError(e)
112-
const val = Number(e.target.value) < minValue ? minValue.toString() : e.target.value
113111
setCustomLogFilterOptions((prevState) => ({
114112
...prevState,
115-
[filterTypeRadio]: { ...prevState[filterTypeRadio], value: val },
113+
[filterTypeRadio]: { ...prevState[filterTypeRadio], value: e.target.value },
116114
}))
117115
}
118116

@@ -138,7 +136,7 @@ export const InputForSelectedOption = ({
138136
<input
139137
type="number"
140138
autoComplete="off"
141-
min={minValue}
139+
min={1}
142140
className="input-focus-none"
143141
value={customLogFilterOptions[filterTypeRadio].value}
144142
onChange={handleInputChange}

0 commit comments

Comments
 (0)