Skip to content

Commit 5d943d8

Browse files
authored
feat: The minimum value of a numeric input box is 0 (#550)
* feat: The minimum value of number type input is 0 Signed-off-by: zhaoxinxin <1186037180@qq.com> * feat: The minimum value of number type input is 0 Signed-off-by: zhaoxinxin <1186037180@qq.com> --------- Signed-off-by: zhaoxinxin <1186037180@qq.com>
1 parent 70e8226 commit 5d943d8

File tree

7 files changed

+25
-9
lines changed

7 files changed

+25
-9
lines changed

cypress/e2e/gc/audit.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('audit', () => {
175175
cy.get('#update').click();
176176

177177
cy.get('#audit-ttl-input').clear();
178-
cy.get('#audit-ttl-input').type('10');
178+
cy.get('#audit-ttl-input').type('100');
179179

180180
cy.get('#ttl-error').should(
181181
'have.text',
@@ -186,7 +186,7 @@ describe('audit', () => {
186186
cy.get('[data-value="hours"]').click();
187187

188188
cy.get('#audit-ttl-input').clear();
189-
cy.get('#audit-ttl-input').type('200');
189+
cy.get('#audit-ttl-input').type('2000');
190190

191191
// Shou error.
192192
cy.get('#ttl-error').should('have.text', 'Fill in the number, the length is 1-1000.');

cypress/e2e/gc/job.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe('audit', () => {
176176
cy.get('#update').click();
177177

178178
cy.get('#job-ttl-input').clear();
179-
cy.get('#job-ttl-input').type('10');
179+
cy.get('#job-ttl-input').type('100');
180180

181181
cy.get('#ttl-error').should(
182182
'have.text',
@@ -187,7 +187,7 @@ describe('audit', () => {
187187
cy.get('[data-value="hours"]').click();
188188

189189
cy.get('#job-ttl-input').clear();
190-
cy.get('#job-ttl-input').type('200');
190+
cy.get('#job-ttl-input').type('2000');
191191

192192
// Shou error.
193193
cy.get('#ttl-error').should('have.text', 'Fill in the number, the length is 1-1000.');

src/components/clusters/edit.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,9 @@ export default function EditCluster() {
851851
className={styles.textField}
852852
color="success"
853853
required
854+
inputProps={{
855+
min: 0,
856+
}}
854857
key={item.formProps.name}
855858
{...item.formProps}
856859
/>

src/components/clusters/new.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,9 @@ export default function NewCluster() {
773773
className={styles.textField}
774774
color="success"
775775
size="small"
776+
inputProps={{
777+
min: 0,
778+
}}
776779
required
777780
key={item.formProps.name}
778781
{...item.formProps}

src/components/gc/audit/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ export default function AuditGC() {
353353
color="success"
354354
sx={{ mr: '1rem', width: '14rem' }}
355355
value={audit}
356-
onChange={(e) => {
357-
setAudit(Number(e.target.value));
356+
inputProps={{
357+
min: 0,
358+
}}
359+
onChange={(e: any) => {
360+
setAudit(e.target.value);
358361
onChangeTTL(Number(e.target.value), auditLogTTL);
359362
}}
360363
/>

src/components/gc/job/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,11 @@ export default function JobGC() {
359359
color="success"
360360
sx={{ mr: '1rem', width: '14rem' }}
361361
value={job}
362-
onChange={(e) => {
363-
setJob(Number(e.target.value));
362+
inputProps={{
363+
min: 0,
364+
}}
365+
onChange={(e: any) => {
366+
setJob(e.target.value);
364367
onChangeTTL(Number(e.target.value), jobUnit);
365368
}}
366369
/>
@@ -373,7 +376,7 @@ export default function JobGC() {
373376
value={jobUnit}
374377
onChange={(e) => {
375378
setJobUnit(e.target.value);
376-
onChangeTTL(job, e.target.value);
379+
onChangeTTL(Number(job), e.target.value);
377380
}}
378381
>
379382
{unit.map((item) => (

src/components/job/preheats/new.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,16 @@ export default function NewPreheat() {
11941194
defaultValue={1}
11951195
placeholder="Enter your count"
11961196
type="number"
1197+
minRows={0}
11971198
error={countError}
11981199
helperText={countError && 'Fill in the characters, the length is 1-200.'}
11991200
onChange={(e) => {
12001201
const validate = countValidate(e.target.value);
12011202
setCountError(!validate);
12021203
}}
1204+
inputProps={{
1205+
min: 0,
1206+
}}
12031207
InputProps={{
12041208
endAdornment: (
12051209
<Tooltip

0 commit comments

Comments
 (0)