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

Add ability to hide token in cli tools page #871

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Nov 14, 2016

@jwforres
Copy link
Member

@spadgett mind taking this one?

@spadgett spadgett self-assigned this Nov 14, 2016
@@ -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>
Copy link
Member

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

@spadgett
Copy link
Member

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

@jwforres
Copy link
Member

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]
wrote:

@jwforres https://github.com/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.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#871 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABZk7Tuz-Jcc1khPePpZw_-dq32STlbbks5q-NHMgaJpZM4Kx0RE
.

@juanvallejo
Copy link
Contributor Author

@jwforres @spadgett
cli-tools-page-copy-token-to-clipboard

cli-tools-page-copied-token-to-clipboard

@spadgett
Copy link
Member

@juanvallejo +1, except I would copy the full command. Something like...?

<pre>oc login https://localhost:8443 --token=&lt;hidden&gt;</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.

@juanvallejo juanvallejo force-pushed the jvallejo/add-option-to-hide-token-cli-tools-page branch from 265d154 to 6694fce Compare November 15, 2016 15:29
@juanvallejo
Copy link
Contributor Author

juanvallejo commented Nov 15, 2016

@spadgett Sounds good, I'll update this.
Thanks for the feedback, addressed review comments on #871 (review) . I tried updating the reveal href to leave ng-show to its parent, however its sibling span has ng-show set to an opposite value:

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

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Nov 15, 2016

@spadgett

cli-tools-page-showtoken-copycommand

Show token is clicked

cli-tools-page-token-shown

Copy to clipboard is clicked

cli-tools-page-copy-to-clipboard

EDIT: Result from copying command oc login https://localhost:8443 --token=KXo2gh27B_V5_k_otUvTxKU8H6gJogJtWdZqtU__OGo

Copy link
Member

@spadgett spadgett left a 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);
Copy link
Member

@spadgett spadgett Nov 16, 2016

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

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

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.

Copy link
Member

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

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.

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Nov 16, 2016

@spadgett Review comments addressed, I'm now re-using the <copy-to-clipboard directive

cli-tools-page-with-new-copy-command

cli-tools-page-with-new-copy-command-show

@spadgett
Copy link
Member

LGTM, @jwforres OK with this change?

@spadgett
Copy link
Member

@sspeiche FYI

@jwforres
Copy link
Member

yep, @spadgett were you going to do the code review on this

@spadgett
Copy link
Member

were you going to do the code review on this

Yeah, code looks good. Thanks @juanvallejo

@spadgett
Copy link
Member

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

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.

@sspeiche
Copy link

Why would this "copy to clipboard" not be the same icon for webhooks ?

@juanvallejo
Copy link
Contributor Author

@spadgett Thanks, review comment addressed

@sspeiche

Why would this "copy to clipboard" not be the same icon for webhooks ?

Would that be the
clip
icon? I did not think it would fit with this page, as I have only seen it used when copying contents from an <input element

@sspeiche
Copy link

It looks like something like this:

image

@spadgett
Copy link
Member

@sspeiche are you proposing to use the entire input field or just the icon?

@sspeiche
Copy link

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.

@spadgett
Copy link
Member

spadgett commented Nov 17, 2016

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.

@jwforres
Copy link
Member

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?

@juanvallejo
Copy link
Contributor Author

@jwforres

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

Sure, I'll put an example together

@juanvallejo
Copy link
Contributor Author

@jwforres @spadgett @sspeiche
cli-tools-page-inputs

@sspeiche
Copy link

Fantastic, shouldn't the input fields be wider?

@jwforres
Copy link
Member

Making the input fields wider would cause the token to be visible, which is
bad. We have them short because they are often obscuring things later in
the input, like with webhooks they are obscuring the secrets in the URL

On Fri, Nov 18, 2016 at 3:25 PM, Steve Speicher [email protected]
wrote:

Fantastic, shouldn't the input fields be wider?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#871 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABZk7QAPLLceF7h2dZ06iFnwQkG9m10Yks5q_gnEgaJpZM4Kx0RE
.

@jwforres
Copy link
Member

That said, I'm fine with this change. @spadgett ?

On Fri, Nov 18, 2016 at 4:09 PM, Jessica Forrester [email protected]
wrote:

Making the input fields wider would cause the token to be visible, which
is bad. We have them short because they are often obscuring things later
in the input, like with webhooks they are obscuring the secrets in the URL

On Fri, Nov 18, 2016 at 3:25 PM, Steve Speicher [email protected]
wrote:

Fantastic, shouldn't the input fields be wider?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#871 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABZk7QAPLLceF7h2dZ06iFnwQkG9m10Yks5q_gnEgaJpZM4Kx0RE
.

@spadgett
Copy link
Member

Does it make sense to copy commands with placeholder values like <project-name>? (Maybe?)

@spadgett
Copy link
Member

Making the input fields wider would cause the token to be visible, which is bad.

We might be able to still show token=<hidden> in the input and copy a different value, although we'd need to add some additional logic to the copy-to-clipboard directive. I'd want to check how 100% width looks in other places we use it since it's a global style.

@juanvallejo
Copy link
Contributor Author

@spadgett I can add a wide option to the directive so that full width does not apply anywhere else. I'll put together an example with this and <hidden> values

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Nov 18, 2016

@spadgett @jwforres @sspeiche
cli-tools-page-wide-inputs

Clipboard contents from copying first input oc login https://localhost:8443 --token=YGvpJBROMXDaY_uO8XZuPKRMh3TKycqGcK9IkBXnxzE

(these changes have not been committed yet)

@juanvallejo
Copy link
Contributor Author

@spadgett added commit with copy-to-clipboard changes, PTAL

@juanvallejo juanvallejo force-pushed the jvallejo/add-option-to-hide-token-cli-tools-page branch from 00dd20a to f2e4fda Compare November 21, 2016 15:44
@@ -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%;' : ''}}">
Copy link
Member

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.

https://github.com/spadgett/origin-web-console/blob/e01508561bb7d0c7f6c53dbedcf7dd42d37e0c52/app/styles/_core.less#L1208-L1210

<span class="input-group-btn" ng-hide="hidden">
<a data-clipboard-target="#{{id}}"
<a ng-show="!inputText" data-clipboard-target="#{{id}}"
Copy link
Member

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?

Copy link
Contributor Author

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)

Copy link
Member

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.

@juanvallejo
Copy link
Contributor Author

@spadgett thanks for the feedback, review comments addressed

@spadgett
Copy link
Member

thanks @juanvallejo

LGTM, please squash, and I'll merge

@juanvallejo juanvallejo force-pushed the jvallejo/add-option-to-hide-token-cli-tools-page branch from 44eb014 to 0b99a35 Compare November 21, 2016 21:33
@juanvallejo
Copy link
Contributor Author

@spadgett

LGTM, please squash, and I'll merge

Thanks, done!

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

thanks @juanvallejo !

@spadgett
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 0b99a35

@openshift-bot
Copy link

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link

Evaluated for origin web console test up to 0b99a35

@openshift-bot
Copy link

Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/748/) (Base Commit: a60cd15)

@openshift-bot
Copy link

openshift-bot commented Nov 21, 2016

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/751/) (Base Commit: c5349e7)

@openshift-bot openshift-bot merged commit 7389ce5 into openshift:master Nov 21, 2016
@juanvallejo juanvallejo deleted the jvallejo/add-option-to-hide-token-cli-tools-page branch November 22, 2016 14:32
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