| 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 {Tooltip} from 'isl-components/Tooltip'; |
| b69ab31 | | | 10 | import {useAtom, useAtomValue} from 'jotai'; |
| b69ab31 | | | 11 | import {publishWhenReady} from '../atoms/submitOptionAtoms'; |
| b69ab31 | | | 12 | import {t, T} from '../i18n'; |
| b69ab31 | | | 13 | import {codeReviewProvider} from './CodeReviewInfo'; |
| b69ab31 | | | 14 | |
| b69ab31 | | | 15 | export {publishWhenReady} from '../atoms/submitOptionAtoms'; |
| b69ab31 | | | 16 | |
| b69ab31 | | | 17 | /** |
| b69ab31 | | | 18 | * Checkbox component for the "Publish when ready" option. |
| b69ab31 | | | 19 | * When enabled, diffs are automatically published after all CI signals pass. |
| b69ab31 | | | 20 | * Only shown for Phabricator repositories (GitHub doesn't support this feature). |
| b69ab31 | | | 21 | * |
| b69ab31 | | | 22 | * The bidirectional relationship with SubmitAsDraftCheckbox is enforced at the atom level: |
| b69ab31 | | | 23 | * - Checking "Publish when ready" automatically enables "Submit as Draft" |
| b69ab31 | | | 24 | * - Unchecking "Submit as Draft" automatically disables "Publish when ready" |
| b69ab31 | | | 25 | * See atoms/submitOptionAtoms.ts for implementation details. |
| b69ab31 | | | 26 | */ |
| b69ab31 | | | 27 | export function PublishWhenReadyCheckbox() { |
| b69ab31 | | | 28 | const [isPublishWhenReady, setPublishWhenReady] = useAtom(publishWhenReady); |
| b69ab31 | | | 29 | const provider = useAtomValue(codeReviewProvider); |
| b69ab31 | | | 30 | |
| b69ab31 | | | 31 | // Only show for Phabricator, not GitHub |
| b69ab31 | | | 32 | if (provider?.name !== 'phabricator') { |
| b69ab31 | | | 33 | return null; |
| b69ab31 | | | 34 | } |
| b69ab31 | | | 35 | |
| b69ab31 | | | 36 | return ( |
| b69ab31 | | | 37 | <Checkbox checked={isPublishWhenReady} onChange={setPublishWhenReady}> |
| b69ab31 | | | 38 | <Tooltip title={t('publishWhenReadyTooltip')}> |
| b69ab31 | | | 39 | <T>Publish when ready</T> |
| b69ab31 | | | 40 | </Tooltip> |
| b69ab31 | | | 41 | </Checkbox> |
| b69ab31 | | | 42 | ); |
| b69ab31 | | | 43 | } |