mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Rows lead with the file name and put its folder under it, so names stop truncating. The whole row opens the diff, one quiet button stages or unstages, and discard moves to a left swipe that still asks first. A status line, a Commits row and a conflict banner with Abort sit above Uncommitted and Staged sections that carry Stage all and Unstage all. The rarer git actions move into the header's grouped menu.
106 lines
3.1 KiB
TypeScript
106 lines
3.1 KiB
TypeScript
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 (
|
|
<>
|
|
<ConfirmModal
|
|
visible={discardTarget !== null}
|
|
title={t('sourceControl.modals.discardTitle', 'Discard Change')}
|
|
message={
|
|
discardTarget
|
|
? t(
|
|
'sourceControl.modals.discardConfirmMessage',
|
|
'Discard changes to "{{path}}"? This cannot be undone.',
|
|
{ path: discardTarget.path }
|
|
)
|
|
: undefined
|
|
}
|
|
confirmLabel={t('sourceControl.modals.discardButton', 'Discard')}
|
|
destructive
|
|
onConfirm={() => {
|
|
if (discardTarget) {
|
|
void runGitAction(`discard:${discardTarget.path}`, 'git.discard', {
|
|
filePath: discardTarget.path
|
|
})
|
|
}
|
|
setDiscardTarget(null)
|
|
}}
|
|
onCancel={() => setDiscardTarget(null)}
|
|
/>
|
|
|
|
<PickerModal
|
|
visible={showBranchPicker}
|
|
title={t('sourceControl.modals.switchBranchTitle', 'Switch Branch')}
|
|
options={(localBranches?.branches ?? []).map((b) => ({
|
|
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)}
|
|
/>
|
|
|
|
<ConfirmModal
|
|
visible={createdPrUrl !== null}
|
|
title={t('sourceControl.modals.prCreatedTitle', 'Pull Request Created')}
|
|
message={
|
|
createdPrWarning
|
|
? t(
|
|
'sourceControl.modals.openPrWithWarning',
|
|
'Open it in your browser?\n\n{{warning}}',
|
|
{
|
|
warning: createdPrWarning
|
|
}
|
|
)
|
|
: t('sourceControl.modals.openPrMessage', 'Open it in your browser?')
|
|
}
|
|
confirmLabel={t('common.open', 'Open')}
|
|
onConfirm={() => {
|
|
if (createdPrUrl) {
|
|
openMobilePrUrl(createdPrUrl)
|
|
}
|
|
setCreatedPrUrl(null)
|
|
setCreatedPrWarning(null)
|
|
}}
|
|
onCancel={() => {
|
|
setCreatedPrUrl(null)
|
|
setCreatedPrWarning(null)
|
|
}}
|
|
/>
|
|
</>
|
|
)
|
|
}
|