-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
feature:check json value #4519
feature:check json value #4519
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
This feature looks great! |
Codecov Report
@@ Coverage Diff @@
## master #4519 +/- ##
============================================
+ Coverage 53.41% 53.43% +0.02%
Complexity 2708 2708
============================================
Files 492 492
Lines 15390 15390
Branches 1596 1596
============================================
+ Hits 8220 8224 +4
+ Misses 6611 6607 -4
Partials 559 559
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
yeah, you are right, that will be terrible if there were so many check button. but it is hard to show the check button if the value is not in JSON format, unless the value is in [] or {}, then I can show the check button. What do you think? |
I think we could first try this. |
ok, I'll do it tomorrow. |
@nobodyiam I have done this feature, it works like that. 2022-08-16.11.04.42.mov |
@@ -46,15 +46,22 @@ <h4 class="modal-title"> | |||
<label class="col-sm-2 control-label">{{'Component.ConfigItem.ItemValue' | translate }}</label> | |||
<div class="col-sm-10" valdr-form-group> | |||
<textarea id="valueEditor" name="value" class="form-control" rows="6" tabindex="2" | |||
ng-required="false" ng-model="item.value"> | |||
ng-required="false" ng-model="item.value" ng-blur="check()"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the experience of the blur
event is not quite good, as it only displays the check json
button after the focus leaves the textarea. However, that normally is when user clicks the submit button, so that the user would not even see the check json
button.
Is it possible to display the check json
button when the user is editing the value? e.g. to check whether the value is json text after user stops typing for several seconds?
Another potential area to improve is to display the check json
button when the user just clicks the edit button but not editing anything in the textarea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, would you please also update the CHANGES.md?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, would you please also update the CHANGES.md?
I'll update the CHANGES.md later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature looks great! However, I'm wondering is it possible to display the json check button only for potential json values? As I could imagine there will be many check in the future, e.g. yaml check, XML check, etc. The edit modal will look very complicated if there are a lot of checks.
from the begining, I thought you might want to show the check json button while the value is JSON , so I set the check rule is the value in {} or [] . but when user is typing , the value is not in {} or [] . because they type { or ] when they finish type.
if then ,
Is it possible to display the check json button when the user is editing the value? e.g. to check whether the value is json text after user stops typing for several seconds?
the way you mentioned is the same as blur. and there is also comment to write after value. but in most time, after writing the value, user may click submit button directly, maybe onchange is better than blur.
since the cost of check is tiny, I'll replace blur with onchange . maybe it is better for UE(User Experience).
BTW,
Another potential area to improve is to display the check json button when the user just clicks the edit button but not editing anything in the textarea.
as the rule (show check button when the value in {} or []) set before , the check button will not show in this scenario.
If you want show check button when user is typing , we will face the situation you metioned before , that is lots of check in defferent format. I think it may not an good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the cost of check is tiny, I'll replace blur with onchange
I'm not sure whether the onchange event could meet this requirement as it is triggered after the input loses focus?
If you want show check button when user is typing , we will face the situation you metioned before , that is lots of check in defferent format. I think it may not an good idea.
I think the main issue that causes the problem is the item doesn't have format info. Maybe we could consider to add format info to the item
entity, see #1517 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I suppose we need to store the format in the Item
table? Besides, we also need to take a look at the Text
edit mode to see whether it is compatible or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, maybe it will be more complicated in this way. what's a touch issue! it has taken too much time in this issue. maybe we should give the matter further thought. in the long term, if you want to support the item value format check more precise, store the format maybe is a good choice. but it should take more time to think about.
at present, shall we just show check button in onchange event to satisfy json format check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or can I add your wechat , if I have any idea, I can talk to you. and it may more effective for communicate. if we reach a consensus, I can post and pr to deal with it. what do you think? if you don't wanna to be bothered, we can also talk in the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. You can find my email from my profile page and tell me your contact info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, nice. I'll send you later. and I'll review and test my code and commit tonight.
I have update CHANGES.md and add json check when modal shown. @nobodyiam |
d89d20d
to
efcd57d
Compare
CHANGES.md
Outdated
@@ -5,6 +5,7 @@ Release Notes. | |||
Apollo 2.1.0 | |||
|
|||
------------------ | |||
* [Add a potential json value check feature](https://github.com/apolloconfig/apollo/pull/4519) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this to the bottom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What's the purpose of this PR
feature:check json value
Which issue(s) this PR fixes:
Fixes #4142
Brief changelog
to be more specific, I made a short video for it, It works like that.
2022-08-13.3.24.52.mov
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.CHANGES
log.