mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
import type {
|
|
SourceControlPrimaryActionDecision,
|
|
SourceControlPrimaryActionDecisionInputs
|
|
} from './source-control-primary-action-decision-types'
|
|
|
|
export function resolveUnpublishedSourceControlPrimaryAction({
|
|
hasCurrentBranch,
|
|
isPRStateLoading,
|
|
prState
|
|
}: Pick<
|
|
SourceControlPrimaryActionDecisionInputs,
|
|
'hasCurrentBranch' | 'isPRStateLoading' | 'prState'
|
|
>): SourceControlPrimaryActionDecision {
|
|
if (!hasCurrentBranch) {
|
|
return {
|
|
kind: 'commit',
|
|
labelIntent: 'commit',
|
|
titleIntent: 'checkout_branch_before_publish',
|
|
disabled: true
|
|
}
|
|
}
|
|
|
|
if (isPRStateLoading) {
|
|
return {
|
|
kind: 'commit',
|
|
labelIntent: 'commit',
|
|
titleIntent: 'checking_review_status',
|
|
disabled: true
|
|
}
|
|
}
|
|
|
|
if (prState === 'merged') {
|
|
return {
|
|
kind: 'commit',
|
|
labelIntent: 'commit',
|
|
titleIntent: 'review_already_merged',
|
|
disabled: true
|
|
}
|
|
}
|
|
|
|
return {
|
|
kind: 'publish',
|
|
labelIntent: 'publish',
|
|
titleIntent: 'publish_branch',
|
|
disabled: false
|
|
}
|
|
}
|