Skip to content

Commit 7d6e58a

Browse files
tweaks
1 parent 34994c8 commit 7d6e58a

File tree

2 files changed

+133
-21
lines changed

2 files changed

+133
-21
lines changed

frontend/src/ide/version-history/GitConfigTab.jsx

Lines changed: 117 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ const GitConfigTab = memo(function GitConfigTab({
9999
if (gitConfig?.pr_branch_prefix) {
100100
setPrBranchPrefix(gitConfig.pr_branch_prefix);
101101
}
102-
}, [gitConfig?.pr_mode, gitConfig?.pr_base_branch, gitConfig?.pr_branch_prefix]);
102+
}, [
103+
gitConfig?.pr_mode,
104+
gitConfig?.pr_base_branch,
105+
gitConfig?.pr_branch_prefix,
106+
]);
103107

104108
useEffect(() => {
105109
loadAvailableRepos();
@@ -283,38 +287,95 @@ const GitConfigTab = memo(function GitConfigTab({
283287
try {
284288
const branchList = await fetchBranches(axiosRef, orgId, projectId);
285289
setBranches(branchList);
286-
} catch { /* silent */ }
287-
finally { setBranchesLoading(false); }
290+
} catch {
291+
/* silent */
292+
} finally {
293+
setBranchesLoading(false);
294+
}
288295
}
289296
setPrSaving(true);
290297
try {
291-
const updated = await updatePRMode(axiosRef, orgId, projectId, csrfToken, newMode, prBaseBranch, prBranchPrefix);
298+
const updated = await updatePRMode(
299+
axiosRef,
300+
orgId,
301+
projectId,
302+
csrfToken,
303+
newMode,
304+
prBaseBranch,
305+
prBranchPrefix
306+
);
292307
setGitConfig(updated);
293-
const modeLabel = newMode === "auto" ? "Auto" : newMode === "manual" ? "Manual" : "Off";
294-
setPrSaveResult({ type: "success", message: newMode === "disabled" ? "PR workflow disabled" : `${modeLabel} PR workflow enabled` });
308+
const modeLabel =
309+
newMode === "auto" ? "Auto" : newMode === "manual" ? "Manual" : "Off";
310+
setPrSaveResult({
311+
type: "success",
312+
message:
313+
newMode === "disabled"
314+
? "PR workflow disabled"
315+
: `${modeLabel} PR workflow enabled`,
316+
});
295317
} catch (error) {
296318
setPrMode(prevMode);
297-
setPrSaveResult({ type: "error", message: error?.response?.data?.error_message || error?.message || "Failed to update PR mode" });
319+
setPrSaveResult({
320+
type: "error",
321+
message:
322+
error?.response?.data?.error_message ||
323+
error?.message ||
324+
"Failed to update PR mode",
325+
});
298326
} finally {
299327
setPrSaving(false);
300328
}
301329
},
302-
[axiosRef, orgId, projectId, csrfToken, prBaseBranch, prBranchPrefix, prMode, branches.length, setGitConfig]
330+
[
331+
axiosRef,
332+
orgId,
333+
projectId,
334+
csrfToken,
335+
prBaseBranch,
336+
prBranchPrefix,
337+
prMode,
338+
branches.length,
339+
setGitConfig,
340+
]
303341
);
304342

305343
const handlePrSettingsSave = useCallback(async () => {
306344
setPrSaving(true);
307345
setPrSaveResult(null);
308346
try {
309-
const updated = await updatePRMode(axiosRef, orgId, projectId, csrfToken, prMode, prBaseBranch, prBranchPrefix);
347+
const updated = await updatePRMode(
348+
axiosRef,
349+
orgId,
350+
projectId,
351+
csrfToken,
352+
prMode,
353+
prBaseBranch,
354+
prBranchPrefix
355+
);
310356
setGitConfig(updated);
311357
setPrSaveResult({ type: "success", message: "PR settings saved" });
312358
} catch (error) {
313-
setPrSaveResult({ type: "error", message: error?.response?.data?.error_message || error?.message || "Failed to save PR settings" });
359+
setPrSaveResult({
360+
type: "error",
361+
message:
362+
error?.response?.data?.error_message ||
363+
error?.message ||
364+
"Failed to save PR settings",
365+
});
314366
} finally {
315367
setPrSaving(false);
316368
}
317-
}, [axiosRef, orgId, projectId, csrfToken, prMode, prBaseBranch, prBranchPrefix, setGitConfig]);
369+
}, [
370+
axiosRef,
371+
orgId,
372+
projectId,
373+
csrfToken,
374+
prMode,
375+
prBaseBranch,
376+
prBranchPrefix,
377+
setGitConfig,
378+
]);
318379

