Remove raw finding view

This commit is contained in:
2026-04-21 13:28:11 +00:00
parent 37e4309524
commit 6d8f7a0559
4 changed files with 4 additions and 122 deletions

View File

@@ -6,7 +6,6 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV
actions: {
runAnalysis: StorageAuditReportApp.#onRunAnalysis,
toggleShowAll: StorageAuditReportApp.#onToggleShowAll,
toggleRaw: StorageAuditReportApp.#onToggleRaw,
exportReport: StorageAuditReportApp.#onExportReport
},
window: {
@@ -24,7 +23,6 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV
#loading = false;
#showAll = false;
#progress = null;
#showRaw = false;
constructor(options = {}) {
super(options);
@@ -39,11 +37,9 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV
loading: this.#loading,
hasAnalysis: !!this.#analysis,
showAll: this.#showAll,
showRaw: this.#showRaw,
progress: this.#progress,
summary: this.#summarize(this.#analysis),
groupedFindings,
findings: await enrichFindings(visibleFindings)
groupedFindings
};
}
@@ -90,35 +86,11 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV
</button>
</div>
</div>
<div class="storage-audit__toggle-group" role="group" aria-label="${escapeHtml(localize("KSA.Action.DetailLabel"))}">
<span class="storage-audit__toggle-label">${localize("KSA.Action.DetailLabel")}</span>
<div class="storage-audit__toggle-buttons">
<button
type="button"
class="button ${context.showRaw ? "" : "active"}"
data-action="toggleRaw"
data-mode="grouped"
aria-pressed="${context.showRaw ? "false" : "true"}"
${context.hasAnalysis ? "" : "disabled"}>
<span>${localize("KSA.Action.GroupedOnly")}</span>
</button>
<button
type="button"
class="button ${context.showRaw ? "active" : ""}"
data-action="toggleRaw"
data-mode="raw"
aria-pressed="${context.showRaw ? "true" : "false"}"
${context.hasAnalysis ? "" : "disabled"}>
<span>${localize("KSA.Action.WithRaw")}</span>
</button>
</div>
</div>
</div>
</section>
${renderProgress(context.progress, context.loading)}
${renderSummary(context.summary, context.loading)}
${renderGroupedFindingList(context.groupedFindings, context.hasAnalysis, context.loading, context.showAll)}
${renderFindingList(context.findings, context.hasAnalysis, context.loading, context.showAll, context.showRaw)}
`;
return container;
}
@@ -165,16 +137,6 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV
return this.render({ force: true });
}
toggleRaw() {
this.#showRaw = !this.#showRaw;
return this.render({ force: true });
}
setShowRaw(value) {
this.#showRaw = !!value;
return this.render({ force: true });
}
exportReport() {
if (!this.#analysis) return;
const payload = {
@@ -245,17 +207,6 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV
return this.toggleShowAll();
}
static #onToggleRaw(_event, _button) {
const mode = _button?.dataset?.mode;
if (mode === "grouped") {
return this.setShowRaw(false);
}
if (mode === "raw") {
return this.setShowRaw(true);
}
return this.toggleRaw();
}
static #onExportReport(_event, _button) {
return this.exportReport();
}
@@ -432,43 +383,6 @@ function renderGroupedSourcesCell(sources) {
return `<div class="storage-audit__source-list">${sources.map(source => `<div>${source.renderedSource ?? renderPlainSourceLabel(source)}</div>`).join("")}</div>`;
}
function renderFindingList(findings, hasAnalysis, loading, showAll, showRaw) {
if (loading) {
return `<section class="storage-audit__list"><p>${localize("KSA.Section.Running")}</p></section>`;
}
if (!hasAnalysis) {
return `<section class="storage-audit__list"><p>${localize("KSA.Section.NoPrompt")}</p></section>`;
}
if (!showRaw) {
return "";
}
if (!findings.length) {
return `<section class="storage-audit__list"><p>${format("KSA.Section.NoRaw", { scope: localize(showAll ? "KSA.Scope.Empty" : "KSA.Scope.Warning") })}</p></section>`;
}
const items = findings.map(finding => `
<article class="storage-audit__finding severity-${finding.severity}">
<header>
<span class="storage-audit__severity">${severityLabel(finding.severity)}</span>
<span>${humanizeKind(finding.kind)}</span>
</header>
<p>${escapeHtml(finding.reason)}</p>
<dl>
<div><dt>${localize("KSA.Field.Target")}</dt><dd><code>${escapeHtml(finding.target.locator ?? `${finding.target.storage}:${finding.target.path}`)}</code></dd></div>
${finding.source ? `<div><dt>${localize("KSA.Field.Source")}</dt><dd>${finding.source.renderedSource ?? renderPlainSourceLabel(finding.source)}</dd></div>` : ""}
</dl>
<p class="storage-audit__recommendation">${escapeHtml(finding.recommendation)}</p>
</article>
`).join("");
return `
<section class="storage-audit__list storage-audit__list--raw">
<h3>${localize("KSA.Section.RawEntries")}</h3>
${items}
</section>
`;
}
function groupFindings(findings) {
return {
brokenReferences: groupByTarget(findings.filter(f => f.kind === "broken-reference")),
@@ -645,24 +559,6 @@ async function enrichGroupedSources(groups) {
return enriched;
}
async function enrichFindings(findings) {
const enriched = [];
for (const finding of findings) {
if (!finding.source) {
enriched.push(finding);
continue;
}
enriched.push({
...finding,
source: {
...finding.source,
renderedSource: await renderSourceHtml(finding.source)
}
});
}
return enriched;
}
async function renderSourceHtml(source) {
const markup = buildSourceMarkup(source);
if (!markup) return renderPlainSourceLabel(source);