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.

1.2 KB
Raw Blame
import type { ReactNode } from 'react';
import { useTranslations } from 'next-intl';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';

export function SettingsInlineEditForm({
  name,
  onNameChange,
  placeholder,
  submitLabel,
  onSubmit,
  onCancel,
  leading,
  trailing,
}: {
  name: string;
  onNameChange: (v: string) => void;
  placeholder: string;
  submitLabel: string;
  onSubmit: () => void;
  onCancel: () => void;
  leading?: ReactNode;
  trailing?: ReactNode;
}) {
  const t = useTranslations('common');

  return (
    <div className="flex items-center gap-2 px-3 py-1.5">
      {leading}
      <Input
        autoFocus
        value={name}
        onChange={(e) => onNameChange(e.target.value)}
        placeholder={placeholder}
        className="h-7"
        onKeyDown={(e) => {
          if (e.key === 'Enter') onSubmit();
          if (e.key === 'Escape') onCancel();
        }}
      />
      {trailing}
      <Button variant="ghost" size="sm" className="h-7" disabled={!name.trim()} onClick={onSubmit}>
        {submitLabel}
      </Button>
      <Button variant="ghost" size="sm" className="h-7" onClick={onCancel}>
        {t('cancel')}
      </Button>
    </div>
  );
}