319380
const canTest =
320381
selectedMode === "default" ||
@@ -396,21 +457,59 @@ const GitConfigTab = memo(function GitConfigTab({
396457
/>
397458
</div>
398459
{prMode === "manual" && (
399-
<Alert type="info" message="Commits push to a feature branch. Create PRs manually from the version timeline." showIcon style={{ marginBottom: 8 }} />
460+
<Alert
461+
type="info"
462+
message="Commits push to a feature branch. Create PRs manually from the version timeline."
463+
showIcon
464+
style={{ marginBottom: 8 }}
465+
/>
400466
)}
401467
{prMode !== "disabled" && (
402468
<div className="git-config-form" style={{ marginTop: 8 }}>
403469
<div className="git-config-field">
404-
<Text type="secondary" style={{ fontSize: 12 }}>Base Branch</Text>
405-
<Select value={prBaseBranch} onChange={setPrBaseBranch} loading={branchesLoading} style={{ width: "100%" }} placeholder="Select base branch" options={branches.map((b) => ({ value: b.name, label: `${b.name}${b.protected ? " (protected)" : ""}` }))} />
470+
<Text type="secondary" style={{ fontSize: 12 }}>
471+
Base Branch
472+
</Text>
473+
<Select
474+
value={prBaseBranch}
475+
onChange={setPrBaseBranch}
476+
loading={branchesLoading}
477+
style={{ width: "100%" }}
478+
placeholder="Select base branch"
479+
options={branches.map((b) => ({
480+
value: b.name,
481+
label: `${b.name}${b.protected ? " (protected)" : ""}`,
482+
}))}
483+
/>
406484
</div>
407485
<div className="git-config-field">
408-
<Text type="secondary" style={{ fontSize: 12 }}>Branch Prefix</Text>
409-
<Input value={prBranchPrefix} onChange={(e) => setPrBranchPrefix(e.target.value)} placeholder="visitran/" />
486+
<Text type="secondary" style={{ fontSize: 12 }}>
487+
Branch Prefix
488+
</Text>
489+
<Input
490+
value={prBranchPrefix}
491+
onChange={(e) => setPrBranchPrefix(e.target.value)}
492+
placeholder="visitran/"
493+
/>
410494
</div>
411-
<Button type="primary" onClick={handlePrSettingsSave} loading={prSaving} block size="small">Save Settings</Button>
495+
<Button
496+
type="primary"
497+
onClick={handlePrSettingsSave}
498+
loading={prSaving}
499+
block
500+
size="small"
501+
>
502+
Save Settings
503+
</Button>
412504
{prSaveResult && (
413-
<Alert type={prSaveResult.type} message={prSaveResult.message} showIcon closable onClose={() => setPrSaveResult(null)} style={{ marginTop: 8 }} />
505+
<Alert
506+
type={prSaveResult.type}
507+
message={prSaveResult.message}
508+
showIcon
509+
closable
510+
onClose={() => setPrSaveResult(null)}
511+
style={{ marginTop: 8 }}
512+
/>
414513
)}
415514
</div>
416515
)}

frontend/src/ide/version-history/services.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,29 @@ export async function updatePRMode(
307307
const res = await axiosRef({
308308
method: "POST",
309309
url: `${getGitConfigUrl(orgId, projectId)}/enable-pr-workflow`,
310-
data: { pr_mode: prMode, pr_base_branch: prBaseBranch, pr_branch_prefix: prBranchPrefix },
310+
data: {
311+
pr_mode: prMode,
312+
pr_base_branch: prBaseBranch,
313+
pr_branch_prefix: prBranchPrefix,
314+
},
311315
headers: { "X-CSRFToken": csrfToken },
312316
});
313317
return res.data.data;
314318
}
315319

316-
export async function createVersionPR(axiosRef, orgId, projectId, csrfToken, versionNumber) {
320+
export async function createVersionPR(
321+
axiosRef,
322+
orgId,
323+
projectId,
324+
csrfToken,
325+
versionNumber
326+
) {
317327
const res = await axiosRef({
318328
method: "POST",
319-
url: `${getVersionUrl(orgId, projectId)}/version/${versionNumber}/create-pr`,
329+
url: `${getVersionUrl(
330+
orgId,
331+
projectId
332+
)}/version/${versionNumber}/create-pr`,
320333
headers: { "X-CSRFToken": csrfToken },
321334
});
322335
return res.data.data;

0 commit comments

Comments
 (0)