Skip to content

Commit

Permalink
Merge pull request #2097 from harrisonliu5/fix/limitValidator
Browse files Browse the repository at this point in the history
fix: Fix add validator of limit resource in container image
  • Loading branch information
ks-ci-bot authored Jul 7, 2021
2 parents c314e83 + 31b3313 commit a0075b4
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export default class ContainerSetting extends React.Component {
})
}

limitError = ''

getFormTemplate(data, imageRegistries) {
if (data && data.image && !data.pullSecret) {
const { registry } = parseDockerImage(data.image)
Expand Down Expand Up @@ -116,6 +118,17 @@ export default class ContainerSetting extends React.Component {
)
}

handleError = err => {
this.limitError = err
}

limitValidator = (rule, value, callback) => {
if (this.limitError !== '') {
callback({ message: '' })
}
callback()
}

renderAdvancedSettings() {
const { defaultContainerType, onContainerTypeChange } = this.props
const defaultResourceLimit = this.defaultResourceLimit
Expand Down Expand Up @@ -159,10 +172,13 @@ export default class ContainerSetting extends React.Component {
type="warning"
message={t('CONTAINER_RESOURCE_LIMIT_TIP')}
/>
<Form.Item>
<Form.Item
rules={[{ validator: this.limitValidator, checkOnSubmit: true }]}
>
<ResourceLimit
name="resources"
defaultValue={defaultResourceLimit}
onError={this.handleError}
/>
</Form.Item>
</>
Expand Down

0 comments on commit a0075b4

Please sign in to comment.