Improves copy clipaboard message and some prop names

This commit is contained in:
Alex Corey 2020-06-05 10:46:45 -04:00
parent 40cd87f253
commit edb0df788b
3 changed files with 10 additions and 10 deletions

View File

@ -41,10 +41,10 @@ class ClipboardCopyButton extends React.Component {
render() {
const {
clickTip,
copyTip,
entryDelay,
exitDelay,
hoverTip,
copiedSuccessTip,
isDisabled,
} = this.props;
const { copied } = this.state;
@ -54,13 +54,13 @@ class ClipboardCopyButton extends React.Component {
entryDelay={entryDelay}
exitDelay={exitDelay}
trigger="mouseenter focus click"
content={copied ? clickTip : hoverTip}
content={copied ? copiedSuccessTip : copyTip}
>
<Button
isDisabled={isDisabled}
variant="plain"
onClick={this.handleCopyClick}
aria-label={hoverTip}
aria-label={copyTip}
>
<CopyIcon />
</Button>
@ -70,10 +70,10 @@ class ClipboardCopyButton extends React.Component {
}
ClipboardCopyButton.propTypes = {
clickTip: PropTypes.string.isRequired,
copyTip: PropTypes.string.isRequired,
entryDelay: PropTypes.number,
exitDelay: PropTypes.number,
hoverTip: PropTypes.string.isRequired,
copiedSuccessTip: PropTypes.string.isRequired,
stringToCopy: PropTypes.string.isRequired,
switchDelay: PropTypes.number,
isDisabled: PropTypes.bool.isRequired,

View File

@ -128,14 +128,14 @@ function ProjectListItem({
{project.scm_revision.substring(0, 7)}
{!project.scm_revision && (
<Label aria-label={i18n._(t`copy to clipboard disabled`)}>
{i18n._(t`Sync to activate`)}
{i18n._(t`Sync for revision`)}
</Label>
)}
<ClipboardCopyButton
isDisabled={!project.scm_revision}
stringToCopy={project.scm_revision}
hoverTip={i18n._(t`Copy full revision to clipboard.`)}
clickTip={i18n._(t`Successfully copied to clipboard!`)}
copyTip={i18n._(t`Copy full revision to clipboard.`)}
copiedSuccessTip={i18n._(t`Successfully copied to clipboard!`)}
/>
</DataListCell>,
]}

View File

@ -245,7 +245,7 @@ describe('<ProjectsListItem />', () => {
);
expect(
wrapper.find('span[aria-label="copy to clipboard disabled"]').text()
).toBe('Sync to activate');
).toBe('Sync for revision');
expect(wrapper.find('ClipboardCopyButton').prop('isDisabled')).toBe(true);
});
});