Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: disable agent in itar environment

Brad Barbin17dd42b2e09d
diff --git a/apps/erp/app/components/AvatarMenu.tsx b/apps/erp/app/components/AvatarMenu.tsx
index a7e73b03de..a6ba78e808 100644
--- a/apps/erp/app/components/AvatarMenu.tsx
+++ b/apps/erp/app/components/AvatarMenu.tsx
@@ -1,4 +1,4 @@
-import { ITAR_ENVIRONMENT } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT } from "@carbon/auth";
import {
DropdownMenu,
DropdownMenuContent,
@@ -198,7 +198,7 @@ const AvatarMenu = () => {
</DropdownMenuSub>
<DropdownMenuSeparator />
- {ITAR_ENVIRONMENT && (
+ {CONTROLLED_ENVIRONMENT && (
<DropdownMenuItem onClick={itarDisclosure.onOpen}>
<DropdownMenuIcon icon={<LuShieldCheck />} />
About
@@ -214,7 +214,7 @@ const AvatarMenu = () => {
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
- {ITAR_ENVIRONMENT && <ItarDisclosure disclosure={itarDisclosure} />}
+ {CONTROLLED_ENVIRONMENT && <ItarDisclosure disclosure={itarDisclosure} />}
</>
);
};
diff --git a/apps/erp/app/components/Layout/Topbar/Topbar.tsx b/apps/erp/app/components/Layout/Topbar/Topbar.tsx
index c389910b1a..c60d1cbf08 100644
--- a/apps/erp/app/components/Layout/Topbar/Topbar.tsx
+++ b/apps/erp/app/components/Layout/Topbar/Topbar.tsx
@@ -1,4 +1,4 @@
-import { ITAR_ENVIRONMENT } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT } from "@carbon/auth";
import { HStack } from "@carbon/react";
import { Agent } from "~/components/Agent/Agent.ee";
import { usePermissions, useUser } from "~/hooks";
@@ -16,7 +16,7 @@ const Topbar = () => {
const notificationsKey = `${user.id}:${user.company.id}`;
const { isInternal } = useFlags();
- const canAccessAgent = isInternal && !ITAR_ENVIRONMENT;
+ const canAccessAgent = isInternal && !CONTROLLED_ENVIRONMENT;
return (
<div className="h-[49px] grid grid-cols-[1fr_200px_1fr] bg-background text-foreground px-4 top-0 sticky z-10 items-center">
diff --git a/apps/erp/app/root.tsx b/apps/erp/app/root.tsx
index 0eb59e4280..84c11e8449 100644
--- a/apps/erp/app/root.tsx
+++ b/apps/erp/app/root.tsx
@@ -53,7 +53,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const {
CARBON_EDITION,
CLOUDFLARE_TURNSTILE_SITE_KEY,
- ITAR_ENVIRONMENT,
+ CONTROLLED_ENVIRONMENT,
POSTHOG_API_HOST,
POSTHOG_PROJECT_PUBLIC_KEY,
SUPABASE_URL,
@@ -70,7 +70,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
env: {
CARBON_EDITION,
CLOUDFLARE_TURNSTILE_SITE_KEY,
- ITAR_ENVIRONMENT,
+ CONTROLLED_ENVIRONMENT,
POSTHOG_API_HOST,
POSTHOG_PROJECT_PUBLIC_KEY,
SUPABASE_URL,
diff --git a/apps/erp/app/routes/_public+/_layout.tsx b/apps/erp/app/routes/_public+/_layout.tsx
index 9d87fe6e59..db099d202b 100644
--- a/apps/erp/app/routes/_public+/_layout.tsx
+++ b/apps/erp/app/routes/_public+/_layout.tsx
@@ -1,6 +1,6 @@
import { Outlet } from "@remix-run/react";
-import { ITAR_ENVIRONMENT } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT } from "@carbon/auth";
import { cn, Heading } from "@carbon/react";
export default function PublicRoute() {
@@ -12,7 +12,7 @@ export default function PublicRoute() {
alt="Carbon Logo"
className={cn(
"max-w-[240px] mb-3 dark:hidden z-50",
- ITAR_ENVIRONMENT && "grayscale"
+ CONTROLLED_ENVIRONMENT && "grayscale"
)}
/>
<img
@@ -20,7 +20,7 @@ export default function PublicRoute() {
alt="Carbon Logo"
className={cn(
"max-w-[240px] mb-3 dark:block hidden z-50",
- ITAR_ENVIRONMENT && "grayscale"
+ CONTROLLED_ENVIRONMENT && "grayscale"
)}
/>
diff --git a/apps/erp/app/routes/_public+/login.tsx b/apps/erp/app/routes/_public+/login.tsx
index b34c7674f3..cded6c46a1 100644
--- a/apps/erp/app/routes/_public+/login.tsx
+++ b/apps/erp/app/routes/_public+/login.tsx
@@ -4,8 +4,8 @@ import {
CarbonEdition,
CLOUDFLARE_TURNSTILE_SECRET_KEY,
CLOUDFLARE_TURNSTILE_SITE_KEY,
+ CONTROLLED_ENVIRONMENT,
error,
- ITAR_ENVIRONMENT,
magicLinkValidator,
} from "@carbon/auth";
import { sendMagicLink, verifyAuthSession } from "@carbon/auth/auth.server";
@@ -191,7 +191,7 @@ export default function LoginRoute() {
<>
<div className="flex justify-center mb-4">
<img
- src={ITAR_ENVIRONMENT ? "/flag.png" : "/carbon-logo-mark.svg"}
+ src={CONTROLLED_ENVIRONMENT ? "/flag.png" : "/carbon-logo-mark.svg"}
alt="Carbon Logo"
className="w-36"
/>
@@ -297,7 +297,7 @@ export default function LoginRoute() {
{mode !== "verify" && fetcher.data?.success !== true && (
<p>Login or create a new account</p>
)}
- {ITAR_ENVIRONMENT && <ItarLoginDisclaimer />}
+ {CONTROLLED_ENVIRONMENT && <ItarLoginDisclaimer />}
{CarbonEdition === Edition.Cloud && (
<p>
By signing in, you agree to the{" "}
diff --git a/apps/erp/app/routes/_public+/magic-link.tsx b/apps/erp/app/routes/_public+/magic-link.tsx
index 3fa7e305f9..a0177b9041 100644
--- a/apps/erp/app/routes/_public+/magic-link.tsx
+++ b/apps/erp/app/routes/_public+/magic-link.tsx
@@ -1,4 +1,4 @@
-import { ITAR_ENVIRONMENT, SUPABASE_URL } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT, SUPABASE_URL } from "@carbon/auth";
import { Button, Heading, VStack } from "@carbon/react";
import { useNavigate, useSearchParams } from "@remix-run/react";
@@ -20,7 +20,7 @@ export default function ConfirmMagicLink() {
<>
<div className="flex justify-center mb-4">
<img
- src={ITAR_ENVIRONMENT ? "/flag.png" : "/carbon-logo-mark.svg"}
+ src={CONTROLLED_ENVIRONMENT ? "/flag.png" : "/carbon-logo-mark.svg"}
alt="Carbon Logo"
className="w-36"
/>
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index 03a3776613..33515cccc1 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -1,8 +1,8 @@
import {
CarbonEdition,
CarbonProvider,
+ CONTROLLED_ENVIRONMENT,
getCarbon,
- ITAR_ENVIRONMENT,
} from "@carbon/auth";
import {
destroyAuthSession,
@@ -152,7 +152,7 @@ export default function AuthenticatedRoute() {
return (
<div className="h-[100dvh] flex flex-col">
- {user?.acknowledgedITAR === false && ITAR_ENVIRONMENT ? (
+ {user?.acknowledgedITAR === false && CONTROLLED_ENVIRONMENT ? (
<ItarPopup
acknowledgeAction={path.to.acknowledge}
logoutAction={path.to.logout}
diff --git a/apps/erp/app/routes/x+/settings+/billing.tsx b/apps/erp/app/routes/x+/settings+/billing.tsx
index 4ecac0dbf6..e8ae635bd2 100644
--- a/apps/erp/app/routes/x+/settings+/billing.tsx
+++ b/apps/erp/app/routes/x+/settings+/billing.tsx
@@ -113,7 +113,17 @@ export async function action({ request }: ActionFunctionArgs) {
if (intent === "billing-portal") {
try {
- const billingPortalUrl = await getBillingPortalRedirectUrl({ companyId });
+ const plans = await client
+ .from("plan")
+ .select("stripePriceId")
+ .eq("userBasedPricing", true);
+
+ const priceIds = plans.data?.map((plan) => plan.stripePriceId);
+
+ const billingPortalUrl = await getBillingPortalRedirectUrl({
+ companyId,
+ priceIds,
+ });
return redirect(billingPortalUrl, 301);
} catch (err) {
console.error("Failed to get billing portal URL:", err);
diff --git a/apps/mes/app/components/AppSidebar.tsx b/apps/mes/app/components/AppSidebar.tsx
index acfed3d6be..81b6900eba 100644
--- a/apps/mes/app/components/AppSidebar.tsx
+++ b/apps/mes/app/components/AppSidebar.tsx
@@ -15,7 +15,7 @@ import {
LuUser,
} from "react-icons/lu";
-import { ITAR_ENVIRONMENT, type Company } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT, type Company } from "@carbon/auth";
import {
Avatar,
cn,
@@ -398,7 +398,7 @@ export function UserNav({
</div>
</DropdownMenuItem>
<DropdownMenuSeparator />
- {ITAR_ENVIRONMENT && (
+ {CONTROLLED_ENVIRONMENT && (
<DropdownMenuItem onClick={itarDisclosure.onOpen}>
<DropdownMenuIcon icon={<LuShieldCheck />} />
About
@@ -415,7 +415,7 @@ export function UserNav({
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
- {ITAR_ENVIRONMENT && <ItarDisclosure disclosure={itarDisclosure} />}
+ {CONTROLLED_ENVIRONMENT && <ItarDisclosure disclosure={itarDisclosure} />}
</SidebarMenu>
);
}
diff --git a/apps/mes/app/root.tsx b/apps/mes/app/root.tsx
index 28908cc2b6..d0d7d44e60 100644
--- a/apps/mes/app/root.tsx
+++ b/apps/mes/app/root.tsx
@@ -51,7 +51,7 @@ export const meta: MetaFunction = () => {
export async function loader({ request }: LoaderFunctionArgs) {
const {
CARBON_EDITION,
- ITAR_ENVIRONMENT,
+ CONTROLLED_ENVIRONMENT,
POSTHOG_API_HOST,
POSTHOG_PROJECT_PUBLIC_KEY,
SUPABASE_URL,
@@ -66,7 +66,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
{
env: {
CARBON_EDITION,
- ITAR_ENVIRONMENT,
+ CONTROLLED_ENVIRONMENT,
POSTHOG_API_HOST,
POSTHOG_PROJECT_PUBLIC_KEY,
SUPABASE_URL,
diff --git a/apps/mes/app/routes/_public+/_layout.tsx b/apps/mes/app/routes/_public+/_layout.tsx
index fddfcaac30..8ad5b7ee87 100644
--- a/apps/mes/app/routes/_public+/_layout.tsx
+++ b/apps/mes/app/routes/_public+/_layout.tsx
@@ -1,6 +1,6 @@
import { Outlet } from "@remix-run/react";
-import { ITAR_ENVIRONMENT } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT } from "@carbon/auth";
import { cn, Heading } from "@carbon/react";
export default function PublicRoute() {
@@ -12,7 +12,7 @@ export default function PublicRoute() {
alt="Carbon Logo"
className={cn(
"max-w-[240px] mb-3 dark:hidden z-50",
- ITAR_ENVIRONMENT && "grayscale"
+ CONTROLLED_ENVIRONMENT && "grayscale"
)}
/>
<img
@@ -20,7 +20,7 @@ export default function PublicRoute() {
alt="Carbon Logo"
className={cn(
"max-w-[240px] mb-3 dark:block hidden z-50",
- ITAR_ENVIRONMENT && "grayscale"
+ CONTROLLED_ENVIRONMENT && "grayscale"
)}
/>
diff --git a/apps/mes/app/routes/_public+/login.tsx b/apps/mes/app/routes/_public+/login.tsx
index 977a2408f1..e9f28c9210 100644
--- a/apps/mes/app/routes/_public+/login.tsx
+++ b/apps/mes/app/routes/_public+/login.tsx
@@ -2,8 +2,8 @@ import {
assertIsPost,
carbonClient,
CarbonEdition,
+ CONTROLLED_ENVIRONMENT,
error,
- ITAR_ENVIRONMENT,
magicLinkValidator,
} from "@carbon/auth";
import { sendMagicLink, verifyAuthSession } from "@carbon/auth/auth.server";
@@ -127,7 +127,7 @@ export default function LoginRoute() {
<>
<div className="flex justify-center mb-4">
<img
- src={ITAR_ENVIRONMENT ? "/flag.png" : "/carbon-logo-mark.svg"}
+ src={CONTROLLED_ENVIRONMENT ? "/flag.png" : "/carbon-logo-mark.svg"}
alt="Carbon Logo"
className="w-36"
/>
@@ -187,7 +187,7 @@ export default function LoginRoute() {
)}
</div>
<div className="flex flex-col gap-4 text-sm text-center text-balance text-muted-foreground w-[380px]">
- {ITAR_ENVIRONMENT && <ItarLoginDisclaimer />}
+ {CONTROLLED_ENVIRONMENT && <ItarLoginDisclaimer />}
{CarbonEdition === Edition.Cloud && (
<p>
By signing in, you agree to the{" "}
diff --git a/apps/mes/app/routes/x+/_layout.tsx b/apps/mes/app/routes/x+/_layout.tsx
index 0b08f4837b..a537abae52 100644
--- a/apps/mes/app/routes/x+/_layout.tsx
+++ b/apps/mes/app/routes/x+/_layout.tsx
@@ -1,10 +1,10 @@
import {
CarbonEdition,
CarbonProvider,
+ CONTROLLED_ENVIRONMENT,
getCarbon,
getCompanies,
getUser,
- ITAR_ENVIRONMENT,
} from "@carbon/auth";
import {
destroyAuthSession,
@@ -143,7 +143,7 @@ export default function AuthenticatedRoute() {
return (
<div className="h-screen w-screen overflow-y-auto md:overflow-hidden">
- {user?.acknowledgedITAR === false && ITAR_ENVIRONMENT ? (
+ {user?.acknowledgedITAR === false && CONTROLLED_ENVIRONMENT ? (
<ItarPopup
acknowledgeAction={path.to.acknowledge}
logoutAction={path.to.logout}
diff --git a/packages/auth/src/config/env.ts b/packages/auth/src/config/env.ts
index 85de73efdb..78fe241014 100644
--- a/packages/auth/src/config/env.ts
+++ b/packages/auth/src/config/env.ts
@@ -5,7 +5,7 @@ declare global {
env: {
CARBON_EDITION: string;
CLOUDFLARE_TURNSTILE_SITE_KEY: string;
- ITAR_ENVIRONMENT: string;
+ CONTROLLED_ENVIRONMENT: string;
POSTHOG_API_HOST: string;
POSTHOG_PROJECT_PUBLIC_KEY: string;
SUPABASE_URL: string;
@@ -107,12 +107,12 @@ export const EXCHANGE_RATES_API_KEY = getEnv("EXCHANGE_RATES_API_KEY", {
isSecret: true,
});
-const itarEnvironment = getEnv("ITAR_ENVIRONMENT", {
+const itarEnvironment = getEnv("CONTROLLED_ENVIRONMENT", {
isRequired: false,
isSecret: false,
});
-export const ITAR_ENVIRONMENT = parseBoolean(itarEnvironment, false);
+export const CONTROLLED_ENVIRONMENT = parseBoolean(itarEnvironment, false);
export const NOVU_APPLICATION_ID = getEnv("NOVU_APPLICATION_ID", {
isRequired: false,
@@ -201,7 +201,7 @@ export const CLOUDFLARE_TURNSTILE_SECRET_KEY = getEnv(
export function getAppUrl() {
if (VERCEL_ENV === "production" || NODE_ENV === "production") {
- return ITAR_ENVIRONMENT
+ return CONTROLLED_ENVIRONMENT
? "https://itar.carbon.ms"
: "https://app.carbon.ms";
}
@@ -215,7 +215,7 @@ export function getAppUrl() {
export function getMESUrl() {
if (VERCEL_ENV === "production" || NODE_ENV === "production") {
- return ITAR_ENVIRONMENT
+ return CONTROLLED_ENVIRONMENT
? "https://mes.itar.carbon.ms"
: "https://mes.carbon.ms";
}
@@ -230,7 +230,7 @@ export function getMESUrl() {
export function getBrowserEnv() {
return {
CARBON_EDITION,
- ITAR_ENVIRONMENT,
+ CONTROLLED_ENVIRONMENT,
SUPABASE_URL,
SUPABASE_ANON_KEY,
POSTHOG_API_HOST,
diff --git a/packages/ee/src/slack/config.tsx b/packages/ee/src/slack/config.tsx
index 2e9a9e0ac8..8af6882000 100644
--- a/packages/ee/src/slack/config.tsx
+++ b/packages/ee/src/slack/config.tsx
@@ -1,4 +1,4 @@
-import { ITAR_ENVIRONMENT } from "@carbon/auth";
+import { CONTROLLED_ENVIRONMENT } from "@carbon/auth";
import { z } from "zod";
import type { IntegrationConfig } from "../types";
@@ -6,7 +6,7 @@ export const Slack: IntegrationConfig = {
name: "Slack",
id: "slack",
category: "Assistant",
- active: ITAR_ENVIRONMENT === false,
+ active: CONTROLLED_ENVIRONMENT === false,
logo: Logo,
shortDescription: "Use the Carbon Assistant in your Slack workspace.",
description:
diff --git a/packages/stripe/src/stripe.server.ts b/packages/stripe/src/stripe.server.ts
index 7c93ab5c23..35658b53fb 100644
--- a/packages/stripe/src/stripe.server.ts
+++ b/packages/stripe/src/stripe.server.ts
@@ -266,8 +266,10 @@ export async function getCheckoutUrl({
export async function getBillingPortalRedirectUrl({
companyId,
+ priceIds,
}: {
companyId: string;
+ priceIds?: string[];
}) {
if (!stripe) {
throw new Error("Stripe is not initialized");
@@ -285,6 +287,7 @@ export async function getBillingPortalRedirectUrl({
const portalSession = await stripe.billingPortal.sessions.create({
customer: customerId,
return_url: `${getAppUrl()}/x/settings/company`,
+ configuration: "",
});
if (!portalSession.url) {
diff --git a/scripts/stripe-configs.ts b/scripts/stripe-configs.ts
new file mode 100644
index 0000000000..e69de29bb2