Skip to content

Commit

Permalink
Fix: uischame render value error and env value error (#309)
Browse files Browse the repository at this point in the history
Signed-off-by: barnettZQG <[email protected]>
  • Loading branch information
barnettZQG authored Dec 29, 2021

Partially verified

This commit is signed with the committer’s verified signature.
spydon’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent aa897dd commit ce29a22
Showing 3 changed files with 22 additions and 21 deletions.
39 changes: 20 additions & 19 deletions src/components/UISchema/index.tsx
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ import locale from '../../utils/locale';
import HelmValues from '../../extends/HelmValues';

type Props = {
_key?: string;
inline?: boolean;
id?: string;
value?: any;
@@ -123,6 +122,7 @@ class UISchema extends Component<Props, State> {
if (param.disable) {
return;
}

const getGroup = (children: React.ReactNode) => {
return (
<Group
@@ -146,10 +146,12 @@ class UISchema extends Component<Props, State> {
</Group>
);
};
const { value } = this.props;
const initValue = param.validate.defaultValue || (value && value[param.jsonKey]);
switch (param.uiType) {
case 'Switch':
const switchResult = init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
});
return (
@@ -180,7 +182,7 @@ class UISchema extends Component<Props, State> {
>
<Input
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
/>
@@ -199,7 +201,7 @@ class UISchema extends Component<Props, State> {
<Input
htmlType="password"
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
/>
@@ -218,7 +220,7 @@ class UISchema extends Component<Props, State> {
<Select
locale={locale.Select}
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
dataSource={param.validate && param.validate.options}
@@ -236,7 +238,7 @@ class UISchema extends Component<Props, State> {
>
<Input
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
htmlType="number"
@@ -254,7 +256,7 @@ class UISchema extends Component<Props, State> {
>
<ImageInput
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: [
{
required: true,
@@ -270,7 +272,7 @@ class UISchema extends Component<Props, State> {
const children = (
<KV
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
additional={param.additional}
@@ -282,7 +284,7 @@ class UISchema extends Component<Props, State> {
return getGroup(
<HelmValues
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
additional={param.additional}
@@ -293,7 +295,7 @@ class UISchema extends Component<Props, State> {
return getGroup(
<Strings
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
/>,
@@ -349,7 +351,7 @@ class UISchema extends Component<Props, State> {
>
<CPUNumber
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: [
{
required: param.validate.required,
@@ -372,7 +374,7 @@ class UISchema extends Component<Props, State> {
>
<MemoryNumber
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: [
{
required: param.validate.required,
@@ -409,7 +411,7 @@ class UISchema extends Component<Props, State> {
>
<UISchema
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: [
// {
// validator: validator,
@@ -432,7 +434,7 @@ class UISchema extends Component<Props, State> {
title={param.label}
description={param.description}
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: converRule(param.validate),
})}
/>
@@ -449,7 +451,7 @@ class UISchema extends Component<Props, State> {
param={param.subParameters}
parameterGroupOption={param.subParameterGroupOption}
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
// rules: [
// {
// validator: validator,
@@ -464,17 +466,16 @@ class UISchema extends Component<Props, State> {
case 'Ignore':
if (param.subParameters && param.subParameters.length > 0) {
const ref: React.RefObject<UISchema> = React.createRef();
const validator = (rule: Rule, value: any, callback: (error?: string) => void) => {
const validator = (rule: Rule, v: any, callback: (error?: string) => void) => {
ref.current?.validate(callback);
};
return (
<UISchema
ref={ref}
key={param.jsonKey}
uiSchema={param.subParameters}
inline={inline}
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: [
{
validator: validator,
@@ -497,7 +498,7 @@ class UISchema extends Component<Props, State> {
>
<K8sObjectsCode
{...init(param.jsonKey, {
initValue: param.validate.defaultValue,
initValue: initValue,
rules: [
{
required: param.validate.required,
3 changes: 2 additions & 1 deletion src/pages/ApplicationList/components/AddAppDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ class AppDialog extends React.Component<Props, State> {
const { envs } = this.state;
let namespace = '';
envs?.map((env: Env) => {
if ((envBindings[0] = env.name)) {
if (envBindings[0] == env.name) {
namespace = env.namespace;
}
});
@@ -255,6 +255,7 @@ class AppDialog extends React.Component<Props, State> {
value: env.name,
};
});
console.log(envOptions);
return (
<DrawerWithFooter
title={<Translation>New Application</Translation>}
1 change: 0 additions & 1 deletion src/pages/ApplicationWorkflow/workflow-item/index.tsx
Original file line number Diff line number Diff line change
@@ -164,7 +164,6 @@ class WorkFlowItem extends Component<WorkFlowItemProps, State> {
newNode[action.payload.id] = action.payload;
const newNodes = Object.assign({}, state.nodes, newNode);
const newState = Object.assign({}, state, { nodes: newNodes });
console.log(newState);
return newState;
default:
return state;

0 comments on commit ce29a22

Please sign in to comment.