Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed disabled switch visual edit when json is empty #2968

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,30 @@ export const RuleEditor = ({ save, initialRule, isLoading, isReserved, internalU
rulesTmp.splice(id, 1);
setRules(rulesTmp);
};

const getRulesFromJson = (jsonRule) => {
if (jsonRule !== '{}') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this PR and the behaviour that @Desvelao has commented would be solved changing if (jsonRule !== '{}') to if (jsonRule !== '')

// empty json is valid
const { customRules, internalUsersRules, wrongFormat, logicalOperator } = decodeJsonRule(
jsonRule,
internalUsers
);
setLogicalOperator(logicalOperator);
setHasWrongFormat(wrongFormat);

const getRulesFromJson = jsonRule => {
const { customRules, internalUsersRules, wrongFormat, logicalOperator } = decodeJsonRule(
jsonRule,
internalUsers
);
setLogicalOperator(logicalOperator);
setHasWrongFormat(wrongFormat);
return { customRules, internalUsersRules, wrongFormat, logicalOperator };
};
return { customRules, internalUsersRules, wrongFormat, logicalOperator };
} else {
setLogicalOperator('');
setHasWrongFormat(false);

return {
customRules: [],
internalUsersRules: [],
wrongFormat: false,
logicalOperator: 'OR',
};
}
};
const printRules = () => {
const rulesList = rules.map((item, idx) => {
return (
Expand Down