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

Integrate with code-mirror to have a fallback to plugins' render issue #815

Closed
juzhiyuan opened this issue Nov 17, 2020 · 19 comments · Fixed by #898
Closed

Integrate with code-mirror to have a fallback to plugins' render issue #815

juzhiyuan opened this issue Nov 17, 2020 · 19 comments · Fixed by #898
Assignees
Milestone

Comments

@juzhiyuan
Copy link
Member

juzhiyuan commented Nov 17, 2020

image

Background

As shown in the figure, on the left side is the current plugin page and an example diagram of the interaction of editing a plugin.

After the user finds the target plugin,

  1. View the data saved by the plugin via the View Raw button
  2. Invoke the Plugin Form, which is a library of react-jsonschema-form, built from the plugin's jsonschema, via the Setting button.
  3. Determine whether to enable the plugin via the Enable/Disable button.

Problem

The problem we are currently experiencing is that many plugins cannot properly render forms via react-jsonschema-form because the library supports most of the features of the jsonschema, but some of them are not supported. In addition, plugin developers only need to focus on the jsonschema, and building interfaces that are supported by the library requires higher development costs.

Over the past few months, we tried to update the plugin schema to match the library, but it was inefficient and users could not edit the plugin data properly.

Solution

Temporarily disables react-jsonschema-form building forms, and only supports manual data entry by the user via the Plugin Data Editor (View Raw) interface.

Disadvantages

  1. This approach would sacrifice user experience and require the user to enter the configuration manually, based on the documentation examples.

Advantages

  1. Solves the problem that all plugins are not rendering the form properly.
  2. Plugin developers only need to care about writing the correct jsonschema.

As for the feature that allows users to enter plugin data via a form (instead of manually entering JSON), this will remain a concern, and we will resubmit the proposal to resolve the issue when a suitable solution is available to cover all plugins.

Reference

@juzhiyuan juzhiyuan changed the title [DRAFT] Integrate with code-mirrot to have a fallback for plugins' issue [DRAFT] Integrate with code-mirror to have a fallback for plugins' issue Nov 17, 2020
@juzhiyuan juzhiyuan changed the title [DRAFT] Integrate with code-mirror to have a fallback for plugins' issue [DRAFT] Integrate with code-mirror to have a fallback to plugins' issue Nov 17, 2020
@juzhiyuan juzhiyuan self-assigned this Nov 17, 2020
@juzhiyuan juzhiyuan changed the title [DRAFT] Integrate with code-mirror to have a fallback to plugins' issue Integrate with code-mirror to have a fallback to plugins' render issue Nov 19, 2020
@juzhiyuan
Copy link
Member Author

juzhiyuan commented Nov 19, 2020

Please take a look at this proposal, though it's not very friendly for users to input JSON, it works for all the plugins.

cc @liuxiran @LiteSun @moonming @membphis @ShiningRush @idbeta @tokers

@juzhiyuan
Copy link
Member Author

We will use CodeMirror to highlight the json data.

@juzhiyuan juzhiyuan added this to the 2.1 milestone Nov 19, 2020
@idbeta
Copy link
Contributor

idbeta commented Nov 19, 2020

Agree, need to provide users with JSONschema examples of each plugin, you can add a link next to the plugin to make it easier for users to find these examples.

@juzhiyuan
Copy link
Member Author

Agree, need to provide users with JSONschema examples of each plugin, you can add a link next to the plugin to make it easier for users to find these examples.

Ya, a quick way is adding a link to that plugin's doc 😂

@liuxiran
Copy link
Contributor

I think this proposal is a good compromise.
We can improve the documentation to increase the experience, we can try to provide some configuration template for common scenarios, then users can use our plugin by copying the template and modifying some configuration parameters.

@juzhiyuan
Copy link
Member Author

juzhiyuan commented Nov 20, 2020

I think this proposal is a good compromise.
We can improve the documentation to increase the experience, we can try to provide some configuration template for common scenarios, then users can use our plugin by copying the template and modifying some configuration parameters.

That's it!!

@liuxiran
Copy link
Contributor

I think this proposal is a good compromise.
We can improve the documentation to increase the experience, we can try to provide some configuration template for common scenarios, then users can use our plugin by copying the template and modifying some configuration parameters.

That's it!!

and this may be easier to use than visual forms :)

@tokers
Copy link
Contributor

tokers commented Nov 20, 2020

I have just one question, is the plugin data editor friendly enough? say user puts some unexpected characters accidently (like adding extra commas)
will the editor highlights the error to help user to rectify it?

@juzhiyuan
Copy link
Member Author

juzhiyuan commented Nov 20, 2020

will the editor highlights the error to help the user to rectify it?

Not sure, if CodeMirror supports it, we will add this feature.
BTW, the frontend will validate the data according to schema before sending APIs.

@tokers
Copy link
Contributor

tokers commented Nov 20, 2020

will the editor highlights the error to help the user to rectify it?

Not sure, if CodeMirror supports it, we will add this feature.
BTW, the frontend will validate the data according to schema before sending APIs.

I think the feeling of interaction is important, some low level syntax errors are not so easy to found especially when the plugin data is fairly long.

@juzhiyuan
Copy link
Member Author

will the editor highlights the error to help the user to rectify it?

Not sure, if CodeMirror supports it, we will add this feature.
BTW, the frontend will validate the data according to schema before sending APIs.

I think the feeling of interaction is important, some low level syntax errors are not so easy to found especially when the plugin data is fairly long.

Got it, we support validating with jsonschema, errors will show up if there has something incompatible with schema.

@juzhiyuan
Copy link
Member Author

juzhiyuan commented Nov 23, 2020

ok, then I'm going to do this week.

@juzhiyuan juzhiyuan removed the discuss label Nov 23, 2020
@juzhiyuan
Copy link
Member Author

This issue is related to those issues.

#764
#802
#812
#814
#790
#788
#762

@juzhiyuan
Copy link
Member Author

juzhiyuan commented Nov 29, 2020

After some research and trying, I find that we should add a Format button instead of auto-formatting because auto-formatting will make the input Textarea lost focus.

cc @liuxiran @moonming @membphis

@juzhiyuan
Copy link
Member Author

When users input or paste some JSON codes here, they could click the format button to achieve code format, easy to implement.

@juzhiyuan
Copy link
Member Author

Snapshot

image

@membphis
Copy link
Member

After some research and trying, I find that we should add a Format button instead of auto-formatting because auto-formatting will make the input Textarea lost focus.

agree ^_^

@juzhiyuan
Copy link
Member Author

ping @membphis

@membphis
Copy link
Member

membphis commented Dec 3, 2020

got it

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

Successfully merging a pull request may close this issue.

5 participants