From 46dc357651afeb4bec614602938dc5b0b549b93c Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 11 Jul 2023 00:04:14 -0700 Subject: [PATCH] final changes to sidebars --- frontend/src/layouts/AppLayout/AppLayout.tsx | 6 +- .../AppLayout/components/NavBar/NavBar.tsx | 359 ------------------ .../AppLayout/components/NavBar/index.tsx | 1 - .../src/pages/org/[id]/overview/index.tsx | 22 +- .../BillingCloudTab/CurrentPlanSection.tsx | 2 +- .../BillingCloudTab/PreviewSection.tsx | 2 +- .../BillingDetailsTab/CompanyNameSection.tsx | 2 +- .../BillingDetailsTab/InvoiceEmailSection.tsx | 2 +- .../BillingDetailsTab/PmtMethodsSection.tsx | 2 +- .../BillingDetailsTab/TaxIDSection.tsx | 2 +- .../BillingReceiptsTab/BillingReceiptsTab.tsx | 2 +- .../BillingTabGroup/BillingTabGroup.tsx | 2 +- 12 files changed, 18 insertions(+), 386 deletions(-) delete mode 100644 frontend/src/layouts/AppLayout/components/NavBar/NavBar.tsx delete mode 100644 frontend/src/layouts/AppLayout/components/NavBar/index.tsx diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 05c1c1532..1f3d8cc9b 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -155,9 +155,9 @@ export const AppLayout = ({ children }: LayoutProps) => { } if (currentOrg && ( - (workspaces?.length === 0 && !router.asPath.includes("org") && !router.asPath.includes("personal") && !router.asPath.includes("integration")) + (workspaces?.length === 0 && router.asPath.includes("project")) || router.asPath.includes("/project/undefined") - || !orgs?.includes(router.query.id) + || (!orgs?.includes(router.query.id) && !router.asPath.includes("project") && !router.asPath.includes("integration")) )) { router.push(`/org/${currentOrg?._id}/overview`); } @@ -186,7 +186,7 @@ export const AppLayout = ({ children }: LayoutProps) => { }; putUserInOrg(); onboardingCheck({}); - }, [currentOrg]); + }, [router.query.id]); const onCreateProject = async ({ name, addMembers }: TAddProjectFormData) => { // type check diff --git a/frontend/src/layouts/AppLayout/components/NavBar/NavBar.tsx b/frontend/src/layouts/AppLayout/components/NavBar/NavBar.tsx deleted file mode 100644 index b263a25ff..000000000 --- a/frontend/src/layouts/AppLayout/components/NavBar/NavBar.tsx +++ /dev/null @@ -1,359 +0,0 @@ -/* eslint-disable jsx-a11y/anchor-is-valid */ -/* eslint-disable react/jsx-key */ -import { Fragment, useMemo } from "react"; -import { useTranslation } from "react-i18next"; -import Image from "next/image"; -import Link from "next/link"; -import { useRouter } from "next/router"; -import { faGithub, faSlack } from "@fortawesome/free-brands-svg-icons"; -import { faCircleQuestion } from "@fortawesome/free-regular-svg-icons"; -import { - faAngleDown, - faBook, - faCoins, - faEnvelope, - faGear, - faPlus, - faRightFromBracket -} from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { Menu, Transition } from "@headlessui/react"; -import {TFunction} from "i18next"; - -import guidGenerator from "@app/components/utilities/randomId"; -import { useOrganization, useSubscription,useUser } from "@app/context"; -import { useLogoutUser } from "@app/hooks/api"; - -const supportOptions = (t: TFunction) => [ - [ - , - t("nav.support.slack"), - "https://infisical.com/slack" - ], - [ - , - t("nav.support.docs"), - "https://infisical.com/docs/documentation/getting-started/introduction" - ], - [ - , - t("nav.support.issue"), - "https://github.com/Infisical/infisical-cli/issues" - ], - [ - , - t("nav.support.email"), - "mailto:support@infisical.com" - ] -]; - -export interface ICurrentOrg { - name: string; -} - -export interface IUser { - firstName: string; - lastName: string; - email: string; -} - -/** - * This is the navigation bar in the main app. - * It has two main components: support options and user menu (inlcudes billing, logout, org/user settings) - * @returns NavBar - */ -export const Navbar = () => { - const router = useRouter(); - const { subscription } = useSubscription(); - - const { currentOrg, orgs } = useOrganization(); - const { user } = useUser(); - - const logout = useLogoutUser(); - - const { t } = useTranslation(); - - // remove this memo - const supportOptionsList = useMemo(() => supportOptions(t), [t]); - - const closeApp = async () => { - try { - console.log("Logging out...") - await logout.mutateAsync(); - localStorage.removeItem("protectedKey"); - localStorage.removeItem("protectedKeyIV"); - localStorage.removeItem("protectedKeyTag"); - localStorage.removeItem("publicKey"); - localStorage.removeItem("encryptedPrivateKey"); - localStorage.removeItem("iv"); - localStorage.removeItem("tag"); - localStorage.removeItem("PRIVATE_KEY"); - localStorage.removeItem("orgData.id"); - localStorage.removeItem("projectData.id"); - router.push("/login"); - } catch (error) { - console.error(error); - } - }; - - function formatPlanSlug(slug: string) { - return slug - .replace(/(\b[a-z])/g, match => match.toUpperCase()) - .replace(/-/g, " "); - } - - const calculateRemainingDays = (date: number) => { - const now = new Date(); - const endDate = new Date(date * 1000); - - const differenceInTime = endDate.getTime() - now.getTime(); - const differenceInDays = Math.ceil(differenceInTime / (1000 * 3600 * 24)); - - return differenceInDays; - } - - const formatDate = (date: number) => { - const endDate = new Date(date * 1000); - const day: number = endDate.getDate(); - const month: number = endDate.getMonth() + 1; - const year: number = endDate.getFullYear(); - - const formattedDate: string = `${day}/${month}/${year}`; - const remainingDays: number = calculateRemainingDays(date); - - return { - formattedDate, - remainingDays - }; - } - - return ( -
-
-
-
- logo -
- - Infisical - -
-
- - - Docs - - -
- - - -
- - - {supportOptionsList.map(([icon, text, url]) => ( - -
- {icon} -
{text}
-
-
- ))} -
-
-
- -
- - {user?.firstName} {user?.lastName} - - -
- - -
-
- {t("nav.user.signed-in-as")} -
-
null} - role="button" - tabIndex={0} - onClick={() => router.push(`/settings/personal/${router.query.id}`)} - className="mx-1 my-1 flex cursor-pointer flex-row items-center rounded-md px-1 hover:bg-white/5" - > -
- {user?.firstName?.charAt(0)} -
-
-
-

