Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deployment #671

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ const config = {
fullUrl: true,
},
},

redirects: async () => [
{
source: "/app/fleet/settings",
destination: "/app/fleet/settings/manufacturer",
permanent: false,
},
],
};

export default withVercelToolbar()(config);
2 changes: 1 addition & 1 deletion app/src/app/_components/CmdK/CmdK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
<Command.Item
keywords={["Admin", "Ships"]}
onSelect={() => {
router.push("/app/fleet/settings");
router.push("/app/fleet/settings/manufacturer");
setOpen(false);
setSearch("");
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { requireAuthentication } from "../../lib/auth/server";
import Avatar from "./Avatar";
import LogoutButton from "./LogoutButton";
import { requireAuthentication } from "../../../lib/auth/server";
import Avatar from "../Avatar";
import LogoutButton from "../LogoutButton";

const Account = async () => {
export const Account = async () => {
const authentication = await requireAuthentication();

const name =
Expand All @@ -26,5 +26,3 @@ const Account = async () => {
</div>
);
};

export default Account;
71 changes: 71 additions & 0 deletions app/src/app/_components/Sidebar/RedBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"use client";

import clsx from "clsx";
import { usePathname } from "next/navigation";
import { useEffect, useState } from "react";

export const RedBar = () => {
const [isInitialized, setIsInitialized] = useState(false);
const [isVisible, setIsVisible] = useState(false);
const pathname = usePathname();
const [style, setStyle] = useState({});

useEffect(() => {
const container = document.querySelector("[data-red-bar-container]");
if (!container) return;

const links = container.querySelectorAll(`a`);
const link = findMatchingLink(links, pathname);
if (!link) return;

const containerRect = container.getBoundingClientRect();
const linkRect = link.getBoundingClientRect();

setStyle({
transform: `translateY(${linkRect.top - containerRect.top}px)`,
});

setIsInitialized(true);

setTimeout(() => {
setIsVisible(true);
}, 100);
}, [pathname]);

return (
<div
className={clsx(
"w-[2px] h-[2em] bg-sinister-red-500 absolute left-4 before:rounded pointer-events-none top-3",
{
"opacity-100": isVisible,
"opacity-0": !isVisible,
"transition-all": isInitialized,
},
)}
style={style}
/>
);
};

const findMatchingLink = (
links: NodeListOf<HTMLAnchorElement>,
pathname: string,
) => {
let bestMatch: HTMLAnchorElement | null = null;
let bestMatchHref = "";

for (let i = 0; i < links.length; i++) {
const link = links[i];
if (!link) continue;

const href = link.getAttribute("href");
if (!href) continue;

if (pathname.startsWith(href) && href.length > bestMatchHref.length) {
bestMatch = link;
bestMatchHref = href;
}
}

return bestMatch;
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import clsx from "clsx";
import Link from "next/link";
import { FaCog, FaHome, FaLock, FaTable, FaUsers } from "react-icons/fa";
import { MdWorkspaces } from "react-icons/md";
import { RiSpyFill, RiSwordFill } from "react-icons/ri";
import { requireAuthentication } from "../../lib/auth/server";
import { getUnleashFlag } from "../../lib/getUnleashFlag";
import Account from "./Account";
import { Chip } from "./Chip";
import { CmdKLoader } from "./CmdK/CmdKLoader";
import { Footer } from "./Footer";
import { requireAuthentication } from "../../../lib/auth/server";
import { getUnleashFlag } from "../../../lib/getUnleashFlag";
import { Chip } from "../Chip";
import { CmdKLoader } from "../CmdK/CmdKLoader";
import { Footer } from "../Footer";
import { Account } from "./Account";
import { RedBar } from "./RedBar";

export const Sidebar = async () => {
const authentication = await requireAuthentication();
Expand Down Expand Up @@ -35,7 +37,10 @@ export const Sidebar = async () => {
className="hidden lg:block mt-4 mx-auto"
/>

<nav className="p-4 border-neutral-800">
<nav
className="p-4 border-neutral-800 relative"
data-red-bar-container
>
<ul>
<li>
<Link
Expand Down Expand Up @@ -111,7 +116,13 @@ export const Sidebar = async () => {
<li>
<Link
href="/app/spynet/citizen"
className="flex gap-2 items-center p-4 hover:bg-neutral-800 rounded"
className={clsx(
"flex gap-2 items-center p-4 hover:bg-neutral-800 rounded",
// {
// "before:w-[2px] before:h-[2em] before:bg-sinister-red-500 before:absolute before:left-0 relative before:rounded bg-neutral-800":
// true,
// },
)}
prefetch={false}
>
<FaTable />
Expand Down Expand Up @@ -193,7 +204,7 @@ export const Sidebar = async () => {
) && (
<li>
<Link
href="/app/fleet/settings"
href="/app/fleet/settings/manufacturer"
className="flex gap-2 items-center p-4 hover:bg-neutral-800 rounded"
prefetch={false}
>
Expand All @@ -217,6 +228,8 @@ export const Sidebar = async () => {
</ul>
</div>
)}

<RedBar />
</nav>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clsx from "clsx";
import { usePathname } from "next/navigation";
import { useEffect, useState, type ReactNode } from "react";
import { FaBars, FaTimes } from "react-icons/fa";
import Button from "./Button";
import Button from "../Button";

interface Props {
children?: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SidebarSkeleton = () => {
export const SidebarSkeleton = () => {
return (
<div className="flex h-full flex-col justify-between">
<div />
Expand All @@ -9,5 +9,3 @@ const SidebarSkeleton = () => {
</div>
);
};

export default SidebarSkeleton;
6 changes: 3 additions & 3 deletions app/src/app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import ImpersonationBannerContainer from "../_components/ImpersonationBannerCont
import { PreviewComments } from "../_components/PreviewComments";
import QueryClientProviderContainer from "../_components/QueryClientProviderContainer";
import SessionProviderContainer from "../_components/SessionProviderContainer";
import { Sidebar } from "../_components/Sidebar";
import SidebarContainer from "../_components/SidebarContainer";
import SidebarSkeleton from "../_components/SidebarSkeleton";
import { Sidebar } from "../_components/Sidebar/Sidebar";
import SidebarContainer from "../_components/Sidebar/SidebarContainer";
import { SidebarSkeleton } from "../_components/Sidebar/SidebarSkeleton";

interface Props {
children: ReactNode;
Expand Down
Loading