-
Notifications
You must be signed in to change notification settings - Fork 702
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
Improved secret style #1887
Improved secret style #1887
Conversation
<div className="secret-datum-text">{name}</div> | ||
</Column> | ||
<Column span={5}> | ||
<input |
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.
Np. I think this is a special case of Input usage
@@ -21,3 +21,7 @@ | |||
outline: none; | |||
} | |||
} | |||
|
|||
.secret-datum-content { | |||
border-bottom: 1px solid var(--clr-forms-border-color, #b3b3b3) !important; |
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 needed this because by default, readOnly
input fields don't have the border-bottom but I wanted it to show the length of the input field.
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.
Interesting!
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, although please check my comments before landing it :)
@@ -21,3 +21,7 @@ | |||
outline: none; | |||
} | |||
} | |||
|
|||
.secret-datum-content { | |||
border-bottom: 1px solid var(--clr-forms-border-color, #b3b3b3) !important; |
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.
Interesting!
<div className="secret-datum-text">{name}</div> | ||
</Column> | ||
<Column span={5}> | ||
<input |
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.
Np. I think this is a special case of Input usage
const [copied, setCopied] = React.useState(false); | ||
const toggleDisplay = () => setHidden(!hidden); | ||
const setCopiedTrue = () => { | ||
setCopied(true); | ||
setTimeout(() => { | ||
setCopied(false); | ||
}, 1000); | ||
}; |
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.
This code may cause an error if the user navigates to a different page when the tooltip is showed. This component will be unmounted and the setCopied
method will disappear from the context. To avoid this, you can use useRef
to keep the timeout reference and useEffect
to control it:
const [copied, setCopied] = React.useState(false); | |
const toggleDisplay = () => setHidden(!hidden); | |
const setCopiedTrue = () => { | |
setCopied(true); | |
setTimeout(() => { | |
setCopied(false); | |
}, 1000); | |
}; | |
const [copied, setCopied] = React.useState(false); | |
const toggleDisplay = () => setHidden(!hidden); | |
const copyTimeout = useRef(null); | |
// You can now remove this intermediate method. | |
const setCopiedTrue = () => { | |
setCopied(true); | |
}; | |
useEffect(() => { | |
if (copied) { | |
copyTimeout.current = setTimeout(() => { | |
setCopied(false); | |
}, 1000); | |
} | |
return () => { | |
if (copyTimeout.current != null) { | |
clearTimeout(copyTimeout.current); | |
} | |
} | |
}, [copied]) |
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.
good catch!
const decodedValue = atob(value); | ||
|
||
return ( | ||
<Row> | ||
<Column span={5}> | ||
<div className="secret-datum-text">{name}</div> |
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 change this to a label and connect it to the input
<button className="secret-datum-icon" aria-expanded={!hidden} onClick={setCopiedTrue}> | ||
<div data-tip={true} data-for="app-status"> | ||
<CopyToClipboard text={decodedValue}> | ||
<CdsIcon shape="copy-to-clipboard" size="md" solid={true} /> |
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.
Add a aria-label
to this icon so it notifies screen readers its purpose:
<CdsIcon shape="copy-to-clipboard" size="md" solid={true} /> | |
<CdsIcon shape="copy-to-clipboard" size="md" solid={true} aria-label={`Copy ${name} secret value to the clipboard`}/> |
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, looking excellent. Just coming back to this discussion from the previous PR:
The goal of this first row is to try to show everything needed to access the repo: readiness, access URL and credentials:
Not all the credentials are actually needed, I don't think? For eg., in the example screenshot, it's only the WP secret which is relevant and needed. I wonder if it'd be worth differentiating.
Yes, they are not. In other cases it will be even less relevant for secrets like encoded certs but we have no way of knowing which of them are "important" to build that list.
Perhaps we could have a way - if a schema has been included for a chart (for easy deployment), it would tend to include secrets that are relevant to users, I'd think? So we could do something like: if the chart has a schema and the schema includes some secret fields, highlight those credentials only (and otherwise highlight all or none - they're still in the resources below). Not suggesting for this PR.
The schema uses the Ideally, what app developers could do is tagging secrets with an annotation. Something like |
Description of the change
Follow up of #1882 (review)
Applicable issues