Skip to content

Conversation

@astroshim
Copy link
Contributor

@astroshim astroshim commented Aug 2, 2016

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)

result

Questions:

  • Does the licenses files need update? no
  • Is there breaking changes for older versions? no
  • Does this needs documentation? no

<div>
<p>
Enter comma separated interpreters in the fields. <br />
Empty field (*) implies anyone can run the interpreters.
Copy link
Contributor

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?

@AhyoungRyu
Copy link
Contributor

@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,

search_users

The suggestion list doesn't disappear after pressing Enter key. Could you check this out?

@astroshim
Copy link
Contributor Author

@AhyoungRyu Let me check. Thanks.

@AhyoungRyu
Copy link
Contributor

AhyoungRyu commented Aug 4, 2016

@astroshim

Does this needs documentation? no

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

@astroshim
Copy link
Contributor Author

@AhyoungRyu I fixed you pointed out and I'll create the document for this separated PR.
Thanks.

if (event.keyCode === 13) {
closeAutoComplete();
}
else if (event.keyCode < 37 || event.keyCode > 40) { // arrow buttons.
Copy link
Contributor

@AhyoungRyu AhyoungRyu Aug 4, 2016

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.

@AhyoungRyu
Copy link
Contributor

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

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?

@astroshim
Copy link
Contributor Author

Thank you for detail review @bzz and @felizbear
I'll fix the codes.

@prabhjyotsingh
Copy link
Contributor

prabhjyotsingh commented Aug 4, 2016

@astroshim A lot of these complications are already reduced with #1236 (which is already merged in master), take a look at it.

@astroshim
Copy link
Contributor Author

@prabhjyotsingh Great. Thank you for giving me the guidance.

@astroshim
Copy link
Contributor Author

\cc @AhyoungRyu @prabhjyotsingh @bzz @felizbear
I fixed UI like #1236. Please review.
Thank you!

@prabhjyotsingh
Copy link
Contributor

I'll try it out, in the mean while, can you update screen-shot in description.

@astroshim
Copy link
Contributor Author

@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) {
Copy link
Contributor

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/*

Copy link
Contributor Author

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!

@prabhjyotsingh
Copy link
Contributor

Except for minor fixes, looks good.

@astroshim
Copy link
Contributor Author

@prabhjyotsingh Thank you for your detail review. I fixed all that you mentioned.

this.host = host;
}

public boolean isSetPermission() {
Copy link
Member

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()) {
 //....
}

@bzz
Copy link
Member

bzz commented Aug 11, 2016

@astroshim your changes look awesome to me!

There is one more improvement on Java side noted above, other than that - looks good to merge.

@astroshim
Copy link
Contributor Author

@bzz please review and Thanks again.

@bzz
Copy link
Member

bzz commented Aug 16, 2016

@astroshim changes looks great to me.

There is one more comment above on isSetPermission naming, please let me know if you want to address this one as well, or want to keep it like that!

Will merge to master right after that, and if there is no further discussion

@astroshim
Copy link
Contributor Author

@bzz I just fixed, I missed that.

@bzz
Copy link
Member

bzz commented Aug 16, 2016

Thank you @astroshim !

Merging to master if there is no further discussion.

@bzz
Copy link
Member

bzz commented Aug 16, 2016

CI fails on web-app \w networking issue :\ which is not relevant here

Could not transfer artifact org.codehaus.plexus:plexus-io:pom:2.1.3 from/to central (https://repo.maven.apache.org/maven2): Connection reset -> [Help 1]

@asfgit asfgit closed this in 43dc32b Aug 16, 2016
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.

5 participants