Merge pull request #2427 from github/koesie10/export-copy-selected-text
Update export/copy buttons copy when repositories are selected
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
- Add settings `codeQL.variantAnalysis.defaultResultsFilter` and `codeQL.variantAnalysis.defaultResultsSort` for configuring how variant analysis results are filtered and sorted in the results view. The default is to show all repositories, and to sort by the number of results. [#2392](https://github.com/github/vscode-codeql/pull/2392)
|
- Add settings `codeQL.variantAnalysis.defaultResultsFilter` and `codeQL.variantAnalysis.defaultResultsSort` for configuring how variant analysis results are filtered and sorted in the results view. The default is to show all repositories, and to sort by the number of results. [#2392](https://github.com/github/vscode-codeql/pull/2392)
|
||||||
- Fix bug to ensure error messages have complete stack trace in message logs. [#2425](https://github.com/github/vscode-codeql/pull/2425)
|
- Fix bug to ensure error messages have complete stack trace in message logs. [#2425](https://github.com/github/vscode-codeql/pull/2425)
|
||||||
- Fix bug where the `CodeQL: Compare Query` command did not work for comparing quick-eval queries. [#2422](https://github.com/github/vscode-codeql/pull/2422)
|
- Fix bug where the `CodeQL: Compare Query` command did not work for comparing quick-eval queries. [#2422](https://github.com/github/vscode-codeql/pull/2422)
|
||||||
|
- Update text of copy and export buttons in variant analysis results view to clarify that they only copy/export the selected/filtered results. [#2427](https://github.com/github/vscode-codeql/pull/2427)
|
||||||
|
|
||||||
## 1.8.4 - 3 May 2023
|
## 1.8.4 - 3 May 2023
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ export type VariantAnalysisActionsProps = {
|
|||||||
onExportResultsClick: () => void;
|
onExportResultsClick: () => void;
|
||||||
copyRepositoryListDisabled?: boolean;
|
copyRepositoryListDisabled?: boolean;
|
||||||
exportResultsDisabled?: boolean;
|
exportResultsDisabled?: boolean;
|
||||||
|
|
||||||
|
hasSelectedRepositories?: boolean;
|
||||||
|
hasFilteredRepositories?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
@@ -26,6 +29,28 @@ const Button = styled(VSCodeButton)`
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const chooseText = ({
|
||||||
|
hasSelectedRepositories,
|
||||||
|
hasFilteredRepositories,
|
||||||
|
normalText,
|
||||||
|
selectedText,
|
||||||
|
filteredText,
|
||||||
|
}: {
|
||||||
|
hasSelectedRepositories?: boolean;
|
||||||
|
hasFilteredRepositories?: boolean;
|
||||||
|
normalText: string;
|
||||||
|
selectedText: string;
|
||||||
|
filteredText: string;
|
||||||
|
}) => {
|
||||||
|
if (hasSelectedRepositories) {
|
||||||
|
return selectedText;
|
||||||
|
}
|
||||||
|
if (hasFilteredRepositories) {
|
||||||
|
return filteredText;
|
||||||
|
}
|
||||||
|
return normalText;
|
||||||
|
};
|
||||||
|
|
||||||
export const VariantAnalysisActions = ({
|
export const VariantAnalysisActions = ({
|
||||||
variantAnalysisStatus,
|
variantAnalysisStatus,
|
||||||
onStopQueryClick,
|
onStopQueryClick,
|
||||||
@@ -35,6 +60,8 @@ export const VariantAnalysisActions = ({
|
|||||||
onExportResultsClick,
|
onExportResultsClick,
|
||||||
copyRepositoryListDisabled,
|
copyRepositoryListDisabled,
|
||||||
exportResultsDisabled,
|
exportResultsDisabled,
|
||||||
|
hasSelectedRepositories,
|
||||||
|
hasFilteredRepositories,
|
||||||
}: VariantAnalysisActionsProps) => {
|
}: VariantAnalysisActionsProps) => {
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
@@ -45,14 +72,26 @@ export const VariantAnalysisActions = ({
|
|||||||
onClick={onCopyRepositoryListClick}
|
onClick={onCopyRepositoryListClick}
|
||||||
disabled={copyRepositoryListDisabled}
|
disabled={copyRepositoryListDisabled}
|
||||||
>
|
>
|
||||||
Copy repository list
|
{chooseText({
|
||||||
|
hasSelectedRepositories,
|
||||||
|
hasFilteredRepositories,
|
||||||
|
normalText: "Copy repository list",
|
||||||
|
selectedText: "Copy selected repositories as a list",
|
||||||
|
filteredText: "Copy filtered repositories as a list",
|
||||||
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
appearance="primary"
|
appearance="primary"
|
||||||
onClick={onExportResultsClick}
|
onClick={onExportResultsClick}
|
||||||
disabled={exportResultsDisabled}
|
disabled={exportResultsDisabled}
|
||||||
>
|
>
|
||||||
Export results
|
{chooseText({
|
||||||
|
hasSelectedRepositories,
|
||||||
|
hasFilteredRepositories,
|
||||||
|
normalText: "Export results",
|
||||||
|
selectedText: "Export selected results",
|
||||||
|
filteredText: "Export filtered results",
|
||||||
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -131,6 +131,13 @@ export const VariantAnalysisHeader = ({
|
|||||||
stopQueryDisabled={!variantAnalysis.actionsWorkflowRunId}
|
stopQueryDisabled={!variantAnalysis.actionsWorkflowRunId}
|
||||||
exportResultsDisabled={!hasDownloadedRepos}
|
exportResultsDisabled={!hasDownloadedRepos}
|
||||||
copyRepositoryListDisabled={!hasReposWithResults}
|
copyRepositoryListDisabled={!hasReposWithResults}
|
||||||
|
hasFilteredRepositories={
|
||||||
|
variantAnalysis.scannedRepos?.length !==
|
||||||
|
filteredRepositories?.length
|
||||||
|
}
|
||||||
|
hasSelectedRepositories={
|
||||||
|
selectedRepositoryIds && selectedRepositoryIds.length > 0
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
<VariantAnalysisStats
|
<VariantAnalysisStats
|
||||||
|
|||||||
@@ -93,4 +93,32 @@ describe(VariantAnalysisActions.name, () => {
|
|||||||
|
|
||||||
expect(container.querySelectorAll("vscode-button").length).toEqual(0);
|
expect(container.querySelectorAll("vscode-button").length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("changes the text on the buttons when repositories are selected", async () => {
|
||||||
|
render({
|
||||||
|
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||||
|
showResultActions: true,
|
||||||
|
hasSelectedRepositories: true,
|
||||||
|
hasFilteredRepositories: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(screen.getByText("Export selected results")).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByText("Copy selected repositories as a list"),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("changes the text on the buttons when repositories are filtered", async () => {
|
||||||
|
render({
|
||||||
|
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||||
|
showResultActions: true,
|
||||||
|
hasSelectedRepositories: false,
|
||||||
|
hasFilteredRepositories: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(screen.getByText("Export filtered results")).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByText("Copy filtered repositories as a list"),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user