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.5 KB
Raw Blame
import { FlowVersionState } from '@activepieces/shared';
import { t } from 'i18next';
import React from 'react';

import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from '@/components/ui/tooltip';

type FlowVersionStateProps = {
  state: FlowVersionState;
  publishedVersionId: string | undefined | null;
  versionId: string;
};

const findVersionStateName: (
  state: FlowVersionStateProps,
) => 'Draft' | 'Published' | 'Locked' = ({
  state,
  publishedVersionId,
  versionId,
}) => {
  if (state === FlowVersionState.DRAFT) {
    return 'Draft';
  }
  if (publishedVersionId === versionId) {
    return 'Published';
  }
  return 'Locked';
};
const FlowVersionStateDot = React.memo((state: FlowVersionStateProps) => {
  const stateName = findVersionStateName(state);
  if (stateName === 'Locked') {
    return null;
  }
  return (
    <Tooltip>
      <TooltipTrigger asChild>
        <div className="size-8 flex justify-center items-center">
          {stateName === 'Draft' && (
            <span className="bg-warning-10 size-1.5 rounded-full"></span>
          )}
          {stateName === 'Published' && (
            <span className="bg-success-10 size-1.5 rounded-full"></span>
          )}
        </div>
      </TooltipTrigger>
      <TooltipContent>
        {stateName === 'Draft' && t('Draft')}
        {stateName === 'Published' && t('Published')}
      </TooltipContent>
    </Tooltip>
  );
});

FlowVersionStateDot.displayName = 'FlowVersionStateDot';
export { FlowVersionStateDot };