From cbb29b68788a1fbcbdf2eae30aca9ce4007af844 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Tue, 12 Mar 2024 11:14:04 -0400 Subject: [PATCH] check if porter operator in component rather than outside (#4399) --- .../porter/PorterOperatorComponent.tsx | 8 +++++- .../modals/PreflightChecksModal.tsx | 27 ++++++++----------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/dashboard/src/components/porter/PorterOperatorComponent.tsx b/dashboard/src/components/porter/PorterOperatorComponent.tsx index 3282ac36b3..1248bc7fb5 100644 --- a/dashboard/src/components/porter/PorterOperatorComponent.tsx +++ b/dashboard/src/components/porter/PorterOperatorComponent.tsx @@ -1,8 +1,9 @@ -import React from "react"; +import React, { useContext } from "react"; import styled from "styled-components"; import Text from "components/porter/Text"; +import { Context } from "shared/Context"; import info from "assets/information-circle-contained.svg"; import Container from "./Container"; @@ -13,6 +14,11 @@ type Props = { children: JSX.Element; }; const PorterOperatorComponent: React.FC = ({ children }) => { + const { user } = useContext(Context); + + if (!user?.email?.endsWith("@porter.run")) { + return null; + } return ( diff --git a/dashboard/src/main/home/infrastructure-dashboard/modals/PreflightChecksModal.tsx b/dashboard/src/main/home/infrastructure-dashboard/modals/PreflightChecksModal.tsx index 12eacd0378..135226da3d 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/modals/PreflightChecksModal.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/modals/PreflightChecksModal.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from "react"; +import React from "react"; import styled from "styled-components"; import { match } from "ts-pattern"; @@ -15,8 +15,6 @@ import StatusDot from "components/porter/StatusDot"; import Text from "components/porter/Text"; import { type ClientPreflightCheck } from "lib/clusters/types"; -import { Context } from "shared/Context"; - import { useClusterFormContext } from "../ClusterFormContextProvider"; import ResolutionStepsModalContents from "./help/preflight/ResolutionStepsModalContents"; @@ -89,7 +87,6 @@ const PreflightChecksModal: React.FC = ({ onClose, preflightChecks, }) => { - const { user } = useContext(Context); const { submitSkippingPreflightChecks } = useClusterFormContext(); return ( @@ -119,18 +116,16 @@ const PreflightChecksModal: React.FC = ({ > Talk to support - {user.email?.endsWith("@porter.run") && ( - - - - )} + + +