in components/Viewer.tsx [104:187]
render() {
const {hideBaseline, hideLevel, showSuppression, showAge, successMessage} = this.props
// Computed values fail to cache if called from onRenderNearElement() for unknown reasons. Thus call them in advance.
const currentfilterState = this.filter.getState()
const filterKeywords = currentfilterState.Keywords?.value
const nearElement = (() => {
const {runStoresSorted} = this
if (!runStoresSorted.length) return null // Interpreted as loading.
const filteredResultsCount = runStoresSorted.reduce((total, run) => total + run.filteredCount, 0)
if (filteredResultsCount === 0) {
const startingFilterState = this.props.filterState || recommendedDefaultState
const startingFilterStateLevel: string[] = startingFilterState['Level']?.value ?? []
if (!startingFilterStateLevel.length) {
startingFilterStateLevel.push('error', 'warning', 'note', 'none') // Normalize.
}
const currentfilterStateLevel: string[] = currentfilterState['Level']?.value ?? []
if (!currentfilterStateLevel.length) {
currentfilterStateLevel.push('error', 'warning', 'note', 'none') // Normalize.
}
// Desired Behavior Matrix:
// start curr
// ew ew success (common)
// ew e- noResult (there could still be warnings)
// ew -w noResult (there could still be errors)
// ew -- noResult (there could still be either)
// e- ew success
// e- e- success (common)
// e- -w noResult (there could still be errors)
// e- -- noResult (there could still be either)
// -w ew success (uncommon)
// -w e- noResult (there could still be warnings, uncommon)
// -w -w success (uncommon)
// -w -- noResult (there could still be either)
// -- ** no scenario
const showSuccess = successMessage
&& (!startingFilterStateLevel.includes('error') || currentfilterStateLevel.includes('error'))
&& (!startingFilterStateLevel.includes('warning') || currentfilterStateLevel.includes('warning'))
if (showSuccess && !filterKeywords) {
return <div className="page-content-left page-content-right page-content-top">
<Card contentProps={{ contentPadding: false }}>
<ZeroData
imagePath={successPng}
imageAltText="Success"
secondaryText={successMessage} />
</Card>
</div>
}
return <div className="page-content-left page-content-right page-content-top">
<Card contentProps={{ contentPadding: false }}>
<ZeroData
imagePath={noResultsPng}
imageAltText="No results found"
secondaryText="No results found" />
</Card>
</div>
}
return runStoresSorted
.filter(run => !filterKeywords || run.filteredCount)
.map((run, index) => <div key={run.logIndex} className="page-content-left page-content-right page-content-top">
<RunCard runStore={run} index={index} runCount={runStoresSorted.length} />
</div>)
})() as JSX.Element
return <FilterKeywordContext.Provider value={filterKeywords ?? ''}>
<SurfaceContext.Provider value={{ background: SurfaceBackground.neutral }}>
<Page>
<div className="swcShim"></div>
<FilterBar filter={this.filter} groupByAge={this.groupByAge.get()} hideBaseline={hideBaseline} hideLevel={hideLevel} showSuppression={showSuppression} showAge={showAge} />
{this.warnOldVersion && <MessageCard
severity={MessageCardSeverity.Warning}
onDismiss={() => this.warnOldVersion = false}>
Pre-SARIF-2.1 logs have been omitted. Use the Artifacts explorer to access all files.
</MessageCard>}
{nearElement}
</Page>
</SurfaceContext.Provider>
</FilterKeywordContext.Provider>
}