authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-14 23:08:05-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-14 23:35:48-08:00
log58d926fcfba701ebf86f596fc8f1023087493419
treee5455694a5e7ac4d8edfc338c979687ecff2f16a
parentb5149f595962b51bf237a4de4a43e3cd4e450272

Use action maps for Git dialog title and description

- Replace nested conditional strings with action-to-copy lookup objects - Keep commit/push/create PR dialog text centralized and easier to maintain

1 files changed, 16 insertions(+), 15 deletions(-)

apps/web/src/components/GitActionsControl.tsx+16-15
...@@ -103,6 +103,18 @@ function getMenuActionDisabledReason(...@@ -103,6 +103,18 @@ function getMenuActionDisabledReason(
103 return "Create PR is currently unavailable.";103 return "Create PR is currently unavailable.";
104}104}
105105
106const DIALOG_TITLE_BY_ACTION = {
107 commit: "Commit changes",
108 push: "Push branch",
109 create_pr: "Create pull request",
110};
111
112const DIALOG_DESCRIPTION_BY_ACTION = {
113 commit: "Review and confirm your commit. Leave the message blank to auto-generate one.",
114 push: "Push this branch now.",
115 create_pr: "Create a pull request using generated title/body content.",
116};
117
106function GitActionItemIcon({ icon }: { icon: GitActionIconName }) {118function GitActionItemIcon({ icon }: { icon: GitActionIconName }) {
107 if (icon === "commit") return <GitCommitIcon />;119 if (icon === "commit") return <GitCommitIcon />;
108 if (icon === "push") return <CloudUploadIcon />;120 if (icon === "push") return <CloudUploadIcon />;
...@@ -423,19 +435,6 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp...@@ -423,19 +435,6 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
423 [api, gitCwd],435 [api, gitCwd],
424 );436 );
425437
426 const dialogTitle =
427 activeDialogAction === "commit"
428 ? "Commit changes"
429 : activeDialogAction === "push"
430 ? "Push branch"
431 : "Create pull request";
432 const dialogDescription =
433 activeDialogAction === "commit"
434 ? "Review and confirm your commit. Leave the message blank to auto-generate one."
435 : activeDialogAction === "push"
436 ? "Push this branch now."
437 : "Create a pull request using generated title/body content.";
438
439 if (!gitCwd) return null;438 if (!gitCwd) return null;
440439
441 return (440 return (
...@@ -576,8 +575,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp...@@ -576,8 +575,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
576 >575 >
577 <DialogPopup>576 <DialogPopup>
578 <DialogHeader>577 <DialogHeader>
579 <DialogTitle>{dialogTitle}</DialogTitle>578 <DialogTitle>{DIALOG_TITLE_BY_ACTION[activeDialogAction ?? "commit"]}</DialogTitle>
580 <DialogDescription>{dialogDescription}</DialogDescription>579 <DialogDescription>
580 {DIALOG_DESCRIPTION_BY_ACTION[activeDialogAction ?? "commit"]}
581 </DialogDescription>
581 </DialogHeader>582 </DialogHeader>
582 <DialogPanel className="space-y-4">583 <DialogPanel className="space-y-4">
583 <div className="space-y-3 rounded-lg border border-input bg-muted/40 p-3 text-xs">584 <div className="space-y-3 rounded-lg border border-input bg-muted/40 p-3 text-xs">