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

feature:check json value #4519

Merged
merged 1 commit into from
Aug 28, 2022
Merged

feature:check json value #4519

merged 1 commit into from
Aug 28, 2022

Conversation

AbnerHuang2
Copy link
Contributor

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:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

@github-actions
Copy link

github-actions bot commented Aug 14, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@AbnerHuang2
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@nobodyiam
Copy link
Member

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.

@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2022

Codecov Report

Merging #4519 (848fa90) into master (0b6c4e9) will increase coverage by 0.02%.
The diff coverage is n/a.

@@             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              
Impacted Files Coverage Δ
...ervice/service/ReleaseMessageServiceWithCache.java 85.88% <0.00%> (-1.18%) ⬇️
...ework/apollo/internals/RemoteConfigRepository.java 88.34% <0.00%> (+3.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@AbnerHuang2
Copy link
Contributor Author

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.

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?

@nobodyiam
Copy link
Member

unless the value is in [] or {}, then I can show the check button.

I think we could first try this.

@AbnerHuang2
Copy link
Contributor Author

I think we could first try this.

ok, I'll do it tomorrow.

@AbnerHuang2
Copy link
Contributor Author

@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()">
Copy link
Member

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.

image

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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).

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@AbnerHuang2
Copy link
Contributor Author

I have update CHANGES.md and add json check when modal shown. @nobodyiam

@AbnerHuang2 AbnerHuang2 force-pushed the master branch 2 times, most recently from d89d20d to efcd57d Compare August 28, 2022 07:47
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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

LGTM

@nobodyiam nobodyiam merged commit 150fe19 into apolloconfig:master Aug 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2022
@nobodyiam nobodyiam added this to the 2.1.0 milestone Feb 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

修改value时加上检测json是否正确的按钮
3 participants