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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat(settings): open Settings → Demo Data to customers, not just internal staff
aashu12b7f5409fc2
diff --git a/apps/erp/app/modules/settings/ui/useSettingsSubmodules.tsx b/apps/erp/app/modules/settings/ui/useSettingsSubmodules.tsxindex 92b8e6aa13..8960806484 100644--- a/apps/erp/app/modules/settings/ui/useSettingsSubmodules.tsx+++ b/apps/erp/app/modules/settings/ui/useSettingsSubmodules.tsx@@ -35,11 +35,6 @@ import { path } from "~/utils/path";const internalOnlyRoutes = new Set<string>([path.to.companies]);-// Demo Data (template seeding) stays internal / local-dev only — mirrors-// `canAccessBackups`. Backups is now a Business/Enterprise feature gated-// separately below (with the same internal/local-dev escape hatch).-const localOrInternalRoutes = new Set<string>([path.to.demoData]);-export default function useSettingsSubmodules() {const { t } = useLingui();const permissions = usePermissions();@@ -252,8 +247,6 @@ export default function useSettingsSubmodules() {if (route.requiresControlledEnvironment && !isControlledEnvironment)return false;if (!isInternal && internalOnlyRoutes.has(route.to)) return false;- if (!isInternal && !isLocalDev && localOrInternalRoutes.has(route.to))- return false;// Backups: visible to Business/Enterprise, internal staff, or local dev.if (route.to === path.to.backups &&diff --git a/apps/erp/app/routes/x+/settings+/demo-data.tsx b/apps/erp/app/routes/x+/settings+/demo-data.tsxindex e897fda1ac..8f73b9f161 100644--- a/apps/erp/app/routes/x+/settings+/demo-data.tsx+++ b/apps/erp/app/routes/x+/settings+/demo-data.tsx@@ -8,13 +8,7 @@ import { msg } from "@lingui/core/macro";import { Trans } from "@lingui/react/macro";import { useEffect, useMemo, useRef, useState } from "react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";-import {- data,- redirect,- useFetcher,- useLoaderData,- useRevalidator-} from "react-router";+import { data, useFetcher, useLoaderData, useRevalidator } from "react-router";import type { CompanyTemplateRun } from "~/modules/settings";import { getCompanyTemplateRun } from "~/modules/settings";import { purgeCorruptedRows } from "~/modules/settings/backups.server";@@ -27,7 +21,6 @@ import {TemplateCards,TemplateReviewRow} from "~/modules/settings/ui/DemoData";-import { canAccessBackups } from "~/utils/backups";import { path } from "~/utils/path";export const handle = {@@ -35,20 +28,10 @@ export const handle = {to: path.to.demoData};-function requireDemoDataAccess(email: string | null) {- // Same gate as Backups: this replaces a company's data wholesale and carries- // the same unhardened multi-tenant caveats, so it stays internal-only in real- // deployments and open to everyone on a local dev stack.- if (!canAccessBackups(email)) {- throw redirect(path.to.settings);- }-}-export async function loader({ request }: LoaderFunctionArgs) {- const { client, companyId, email } = await requirePermissions(request, {+ const { client, companyId } = await requirePermissions(request, {update: "settings"});- requireDemoDataAccess(email);const run = await getCompanyTemplateRun(client, companyId);@@ -65,13 +48,9 @@ export async function loader({ request }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);- const { client, companyId, userId, email } = await requirePermissions(- request,- {- update: "settings"- }- );- requireDemoDataAccess(email);+ const { client, companyId, userId } = await requirePermissions(request, {+ update: "settings"+ });const formData = await request.formData();const intent = formData.get("intent");diff --git a/apps/erp/app/utils/backups.ts b/apps/erp/app/utils/backups.tsindex 86853d8836..9ab9e74355 100644--- a/apps/erp/app/utils/backups.ts+++ b/apps/erp/app/utils/backups.ts@@ -6,8 +6,8 @@ import { isInternalEmail } from "@carbon/utils";* Business/Enterprise feature — the authoritative gate is* `canManageBackups` (`~/modules/settings/backups.server`), which is* `canAccessBackups(email) || companyHasFeature(BACKUPS)`. This helper stays a- * pure, browser-safe predicate (no plan/DB read) so it can back Demo Data — which- * remains internal-only — and be the escape hatch inside `canManageBackups`.+ * pure, browser-safe predicate (no plan/DB read) so it can be the escape hatch+ * inside `canManageBackups`.*/export function canAccessBackups(email: string | null | undefined): boolean {return IS_LOCAL_DEV || isInternalEmail(email);diff --git a/docs/content/docs/platform/demo-data.mdx b/docs/content/docs/platform/demo-data.mdxindex 67c5e37d7c..196e2653de 100644--- a/docs/content/docs/platform/demo-data.mdx+++ b/docs/content/docs/platform/demo-data.mdx@@ -72,14 +72,14 @@ The same templates power onboarding. When anyone creates a new company, the dataChoosing a template then asks **"Which best describes your company?"** and seeds the matching industry. See [Getting started](/docs/reference/onboarding) for the rest of the wizard.<Callout type="info" title="Who can see the Demo Data page">-Demo Data sits behind the same gate as Backups, since it replaces a company's data wholesale. On production deployments it is currently limited to Carbon staff; on a local development stack it is open to everyone.+Anyone with permission to update settings can open Settings → Demo Data.</Callout><AgentContext>## Troubleshooting### The Demo Data page isn't in my Settings menu-On production deployments Demo Data is visible to internal Carbon staff accounts only; on a local development stack it is open to everyone. Its absence for a regular customer account is expected — same gate as Backups.+The page needs permission to update settings. Ask an admin to grant it to your role.### I applied a template and want my old data backUse "Revert" on the "Demo data applied" card. Carbon saved a copy of your data immediately before applying, and the card stays open until you choose Keep or Revert — reverting puts back exactly what was there before.