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

Improved secret style #1887

Merged
merged 2 commits into from
Jul 24, 2020
Merged

Improved secret style #1887

merged 2 commits into from
Jul 24, 2020

Conversation

andresmgot
Copy link
Contributor

Description of the change

Follow up of #1882 (review)

Peek 2020-07-23 13-00

Applicable issues

<div className="secret-datum-text">{name}</div>
</Column>
<Column span={5}>
<input
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I couldn't use the Input component, the style was not properly applied :/

Screenshot from 2020-07-23 13-05-37

Copy link
Member

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;
Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting!

Copy link
Member

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

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

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

Comment on lines 19 to 26
const [copied, setCopied] = React.useState(false);
const toggleDisplay = () => setHidden(!hidden);
const setCopiedTrue = () => {
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 1000);
};
Copy link
Member

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:

Suggested change
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])

Copy link
Contributor Author

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

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:

Suggested change
<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`}/>

Copy link
Contributor

@absoludity absoludity left a 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.

@andresmgot
Copy link
Contributor Author

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 values.yaml, there is no way to map .values.wordpressPassword to the secret containing those credentials.

Ideally, what app developers could do is tagging secrets with an annotation. Something like kubeapps.com/credentials/username: foo, kubeapps.com/credentials/password: wordpress-password (being wordpress-password the key of the secret data). That way we could ensure those are the app credentials and we can highlight only that.

@andresmgot andresmgot merged commit e87e197 into master Jul 24, 2020
@andresmgot andresmgot deleted the secretStyle branch September 8, 2020 09:27
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.

None yet

3 participants