Enable hideBaseline and hideLevel.
This commit is contained in:
Родитель
e1378d85eb
Коммит
5536671a92
|
@ -28,28 +28,28 @@ export class MobxFilter extends Filter {
|
|||
}
|
||||
}
|
||||
|
||||
@observer export class FilterBar extends React.Component<{ filter: MobxFilter, showReview: boolean }> {
|
||||
@observer export class FilterBar extends React.Component<{ filter: MobxFilter, hideBaseline?:boolean, hideLevel?: boolean, showReview: boolean }> {
|
||||
private ms1 = new DropdownMultiSelection()
|
||||
private ms2 = new DropdownMultiSelection()
|
||||
private ms3 = new DropdownMultiSelection()
|
||||
render() {
|
||||
const {filter, showReview} = this.props
|
||||
const {filter, hideBaseline, hideLevel, showReview} = this.props
|
||||
return <AzFilterBar filter={filter}>
|
||||
<KeywordFilterBarItem filterItemKey="Keywords" placeholder="Filter by keyword" />
|
||||
<AzDropdownFilterBarItem
|
||||
{!hideBaseline && <AzDropdownFilterBarItem
|
||||
filterItemKey="Baseline"
|
||||
placeholder="Baseline"
|
||||
showPlaceholderAsLabel
|
||||
items={['New', 'Unchanged', 'Updated', 'Absent'].map(text => ({ id: text.toLowerCase(), text }))}
|
||||
selection={this.ms1}
|
||||
/>
|
||||
<AzDropdownFilterBarItem
|
||||
/>}
|
||||
{!hideLevel && <AzDropdownFilterBarItem
|
||||
filterItemKey="Level"
|
||||
placeholder="Level"
|
||||
showPlaceholderAsLabel
|
||||
items={['None', 'Note', 'Warning', 'Error'].map(text => ({ id: text.toLowerCase(), text }))}
|
||||
selection={this.ms2}
|
||||
/>
|
||||
/>}
|
||||
{showReview && <AzDropdownFilterBarItem
|
||||
filterItemKey="Review"
|
||||
placeholder="Review"
|
||||
|
|
|
@ -23,11 +23,19 @@ export class RunStore {
|
|||
@observable sortOrder = SortOrder.ascending
|
||||
private rulesInUse: Map<string, Rule>
|
||||
|
||||
constructor(readonly run: Run, readonly logIndex, readonly filter: MobxFilter, readonly pipeline?: PipelineContext) {
|
||||
constructor(readonly run: Run, readonly logIndex, readonly filter: MobxFilter, readonly pipeline?: PipelineContext, readonly hideBaseline?: boolean) {
|
||||
const {driver} = run.tool
|
||||
const rules = driver.rules || []
|
||||
this.driverName = run.properties && run.properties['logFileName'] || driver.name.replace(/^Microsoft.CodeAnalysis.Sarif.PatternMatcher$/, 'CredScan on Push')
|
||||
|
||||
if (!hideBaseline) {
|
||||
this.columns.push({
|
||||
id: 'Baseline',
|
||||
filterString: (result: Result) => result.baselineState as string || 'new',
|
||||
sortString: (result: Result) => result.baselineState as string || 'new',
|
||||
})
|
||||
}
|
||||
|
||||
const hasWorkItemUris = run.results && run.results.some(result => result.workItemUris && !!result.workItemUris.length)
|
||||
if (hasWorkItemUris) {
|
||||
this.columns.push({
|
||||
|
@ -134,13 +142,14 @@ export class RunStore {
|
|||
|
||||
treeItem.childItemsAll = rule.results
|
||||
.filter(result => {
|
||||
if (filterBaseline.length && !filterBaseline.includes(this.columns[2].filterString(result))) return false
|
||||
if (filterLevel .length && !filterLevel .includes(result.level || 'warning') ) return false
|
||||
if (filterReview .length && !filterReview .includes(this.columns[3].filterString(result))) return false
|
||||
// Possible bug with certain combinations of baseline/review show/hide.
|
||||
if (this.columns[2] && filterBaseline.length && !filterBaseline.includes(this.columns[2].filterString(result))) return false
|
||||
if ( filterLevel .length && !filterLevel .includes(result.level || 'warning') ) return false
|
||||
if (this.columns[3] && filterReview .length && !filterReview .includes(this.columns[3].filterString(result))) return false
|
||||
|
||||
const path = this.columns[0].filterString(result).toLowerCase()
|
||||
const details = this.columns[1].filterString(result).toLowerCase()
|
||||
const baseline = this.columns[2].filterString(result).toLowerCase()
|
||||
const path = this.columns[0]?.filterString(result).toLowerCase() ?? ''
|
||||
const details = this.columns[1]?.filterString(result).toLowerCase() ?? ''
|
||||
const baseline = this.columns[2]?.filterString(result).toLowerCase() ?? ''
|
||||
|
||||
return isDriverMatch || isRuleMatch || isMatch(path, filterKeywords) || isMatch( details, filterKeywords) || isMatch(baseline, filterKeywords)
|
||||
})
|
||||
|
@ -207,10 +216,5 @@ export class RunStore {
|
|||
},
|
||||
sortString: (result: Result) => result.message.text as string || '',
|
||||
},
|
||||
{
|
||||
id: 'Baseline',
|
||||
filterString: (result: Result) => result.baselineState as string || 'new',
|
||||
sortString: (result: Result) => result.baselineState as string || 'new',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
@ -33,7 +33,16 @@ import { IFilterState } from 'azure-devops-ui/Utilities/Filter'
|
|||
import { ZeroData } from 'azure-devops-ui/ZeroData'
|
||||
import { ObservableValue } from 'azure-devops-ui/Core/Observable'
|
||||
|
||||
@observer export class Viewer extends Component<{ logs?: Log[], filterState?: IFilterState, pipelineId?: string, user?: string }> {
|
||||
interface ViewerProps {
|
||||
logs?: Log[]
|
||||
filterState?: IFilterState
|
||||
pipelineId?: string
|
||||
user?: string
|
||||
hideBaseline?: boolean
|
||||
hideLevel?: boolean
|
||||
}
|
||||
|
||||
@observer export class Viewer extends Component<ViewerProps> {
|
||||
private collapseComments = new ObservableValue(false)
|
||||
private filter: MobxFilter
|
||||
private pipelineContext?: PipelineContext
|
||||
|
@ -62,10 +71,10 @@ import { ObservableValue } from 'azure-devops-ui/Core/Observable'
|
|||
})
|
||||
|
||||
@computed get runStores() {
|
||||
const {logs} = this.props
|
||||
const {logs, hideBaseline} = this.props
|
||||
if (!logs) return [] // Undef interpreted as loading.
|
||||
const runs = [].concat(...logs.filter(log => log.version === '2.1.0').map(log => log.runs)) as Run[]
|
||||
const runStores = runs.map((run, i) => new RunStore(run, i, this.filter, this.pipelineContext))
|
||||
const runStores = runs.map((run, i) => new RunStore(run, i, this.filter, this.pipelineContext, hideBaseline))
|
||||
runStores.sort((a, b) => a.driverName.localeCompare(b.driverName)) // May not be required after introduction of runStoresSorted.
|
||||
return runStores
|
||||
}
|
||||
|
@ -78,11 +87,13 @@ import { ObservableValue } from 'azure-devops-ui/Core/Observable'
|
|||
const {pipelineContext} = this
|
||||
if (pipelineContext && !pipelineContext.reviews) return null
|
||||
|
||||
const {hideBaseline, hideLevel} = this.props
|
||||
|
||||
// Computed values fail to cache if called from onRenderNearElement() for unknown reasons. Thus call them in advance.
|
||||
const filterKeywords = this.filter.getState().Keywords?.value
|
||||
const nearElement = <Page>
|
||||
<div className="swcShim"></div>
|
||||
<FilterBar filter={this.filter} showReview={false} />
|
||||
<FilterBar filter={this.filter} hideBaseline={hideBaseline} hideLevel={hideLevel} showReview={false} />
|
||||
{this.warnOldVersion && <MessageCard
|
||||
severity={MessageCardSeverity.Warning}
|
||||
onDismiss={() => this.warnOldVersion = false}>
|
||||
|
|
Загрузка…
Ссылка в новой задаче