- {" "} - {user?.firstName} {user?.lastName} -

-

{user?.email}

-
- -
-
-
-
-
- {t("nav.user.current-organization")} -
-
null} - role="button" - tabIndex={0} - onClick={() => router.push(`/settings/org/${router.query.id}`)} - className="mt-2 flex cursor-pointer flex-row items-center rounded-md px-2 py-1 hover:bg-white/5" - > -
- {currentOrg?.name?.charAt(0)} -
-
-

{currentOrg?.name}

- -
-
- {subscription && subscription.slug !== null && ( - - )} - -
- {orgs && orgs?.length > 1 && ( -
-
- {t("nav.user.other-organizations")} -
-
- {orgs - ?.filter((org: { _id: string }) => org._id !== currentOrg?._id) - .map((org: { _id: string; name: string }) => ( -
null} - role="button" - tabIndex={0} - key={guidGenerator()} - onClick={() => { - localStorage.setItem("orgData.id", org._id); - router.reload(); - }} - className="flex w-full cursor-pointer flex-row items-center justify-start rounded-md p-1.5 hover:bg-white/5" - > -
- {org.name.charAt(0)} -
-
-

{org.name}

-
-
- ))} -
-
- )} -
- - {({ active }) => ( - - )} - -
-
-
-
-
-
- {subscription && subscription.status === "trialing" && subscription.trial_end && ( -
-

- {`Currently trialing the ${formatPlanSlug(subscription.slug)} plan until ${formatDate(subscription.trial_end).formattedDate} - ${formatDate(subscription.trial_end).remainingDays} day(s) left. `} - Add a card to avoid being downgraded to the Starter plan afterward → -

-
- )} -
- ); -}; \ No newline at end of file diff --git a/frontend/src/layouts/AppLayout/components/NavBar/index.tsx b/frontend/src/layouts/AppLayout/components/NavBar/index.tsx deleted file mode 100644 index 29a826d1a..000000000 --- a/frontend/src/layouts/AppLayout/components/NavBar/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { Navbar } from "./NavBar"; diff --git a/frontend/src/pages/org/[id]/overview/index.tsx b/frontend/src/pages/org/[id]/overview/index.tsx index d7512a168..cc086937c 100644 --- a/frontend/src/pages/org/[id]/overview/index.tsx +++ b/frontend/src/pages/org/[id]/overview/index.tsx @@ -289,7 +289,7 @@ export default function Organization() { )} -
+ {((new Date()).getTime() - (new Date(user?.createdAt)).getTime()) < 30 * 24 * 60 * 60 * 1000 &&

Onboarding Guide

{learningItem({ text: "Watch a video about Infisical", @@ -300,7 +300,7 @@ export default function Organization() { userAction: "intro_cta_clicked", link: "https://www.youtube.com/watch?v=PK23097-25I" })} - {learningItem({ + {workspaces.length !== 0 && learningItem({ text: "Add your secrets", subText: "Click to see example secrets, and add your own.", complete: hasUserPushedSecrets, @@ -309,7 +309,7 @@ export default function Organization() { userAction: "first_time_secrets_pushed", link: `/project/${workspaces[0]?._id}/secrets` })} -
+ {workspaces.length !== 0 &&
@@ -331,8 +331,8 @@ export default function Organization() {
{false &&
} -
- {learningItem({ +
} + {workspaces.length !== 0 && learningItem({ text: "Integrate Infisical with your infrastructure", subText: "Connect Infisical to various 3rd party services and platforms.", complete: false, @@ -346,7 +346,7 @@ export default function Organization() { complete: usersInOrg, icon: faUserPlus, time: "2 min", - link: `/settings/org/${router.query.id}?invite` + link: `/org/${router.query.id}/members?action=invite` })} {learningItem({ text: "Join Infisical Slack", @@ -357,15 +357,7 @@ export default function Organization() { userAction: "slack_cta_clicked", link: "https://join.slack.com/t/infisical-users/shared_invite/zt-1ye0tm8ab-899qZ6ZbpfESuo6TEikyOQ" })} - {/*
- {workspaces.map(workspace =>
-
{workspace.name}
- -
Explore
- -
)} -
*/} -
+
}

Explore More

diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx index d5255043b..3caad28c5 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx @@ -43,7 +43,7 @@ export const CurrentPlanSection = () => { } return ( -
+

Current Usage

diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/PreviewSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/PreviewSection.tsx index 23a4be24d..e1a39ca06 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/PreviewSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/PreviewSection.tsx @@ -45,7 +45,7 @@ export const PreviewSection = () => { return (
{!isSubscriptionLoading && subscription?.slug !== "enterprise" && subscription?.slug !== "pro" && subscription?.slug !== "pro-annual" && ( -
+

Become Infisical

Unlimited members, projects, RBAC, smart alerts, and so much more

diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx index 61204eb3b..e763691d5 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx @@ -63,7 +63,7 @@ export const CompanyNameSection = () => { return (

Business name diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx index 2e9ba649a..441cb9cb4 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx @@ -64,7 +64,7 @@ export const InvoiceEmailSection = () => { return (

Invoice email recipient diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsSection.tsx index 30af879e3..7f566c5f3 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsSection.tsx @@ -26,7 +26,7 @@ export const PmtMethodsSection = () => { } return ( -
+

Payment Methods diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDSection.tsx index b918205e6..198e02f62 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDSection.tsx @@ -14,7 +14,7 @@ export const TaxIDSection = () => { ] as const); return ( -
+

Tax ID diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/BillingReceiptsTab.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/BillingReceiptsTab.tsx index 574435afc..e6b75a0cb 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/BillingReceiptsTab.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/BillingReceiptsTab.tsx @@ -2,7 +2,7 @@ import { InvoicesTable } from "./InvoicesTable"; export const BillingReceiptsTab = () => { return ( -
+

Invoices

diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingTabGroup/BillingTabGroup.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingTabGroup/BillingTabGroup.tsx index a87b0de79..417f06165 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingTabGroup/BillingTabGroup.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingTabGroup/BillingTabGroup.tsx @@ -14,7 +14,7 @@ const tabs = [ export const BillingTabGroup = () => { return ( - + {tabs.map((tab) => ( {({ selected }) => (