import { ConfirmModal } from '../components/ConfirmModal' import { PickerModal } from '../components/PickerModal' import { openMobilePrUrl } from '../components/mobile-pr-url' import { useMobileTranslation } from '../i18n/use-mobile-translation' import type { MobileSourceControlState } from './use-mobile-source-control-state' type Props = { state: MobileSourceControlState } export function MobileSourceControlModals({ state }: Props) { const t = useMobileTranslation() const { discardTarget, setDiscardTarget, showBranchPicker, setShowBranchPicker, localBranches, createdPrUrl, setCreatedPrUrl, createdPrWarning, setCreatedPrWarning, checkoutBranch, runGitAction } = state return ( <> { if (discardTarget) { void runGitAction(`discard:${discardTarget.path}`, 'git.discard', { filePath: discardTarget.path }) } setDiscardTarget(null) }} onCancel={() => setDiscardTarget(null)} /> ({ value: b, label: b, subtitle: b === localBranches?.current ? t('sourceControl.modals.currentBranch', 'current') : undefined }))} selected={localBranches?.current ?? ''} onSelect={(branch) => { if (branch !== localBranches?.current) { void checkoutBranch(branch) } else { setShowBranchPicker(false) } }} onClose={() => setShowBranchPicker(false)} /> { if (createdPrUrl) { openMobilePrUrl(createdPrUrl) } setCreatedPrUrl(null) setCreatedPrWarning(null) }} onCancel={() => { setCreatedPrUrl(null) setCreatedPrWarning(null) }} /> ) }