-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Zeppelin-945] Interpreter authorization #1257
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
Conversation
| <div> | ||
| <p> | ||
| Enter comma separated interpreters in the fields. <br /> | ||
| Empty field (*) implies anyone can run the interpreters. |
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.
It's a minor thing; how about this interpreter instead of the interpreters?
|
@astroshim Awesome. I saw many people have talked about this feature :) I tested your patch locally, it works well as expected. But I found one issue regarding user suggestion, The suggestion list doesn't disappear after pressing |
|
@AhyoungRyu Let me check. Thanks. |
I think we need a documentation for "Interpreter Authorization" feature as well like we have below docs pages. But separated PR would be okay i think :) |
|
@AhyoungRyu I fixed you pointed out and I'll create the document for this separated PR. |
| if (event.keyCode === 13) { | ||
| closeAutoComplete(); | ||
| } | ||
| else if (event.keyCode < 37 || event.keyCode > 40) { // arrow buttons. |
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.
Can we move this line to the above line? As google code style said https://google.github.io/styleguide/javaguide.html#s4.1.2-blocks-k-r-style. Maybe you can't build this with grunt because of disallowKeywordsOnNewLine error.
|
@astroshim Tested again and checked the bug is gone. Thanks for the prompt fix 👍 |
| var checkIfSelected = function() { | ||
| if (($scope.suggestions.length === 0) && | ||
| ($scope.selectIndex < 0 || $scope.selectIndex >= $scope.suggestions.length) || | ||
| ($scope.suggestions.length !== 0 && ($scope.selectIndex < 0 || $scope.selectIndex >= $scope.suggestions.length)) |
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.
Long condition inside the if becomes quite hard to understand and follow here.
What do you think, could this be changed a bit to make it more readable i.e:
if (suggestionSelected($scope.suggestions.length, $scope.selectIndex)) {
//....
}
function suggestionSelected(len, i) {
return (len === 0) && (i < 0 || i >= len) ||
(len !== 0 && (i < 0 || i >= len))
}And now it's easy to see how suggestionSelected can be further improved, keeping invariants.
Normalizing the parantheses according to logical operator precedence in javascript we get
return (len === 0 && (i < 0 || i >= len)) ||
(len !== 0 && (i < 0 || i >= len))
}which, in turn, is the same as
return (i < 0 || i >= len) && (len === 0 || len !== 0)and as the right side of the && is always true for an integer, we get
function suggestionSelected(len, i) {
return i < 0 || i >= len
}At the end, this might not worth extracting to a separate function, but this shows the benefits we can get from it.
The result is much simpler to understand and reason about.
@astroshim what do you think?
|
Thank you for detail review @bzz and @felizbear |
|
@astroshim A lot of these complications are already reduced with #1236 (which is already merged in master), take a look at it. |
|
@prabhjyotsingh Great. Thank you for giving me the guidance. |
|
\cc @AhyoungRyu @prabhjyotsingh @bzz @felizbear |
|
I'll try it out, in the mean while, can you update screen-shot in description. |
|
@prabhjyotsingh I just updated screen-shot. Thank you for taking care of this. |
|
|
||
| angular.module('zeppelinWebApp').controller('InterpreterCtrl', | ||
| angular.module('zeppelinWebApp') | ||
| .directive('interpreterDirective', function($timeout) { |
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.
can you move this directive to a different file zeppelin-web/src/components/*
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 moved the directive. Thanks!
|
Except for minor fixes, looks good. |
|
@prabhjyotsingh Thank you for your detail review. I fixed all that you mentioned. |
| this.host = host; | ||
| } | ||
|
|
||
| public boolean isSetPermission() { |
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 is quite an ambiguous naming - usually in Java set\get used as a convention for getters and setters, so may be here we better call it like permissionIsSet() or permissionWasSet() - in this way we keep the almos-eglish readability in case of the code like
if (permissionIsSet()) {
//....
}|
@astroshim your changes look awesome to me! There is one more improvement on Java side noted above, other than that - looks good to merge. |
|
@bzz please review and Thanks again. |
|
@astroshim changes looks great to me. There is one more comment above on Will merge to master right after that, and if there is no further discussion |
|
@bzz I just fixed, I missed that. |
|
Thank you @astroshim ! Merging to master if there is no further discussion. |
|
CI fails on web-app \w networking issue :\ which is not relevant here |

What is this PR for?
This PR is derived from #1223
What type of PR is it?
Improvement
What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-945
How should this be tested?
You can change user permission of interpreter at interpreter setting page.
Screenshots (if appropriate)
Questions: