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