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

feat(ui): Add copy to clipboard shortcut #6217

Merged
merged 1 commit into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ui/src/app/shared/components/clipboard-text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Tooltip} from 'argo-ui';
import * as React from 'react';
import {useState} from 'react';

export const ClipboardText = ({text}: {text: string}) => {
const [justClicked, setJustClicked] = useState<boolean>(false);

return (
<>
{text}
&nbsp; &nbsp;
<Tooltip content={justClicked ? 'Copied!' : 'Copy to clipboard'}>
<a>
<i
className={'fa fa-clipboard'}
onClick={() => {
setJustClicked(true);
navigator.clipboard.writeText(text);
setInterval(() => setJustClicked(false), 2000);
}}
/>
</a>
</Tooltip>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from 'react';
import * as models from '../../../../models';
import {Artifact, NodeStatus, Workflow} from '../../../../models';
import {Button} from '../../../shared/components/button';
import {ClipboardText} from '../../../shared/components/clipboard-text';
import {DropDownButton} from '../../../shared/components/drop-down-button';
import {DurationPanel} from '../../../shared/components/duration-panel';
import {InlineTable} from '../../../shared/components/inline-table/inline-table';
Expand Down Expand Up @@ -61,7 +62,7 @@ const AttributeRows = (props: {attributes: {title: string; value: any}[]}) => (

const WorkflowNodeSummary = (props: Props) => {
const attributes = [
{title: 'NAME', value: props.node.name},
{title: 'NAME', value: <ClipboardText text={props.node.name} />},
{title: 'TYPE', value: props.node.type},
{
title: 'PHASE',
Expand Down Expand Up @@ -112,10 +113,10 @@ const WorkflowNodeSummary = (props: Props) => {
attributes.splice(
2,
0,
{title: 'POD NAME', value: props.node.id},
{title: 'POD NAME', value: <ClipboardText text={props.node.id} />},
{
title: 'HOST NODE NAME',
value: props.node.hostNodeName
value: <ClipboardText text={props.node.hostNodeName} />
}
);
}
Expand Down