forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: UI Add copy to clipboard shortcut (argoproj#10958)
* feat: UI Add copy to clipboard shortcut argoproj#10803 Signed-off-by: tramanathan <thirunavukkarasu_ramanathan@intuit.com> * fix: Use os.PathSeparator instead of hard-coded string to resolve local file paths (argoproj#10945) (argoproj#10946) fix: Use os.PathSeparator instead of hard-coded string to resolve local file paths (argoproj#10945) (argoproj#10946) Signed-off-by: tramanathan <thirunavukkarasu_ramanathan@intuit.com> * feat: UI Add copy to clipboard shortcut Signed-off-by: tramanathan <thirunavukkarasu_ramanathan@intuit.com> Signed-off-by: tramanathan <thirunavukkarasu_ramanathan@intuit.com> Co-authored-by: tramanathan <thirunavukkarasu_ramanathan@intuit.com> Co-authored-by: Chris Davis <chris@codeflow.org.uk> Signed-off-by: Nicholas Johnson <nbjohnson10@gmail.com>
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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); | ||
|
||
if (!text) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<> | ||
{text} | ||
| ||
<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> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters