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)
|
||||
- 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)
|
||||
- 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
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ export type VariantAnalysisActionsProps = {
|
||||
onExportResultsClick: () => void;
|
||||
copyRepositoryListDisabled?: boolean;
|
||||
exportResultsDisabled?: boolean;
|
||||
|
||||
hasSelectedRepositories?: boolean;
|
||||
hasFilteredRepositories?: boolean;
|
||||
};
|
||||
|
||||
const Container = styled.div`
|
||||
@@ -26,6 +29,28 @@ const Button = styled(VSCodeButton)`
|
||||
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 = ({
|
||||
variantAnalysisStatus,
|
||||
onStopQueryClick,
|
||||
@@ -35,6 +60,8 @@ export const VariantAnalysisActions = ({
|
||||
onExportResultsClick,
|
||||
copyRepositoryListDisabled,
|
||||
exportResultsDisabled,
|
||||
hasSelectedRepositories,
|
||||
hasFilteredRepositories,
|
||||
}: VariantAnalysisActionsProps) => {
|
||||
return (
|
||||
<Container>
|
||||
@@ -45,14 +72,26 @@ export const VariantAnalysisActions = ({
|
||||
onClick={onCopyRepositoryListClick}
|
||||
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
|
||||
appearance="primary"
|
||||
onClick={onExportResultsClick}
|
||||
disabled={exportResultsDisabled}
|
||||
>
|
||||
Export results
|
||||
{chooseText({
|
||||
hasSelectedRepositories,
|
||||
hasFilteredRepositories,
|
||||
normalText: "Export results",
|
||||
selectedText: "Export selected results",
|
||||
filteredText: "Export filtered results",
|
||||
})}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -131,6 +131,13 @@ export const VariantAnalysisHeader = ({
|
||||
stopQueryDisabled={!variantAnalysis.actionsWorkflowRunId}
|
||||
exportResultsDisabled={!hasDownloadedRepos}
|
||||
copyRepositoryListDisabled={!hasReposWithResults}
|
||||
hasFilteredRepositories={
|
||||
variantAnalysis.scannedRepos?.length !==
|
||||
filteredRepositories?.length
|
||||
}
|
||||
hasSelectedRepositories={
|
||||
selectedRepositoryIds && selectedRepositoryIds.length > 0
|
||||
}
|
||||
/>
|
||||
</Row>
|
||||
<VariantAnalysisStats
|
||||
|
||||
@@ -93,4 +93,32 @@ describe(VariantAnalysisActions.name, () => {
|
||||
|
||||
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