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.0 KB
Raw Blame
import { ProjectReleaseType } from '@activepieces/shared';
import { ReactNode, useState } from 'react';

import { Button, ButtonProps } from '@/components/ui/button';
import { projectCollectionUtils } from '@/features/projects';

import { ProjectSelectionDialog } from './selection-release-dialog/project-dialog';

type SelectionButtonProps = ButtonProps & {
  ReleaseType: ProjectReleaseType;
  children: ReactNode;
  onSuccess: () => void;
};
export function SelectionButton({
  ReleaseType,
  children,
  onSuccess,
  ...props
}: SelectionButtonProps) {
  const { project } = projectCollectionUtils.useCurrentProject();
  const [open, setOpen] = useState(false);

  return (
    <>
      <Button
        {...props}
        onClick={() => {
          setOpen(true);
        }}
      >
        {children}
      </Button>
      {ReleaseType === ProjectReleaseType.PROJECT && (
        <ProjectSelectionDialog
          open={open}
          setOpen={setOpen}
          projectId={project.id}
          onSuccess={onSuccess}
        />
      )}
    </>
  );
}