Skip to content

Commit

Permalink
fix: Set default values for traits in VelaUX
Browse files Browse the repository at this point in the history
Added `setDefaultProperties` to ensure default values are correctly set for traits like "cpuscaler", "hpa", "resource", and "k8s-update-strategy".

Signed-off-by: am6737 <1359816810@qq.com>
  • Loading branch information
am6737 committed Oct 11, 2024
1 parent 5704854 commit 744af13
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,28 @@ class TraitDialog extends React.Component<Props, State> {
.then((re) => {
if (re) {
this.setState({ definitionDetail: re, definitionLoading: false });
if (callback) {
callback();
}
this.setDefaultProperties(re)
if (callback) {
callback();
}
}
})
.catch(() => this.setState({ definitionLoading: false }));
};

setDefaultProperties = (definitionDetail: DefinitionDetail) => {
const properties = definitionDetail.schema?.properties;
if (properties) {
const defaultValues = {};
for (const key in properties) {
if (properties[key].default !== undefined) {
defaultValues[key] = properties[key].default;
}
}
this.field.setValues({ properties: defaultValues });
}
};

handleTypeChange = (value: string) => {
this.removeProperties();
this.field.setValues({ type: value });
Expand Down

0 comments on commit 744af13

Please sign in to comment.