@(
    projectsWithSelection: ProjectsWithSelection,
    vulnerability: Vulnerability,
    affectedProjects: Map[ReportInfo, Set[GroupedDependency]],
    vulnerableDependencies: Set[GroupedDependency],
    affectedLibraries: Set[PlainLibraryIdentifier],
    issueOption: Option[(ExportedVulnerability[String], String)]
)(implicit header: DefaultRequest)
@section = @{views.html.genericSection("vuln")("h2") _}
@main(
    title = s"vulnerability ${vulnerability.name} for ${projectsWithSelection.projectNameText}",
    projectsOption = Some((projectsWithSelection, p => routes.Statistics.vulnerability(vulnerability.name, p)))
) {
    @if(projectsWithSelection.isProjectSpecified){
        <div class="alert alert-warning">The vulnerability details are limited to some subset of projects.<br><a class="btn btn-default" href="@routes.Statistics.vulnerability(vulnerability.name, None)">Show it for all projects!</a></div>
    }
    @for((ticket, issueLink) <- issueOption){
        <a class="btn btn-block btn-primary" href="@issueLink">Issue in your issue tracker: @ticket.ticket</a>
    }
    @section("details", "Vulnerability details") {
        @views.html.vulnerability("h2", "vuln-details", vulnerability)
    }
    @section("affected-libs", s"Unique affected libraries – without version number (${affectedLibraries.size})"){
        <ul>
            @for(lib <- affectedLibraries){
                <li>@lib</li>
            }
        </ul>
    }
    @section("affected-deps", s"Unique affected dependencies (${vulnerableDependencies.size})"){
        <ul>
            @for(dep <- vulnerableDependencies){
                <li class="library-identification">@libraryIdentification(dep)</li>
            }
        </ul>
    }
    @section("affected-projects", s"Affected projects (${affectedProjects.size} projects with ${affectedProjects.flatMap(_._2).size} occurrences)"){
        @for((project, dependencies) <- affectedProjects.toSeq.sortBy(_._1)){
            <h3><a href="@routes.Statistics.basic(Some("project:"+project.fullId))">@friendlyProjectName(project)</a> (@dependencies.size)</h3>
            <ul>
                @for(dep <- dependencies.toSeq){
                    <li class="library-identification">@libraryIdentification(dep)</li>
                }
            </ul>
        }
    }
}
