addons/isl/src/mergeConflicts/state.tsxblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import {Checkbox} from 'isl-components/Checkbox';
b69ab319import {Subtle} from 'isl-components/Subtle';
b69ab3110import {Tooltip} from 'isl-components/Tooltip';
b69ab3111import {useAtom} from 'jotai';
b69ab3112import {Internal} from '../Internal';
b69ab3113import {T, t} from '../i18n';
b69ab3114import {localStorageBackedAtom} from '../jotaiUtils';
b69ab3115
b69ab3116export const shouldAutoResolveAllBeforeContinue = localStorageBackedAtom<boolean>(
b69ab3117 'isl.auto-resolve-before-continue',
b69ab3118 // OSS doesn't typically use merge drivers, so `sl resolve --all` would be added overhead for little gain.
b69ab3119 // You can still configure this in settings if you want.
b69ab3120 Internal.autoRunMergeDriversByDefault === true,
b69ab3121);
b69ab3122
b69ab3123export function AutoResolveSettingCheckbox({subtle}: {subtle?: boolean}) {
b69ab3124 const [shouldAutoResolve, setShouldAutoResolve] = useAtom(shouldAutoResolveAllBeforeContinue);
b69ab3125
b69ab3126 const label = <T>Auto-run Merge Drivers</T>;
b69ab3127 return (
b69ab3128 <Tooltip
b69ab3129 title={t(
b69ab3130 'Whether to run `sl resolve --all` before `sl continue`. ' +
b69ab3131 'This runs automated merge drivers to regenerate generated files.\n' +
b69ab3132 'This is usually needed to finish a merge, but merge drivers can be slow.',
b69ab3133 )}>
b69ab3134 <Checkbox checked={shouldAutoResolve} onChange={setShouldAutoResolve}>
b69ab3135 {subtle ? <Subtle>{label}</Subtle> : label}
b69ab3136 </Checkbox>
b69ab3137 </Tooltip>
b69ab3138 );
b69ab3139}
b69ab3140
b69ab3141export const shouldPartialAbort = localStorageBackedAtom<boolean>('isl.partial-abort', false);
b69ab3142
b69ab3143export function PartialAbortSettingCheckbox({subtle}: {subtle?: boolean}) {
b69ab3144 const [isPartialAbort, setShouldPartialAbort] = useAtom(shouldPartialAbort);
b69ab3145
b69ab3146 const label = <T>Keep Rebased Commits on Abort</T>;
b69ab3147 return (
b69ab3148 <Tooltip title={t('Keep already rebased commits when aborting a rebase operation.')}>
b69ab3149 <Checkbox checked={isPartialAbort} onChange={setShouldPartialAbort}>
b69ab3150 {subtle ? <Subtle>{label}</Subtle> : label}
b69ab3151 </Checkbox>
b69ab3152 </Tooltip>
b69ab3153 );
b69ab3154}