AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(workers): show the worker groups page to users who can't use it, with how to get it (#17151)
moaaz8611a90d4bda
diff --git a/packages/web/public/locales/de/translation.json b/packages/web/public/locales/de/translation.jsonindex 3b072198f1e..12458c22282 100644--- a/packages/web/public/locales/de/translation.json+++ b/packages/web/public/locales/de/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "Keine Trigger-Daten verfügbar","Trigger health information will appear here": "Gesundheitsinformationen werden hier angezeigt","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "Prüfen Sie die Gesundheit Ihrer Mitarbeiter","Upgrade to Dedicated Workers": "Upgrade auf dedizierte Arbeiter","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Ihre Automatisierungen laufen auf geteilten Arbeitnehmern, wo strenge Sandboxen zu jeder Ausführung einen Overhead hinzufügt. Dedizierte Arbeiter geben Ihnen Ihren eigenen Hinrichtungspool, der warm und bereit bleibt, so dass Ihre Automatisierungen viel schneller starten.",diff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.jsonindex d7f489b98f3..a05493b72f1 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "No trigger data available","Trigger health information will appear here": "Trigger health information will appear here","trigger status": "trigger status",- "Unlock worker groups": "Unlock worker groups",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "Set aside servers for specific projects or flows, so a busy project never slows down the rest.","Check the health of your workers": "Check the health of your workers","Upgrade to Dedicated Workers": "Upgrade to Dedicated Workers","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.",@@ -3709,5 +3707,17 @@"1 min ago": "1 min ago","{count} mins ago": "{count} mins ago","1 hour ago": "1 hour ago",- "{count} hours ago": "{count} hours ago"+ "{count} hours ago": "{count} hours ago",+ "Worker groups run on your own servers": "Worker groups run on your own servers",+ "Worker groups need the Enterprise edition": "Worker groups need the Enterprise edition",+ "Switch your Activepieces to the Enterprise edition to use them.": "Switch your Activepieces to the Enterprise edition to use them.",+ "How to switch": "How to switch",+ "Enterprise plan": "Enterprise plan",+ "Self-hosted": "Self-hosted",+ "Add your license key to use worker groups": "Add your license key to use worker groups",+ "Worker groups come with an Enterprise license. Add yours in Billing.": "Worker groups come with an Enterprise license. Add yours in Billing.",+ "Add license key": "Add license key",+ "Your license doesn’t include worker groups": "Your license doesn’t include worker groups",+ "Ask us to add them to your license, then follow the setup guide to start your first group.": "Ask us to add them to your license, then follow the setup guide to start your first group.",+ "Available on self-hosted Activepieces. Talk to sales to set it up.": "Available on self-hosted Activepieces. Talk to sales to set it up."}diff --git a/packages/web/public/locales/es/translation.json b/packages/web/public/locales/es/translation.jsonindex 22e2d25ab9a..82e60ee107e 100644--- a/packages/web/public/locales/es/translation.json+++ b/packages/web/public/locales/es/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "No hay datos de disparo disponibles","Trigger health information will appear here": "La información de salud del activador aparecerá aquí","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "Compruebe la salud de sus trabajadores","Upgrade to Dedicated Workers": "Actualizar a Trabajadores Dedicados","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Sus automatizaciones se ejecutan en trabajadores compartidos donde el sandboxing estricto añade sobrecarga a cada ejecución. Los trabajadores dedicados le dan su propia piscina de ejecución que permanece cálida y lista, para que sus automatizaciones comiencen mucho más rápido.",diff --git a/packages/web/public/locales/fr/translation.json b/packages/web/public/locales/fr/translation.jsonindex 40ca3d8b760..057e5768df7 100644--- a/packages/web/public/locales/fr/translation.json+++ b/packages/web/public/locales/fr/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "Aucune donnée de déclencheur disponible","Trigger health information will appear here": "Les informations sur la santé du déclencheur apparaîtront ici","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "Vérifiez la santé de vos employés","Upgrade to Dedicated Workers": "Mettre à niveau vers des employés dédiés","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Vos automatisations fonctionnent sur des employés partagés où la boxe à sable stricte ajoute des frais à chaque exécution. Des employés dévoués vous donnent votre propre bassin d'exécution qui reste chaud et prêt, afin que vos automatisations commencent beaucoup plus rapidement.",diff --git a/packages/web/public/locales/ja/translation.json b/packages/web/public/locales/ja/translation.jsonindex 88a77296300..3840f5b2b87 100644--- a/packages/web/public/locales/ja/translation.json+++ b/packages/web/public/locales/ja/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "利用可能なトリガーデータがありません","Trigger health information will appear here": "トリガーの健康情報がここに表示されます","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "労働者の健康状態を確認する","Upgrade to Dedicated Workers": "Dedicated Worker にアップグレード","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "自動化は共有ワーカー上で実行され、厳密なサンドボックス化によってすべての実行にオーバーヘッドが加わります。 専用のワーカーは、暖かく準備ができているあなた自身の実行プールを与えるので、自動化がはるかに速く始まります。",diff --git a/packages/web/public/locales/nl/translation.json b/packages/web/public/locales/nl/translation.jsonindex 59b7872d9ce..7c17fc0e0db 100644--- a/packages/web/public/locales/nl/translation.json+++ b/packages/web/public/locales/nl/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "Geen triggergegevens beschikbaar","Trigger health information will appear here": "Trigger gezondheidsinformatie verschijnt hier","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "Controleer de gezondheid van uw medewerkers","Upgrade to Dedicated Workers": "Upgrade naar toegewijde arbeiders","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Uw automatiseringen worden uitgevoerd op gedeelde medewerkers, waarbij strikte sandboxing overhead toevoegt aan elke executie. Speciale werknemers geven je eigen executiepoel die warm en klaar blijft, dus je automatiseringen beginnen veel sneller.",diff --git a/packages/web/public/locales/pt/translation.json b/packages/web/public/locales/pt/translation.jsonindex 40e22aafff1..1decc3dfc5e 100644--- a/packages/web/public/locales/pt/translation.json+++ b/packages/web/public/locales/pt/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "Sem dados de gatilho disponíveis","Trigger health information will appear here": "Disparar informações de saúde aparecerá aqui","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "Verifique a saúde de seus workers","Upgrade to Dedicated Workers": "Atualize para os Trabalhadores Dedicados","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Suas automações são executadas em funcionários compartilhados, onde a área restrita adiciona maior profundidade a cada execução. Trabalhadores dedicados lhe dão sua própria pool de execução que permanece quente e pronto, para que suas automações comecem muito mais rápido.",diff --git a/packages/web/public/locales/zh-TW/translation.json b/packages/web/public/locales/zh-TW/translation.jsonindex 280b9ffc4e1..773212b3197 100644--- a/packages/web/public/locales/zh-TW/translation.json+++ b/packages/web/public/locales/zh-TW/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "","Trigger health information will appear here": "","trigger status": "",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "","Upgrade to Dedicated Workers": "","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "",diff --git a/packages/web/public/locales/zh/translation.json b/packages/web/public/locales/zh/translation.jsonindex 4e27c01fdac..6f9ff21f696 100644--- a/packages/web/public/locales/zh/translation.json+++ b/packages/web/public/locales/zh/translation.json@@ -1617,8 +1617,6 @@"No trigger data available": "No trigger data available","Trigger health information will appear here": "Trigger health information will appear here","trigger status": "trigger status",- "Unlock worker groups": "",- "Set aside servers for specific projects or flows, so a busy project never slows down the rest.": "","Check the health of your workers": "Check the health of your workers","Upgrade to Dedicated Workers": "Upgrade to Dedicated Workers","Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.": "Your automations run on shared workers where strict sandboxing adds overhead to every execution. Dedicated workers give you your own execution pool that stays warm and ready, so your automations start much faster.",diff --git a/packages/web/src/app/components/locked-feature-guard.tsx b/packages/web/src/app/components/locked-feature-guard.tsxindex b55edb365a0..b8baf29c3b0 100644--- a/packages/web/src/app/components/locked-feature-guard.tsx+++ b/packages/web/src/app/components/locked-feature-guard.tsx@@ -34,8 +34,6 @@ export const LockedFeatureGuard = ({);};-export default LockedFeatureGuard;-type LockedFeatureGuardProps = {children: React.ReactNode;featureKey: FeatureKey;diff --git a/packages/web/src/app/components/project-settings/general/index.tsx b/packages/web/src/app/components/project-settings/general/index.tsxindex 6c56b53fe89..83c25c66193 100644--- a/packages/web/src/app/components/project-settings/general/index.tsx+++ b/packages/web/src/app/components/project-settings/general/index.tsx@@ -32,6 +32,7 @@ import {PopoverTrigger,} from '@/components/ui/popover';import { Switch } from '@/components/ui/switch';+import { workerGroupsLock } from '@/features/platform-admin';import { projectCollectionUtils } from '@/features/projects';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';@@ -212,7 +213,7 @@ export const GeneralSettings = ({ form }: GeneralSettingsProps) => {)}/>)}- {!platform.plan.workerGroupsEnabled &&+ {workerGroupsLock.reason({ edition, plan: platform.plan }) !== null &&platformRole === PlatformRole.ADMIN && (<FormFieldname="maxConcurrentJobs"diff --git a/packages/web/src/app/components/sidebar/platform/index.tsx b/packages/web/src/app/components/sidebar/platform/index.tsxindex b1d8b47949e..54783c543df 100644--- a/packages/web/src/app/components/sidebar/platform/index.tsx+++ b/packages/web/src/app/components/sidebar/platform/index.tsx@@ -26,6 +26,7 @@ import {SidebarMenu,} from '@/components/ui/sidebar-shadcn';import { PLATFORM_FEATURES } from '@/features/billing';+import { workerGroupsLock } from '@/features/platform-admin';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';@@ -203,7 +204,9 @@ export function PlatformNav() {{to: '/platform/workers/groups',label: t('Worker groups'),- locked: !platform.plan.workerGroupsEnabled,+ locked:+ workerGroupsLock.reason({ edition, plan: platform.plan }) !==+ null,},],},diff --git a/packages/web/src/app/routes/platform/infra/workers/index.tsx b/packages/web/src/app/routes/platform/infra/workers/index.tsxindex 28bb0b8273b..ac48f1cfc6d 100644--- a/packages/web/src/app/routes/platform/infra/workers/index.tsx+++ b/packages/web/src/app/routes/platform/infra/workers/index.tsx@@ -28,7 +28,6 @@ import {adminPageResources,adminSurface,} from '@/app/components/admin';-import LockedFeatureGuard from '@/app/components/locked-feature-guard';import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';import { Badge } from '@/components/ui/badge';import {@@ -37,7 +36,7 @@ import {TooltipTrigger,} from '@/components/ui/tooltip';import { RequestTrial } from '@/features/billing';-import { workersQueries } from '@/features/platform-admin';+import { workerGroupsLock, workersQueries } from '@/features/platform-admin';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';import { useTimeAgo } from '@/hooks/use-time-ago';@@ -45,6 +44,7 @@ import { cn } from '@/lib/utils';import { SandboxesPopover } from './sandboxes-popover';import { WorkerConfigsPopover } from './worker-configs-popover';+import { LockedWorkerGroups } from './worker-groups/locked-worker-groups';import { WorkerGroupsPage } from './worker-groups/worker-groups-page';export default function WorkersPage({ section }: WorkersPageProps) {@@ -56,18 +56,14 @@ export default function WorkersPage({ section }: WorkersPageProps) {const fleetType = workersData?.[0]?.type;if (section === 'worker-groups') {- return (- <LockedFeatureGuard- featureKey="DEDICATED_WORKERS"- locked={!platform.plan.workerGroupsEnabled}- lockTitle={t('Unlock worker groups')}- lockDescription={t(- 'Set aside servers for specific projects or flows, so a busy project never slows down the rest.',- )}- lockDocumentationUrl="https://www.activepieces.com/docs/install/configure-operate/worker-groups"- >- <WorkerGroupsPage />- </LockedFeatureGuard>+ const lockReason = workerGroupsLock.reason({+ edition,+ plan: platform.plan,+ });+ return lockReason === null ? (+ <WorkerGroupsPage />+ ) : (+ <LockedWorkerGroups reason={lockReason} />);}diff --git a/packages/web/src/app/routes/platform/infra/workers/worker-groups/locked-worker-groups.tsx b/packages/web/src/app/routes/platform/infra/workers/worker-groups/locked-worker-groups.tsxnew file mode 100644index 00000000000..6944fbdad93--- /dev/null+++ b/packages/web/src/app/routes/platform/infra/workers/worker-groups/locked-worker-groups.tsx@@ -0,0 +1,193 @@+import { PlatformAdminSurface } from '@activepieces/shared';+import { t } from 'i18next';+import { Gem, Server } from 'lucide-react';+import { Link } from 'react-router-dom';++import {+ AdminPage,+ AdminPageHeader,+ adminDocs,+ adminPageResources,+ adminSurface,+} from '@/app/components/admin';+import { sampleData } from '@/app/routes/platform/sample-data';+import { Badge } from '@/components/ui/badge';+import { Button } from '@/components/ui/button';+import { useOpenSales } from '@/features/billing';+import { WorkerGroupsLockReason } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';+import { cn } from '@/lib/utils';++import { GroupCards } from './group-cards';+import { DOCS_URL, SearchBox, modelSentence } from './parts';++export function LockedWorkerGroups({+ reason,+}: {+ reason: WorkerGroupsLockReason;+}) {+ const copy = lockCopy(reason);+ const openSales = useOpenSales({+ featureKey: 'DEDICATED_WORKERS',+ surface: PlatformAdminSurface.SAMPLE,+ });++ return (+ <AdminPage className="max-w-6xl">+ <AdminPageHeader+ title={t('Worker groups')}+ description={modelSentence()}+ resources={adminPageResources.workerGroups}+ />+ <div className={cn(adminSurface.card, '@container shrink-0 p-5')}>+ <div className="flex flex-col gap-4 @3xl:flex-row @3xl:items-center @3xl:gap-8">+ <div className="flex min-w-0 flex-1 flex-col gap-1">+ <div className="flex flex-wrap items-center gap-x-2 gap-y-1">+ <h2 className="text-base font-semibold tracking-tight text-gray-12">+ {copy.title}+ </h2>+ {reason === 'cloud' ? (+ <Badge variant="secondary">+ <Server />+ {t('Self-hosted')}+ </Badge>+ ) : (+ <Badge variant="info">+ <Gem />+ {t('Enterprise plan')}+ </Badge>+ )}+ </div>+ <p className="text-sm text-gray-11">{copy.description}</p>+ </div>+ <div className="flex shrink-0 flex-wrap items-center gap-2">+ <LockAction+ action={copy.secondary}+ variant="outline"+ openSales={openSales}+ />+ <LockAction+ action={copy.primary}+ variant="default"+ openSales={openSales}+ />+ </div>+ </div>+ </div>+ <div+ inert+ className="flex flex-col gap-6 opacity-50 grayscale mask-b-from-40%"+ >+ <SearchBox+ value=""+ onChange={() => undefined}+ placeholder={t('Where does a project or flow run?')}+ />+ <GroupCards+ overview={sampleData.workerGroupsOverview()}+ onOpen={() => undefined}+ onAdd={() => undefined}+ />+ </div>+ </AdminPage>+ );+}++function LockAction({+ action,+ variant,+ openSales,+}: {+ action: LockActionCopy;+ variant: 'default' | 'outline';+ openSales: () => void;+}) {+ if ('href' in action) {+ return (+ <Button variant={variant} asChild>+ <a+ {...adminControl(AdminControl.PLAN_SAMPLE_LINK)}+ href={action.href}+ target="_blank"+ rel="noopener noreferrer"+ >+ {action.label}+ </a>+ </Button>+ );+ }+ if ('to' in action) {+ return (+ <Button variant={variant} asChild>+ <Link {...adminControl(AdminControl.PLAN_SAMPLE_LINK)} to={action.to}>+ {action.label}+ </Link>+ </Button>+ );+ }+ return (+ <Button variant={variant} onClick={openSales}>+ {action.label}+ </Button>+ );+}++function lockCopy(reason: WorkerGroupsLockReason): LockCopy {+ const setupGuide = { label: t('Setup guide'), href: DOCS_URL };+ const talkToSales = { label: t('Talk to sales') };+ switch (reason) {+ case 'cloud':+ return {+ title: t('Worker groups run on your own servers'),+ description: t(+ 'Available on self-hosted Activepieces. Talk to sales to set it up.',+ ),+ secondary: setupGuide,+ primary: talkToSales,+ };+ case 'community':+ return {+ title: t('Worker groups need the Enterprise edition'),+ description: t(+ 'Switch your Activepieces to the Enterprise edition to use them.',+ ),+ secondary: {+ label: t('How to switch'),+ href: adminDocs.url(+ 'install/configure-operate/enterprise-license#billing-page-not-showing',+ ),+ },+ primary: talkToSales,+ };+ case 'no-license':+ return {+ title: t('Add your license key to use worker groups'),+ description: t(+ 'Worker groups come with an Enterprise license. Add yours in Billing.',+ ),+ secondary: talkToSales,+ primary: { label: t('Add license key'), to: '/platform/billing' },+ };+ case 'not-in-license':+ return {+ title: t('Your license doesn’t include worker groups'),+ description: t(+ 'Ask us to add them to your license, then follow the setup guide to start your first group.',+ ),+ secondary: setupGuide,+ primary: talkToSales,+ };+ }+}++type LockActionCopy =+ | { label: string; href: string }+ | { label: string; to: string }+ | { label: string };++type LockCopy = {+ title: string;+ description: string;+ secondary: LockActionCopy;+ primary: LockActionCopy;+};diff --git a/packages/web/src/app/routes/platform/sample-data.ts b/packages/web/src/app/routes/platform/sample-data.tsindex b00e90d9a27..dcd55973c60 100644--- a/packages/web/src/app/routes/platform/sample-data.ts+++ b/packages/web/src/app/routes/platform/sample-data.ts@@ -21,6 +21,8 @@ import {Template,TemplateStatus,TemplateType,+ WorkerGroupScope,+ WorkerGroupsOverview,} from '@activepieces/shared';const SAMPLE_PLATFORM_ID = 'sample-platform';@@ -227,6 +229,70 @@ function signingKeys(): SigningKey[] {}));}+function workerGroupsOverview(): WorkerGroupsOverview {+ return {+ defaultGroup: {+ online: 6,+ slots: 24,+ projectCount: 14,+ flowCount: 0,+ sample: [],+ },+ groups: [+ {+ label: 'Finance (EU)',+ scope: WorkerGroupScope.PROJECT,+ online: 2,+ slots: 8,+ waiting: 1,+ projectCount: 3,+ flowCount: 0,+ sample: ['Billing', 'Payroll', 'Invoicing'],+ },+ {+ label: 'Customer support',+ scope: WorkerGroupScope.PROJECT,+ online: 3,+ slots: 12,+ waiting: 0,+ projectCount: 2,+ flowCount: 0,+ sample: ['Helpdesk', 'Live chat'],+ },+ {+ label: 'High-volume webhooks',+ scope: WorkerGroupScope.FLOW,+ online: 2,+ slots: 8,+ waiting: 4,+ projectCount: 0,+ flowCount: 3,+ sample: ['Stripe events', 'Shopify orders', 'Order sync'],+ },+ {+ label: 'Nightly reports',+ scope: WorkerGroupScope.FLOW,+ online: 1,+ slots: 4,+ waiting: 2,+ projectCount: 0,+ flowCount: 2,+ sample: ['Weekly churn digest', 'Revenue rollup'],+ },+ {+ label: 'GPU flows',+ scope: WorkerGroupScope.FLOW,+ online: 1,+ slots: 2,+ waiting: 0,+ projectCount: 0,+ flowCount: 2,+ sample: ['Invoice OCR', 'Image tagging'],+ },+ ],+ };+}+export const sampleData = {signingKeys,templatesPage: () => toPage(templates()),@@ -237,6 +303,7 @@ export const sampleData = {defaultProjects,eventDestinations,secretManagers,+ workerGroupsOverview,};export type SampleDefaultProject = {diff --git a/packages/web/src/features/billing/components/request-trial.tsx b/packages/web/src/features/billing/components/request-trial.tsxindex 6fe75d16f1a..ba0bf90668c 100644--- a/packages/web/src/features/billing/components/request-trial.tsx+++ b/packages/web/src/features/billing/components/request-trial.tsx@@ -1,16 +1,9 @@-import { isNil } from '@activepieces/core-utils';-import {- PlatformAdminSurface,- TelemetryEventName,- UserWithMetaInformation,-} from '@activepieces/shared';import { t } from 'i18next';import { AnimatedIconButton } from '@/components/custom/animated-icon-button';import { SendIcon } from '@/components/icons/send';-import { useTelemetry } from '@/components/providers/telemetry-provider';-import { userHooks } from '@/hooks/user-hooks';-import { telemetryUtils } from '@/lib/telemetry-utils';++import { OpenSalesParams, useOpenSales } from '../hooks/use-open-sales';export const RequestTrial = ({featureKey,@@ -18,32 +11,13 @@ export const RequestTrial = ({buttonVariant = 'default',buttonSize = 'default',}: RequestTrialProps) => {- const { data: currentUser } = userHooks.useCurrentUser();- const { capture } = useTelemetry();-- const handleClick = () => {- if (surface !== undefined) {- capture({- name: TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED,- payload: { feature: featureKey, surface },- });- }- capture({- name: TelemetryEventName.SALES_HANDOFF_CLICKED,- payload: { featureKey, surface: 'locked_feature' },- });- window.open(- buildSalesUrl({ currentUser, featureKey }),- '_blank',- 'noopener noreferrer',- );- };+ const openSales = useOpenSales({ featureKey, surface });return (<AnimatedIconButtonvariant={buttonVariant}size={buttonSize}- onClick={handleClick}+ onClick={openSales}icon={SendIcon}iconSize={14}>@@ -52,28 +26,6 @@ export const RequestTrial = ({);};-function buildSalesUrl({- currentUser,- featureKey,-}: {- currentUser: UserWithMetaInformation | null | undefined;- featureKey: FeatureKey;-}): string {- const url = new URL(SALES_URL);- url.searchParams.set('email', currentUser?.email ?? '');- url.searchParams.set('firstName', currentUser?.firstName ?? '');- url.searchParams.set('lastName', currentUser?.lastName ?? '');- url.searchParams.set('featureKey', featureKey);- url.searchParams.set('ap_cta', `app_${featureKey.toLowerCase()}`);- const sessionId = telemetryUtils.getSessionId();- if (!isNil(sessionId)) {- url.searchParams.set('ap_sid', sessionId);- }- return url.toString();-}--const SALES_URL = 'https://www.activepieces.com/sales';-export type FeatureKey =| 'PROJECTS'| 'BRANDING'@@ -102,9 +54,7 @@ export type FeatureKey =| 'SECRET_MANAGERS'| 'DEDICATED_WORKERS';-type RequestTrialProps = {- featureKey: FeatureKey;- surface?: Exclude<PlatformAdminSurface, PlatformAdminSurface.DIALOG>;+type RequestTrialProps = OpenSalesParams & {customButton?: React.ReactNode;buttonVariant?: 'default' | 'basic';buttonSize?: 'default' | 'sm' | 'xs';diff --git a/packages/web/src/features/billing/hooks/use-open-sales.ts b/packages/web/src/features/billing/hooks/use-open-sales.tsnew file mode 100644index 00000000000..2e2d4ea9cb9--- /dev/null+++ b/packages/web/src/features/billing/hooks/use-open-sales.ts@@ -0,0 +1,62 @@+import { isNil } from '@activepieces/core-utils';+import {+ PlatformAdminSurface,+ TelemetryEventName,+ UserWithMetaInformation,+} from '@activepieces/shared';++import { useTelemetry } from '@/components/providers/telemetry-provider';+import { userHooks } from '@/hooks/user-hooks';+import { telemetryUtils } from '@/lib/telemetry-utils';++import { FeatureKey } from '../components/request-trial';++export function useOpenSales({ featureKey, surface }: OpenSalesParams) {+ const { data: currentUser } = userHooks.useCurrentUser();+ const { capture } = useTelemetry();++ return () => {+ if (surface !== undefined) {+ capture({+ name: TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED,+ payload: { feature: featureKey, surface },+ });+ }+ capture({+ name: TelemetryEventName.SALES_HANDOFF_CLICKED,+ payload: { featureKey, surface: 'locked_feature' },+ });+ window.open(+ buildSalesUrl({ currentUser, featureKey }),+ '_blank',+ 'noopener noreferrer',+ );+ };+}++function buildSalesUrl({+ currentUser,+ featureKey,+}: {+ currentUser: UserWithMetaInformation | null | undefined;+ featureKey: FeatureKey;+}): string {+ const url = new URL(SALES_URL);+ url.searchParams.set('email', currentUser?.email ?? '');+ url.searchParams.set('firstName', currentUser?.firstName ?? '');+ url.searchParams.set('lastName', currentUser?.lastName ?? '');+ url.searchParams.set('featureKey', featureKey);+ url.searchParams.set('ap_cta', `app_${featureKey.toLowerCase()}`);+ const sessionId = telemetryUtils.getSessionId();+ if (!isNil(sessionId)) {+ url.searchParams.set('ap_sid', sessionId);+ }+ return url.toString();+}++const SALES_URL = 'https://www.activepieces.com/sales';++export type OpenSalesParams = {+ featureKey: FeatureKey;+ surface?: Exclude<PlatformAdminSurface, PlatformAdminSurface.DIALOG>;+};diff --git a/packages/web/src/features/billing/index.ts b/packages/web/src/features/billing/index.tsindex 4fbbdec1448..4cf955aa3cd 100644--- a/packages/web/src/features/billing/index.ts+++ b/packages/web/src/features/billing/index.ts@@ -32,6 +32,7 @@ export { billingDialogHooks } from './hooks/billing-dialog-hooks';export { AutomaticTrialActivation } from './components/automatic-trial-activation';export { useFeatureGate, UpgradeFeatureDialog } from './hooks/use-feature-gate';export { useUpgradeClick } from './hooks/use-upgrade-click';+export { useOpenSales } from './hooks/use-open-sales';export type { PlatformFeature } from './hooks/use-feature-gate';export { RequestTrial } from './components/request-trial';export type { FeatureKey } from './components/request-trial';diff --git a/packages/web/src/features/platform-admin/index.ts b/packages/web/src/features/platform-admin/index.tsindex e9caca98f5e..c9ce20aaf2e 100644--- a/packages/web/src/features/platform-admin/index.ts+++ b/packages/web/src/features/platform-admin/index.ts@@ -16,6 +16,8 @@ export {} from './hooks/embed-subdomain-hooks';export { AuditLogRetentionButton } from './components/audit-log-retention-dialog';export { auditLogRetentionUtils } from './lib/audit-log-retention-utils';+export { workerGroupsLock } from './lib/worker-groups-lock';+export type { WorkerGroupsLockReason } from './lib/worker-groups-lock';export { NewSigningKeyDialog } from './components/new-signing-key-dialog';export { platformAnalyticsHooks } from './hooks/analytics-hooks';export {diff --git a/packages/web/src/features/platform-admin/lib/worker-groups-lock.ts b/packages/web/src/features/platform-admin/lib/worker-groups-lock.tsnew file mode 100644index 00000000000..d83e4bc749d--- /dev/null+++ b/packages/web/src/features/platform-admin/lib/worker-groups-lock.ts@@ -0,0 +1,26 @@+import { isNil } from '@activepieces/core-utils';+import { ApEdition, PlatformWithoutSensitiveData } from '@activepieces/shared';++export const workerGroupsLock = {+ reason({+ edition,+ plan,+ }: {+ edition: ApEdition | null | undefined;+ plan: Pick<+ PlatformWithoutSensitiveData['plan'],+ 'workerGroupsEnabled' | 'licenseKey'+ >;+ }): WorkerGroupsLockReason | null {+ if (edition === ApEdition.CLOUD) return 'cloud';+ if (plan.workerGroupsEnabled) return null;+ if (edition === ApEdition.COMMUNITY) return 'community';+ return isNil(plan.licenseKey) ? 'no-license' : 'not-in-license';+ },+};++export type WorkerGroupsLockReason =+ | 'cloud'+ | 'community'+ | 'no-license'+ | 'not-in-license';diff --git a/packages/web/test/features/platform-admin/lib/worker-groups-lock.test.ts b/packages/web/test/features/platform-admin/lib/worker-groups-lock.test.tsnew file mode 100644index 00000000000..a9a4ac608fd--- /dev/null+++ b/packages/web/test/features/platform-admin/lib/worker-groups-lock.test.ts@@ -0,0 +1,28 @@+import { ApEdition } from '@activepieces/shared';+import { describe, expect, it } from 'vitest';++import { workerGroupsLock } from '@/features/platform-admin/lib/worker-groups-lock';++describe('workerGroupsLock.reason', () => {+ it.each([+ [ApEdition.CLOUD, false, null, 'cloud'],+ [ApEdition.CLOUD, true, 'key', 'cloud'],+ [ApEdition.COMMUNITY, false, null, 'community'],+ [ApEdition.COMMUNITY, true, null, null],+ [ApEdition.COMMUNITY, false, 'key', 'community'],+ [ApEdition.ENTERPRISE, false, null, 'no-license'],+ [ApEdition.ENTERPRISE, false, 'key', 'not-in-license'],+ [ApEdition.ENTERPRISE, true, 'key', null],+ [ApEdition.ENTERPRISE, true, null, null],+ ])(+ 'edition %s, enabled %s, license %s → %s',+ (edition, workerGroupsEnabled, licenseKey, expected) => {+ expect(+ workerGroupsLock.reason({+ edition,+ plan: { workerGroupsEnabled, licenseKey },+ }),+ ).toBe(expected);+ },+ );+});