Skip to content

[Zeppelin-945] Interpreter authorization - #1257

Closed
astroshim wants to merge 16 commits into
apache:masterfrom
astroshim:ZEPPELIN-945_1
Closed

[Zeppelin-945] Interpreter authorization#1257
astroshim wants to merge 16 commits into
apache:masterfrom
astroshim:ZEPPELIN-945_1

Conversation

@astroshim

@astroshimastroshim commented Aug 2, 2016

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

@AhyoungRyu Let me check. Thanks.

@AhyoungRyu

AhyoungRyu commented Aug 4, 2016

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
ContributorAuthor

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

@AhyoungRyuAhyoungRyuAug 4, 2016

Copy link
Copy Markdown
Contributor

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

functionsuggestionSelected(len,i){returni<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
Copy Markdown
ContributorAuthor

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

@prabhjyotsingh

prabhjyotsingh commented Aug 4, 2016

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
ContributorAuthor

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

@astroshim

Copy link
Copy Markdown
ContributorAuthor

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

@prabhjyotsingh

Copy link
Copy Markdown
Contributor

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

@astroshim

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

Except for minor fixes, looks good.

@astroshim

Copy link
Copy Markdown
ContributorAuthor

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

this.host = host;
}

public boolean isSetPermission() {

Copy link
Copy Markdown
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

bzz commented Aug 11, 2016

Copy link
Copy Markdown
Member

@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
Copy Markdown
ContributorAuthor

@bzz please review and Thanks again.

@bzz

bzz commented Aug 16, 2016

Copy link
Copy Markdown
Member

@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
Copy Markdown
ContributorAuthor

@bzz I just fixed, I missed that.

@bzz

bzz commented Aug 16, 2016

Copy link
Copy Markdown
Member

Thank you @astroshim !

Merging to master if there is no further discussion.

@bzz

bzz commented Aug 16, 2016

Copy link
Copy Markdown
Member

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]

Sign up for freeto 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

@astroshim@AhyoungRyu@prabhjyotsingh@bzz@heruka-urgyen