mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
1 parent
9b876077e3
commit
7f221ad3d5
43 files changed
+409
-195
No files matched your search
@@ -40,8 +40,18 @@ function tickKey(end) {
|
||||
return `review|${end.line}|${end.reason}|${end.signedOff ? "signed" : "open"}`;
|
||||
}
|
||||
|
||||
function button(label, id, cls, disabled, onClick) {
|
||||
const b = el("button", "btn" + (cls ? " " + cls : ""), label);
|
||||
// The press the page is waiting on (set each draw), so its button can show work.
|
||||
let busyWhat = "";
|
||||
|
||||
function button(label, id, cls, disabled, onClick, what = "") {
|
||||
const working = Boolean(what) && busyWhat === what;
|
||||
const b = el("button", "btn" + (cls ? " " + cls : "") + (working ? " is-busy" : ""), working ? "" : label);
|
||||
if (working) {
|
||||
const spin = el("span", "spinner tiny");
|
||||
spin.setAttribute("aria-hidden", "true");
|
||||
b.append(spin, document.createTextNode("Working…"));
|
||||
b.setAttribute("aria-busy", "true");
|
||||
}
|
||||
b.type = "button";
|
||||
b.id = id;
|
||||
b.disabled = disabled;
|
||||
@@ -75,6 +85,7 @@ export function renderReviewLoopEnd(end) {
|
||||
const failed =
|
||||
page.reviewAction && !page.reviewAction.ok ? page.reviewAction.error : page.loopAction && !page.loopAction.ok ? page.loopAction.error : "";
|
||||
const busy = pressed.key === key && !failed;
|
||||
busyWhat = busy ? pressed.what : "";
|
||||
const press = (what, kind, extra) => {
|
||||
if (page.gone || busy) return;
|
||||
pressed = { key, what };
|
||||
@@ -125,8 +136,8 @@ function drawPartial(card, end, busy, press) {
|
||||
}
|
||||
box.appendChild(el("p", "loop-end-hint", "Keep leaves these changes in your files. Discard takes them out and cannot be undone."));
|
||||
const row = el("div", "btn-row");
|
||||
row.appendChild(button("Keep these changes", "review-end-keep", "primary", busy, () => press("keep", "review-loop-partial", { keep: true })));
|
||||
row.appendChild(button("Discard them", "review-end-discard", "", busy, () => press("discard", "review-loop-partial", { keep: false })));
|
||||
row.appendChild(button("Keep these changes", "review-end-keep", "primary", busy, () => press("keep", "review-loop-partial", { keep: true }), "keep"));
|
||||
row.appendChild(button("Discard them", "review-end-discard", "", busy, () => press("discard", "review-loop-partial", { keep: false }), "discard"));
|
||||
box.appendChild(row);
|
||||
card.appendChild(box);
|
||||
}
|
||||
@@ -137,7 +148,7 @@ function drawStop(card, end, busy, press) {
|
||||
if (end.canContinue && !end.partial) {
|
||||
const choice = el("div", "loop-end-choice");
|
||||
const label = end.reason === "cap" ? "Run one more round" : "Continue";
|
||||
choice.appendChild(button(label, "review-end-continue", "", busy, () => press("continue", "review-loop-continue")));
|
||||
choice.appendChild(button(label, "review-end-continue", "", busy, () => press("continue", "review-loop-continue"), "continue"));
|
||||
choice.appendChild(el("p", "loop-end-hint", "Pick the review up again with the same setup."));
|
||||
card.appendChild(choice);
|
||||
}
|
||||
@@ -167,7 +178,7 @@ function drawStop(card, end, busy, press) {
|
||||
}
|
||||
const row = el("div", "btn-row");
|
||||
row.appendChild(
|
||||
button("Sign off", "review-end-signoff", "primary", busy || Boolean(end.partial), () => press("sign-off", "review-loop-sign-off", { picks: [...ticks.picks], squash: ticks.squash }))
|
||||
button("Sign off", "review-end-signoff", "primary", busy || Boolean(end.partial), () => press("sign-off", "review-loop-sign-off", { picks: [...ticks.picks], squash: ticks.squash }), "sign-off")
|
||||
);
|
||||
card.appendChild(row);
|
||||
card.appendChild(
|
||||
@@ -177,19 +188,19 @@ function drawStop(card, end, busy, press) {
|
||||
|
||||
function drawFinished(card, end, busy, press) {
|
||||
const actions = el("div", "loop-end-actions review-end-next");
|
||||
const add = (label, id, hint, primary, onClick) => {
|
||||
const add = (label, id, hint, primary, onClick, what) => {
|
||||
const choice = el("div", "loop-end-choice" + (primary ? " is-recommended" : ""));
|
||||
choice.appendChild(button(label, id, primary ? "primary" : "", busy, onClick));
|
||||
choice.appendChild(button(label, id, primary ? "primary" : "", busy, onClick, what));
|
||||
choice.appendChild(el("p", "loop-end-hint", hint));
|
||||
actions.appendChild(choice);
|
||||
};
|
||||
add("PR Prep", "review-end-pr-prep", "Get the branch ready for a pull request.", true, () => press("pr-prep", "review-loop-next", { next: "pr-prep" }));
|
||||
add("PR Prep", "review-end-pr-prep", "Get the branch ready for a pull request.", true, () => press("pr-prep", "review-loop-next", { next: "pr-prep" }), "pr-prep");
|
||||
if (Array.isArray(end.open) && end.open.length) {
|
||||
add("Fix what's left by hand", "review-end-quick-task", "Start a Quick task with the Critical and Warning findings still open.", false, () =>
|
||||
press("quick-task", "review-loop-next", { next: "quick-task" })
|
||||
press("quick-task", "review-loop-next", { next: "quick-task" }), "quick-task"
|
||||
);
|
||||
}
|
||||
add("Back to the dashboard", "review-end-dashboard", "Leave this screen and pick another skill. Your work stays as it is.", false, () => press("dashboard", "loop-dashboard"));
|
||||
add("Back to the dashboard", "review-end-dashboard", "Leave this screen and pick another skill. Your work stays as it is.", false, () => press("dashboard", "loop-dashboard"), "dashboard");
|
||||
card.appendChild(actions);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user