Skip to content

Commit

Permalink
fix: make JavaScript usable in Snyk Report tab
Browse files Browse the repository at this point in the history
  • Loading branch information
schottsfired committed Jan 24, 2025
1 parent 27a4930 commit 3a437cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion ui/enhancer/snyk-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ export class SnykReportTab extends Controls.BaseControl {
};

private fillReportIFrameContent = (content: string): void => {
(document.getElementById('iframeID') as HTMLDivElement).innerHTML = content;
const iframe = document.getElementById('snyk-report') as HTMLIFrameElement;
const doc = iframe.contentDocument || iframe.contentWindow?.document;
if (doc) {
doc.open();
doc.write(content);
doc.close();
}
};
}

Expand Down
19 changes: 12 additions & 7 deletions ui/snyk-report-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
height: 100%;
overflow: auto;
}
.iframeContainer {
.snyk-report {
overflow: auto;
min-width: 100%;
min-height: 100%;
}
.list {
Expand Down Expand Up @@ -65,7 +66,7 @@
<script type="text/javascript">
VSS.init({
explicitNotifyLoaded: true,
usePlatformScripts: true,
usePlatformScripts: false,
usePlatformStyles: true,
moduleLoaderConfig: {
paths: {
Expand All @@ -84,11 +85,15 @@
<script type="text/javascript">
VSS.init();
</script>
<h2>Reports:</h2>
<ul id="reportList" class="list"></ul>
<div class="iframeContainer">
<div id="iframeID" class="iframe"></div>
<div class="header">
<h2>Reports:</h2>
</div>
<div id="snyk-report" class="container"></div>
<ul id="reportList" class="list"></ul>
<iframe
id="snyk-report"
class="snyk-report"
sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-presentation"
src="about:blank"
></iframe>
</body>
</html>

0 comments on commit 3a437cd

Please sign in to comment.