@@ -280,9 +280,7 @@ export function renderDashboard(token) {
280280 <table aria-label="Process-PSModule caller workflow inventory">
281281 <thead>
282282 <tr>
283- <th scope="col">Select</th>
284283 <th scope="col">Repository</th>
285- <th scope="col">Workflow</th>
286284 <th scope="col">Reference / compliance</th>
287285 <th scope="col">Triggers</th>
288286 <th scope="col">Concurrency</th>
@@ -410,22 +408,6 @@ export function renderDashboard(token) {
410408 return cell;
411409 }
412410
413- function workflowCell(record) {
414- const cell = document.createElement("td");
415- const path = document.createElement(record.workflowUrl ? "a" : "span");
416- path.textContent = text(record.workflowPath);
417- if (record.workflowUrl) {
418- path.href = record.workflowUrl;
419- path.target = "_blank";
420- path.rel = "noreferrer";
421- }
422- const name = document.createElement("div");
423- name.className = "muted";
424- name.textContent = text(record.workflowName);
425- cell.append(path, name);
426- return cell;
427- }
428-
429411 function complianceCell(record) {
430412 const cell = document.createElement("td");
431413 const references = record.processJobs.map((job) => job.reference);
@@ -470,7 +452,6 @@ export function renderDashboard(token) {
470452 renderRows();
471453 renderInspector(record);
472454 });
473- const selectCell = document.createElement("td");
474455 const checkbox = document.createElement("input");
475456 checkbox.type = "checkbox";
476457 checkbox.checked = ui.state.selection.includes(record.repository);
@@ -480,11 +461,10 @@ export function renderDashboard(token) {
480461 checkbox.checked ? next.add(record.repository) : next.delete(record.repository);
481462 await updateSelection([...next]);
482463 });
483- selectCell.append(checkbox);
464+ const identityCell = repositoryCell(record);
465+ identityCell.prepend(checkbox, document.createTextNode(" "));
484466 row.append(
485- selectCell,
486- repositoryCell(record),
487- workflowCell(record),
467+ identityCell,
488468 complianceCell(record),
489469 codeCell(triggerText(record)),
490470 codeCell("group=" + text(record.concurrencyGroup) + "\\ncancel=" + text(record.cancelInProgress)),
@@ -558,7 +538,16 @@ export function renderDashboard(token) {
558538 statusBadge.textContent = record.analysis.status;
559539 const path = document.createElement("p");
560540 path.className = "muted";
561- path.textContent = text(record.workflowPath);
541+ if (record.workflowUrl) {
542+ const link = document.createElement("a");
543+ link.href = record.workflowUrl;
544+ link.target = "_blank";
545+ link.rel = "noreferrer";
546+ link.textContent = text(record.workflowPath);
547+ path.append(link, document.createTextNode(" · " + text(record.workflowName)));
548+ } else {
549+ path.textContent = text(record.workflowPath) + " · " + text(record.workflowName);
550+ }
562551 const deltaSection = detailSection(
563552 "Required changes",
564553 record.analysis.deltas,
@@ -604,9 +593,36 @@ export function renderDashboard(token) {
604593 }
605594 }
606595
596+ function shouldAutoRefresh() {
597+ if (ui.state.inventoryStatus === "not-refreshed") return true;
598+ if (ui.state.inventoryStatus !== "ready" || !ui.state.generatedAt) return false;
599+ const generatedAt = Date.parse(ui.state.generatedAt);
600+ return Number.isFinite(generatedAt) && Date.now() - generatedAt > 15 * 60 * 1000;
601+ }
602+
603+ async function refreshInventory() {
604+ byId("refresh").disabled = true;
605+ setStatus("Refreshing authenticated GitHub inventory…");
606+ try {
607+ await api("/api/refresh", {
608+ method: "POST",
609+ body: JSON.stringify({ organization: ui.state.organization || "PSModule" }),
610+ });
611+ } catch (error) {
612+ setStatus(error.message, "error");
613+ } finally {
614+ ui.state = await api("/api/state");
615+ renderState();
616+ byId("refresh").disabled = false;
617+ }
618+ }
619+
607620 async function loadState() {
608621 ui.state = await api("/api/state");
609622 renderState();
623+ if (shouldAutoRefresh()) {
624+ await refreshInventory();
625+ }
610626 }
611627
612628 async function updateSelection(repositories) {
@@ -634,21 +650,7 @@ export function renderDashboard(token) {
634650 });
635651 }
636652
637- byId("refresh").addEventListener("click", async () => {
638- byId("refresh").disabled = true;
639- setStatus("Refreshing authenticated GitHub inventory…");
640- try {
641- await api("/api/refresh", {
642- method: "POST",
643- body: JSON.stringify({ organization: ui.state.organization || "PSModule" }),
644- });
645- } catch (error) {
646- setStatus(error.message, "error");
647- } finally {
648- await loadState();
649- byId("refresh").disabled = false;
650- }
651- });
653+ byId("refresh").addEventListener("click", refreshInventory);
652654 byId("search").addEventListener("input", renderRows);
653655 byId("filter").addEventListener("change", renderRows);
654656 byId("select-visible").addEventListener("click", () => updateSelection(ui.visible.map((record) => record.repository)));
0 commit comments