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