Skip to content

Fixed #1267 add ability to import from JsonLogic #1271

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

Closed
wants to merge 4 commits into from

Conversation

Sulaimonyusuf123
Copy link

No description provided.

Copy link

codesandbox bot commented Jun 2, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Jun 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-awesome-query-builder-examples ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 8:37pm
react-awesome-query-builder-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 8:37pm
react-awesome-query-builder-sandbox-next ✅ Ready (Inspect) Visit Preview Jun 2, 2025 8:37pm

Copy link

codesandbox-ci bot commented Jun 2, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e15d1e3:

Sandbox Source
@react-awesome-query-builder/examples Configuration
@react-awesome-query-builder/sandbox Configuration
@react-awesome-query-builder/sandbox-simple Configuration
@react-awesome-query-builder/sandbox-next Configuration

Copy link

codecov bot commented Jun 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.73%. Comparing base (fdc33ca) to head (e15d1e3).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1271   +/-   ##
=======================================
  Coverage   79.73%   79.73%           
=======================================
  Files         246      246           
  Lines       13104    13104           
  Branches     1728     1728           
=======================================
  Hits        10448    10448           
  Misses       1792     1792           
  Partials      864      864           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ukrbublik
Copy link
Owner

I've removed changes to a lock file from your branch to fix issues with CI (pnpm lock file should have version 6)
Please run pnpm lint-fix to fix lint errors.

@Sulaimonyusuf123
Copy link
Author

Sulaimonyusuf123 commented Jun 2, 2025 via email

// Parse the JSON string
const jsonLogicObj = JSON.parse(jsonLogicStr);

// Import using Utils.loadFromJsonLogic (or Utils.Import._loadFromJsonLogic if that's the correct path)
Copy link
Owner

Choose a reason for hiding this comment

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

Please use

const [tree, logicErrors] = Utils.Import._loadFromJsonLogic(jsonLogicObj, state.config)

and render logicErrors (it's list of errors)

</button>
</div>

{jsonLogicErrors.length > 0 && (
Copy link
Owner

Choose a reason for hiding this comment

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

Please move this to top of modal

const jsonLogicObj: unknown = JSON.parse(jsonLogicStr);

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const tree = Utils.loadFromJsonLogic(jsonLogicObj as JsonLogicFunction, state.config);
Copy link
Owner

Choose a reason for hiding this comment

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

The correct type is JsonLogicTree

_loadFromJsonLogic(logicTree: JsonLogicTree | undefined, config: Config): [ImmutableTree | undefined, Array<string>];

Suggested change
const tree = Utils.loadFromJsonLogic(jsonLogicObj as JsonLogicFunction, state.config);
const [tree, logicErrors] = Utils._loadFromJsonLogic(jsonLogicObj as JsonLogicTree, state.config);
if (logicErrors?.length) {
throw logicErrors; // TODO: use in `setJsonLogicErrors`
}

Copy link
Owner

@ukrbublik ukrbublik left a comment

Choose a reason for hiding this comment

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

See comments

@johnkennedyb
Copy link

johnkennedyb commented Jul 22, 2025

Thanks for pointing that out — I had a look at PR #1271 and saw that the core logic for importing from JsonLogic is already in place. My proposal is to build on top of that by adding a simple JSON editor (e.g. modal with monaco or react-json-view) so users can paste their JsonLogic directly into the UI and trigger the import without touching the code.

This would make the feature more accessible for non-dev users and better for testing. I’d be happy to keep the UI clean and follow the structure used in the existing implementation. Let me know if you’re open to that direction. I am available to start working on the project now

@ukrbublik ukrbublik closed this Jul 25, 2025
@johnkennedyb
Copy link

“Hi @ukrbublik I contributed this PR via OnlyDust and was wondering if it might be eligible for reward. Let me know if there's anything I should improve or focus on in future contributions!”

@ukrbublik
Copy link
Owner

What kind of reward?

With next contributions please create new branch for your changes instead of pushing to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Demo app: add ability to import from JsonLogic
3 participants