Skip to content

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

4.6 KB
Raw Blame
import { PlatformWithoutSensitiveData } from '@activepieces/shared';
import React from 'react';

import { FeatureSample } from '@/app/components/feature-sample';
import {
  FeatureTeaser,
  FeatureTeaserProps,
} from '@/app/components/feature-teaser';
import { platformHooks } from '@/hooks/platform-hooks';

export function PlanFeatureSample({
  feature,
  children,
}: PlanFeatureSampleProps) {
  const { platform } = platformHooks.useCurrentPlatform();
  const { isLocked, teaser } = PLAN_FEATURE_SAMPLES[feature];

  return (
    <FeatureSample
      locked={isLocked(platform.plan)}
      title={teaser.title}
      description={teaser.description}
      tier={teaser.tier}
      documentationUrl={teaser.documentationUrl}
      featureKey={teaser.featureKey}
      showContactSales={teaser.showContactSales}
    >
      {children}
    </FeatureSample>
  );
}

export function PlanFeatureGuard({
  feature,
  children,
}: PlanFeatureSampleProps) {
  const { platform } = platformHooks.useCurrentPlatform();
  const { isLocked, teaser } = PLAN_FEATURE_SAMPLES[feature];

  return isLocked(platform.plan) ? <FeatureTeaser {...teaser} /> : children;
}

const PLAN_FEATURE_SAMPLES: Record<PlanFeature, PlanFeatureSampleSpec> = {
  sso: {
    isLocked: (plan) => !plan.ssoEnabled,
    teaser: {
      featureKey: 'SSO',
      title: 'Enable Single Sign On',
      description:
        'Let your users sign in with your current SSO provider or give them self serve sign up access',
      tier: 'team',
    },
  },
  projectRoles: {
    isLocked: (plan) => !plan.projectRolesEnabled,
    teaser: {
      featureKey: 'CUSTOM_ROLES',
      title: 'Enable Roles & Access',
      description:
        'Create custom roles, set default projects for new members, and choose whether they get a personal project.',
      tier: 'team',
    },
  },
  globalConnections: {
    isLocked: (plan) => !plan.globalConnectionsEnabled,
    teaser: {
      featureKey: 'GLOBAL_CONNECTIONS',
      title: 'Enable Global Connections',
      description: 'Manage platform-wide connections to external systems.',
      tier: 'team',
    },
  },
  templates: {
    isLocked: (plan) => !plan.manageTemplatesEnabled,
    teaser: {
      featureKey: 'TEMPLATES',
      title: 'Unlock Templates',
      description:
        'Convert the most common automations into reusable templates 1 click away from your users',
      tier: 'enterprise',
    },
  },
  embedding: {
    isLocked: (plan) => !plan.embeddingEnabled,
    teaser: {
      featureKey: 'SIGNING_KEYS',
      title: 'Unlock Embedding Through JS SDK',
      description: 'Enable signing keys to access embedding functionalities.',
      tier: 'enterprise',
    },
  },
  apiKeys: {
    isLocked: (plan) => !plan.apiKeysEnabled,
    teaser: {
      featureKey: 'API',
      title: 'Enable API Keys',
      description: 'Create and manage API keys to access Activepieces APIs.',
      tier: 'team',
    },
  },
  secretManagers: {
    isLocked: (plan) => !plan.secretManagersEnabled,
    teaser: {
      featureKey: 'SECRET_MANAGERS',
      title: 'Enable Secret Managers',
      description: 'Manage your secrets from a single and secure place',
      tier: 'enterprise',
    },
  },
  auditLogs: {
    isLocked: (plan) => !plan.auditLogEnabled,
    teaser: {
      featureKey: 'AUDIT_LOGS',
      title: 'Unlock Audit Logs',
      description:
        'Comply with internal and external security policies by tracking activities done within your account',
      tier: 'enterprise',
    },
  },
  eventStreaming: {
    isLocked: (plan) => !plan.eventStreamingEnabled,
    teaser: {
      featureKey: 'EVENT_DESTINATIONS',
      title: 'Unlock Event Streaming',
      description:
        'Stream every audit event in OpenTelemetry (OTLP) format to Datadog, PostHog, Grafana Loki, or any OTLP backend. Or send it as raw JSON to a webhook or a handler flow.',
      tier: 'enterprise',
      documentationUrl:
        'https://www.activepieces.com/docs/admin-guide/guides/event-streaming',
    },
  },
  aiProviders: {
    isLocked: (plan) => !plan.aiProvidersEnabled,
    teaser: {
      featureKey: 'UNIVERSAL_AI',
      title: 'Unlock AI Center',
      description:
        'Bring your own AI provider keys and choose the models that power your automations',
      tier: 'plus',
    },
  },
};

type PlanFeature =
  | 'sso'
  | 'projectRoles'
  | 'globalConnections'
  | 'templates'
  | 'embedding'
  | 'apiKeys'
  | 'secretManagers'
  | 'auditLogs'
  | 'eventStreaming'
  | 'aiProviders';

type PlanFeatureSampleSpec = {
  isLocked: (plan: PlatformWithoutSensitiveData['plan']) => boolean;
  teaser: FeatureTeaserProps;
};

type PlanFeatureSampleProps = {
  feature: PlanFeature;
  children: React.ReactNode;
};