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,
);
const variantAnalysisQueryKind = "problem";
return (
<RepositoriesSearchSortRowComponent
filterSortValue={filterSortValue}
resultFormatValue={resultFormatValue}
onFilterSortChange={setFilterSortValue}
onResultFormatChange={setResultFormatValue}
variantAnalysisQueryKind={variantAnalysisQueryKind}
/>
);
};

View File

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

View File

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