addons/isl/src/codeReview/PublishWhenReadyCheckbox.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 {Tooltip} from 'isl-components/Tooltip';
b69ab3110import {useAtom, useAtomValue} from 'jotai';
b69ab3111import {publishWhenReady} from '../atoms/submitOptionAtoms';
b69ab3112import {t, T} from '../i18n';
b69ab3113import {codeReviewProvider} from './CodeReviewInfo';
b69ab3114
b69ab3115export {publishWhenReady} from '../atoms/submitOptionAtoms';
b69ab3116
b69ab3117/**
b69ab3118 * Checkbox component for the "Publish when ready" option.
b69ab3119 * When enabled, diffs are automatically published after all CI signals pass.
b69ab3120 * Only shown for Phabricator repositories (GitHub doesn't support this feature).
b69ab3121 *
b69ab3122 * The bidirectional relationship with SubmitAsDraftCheckbox is enforced at the atom level:
b69ab3123 * - Checking "Publish when ready" automatically enables "Submit as Draft"
b69ab3124 * - Unchecking "Submit as Draft" automatically disables "Publish when ready"
b69ab3125 * See atoms/submitOptionAtoms.ts for implementation details.
b69ab3126 */
b69ab3127export function PublishWhenReadyCheckbox() {
b69ab3128 const [isPublishWhenReady, setPublishWhenReady] = useAtom(publishWhenReady);
b69ab3129 const provider = useAtomValue(codeReviewProvider);
b69ab3130
b69ab3131 // Only show for Phabricator, not GitHub
b69ab3132 if (provider?.name !== 'phabricator') {
b69ab3133 return null;
b69ab3134 }
b69ab3135
b69ab3136 return (
b69ab3137 <Checkbox checked={isPublishWhenReady} onChange={setPublishWhenReady}>
b69ab3138 <Tooltip title={t('publishWhenReadyTooltip')}>
b69ab3139 <T>Publish when ready</T>
b69ab3140 </Tooltip>
b69ab3141 </Checkbox>
b69ab3142 );
b69ab3143}