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
import { isNil } from '@activepieces/shared';
import { t } from 'i18next';
import { Check, ChevronDown } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import {
ApProjectDisplay,
getProjectName,
projectCollectionUtils,
} from '@/features/projects';
import { cn } from '@/lib/utils';
type ProjectPickerProps = {
projectId: string | null;
allowedProjectIds?: string[] | null;
onSelect: (projectId: string) => void;
};
export function ProjectPicker({
projectId,
allowedProjectIds,
onSelect,
}: ProjectPickerProps) {
const { data: allProjects = [] } = projectCollectionUtils.useAll();
const projects = isNil(allowedProjectIds)
? allProjects
: allProjects.filter((project) => allowedProjectIds.includes(project.id));
const selectedProject = projects.find((project) => project.id === projectId);
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">
<span className="text-gray-11">{t('Project')}</span>
{selectedProject ? (
<ApProjectDisplay
title={getProjectName(selectedProject)}
icon={selectedProject.icon}
projectType={selectedProject.type}
iconClassName="size-4.5 text-xs"
titleClassName="font-medium"
maxLengthToNotShowTooltip={24}
/>
) : (
<span className="font-medium">{t('Select a project')}</span>
)}
<ChevronDown className="size-4 text-gray-11" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="min-w-[240px]">
{projects.map((project) => (
<DropdownMenuItem
key={project.id}
className="gap-2"
onSelect={() => onSelect(project.id)}
>
<ApProjectDisplay
title={getProjectName(project)}
icon={project.icon}
projectType={project.type}
iconClassName="size-4.5 text-xs"
maxLengthToNotShowTooltip={24}
/>
<Check
className={cn('ml-auto size-4', {
'opacity-0': project.id !== projectId,
})}
/>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
);
}