mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
* fix(i18n): localize the rest of the source control dropdown The Commit & Push, Push, Force Push, Pull, Fast-forward, Sync, Publish, abort and Push-before-PR rows and their tooltips were English literals next to rows that already go through translate(). Route them through translate(), reusing the primary button's and the conflict card's keys where the words match, and add 42 keys to the English catalog. Commit blockers stay English inside eligibility, which compares them, and are translated only when the dropdown shows them. * test(i18n): pin the other two commit blockers under the pseudo-locale The pseudo-locale test only reached the stage-file blocker, so an English return for the conflict or commit-message blocker still passed. The new case checks both in the Commit, Commit & Push and Commit & Sync titles. * i18n: translate source control dropdown keys; trim duplicate pseudo-locale test Add zh/ko/ja/es/fr/pt translations for the 42 dropdown keys this PR adds to en.json, matching each catalog's existing source-control glossary. Drop the second pseudo-locale test; the first already covers commit-blocker titles through the active locale. --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
export const COMMIT_MESSAGE_REQUIRED_REASON = 'Enter a commit message to commit' as const
|
|
|
|
export type CommitDisabledReason =
|
|
| 'Resolve conflicts before committing'
|
|
| 'Stage at least one file to commit'
|
|
| typeof COMMIT_MESSAGE_REQUIRED_REASON
|
|
|
|
export type CommitEligibilityInputs = {
|
|
stagedCount: number
|
|
hasPartiallyStagedChanges: boolean
|
|
hasMessage: boolean
|
|
hasUnresolvedConflicts: boolean
|
|
isCommitting: boolean
|
|
isRemoteOperationActive: boolean
|
|
isPullRequestOperationActive?: boolean
|
|
}
|
|
|
|
export function resolveCommitDisabledReason(
|
|
inputs: Pick<
|
|
CommitEligibilityInputs,
|
|
'stagedCount' | 'hasPartiallyStagedChanges' | 'hasMessage' | 'hasUnresolvedConflicts'
|
|
>
|
|
): CommitDisabledReason | null {
|
|
if (inputs.hasUnresolvedConflicts) {
|
|
return 'Resolve conflicts before committing'
|
|
}
|
|
if (inputs.stagedCount === 0) {
|
|
return 'Stage at least one file to commit'
|
|
}
|
|
if (!inputs.hasMessage) {
|
|
return COMMIT_MESSAGE_REQUIRED_REASON
|
|
}
|
|
return null
|
|
}
|
|
|
|
function isCommitGloballyBusy(inputs: CommitEligibilityInputs): boolean {
|
|
return (
|
|
inputs.isCommitting ||
|
|
inputs.isRemoteOperationActive ||
|
|
(inputs.isPullRequestOperationActive ?? false)
|
|
)
|
|
}
|
|
|
|
export function canSubmitCommit(inputs: CommitEligibilityInputs): boolean {
|
|
return !isCommitGloballyBusy(inputs) && resolveCommitDisabledReason(inputs) === null
|
|
}
|
|
|
|
// Allow typing through the empty-message blocker; other commit blockers and in-flight work lock editing.
|
|
export function isCommitMessageFieldDisabled(inputs: CommitEligibilityInputs): boolean {
|
|
if (isCommitGloballyBusy(inputs)) {
|
|
return true
|
|
}
|
|
const commitDisabledReason = resolveCommitDisabledReason(inputs)
|
|
return commitDisabledReason !== null && commitDisabledReason !== COMMIT_MESSAGE_REQUIRED_REASON
|
|
}
|