import { useState } from "react"; import { faAngleRight, faCheck, faCopy, faLock } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Link, useParams } from "@tanstack/react-router"; import { twMerge } from "tailwind-merge"; import { useOrganization, useProject } from "@app/context"; import { useToggle } from "@app/hooks"; import { createNotification } from "../notifications"; import { IconButton, Select, SelectItem, Tooltip } from "../v2"; type Props = { pageName: string; isProjectRelated?: boolean; isOrganizationRelated?: boolean; currentEnv?: string; userAvailableEnvs?: any[]; onEnvChange?: (slug: string) => void; secretPath?: string; isFolderMode?: boolean; isProtectedBranch?: boolean; protectionPolicyName?: string; }; // TODO: make links clickable and clean up /** * This is the component at the top of almost every page. * It shows how to navigate to a certain page. * It future these links should also be clickable and hoverable * @param {object} obj * @param {string} obj.pageName - Name of the page * @param {boolean} obj.isProjectRelated - whether or not this page is related to project (determine if it's 2 or 3 navigation steps) * @param {boolean} obj.isOrganizationRelated - whether or not this page is related to organization (determine if it's 2 or 3 navigation steps) * @param {string} obj.currentEnv - current environment inside a project * @param {string} obj.userAvailableEnvs - environments that are available to a user in this project (used for the dropdown) * @param {string} obj.onEnvChange - the action that happens when an env is changed * @returns */ // TODO(akhilmhdh): simply this header and nav system later export default function NavHeader({ pageName, isProjectRelated, isOrganizationRelated, currentEnv, userAvailableEnvs = [], onEnvChange, isFolderMode, secretPath = "/", isProtectedBranch = false, protectionPolicyName }: Props): JSX.Element { const { currentProject } = useProject(); const { currentOrg } = useOrganization(); const [isCopied, { timedToggle: toggleIsCopied }] = useToggle(false); const [isHoveringCopyButton, setIsHoveringCopyButton] = useState(false); const routerEnvSlug = useParams({ strict: false, select: (el) => el.envSlug }); const secretPathSegments = secretPath.split("/").filter(Boolean); return (