Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

2.2 KB
Raw Blame
import { useTranslations } from 'next-intl';
import type { Column } from '@/lib/api/endpoints/columns';
import type { GitSettings } from '@/lib/api/endpoints/git';
import SettingsCard from '@/components/common/page/SettingsCard';
import SettingsSection from '@/components/common/page/SettingsSection';
import SettingsRow from '@/components/common/page/SettingsRow';
import { Switch } from '@/components/ui/switch';
import GitColumnSelect from './GitColumnSelect';

// The pull request automations: which state a linked issue moves to when the pull
// request merges into the default branch, and (optionally) when it is opened.
export default function GitAutomationsCard({
  columns,
  settings,
  onChange,
}: {
  columns: Column[];
  settings: GitSettings;
  onChange: (patch: {
    onMergeColumnId?: number | null;
    onOpenColumnId?: number | null;
    linkbackComments?: boolean;
  }) => void;
}) {
  const t = useTranslations('settings.git');

  return (
    <SettingsSection title={t('automations')} description={t('automationsHint')}>
      <SettingsCard className="divide-y divide-border/60">
        <SettingsRow
          title={t('linkbackComments')}
          description={t('linkbackCommentsHint')}
          control={
            <Switch
              checked={settings.linkbackComments}
              onCheckedChange={(linkbackComments) => onChange({ linkbackComments })}
            />
          }
        />
        <SettingsRow
          title={t('onMerge')}
          description={t('onMergeHint')}
          control={
            <GitColumnSelect
              columns={columns}
              value={settings.onMergeColumnId}
              noneLabel={t('onMergeNone')}
              onChange={(id) => onChange({ onMergeColumnId: id })}
            />
          }
        />
        <SettingsRow
          title={t('onOpen')}
          description={t('onOpenHint')}
          control={
            <GitColumnSelect
              columns={columns}
              value={settings.onOpenColumnId}
              noneLabel={t('onOpenNone')}
              onChange={(id) => onChange({ onOpenColumnId: id })}
            />
          }
        />
      </SettingsCard>
    </SettingsSection>
  );
}