| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | import {Checkbox} from 'isl-components/Checkbox'; |
| b69ab31 | | | 9 | import {Subtle} from 'isl-components/Subtle'; |
| b69ab31 | | | 10 | import {Tooltip} from 'isl-components/Tooltip'; |
| b69ab31 | | | 11 | import {useAtom} from 'jotai'; |
| b69ab31 | | | 12 | import {Internal} from '../Internal'; |
| b69ab31 | | | 13 | import {T, t} from '../i18n'; |
| b69ab31 | | | 14 | import {localStorageBackedAtom} from '../jotaiUtils'; |
| b69ab31 | | | 15 | |
| b69ab31 | | | 16 | export const shouldAutoResolveAllBeforeContinue = localStorageBackedAtom<boolean>( |
| b69ab31 | | | 17 | 'isl.auto-resolve-before-continue', |
| b69ab31 | | | 18 | // OSS doesn't typically use merge drivers, so `sl resolve --all` would be added overhead for little gain. |
| b69ab31 | | | 19 | // You can still configure this in settings if you want. |
| b69ab31 | | | 20 | Internal.autoRunMergeDriversByDefault === true, |
| b69ab31 | | | 21 | ); |
| b69ab31 | | | 22 | |
| b69ab31 | | | 23 | export function AutoResolveSettingCheckbox({subtle}: {subtle?: boolean}) { |
| b69ab31 | | | 24 | const [shouldAutoResolve, setShouldAutoResolve] = useAtom(shouldAutoResolveAllBeforeContinue); |
| b69ab31 | | | 25 | |
| b69ab31 | | | 26 | const label = <T>Auto-run Merge Drivers</T>; |
| b69ab31 | | | 27 | return ( |
| b69ab31 | | | 28 | <Tooltip |
| b69ab31 | | | 29 | title={t( |
| b69ab31 | | | 30 | 'Whether to run `sl resolve --all` before `sl continue`. ' + |
| b69ab31 | | | 31 | 'This runs automated merge drivers to regenerate generated files.\n' + |
| b69ab31 | | | 32 | 'This is usually needed to finish a merge, but merge drivers can be slow.', |
| b69ab31 | | | 33 | )}> |
| b69ab31 | | | 34 | <Checkbox checked={shouldAutoResolve} onChange={setShouldAutoResolve}> |
| b69ab31 | | | 35 | {subtle ? <Subtle>{label}</Subtle> : label} |
| b69ab31 | | | 36 | </Checkbox> |
| b69ab31 | | | 37 | </Tooltip> |
| b69ab31 | | | 38 | ); |
| b69ab31 | | | 39 | } |
| b69ab31 | | | 40 | |
| b69ab31 | | | 41 | export const shouldPartialAbort = localStorageBackedAtom<boolean>('isl.partial-abort', false); |
| b69ab31 | | | 42 | |
| b69ab31 | | | 43 | export function PartialAbortSettingCheckbox({subtle}: {subtle?: boolean}) { |
| b69ab31 | | | 44 | const [isPartialAbort, setShouldPartialAbort] = useAtom(shouldPartialAbort); |
| b69ab31 | | | 45 | |
| b69ab31 | | | 46 | const label = <T>Keep Rebased Commits on Abort</T>; |
| b69ab31 | | | 47 | return ( |
| b69ab31 | | | 48 | <Tooltip title={t('Keep already rebased commits when aborting a rebase operation.')}> |
| b69ab31 | | | 49 | <Checkbox checked={isPartialAbort} onChange={setShouldPartialAbort}> |
| b69ab31 | | | 50 | {subtle ? <Subtle>{label}</Subtle> : label} |
| b69ab31 | | | 51 | </Checkbox> |
| b69ab31 | | | 52 | </Tooltip> |
| b69ab31 | | | 53 | ); |
| b69ab31 | | | 54 | } |