-
Notifications
You must be signed in to change notification settings - Fork 231
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
Add ability to hide token in cli tools page #871
Add ability to hide token in cli tools page #871
Conversation
@spadgett mind taking this one? |
@@ -48,7 +48,7 @@ <h1 id="cli">Command Line Tools</h1> | |||
<div ng-show="showSessionToken" class="alert alert-warning"> | |||
<span class="pficon pficon-warning-triangle-o" aria-hidden="true"></span> | |||
<strong>A token is a form of a password.</strong> | |||
Do not share your API token. | |||
Do not share your API token. <a href="#" ng-click="toggleShowSessionToken()" ng-show="showSessionToken">Click to hide the token...</a> |
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'd probably just say "Hide token".
You don't need the ng-show
here since it's on the parent div
.
You only need href=""
. (Do you mind fixing the reveal href
above as well?)
@jwforres Opinion on a copy to clipboard link (without needing to reveal the token)? Right now I have to click show token and then manually select the command. |
wouldn't be opposed to the idea, would need to see how it looks in context On Mon, Nov 14, 2016 at 4:25 PM, Sam Padgett [email protected]
|
@juanvallejo +1, except I would copy the full command. Something like...? <pre>oc login https://localhost:8443 --token=<hidden></pre>
<a href="">Show token</a>
<span class="action-divider">|</span>
<a href="">Copy command to clipboard</a> If we made that change, we'd probably always show the warning about tokens. And might want to avoid the copy to clipboard link for browsers that don't support it like iOS Safari. |
265d154
to
6694fce
Compare
@spadgett Sounds good, I'll update this. <div class="code prettyprint ng-binding" ng-if="sessionToken">
oc login {{loginBaseURL}} --token=<span ng-show="showSessionToken">{{sessionToken}}</span><a href="#" ng-click="toggleShowSessionToken()" ng-show="!showSessionToken">...click to show token...</a>
</div> |
EDIT: Result from copying command |
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.
Thanks @juanvallejo, I think this is better than what we had before. A few comments.
|
||
$scope.toggleShowSessionToken = function() { | ||
$scope.showSessionToken = !$scope.showSessionToken; | ||
}; | ||
|
||
$scope.copySessionToken = function($scope) { | ||
var node = $('#' + $scope.copySessionTokenId); |
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 suggest we update the copy-to-clipboard
directive to take in an optional element ID or create a new directive we could reuse (scripts/directives/util.js).
@@ -48,7 +53,7 @@ <h1 id="cli">Command Line Tools</h1> | |||
<div ng-show="showSessionToken" class="alert alert-warning"> |
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.
Might want to show to show this always since I won't see the warning if I click copy to clipboard.
<span ng-show="!showSessionToken"> | ||
<a href="#" ng-click="toggleShowSessionToken()">Show token</a> | ||
<span class="action-divider">|</span> | ||
<a href="#" id="{{copySessionTokenId}}" ng-click="copySessionToken(this)" title="Copy command to clipboard" data-toggle="tooltip">Copy command to clipboard</a> |
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.
Hide this if it's iOS? There's an IS_IOS
constant you can use in the controller to set a scope var.
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.
How do the actions look if you move them below the prettyprint
div?
@@ -48,7 +53,7 @@ <h1 id="cli">Command Line Tools</h1> | |||
<div ng-show="showSessionToken" class="alert alert-warning"> | |||
<span class="pficon pficon-warning-triangle-o" aria-hidden="true"></span> | |||
<strong>A token is a form of a password.</strong> | |||
Do not share your API token. | |||
Do not share your API token. <a href="#" ng-click="toggleShowSessionToken()">Hide token.</a> |
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.
Might want to change the show link to a hide link and just have it toggle.
@spadgett Review comments addressed, I'm now re-using the |
LGTM, @jwforres OK with this change? |
@sspeiche FYI |
yep, @spadgett were you going to do the code review on this |
Yeah, code looks good. Thanks @juanvallejo |
hold, spotted one problem |
@@ -38,14 +38,22 @@ <h1 id="cli">Command Line Tools</h1> | |||
<p> | |||
After downloading and installing it, you can start by logging in using<span ng-if="sessionToken"> this current session token</span>: | |||
<div class="code prettyprint ng-binding" ng-if="sessionToken"> |
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.
@juanvallejo need an outer div with ng-if="sessionToken"
surrounding both the prettyprint
div and the action links below.
Why would this "copy to clipboard" not be the same icon for webhooks ? |
@sspeiche are you proposing to use the entire input field or just the icon? |
I'm proposing that everywhere in the web console that we "copy to clipboard" it doesn't do something that looks and feels that different. |
I agree consistency is good, but we're being careful not to show the token value. Maybe the copy-to-clipboard input is not wide enough to reveal it. I'm not sure we should count on that, though. |
if we are going to do that, we should just switch all of these code blocks on this page to copy to clipboard elements instead @juanvallejo mind getting a screenshot of what that would look like? |
Sure, I'll put an example together |
Fantastic, shouldn't the input fields be wider? |
Making the input fields wider would cause the token to be visible, which is On Fri, Nov 18, 2016 at 3:25 PM, Steve Speicher [email protected]
|
That said, I'm fine with this change. @spadgett ? On Fri, Nov 18, 2016 at 4:09 PM, Jessica Forrester [email protected]
|
Does it make sense to copy commands with placeholder values like |
We might be able to still show |
@spadgett I can add a |
@spadgett added commit with |
00dd20a
to
f2e4fda
Compare
@@ -1,11 +1,17 @@ | |||
<div class="input-group copy-to-clipboard"> | |||
<input id="{{id}}" type="text" class="form-control" value="{{clipboardText}}" ng-disabled="isDisabled" ng-readonly="!isDisabled" select-on-focus> | |||
<div class="input-group copy-to-clipboard" style="{{displayWide ? 'max-width:100%;' : ''}}"> |
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.
Suggest something like
ng-class="{ 'limit-width': !displayWide }"
then update the CSS to key off that class.
<span class="input-group-btn" ng-hide="hidden"> | ||
<a data-clipboard-target="#{{id}}" | ||
<a ng-show="!inputText" data-clipboard-target="#{{id}}" |
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.
If you use ng-if
here and line 10, does it let you remove the get(0)
/ get(1)
special case in the controller?
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.
If I use ng-if
, I receive a console error about the element not being found (this happens on this page, as well as every other page that uses this directive)
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.
Ah, OK. We could wrap the controller code in a $timeout
to let the DOM render first, but what you have is probably better.
@spadgett thanks for the feedback, review comments addressed |
thanks @juanvallejo LGTM, please squash, and I'll merge |
44eb014
to
0b99a35
Compare
Thanks, done! |
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.
thanks @juanvallejo !
[merge] |
Evaluated for origin web console merge up to 0b99a35 |
[Test]ing while waiting on the merge queue |
Evaluated for origin web console test up to 0b99a35 |
Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/748/) (Base Commit: a60cd15) |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/751/) (Base Commit: c5349e7) |
Related Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1388770
Fixes openshift/origin#11975
cc @spadgett @jwforres