Only show the "result format" dropdown for (path-)problem queries

This commit is contained in:
shati-patel
2023-08-24 12:32:24 +01:00
parent 6715669036
commit f8d542d141
3 changed files with 22 additions and 4 deletions

View File

@@ -28,12 +28,15 @@ export const RepositoriesSearchSortRow = () => {
ResultFormat.Alerts, ResultFormat.Alerts,
); );
const variantAnalysisQueryKind = "problem";
return ( return (
<RepositoriesSearchSortRowComponent <RepositoriesSearchSortRowComponent
filterSortValue={filterSortValue} filterSortValue={filterSortValue}
resultFormatValue={resultFormatValue} resultFormatValue={resultFormatValue}
onFilterSortChange={setFilterSortValue} onFilterSortChange={setFilterSortValue}
onResultFormatChange={setResultFormatValue} onResultFormatChange={setResultFormatValue}
variantAnalysisQueryKind={variantAnalysisQueryKind}
/> />
); );
}; };

View File

@@ -17,6 +17,7 @@ type Props = {
resultFormatValue: ResultFormat; resultFormatValue: ResultFormat;
onFilterSortChange: Dispatch<SetStateAction<RepositoriesFilterSortState>>; onFilterSortChange: Dispatch<SetStateAction<RepositoriesFilterSortState>>;
onResultFormatChange: Dispatch<SetStateAction<ResultFormat>>; onResultFormatChange: Dispatch<SetStateAction<ResultFormat>>;
variantAnalysisQueryKind: string | undefined;
}; };
const Container = styled.div` const Container = styled.div`
@@ -43,11 +44,21 @@ const RepositoriesResultFormatColumn = styled(RepositoriesResultFormat)`
flex: 1; flex: 1;
`; `;
function showResultFormatColumn(
variantAnalysisQueryKind: string | undefined,
): boolean {
return (
variantAnalysisQueryKind === "problem" ||
variantAnalysisQueryKind === "path-problem"
);
}
export const RepositoriesSearchSortRow = ({ export const RepositoriesSearchSortRow = ({
filterSortValue, filterSortValue,
resultFormatValue, resultFormatValue,
onFilterSortChange, onFilterSortChange,
onResultFormatChange, onResultFormatChange,
variantAnalysisQueryKind,
}: Props) => { }: Props) => {
const handleSearchValueChange = useCallback( const handleSearchValueChange = useCallback(
(searchValue: string) => { (searchValue: string) => {
@@ -100,10 +111,12 @@ export const RepositoriesSearchSortRow = ({
value={filterSortValue.sortKey} value={filterSortValue.sortKey}
onChange={handleSortKeyChange} onChange={handleSortKeyChange}
/> />
<RepositoriesResultFormatColumn {showResultFormatColumn(variantAnalysisQueryKind) && (
value={resultFormatValue} <RepositoriesResultFormatColumn
onChange={handleResultFormatChange} value={resultFormatValue}
/> onChange={handleResultFormatChange}
/>
)}
</Container> </Container>
); );
}; };

View File

@@ -129,6 +129,7 @@ export const VariantAnalysisOutcomePanels = ({
resultFormatValue={resultFormat} resultFormatValue={resultFormat}
onFilterSortChange={setFilterSortState} onFilterSortChange={setFilterSortState}
onResultFormatChange={setResultFormat} onResultFormatChange={setResultFormat}
variantAnalysisQueryKind={variantAnalysis.query.kind}
/> />
<VariantAnalysisAnalyzedRepos <VariantAnalysisAnalyzedRepos
variantAnalysis={variantAnalysis} variantAnalysis={variantAnalysis}
@@ -150,6 +151,7 @@ export const VariantAnalysisOutcomePanels = ({
resultFormatValue={resultFormat} resultFormatValue={resultFormat}
onFilterSortChange={setFilterSortState} onFilterSortChange={setFilterSortState}
onResultFormatChange={setResultFormat} onResultFormatChange={setResultFormat}
variantAnalysisQueryKind={variantAnalysis.query.kind}
/> />
<VSCodePanels> <VSCodePanels>
{scannedReposCount > 0 && ( {scannedReposCount > 0 && (