-
Notifications
You must be signed in to change notification settings - Fork 592
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
frontend: Route Details - Updated TLS Settings to allow Copy and Mask settings #87
Conversation
Only key is sensitive. I'm not sure I'd conceal them all (even if we do in OpenShift console) |
const { showSecret } = this.state; | ||
const dl = []; | ||
Object.keys(data || {}).sort().forEach(k => { | ||
const value = window.atob(data[k]); | ||
const value = type === 'route.openshift.io' ? data[k] : window.atob(data[k]); |
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 rather not have a special check like this. We should generalize the component if we want to reuse it.
I think it's cleaner just not to use SecretData since it's only one field we want to mask.
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.
Also, this is still cluttered way to make a new array...(but that's a lingering comment).
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.
+1 for generalizing component.
It would be nice to still be able to copy the other certs even if we don't mask them. |
Suggest moving termination type and allow insecure traffic above the certificates |
For that either use the |
Why not just use the |
const { showSecret } = this.state; | ||
const dl = []; | ||
Object.keys(data || {}).sort().forEach(k => { | ||
const value = window.atob(data[k]); | ||
const value = type === 'route.openshift.io' ? data[k] : window.atob(data[k]); |
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.
+1 for generalizing component.
let secrets = _.omit(props.tls, ['termination', 'insecureEdgeTerminationPolicy']); | ||
|
||
return <React.Fragment> | ||
<SecretData heading="TLS Settings" data={secrets} type="route.openshift.io"/> |
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.
Switching to SecretData also changes properties to alphabetical order, which is not really what we want here.
LGTM @dtaylor113 |
ace7b9a
to
28bd895
Compare
This looks really complicated for what we want and we also lose the ordering of the fields. Is it possible to create a simple show/hide component we can use for the one field we want to hide? And just use CopyToClipboard directly for the other 3 fields? |
Agreed @spadgett |
28bd895
to
1569925
Compare
|
||
return <React.Fragment> | ||
<dt>{title} {value && | ||
<button className="btn btn-link co-mask-data__btn" style={{paddingLeft: '24px'}} type="button" onClick={this.toggleSecret}> |
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 can't get co-mask-data__btn
to reflect in the browser thus the hard-coded style=...
.
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 rather add a class and we can help you test if necessary. (We should figure out what's wrong in your environment, though.)
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 would rather add a class as well, but at this point I can't even change an existing scss value. Here I changed top
to 10px
, but when I inspect it it still says 0:
When I click on the link to the .scss file, it does display the updated value:
I've tried starting/stopping server and dev, ./build.sh
, ./build-frontend.sh
, yarn run build
, etc.. Very frustrating, I just can't get scss changes/additions to show up in browser :-(
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 add a screenshot?
<dt>CA Certificate</dt> | ||
<dd>{props.tls.caCertificate || '-'}</dd> | ||
<dd>{props.tls.caCertificate ? <CopyToClipboard value={props.tls.caCertificate}/> : '-'}</dd> | ||
{_.get(props.tls, 'termination') === 'reencrypt' && <span> |
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.
not new, but this should be a React.Fragment instead of span
const visibleValue = showSecret ? value : <MaskedData /> ; | ||
|
||
return <React.Fragment> | ||
<dt>{title} {value && |
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.
Let's not have the dt
/dd
be part of this. Better to make this just the value so that it can be used outside of a dl
element.
export const MaskedData = () => <React.Fragment> | ||
<span className="sr-only">Value hidden</span> | ||
<span aria-hidden="true">•••••</span> | ||
</React.Fragment>; |
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.
Since this is exactly the same as the one in secret data, we should be able to reuse this there instead of copying.
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 it from secretData to the new MaskData component, seems more appropriate in the new component.
|
||
return <React.Fragment> | ||
<dt>{title} {value && | ||
<button className="btn btn-link co-mask-data__btn" style={{paddingLeft: '24px'}} type="button" onClick={this.toggleSecret}> |
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 rather add a class and we can help you test if necessary. (We should figure out what's wrong in your environment, though.)
1569925
to
6af825d
Compare
Hi @spadgett, I think this is the format you want. Also, I think the .scss problem I was having was some issue processing scss in a .jsx file and using it in a .tsx file?...if I had to guess. Now that I've declared the component in .tsx, rather than a separate component in a .jsx, my scss changes now appear in the browser. |
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 @dtaylor113. This looks a lot simpler.
} | ||
|
||
render() { | ||
const { showPrivateKey } = this.state; |
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 add
const { tls } = this.props;
to avoid having to repeat this.props.tls everywhere
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.
Done
<dt>Certificate</dt> | ||
<dd>{this.props.tls.certificate ? <CopyToClipboard value={this.props.tls.certificate}/> : '-'}</dd> | ||
<dt>Key {this.props.tls.key && | ||
<button className="btn btn-link co-mask-data__btn" type="button" onClick={this.toggleKey}> |
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.
Do we want the button right-aligned like the secret page?
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.
Seems like a @openshift/team-ux-review question :-) My only concern is that perhaps users would think they would have to 'Reveal' the value in order to 'Copy' it -if the buttons are close together.
<dd>{this.props.tls.key ? <CopyToClipboard value={this.props.tls.key} visibleValue={visibleKeyValue}/> : '-'}</dd> | ||
<dt>CA Certificate</dt> | ||
<dd>{this.props.tls.caCertificate ? <CopyToClipboard value={this.props.tls.caCertificate}/> : '-'}</dd> | ||
{_.get(this.props.tls, 'termination') === 'reencrypt' && <React.Fragment> |
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.
We already know tls is defined from above, so you don't need to use _.get.
{this.props.tls.termination === 'reencrypt' && <React.Fragment>
import { registerTemplate } from '../yaml-templates'; | ||
// eslint-disable-next-line no-unused-vars | ||
import {K8sResourceKind, K8sResourceKindReference} from '../module/k8s'; | ||
import {SafetyFirst} from './safety-first'; |
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.
nit: I'd change this lines 10-11 to have spaces inside the curly braces to use a consistent style as above.
Hi @beanh66, any update on this? I think we're just questioning whether the 'Reveal Value' link/button should be right-aligned over the Copy button. -thanks :-) |
@dtaylor113 yes can you change the reveal for an individual value to be right aligned and drop the word "value" since in this case it is clear which field you will be revealing. |
5c57458
to
ec34e65
Compare
@beanh66 updated screenshots in PR description. -thanks! |
@dtaylor113 Looks good to me |
Code has significantly changed
@spadgett PTAL when you get a moment, thanks |
<button className="btn btn-link co-m-route-tls-reveal__btn" type="button" onClick={this.toggleKey}> | ||
{ | ||
showPrivateKey | ||
? <React.Fragment><i className="fa fa-eye-slash" aria-hidden="true"></i> Hide</React.Fragment> |
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.
Does this need a <React.Fragment>
wrapper? I thought that was only necessary if you were going to render sibling nodes. It looks like you are returning a single <i>
node.
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.
The <React.Fragment>
encapsulates the icon and the text ('Hide' or 'Reveal')
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, i see it, sorry about that :)
const visibleKeyValue = showPrivateKey ? tls.key : <MaskedData /> ; | ||
|
||
return !tls ? 'TLS is not enabled.' | ||
: <dl> |
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.
Care to indent the <dt>
under the <dl>
?
return !tls ?
'TLS is not enabled' :
<dl>
<dt>stuff</dt>
<dt>things</dt>
</dl>;
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.
fixed
} | ||
</span>; | ||
} | ||
|
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.
Missed on the prev PR for this, but you might consider upgrading your _.each
to a _.reduce
& eliminate some bookkeeping in calcTrafficPercentage
:
const calcTrafficPercentage = (weight: number, route: any) => {
return _.reduce(route.spec.alternateBackends, (result, alternate) => {
return result += alternate.weight;
}, 0 + route.spec.to.weight);
};
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.
Hi @benjaminapetersen, still trying to understand this formula. When I plug it in, all percentages come back as 100%:
Whereas, they should equal the Origin Console Route's Traffic table:
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.
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.
Sorry for oops on syntax, didn't pull your code & test, but was just pointing out an alt to .each
to abstract some of bookkeeping.
ec34e65
to
f692a32
Compare
jenkins rebuild |
let totalWeight = _.reduce(route.spec.alternateBackends, (result, alternate) => { | ||
return result += alternate.weight; | ||
}, 0 + route.spec.to.weight); | ||
|
||
return (weight/totalWeight*100).toFixed(1); |
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.
@dtaylor113 Can you confirm it's not possible to set all weights to 0? Otherwise this could be a divide by zero error.
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.
Weights can be set to 0, adjusted code to handle
Ignore the ci/* failures. It's a CI problem we're working to fix. |
_.each(route.spec.alternateBackends, alternate => totalWeight += alternate.weight); | ||
let totalWeight = _.reduce(route.spec.alternateBackends, (result, alternate) => { | ||
return result += alternate.weight; | ||
}, 0 + route.spec.to.weight); |
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.
Why do we need 0 +
?
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.
no, fixed
f692a32
to
1a81840
Compare
return result += alternate.weight; | ||
}, route.spec.to.weight); | ||
|
||
return totalWeight ? (weight/totalWeight*100).toFixed(1) : (weight*100).toFixed(1); |
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 totalWeight is 0, we know weight is 0, too. So we can just return 0.
const percentage = totalWeight ? ((weight / totalWeight) * 100) : 0;
// Format to one decimal place.
return percentage.toFixed(1);
But if weight is 0, we can return early without calculating since percentage will always be 0. (We might just use -
in that case since the function is already returning a string and I think it displays better.)
const calcTrafficPercentage = (weight: number, route: any) => {
if (!weight) {
return '-';
}
Not new, but it's a little strange that we do some formatting here, but add the %
below. toFixed
already converts to a string, so we can't use the result as a number. Might as well add the %
here.
const percentage = (weight / totalWeight) * 100;
// Format to one decimal place.
return `${percentage.toFixed(1)}%`;
(Sorry I should have caught that on previous review.)
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.
fixed, thanks Sam
totalWeight += route.spec.to.weight; | ||
_.each(route.spec.alternateBackends, alternate => totalWeight += alternate.weight); | ||
return (weight/totalWeight*100).toFixed(1); | ||
let totalWeight = _.reduce(route.spec.alternateBackends, (result, alternate) => { |
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.
const
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.
fixed
1a81840
to
40b045b
Compare
Hi @spadgett, PTAL when you get a moment. -thanks |
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.
👍
/lgtm
* added action and reducer for storing and updating activeApplication * created application-switcher * show nothing in title when app switcher is disabled * remove application specific logic from label-dropdown * fixed bugs in label-dropdown and dropdown * show all apps when namespace is changed * added changes according to review comments
Updated TLS Settings section of Route Details page:
@openshift/team-ux-review
Related PRs for hide/reveal secrets; lots of design conversations:
#23
#50