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

1.9 KB
Raw Blame
import { ApEdition, ApFlagId } from '@activepieces/shared';
import { t } from 'i18next';
import { ExternalLink } from 'lucide-react';

import { Alert, AlertDescription } from '@/components/ui/alert';
import { billingDialogHooks } from '@/features/billing';
import { flagsHooks } from '@/hooks/flags-hooks';
import { AdminControl, adminControl } from '@/lib/admin-control';

export function FeatureBanner({
  message,
  documentationUrl,
  className,
}: FeatureBannerProps) {
  const { openDialog: openManagePlanDialog } =
    billingDialogHooks.useManagePlanDialogStore();
  const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);
  const isCommunity = edition === ApEdition.COMMUNITY;
  const docsUrl = documentationUrl ?? ENTERPRISE_DOCUMENTATION_URL;

  return (
    <Alert variant="primary" className={className}>
      <AlertDescription className="flex flex-wrap items-center gap-x-2 gap-y-1">
        <span>{message}</span>
        {isCommunity ? (
          <a
            {...adminControl(AdminControl.PLAN_BANNER_LINK)}
            href={docsUrl}
            target="_blank"
            rel="noopener noreferrer"
            className="inline-flex items-center gap-1 font-medium text-accent-11 hover:underline"
          >
            {t('Read the docs')}
            <ExternalLink className="size-3.5" />
          </a>
        ) : (
          <button
            {...adminControl(AdminControl.PLAN_BANNER_OPEN)}
            type="button"
            onClick={() => openManagePlanDialog()}
            className="font-medium text-accent-11 hover:underline"
          >
            {t('Upgrade plan')}
          </button>
        )}
      </AlertDescription>
    </Alert>
  );
}

const ENTERPRISE_DOCUMENTATION_URL =
  'https://www.activepieces.com/docs/install/configuration/overview#enterprise-edition-optional';

export type FeatureBannerProps = {
  message: string;
  documentationUrl?: string;
  className?: string;
};