mirror of
https://github.com/openziti/zrok.git
synced 2025-06-26 04:31:30 +02:00
'Copy' component in 'Token' (#72)
This commit is contained in:
parent
c739a2da69
commit
3639635d48
15
ui/src/Copy.js
Normal file
15
ui/src/Copy.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import Icon from "@mdi/react";
|
||||||
|
import {mdiContentCopy} from "@mdi/js";
|
||||||
|
|
||||||
|
const Copy = (props) => {
|
||||||
|
function handleClick(event) {
|
||||||
|
navigator.clipboard.writeText(props.text);
|
||||||
|
console.log("copied", props.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button onClick={handleClick}><Icon path={mdiContentCopy} size={0.5}/></button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Copy;
|
@ -2,6 +2,7 @@ import Icon from "@mdi/react";
|
|||||||
import {mdiKey} from "@mdi/js";
|
import {mdiKey} from "@mdi/js";
|
||||||
import Popover from "@mui/material/Popover";
|
import Popover from "@mui/material/Popover";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
|
import Copy from "./Copy";
|
||||||
|
|
||||||
const Token = (props) => {
|
const Token = (props) => {
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
@ -15,6 +16,8 @@ const Token = (props) => {
|
|||||||
const popoverOpen = Boolean(anchorEl);
|
const popoverOpen = Boolean(anchorEl);
|
||||||
const popoverId = popoverOpen ? 'token-popover' : undefined;
|
const popoverId = popoverOpen ? 'token-popover' : undefined;
|
||||||
|
|
||||||
|
const text = "zrok enable " + props.user.token
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button aria-describedby={popoverId} onClick={handlePopoverClick}><Icon path={mdiKey} size={0.7}/></button>
|
<button aria-describedby={popoverId} onClick={handlePopoverClick}><Icon path={mdiKey} size={0.7}/></button>
|
||||||
@ -31,7 +34,7 @@ const Token = (props) => {
|
|||||||
<div className={"popover"}>
|
<div className={"popover"}>
|
||||||
<h3>Enable zrok access in your shell:</h3>
|
<h3>Enable zrok access in your shell:</h3>
|
||||||
<pre>
|
<pre>
|
||||||
$ zrok enable {props.user.token}
|
{text} <Copy text={text}/>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user