mirror of
https://github.com/openziti/zrok.git
synced 2024-12-23 07:09:12 +01:00
copy enable command (#72)
This commit is contained in:
parent
0b13ec7bd4
commit
447bb2ae90
@ -1,8 +1,7 @@
|
|||||||
import Icon from "@mdi/react";
|
import Icon from "@mdi/react";
|
||||||
import {mdiKey} from "@mdi/js";
|
import {mdiKey, mdiContentCopy} 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);
|
||||||
@ -17,6 +16,15 @@ const Token = (props) => {
|
|||||||
const popoverId = popoverOpen ? 'token-popover' : undefined;
|
const popoverId = popoverOpen ? 'token-popover' : undefined;
|
||||||
|
|
||||||
const text = "zrok enable " + props.user.token
|
const text = "zrok enable " + props.user.token
|
||||||
|
const handleCopy = async () => {
|
||||||
|
let copiedText = document.getElementById("zrok-enable-command").innerHTML;
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(copiedText);
|
||||||
|
console.log("copied enable command");
|
||||||
|
} catch(err) {
|
||||||
|
console.error("failed to copy", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -34,7 +42,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>
|
||||||
{text} <Copy text={text}/>
|
$ <span id={"zrok-enable-command"}>{text}</span> <Icon path={mdiContentCopy} size={0.7} onClick={handleCopy}/>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
Loading…
Reference in New Issue
Block a user