Skip to content

Commit

Permalink
Make height dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Reamer committed Mar 17, 2020
1 parent aa7fa15 commit 36187f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Expand Up @@ -26,7 +26,8 @@ import { getJSON } from "sonar-request";
export default class DependencyCheckReportApp extends React.PureComponent {
state = {
loading: true,
data: []
data: [],
height: 0,
};

componentDidMount() {
Expand All @@ -36,16 +37,35 @@ export default class DependencyCheckReportApp extends React.PureComponent {
data
});
});
/**
* Add event listener
*/
this.updateDimensions();
window.addEventListener("resize", this.updateDimensions.bind(this));
}

/**
* Remove event listener
*/
componentWillUnmount() {
window.removeEventListener("resize", this.updateDimensions.bind(this));
}

updateDimensions() {
// 72px SonarQube common pane
// 72px SonarQube project pane
// 145,5 SonarQube footer
let update_height = window.innerHeight - (72 + 48 + 145.5);
this.setState({ height: update_height });
}

render() {
if (this.state.loading) {
return <div className="page page-limited"><DeferredSpinner /></div>;
}


return (<div className="page dependency-check-report-container dependency-check-report-content" >
<iframe classsandbox="allow-scripts allow-same-origin" srcdoc={this.state.data} style={{border: 'none', flex: '1 1 auto'}} />
return (<div className="page dependency-check-report-container" >
<iframe classsandbox="allow-scripts allow-same-origin" height={this.state.height} srcdoc={this.state.data} style={{border: 'none'}} />
</div>);
}
}
Expand Down
5 changes: 0 additions & 5 deletions sonar-dependency-check-plugin/src/main/js/style.css
Expand Up @@ -17,12 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
.dependency-check-report-content {
flex: 1 1 auto;
}

.dependency-check-report-container {
display: flex;
flex-direction: column;
height: 720px;
}

0 comments on commit 36187f9

Please sign in to comment.