mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 13:27:22 +00:00
Update NavHeader.tsx
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
|
import { ParsedUrlQuery } from "querystring";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { faAngleRight, faLock } from "@fortawesome/free-solid-svg-icons";
|
import { faAngleRight, faCheck, faCopy, faLock } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
import { useOrganization, useWorkspace } from "@app/context";
|
import { useOrganization, useWorkspace } from "@app/context";
|
||||||
|
import { useToggle } from "@app/hooks";
|
||||||
|
|
||||||
import { Select, SelectItem, Tooltip } from "../v2";
|
import { createNotification } from "../notifications";
|
||||||
|
import { IconButton, Select, SelectItem, Tooltip } from "../v2";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
pageName: string;
|
pageName: string;
|
||||||
@@ -50,6 +54,9 @@ export default function NavHeader({
|
|||||||
}: Props): JSX.Element {
|
}: Props): JSX.Element {
|
||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace } = useWorkspace();
|
||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
|
|
||||||
|
const [isCopied, { timedToggle: toggleIsCopied }] = useToggle(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const secretPathSegments = secretPath.split("/").filter(Boolean);
|
const secretPathSegments = secretPath.split("/").filter(Boolean);
|
||||||
@@ -132,8 +139,10 @@ export default function NavHeader({
|
|||||||
)}
|
)}
|
||||||
{isFolderMode &&
|
{isFolderMode &&
|
||||||
secretPathSegments?.map((folderName, index) => {
|
secretPathSegments?.map((folderName, index) => {
|
||||||
const query = { ...router.query };
|
const query: ParsedUrlQuery & { secretPath: string } = {
|
||||||
query.secretPath = `/${secretPathSegments.slice(0, index + 1).join("/")}`;
|
...router.query,
|
||||||
|
secretPath: `/${secretPathSegments.slice(0, index + 1).join("/")}`
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -142,7 +151,38 @@ export default function NavHeader({
|
|||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-1.5 text-xs text-gray-400" />
|
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-1.5 text-xs text-gray-400" />
|
||||||
{index + 1 === secretPathSegments?.length ? (
|
{index + 1 === secretPathSegments?.length ? (
|
||||||
<span className="text-sm font-semibold text-bunker-300">{folderName}</span>
|
<div className="flex items-center space-x-2">
|
||||||
|
<span className="text-sm font-semibold text-bunker-300">{folderName}</span>
|
||||||
|
<Tooltip
|
||||||
|
className="relative right-2"
|
||||||
|
position="bottom"
|
||||||
|
content="Copy secret path"
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
variant="plain"
|
||||||
|
ariaLabel="copy"
|
||||||
|
onClick={() => {
|
||||||
|
if (isCopied) return;
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(query.secretPath);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Copied secret path to clipboard",
|
||||||
|
type: "info"
|
||||||
|
});
|
||||||
|
|
||||||
|
toggleIsCopied(2000);
|
||||||
|
}}
|
||||||
|
className="hover:bg-bunker-100/10"
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={!isCopied ? faCopy : faCheck}
|
||||||
|
size="sm"
|
||||||
|
className="cursor-pointer"
|
||||||
|
/>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Link
|
<Link
|
||||||
passHref
|
passHref
|
||||||
|
|||||||
Reference in New Issue
Block a user