Update export/copy buttons copy when repositories are selected

This changes the text of the export/copy buttons on a variant analysis
when at least one repository is selected. This makes it more clear that
the user is only exporting/copying the results of the selected
repositories.
This commit is contained in:
Koen Vlaswinkel
2023-05-17 15:03:28 +02:00
parent baea36561d
commit fa39bd1c2c
3 changed files with 25 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ export type VariantAnalysisActionsProps = {
onExportResultsClick: () => void;
copyRepositoryListDisabled?: boolean;
exportResultsDisabled?: boolean;
hasSelectedRepositories?: boolean;
};
const Container = styled.div`
@@ -35,6 +37,7 @@ export const VariantAnalysisActions = ({
onExportResultsClick,
copyRepositoryListDisabled,
exportResultsDisabled,
hasSelectedRepositories,
}: VariantAnalysisActionsProps) => {
return (
<Container>
@@ -45,14 +48,18 @@ export const VariantAnalysisActions = ({
onClick={onCopyRepositoryListClick}
disabled={copyRepositoryListDisabled}
>
Copy repository list
{hasSelectedRepositories
? "Copy selected repositories as a list"
: "Copy repository list"}
</Button>
<Button
appearance="primary"
onClick={onExportResultsClick}
disabled={exportResultsDisabled}
>
Export results
{hasSelectedRepositories
? "Export selected results"
: "Export results"}
</Button>
</>
)}

View File

@@ -131,6 +131,9 @@ export const VariantAnalysisHeader = ({
stopQueryDisabled={!variantAnalysis.actionsWorkflowRunId}
exportResultsDisabled={!hasDownloadedRepos}
copyRepositoryListDisabled={!hasReposWithResults}
hasSelectedRepositories={
selectedRepositoryIds && selectedRepositoryIds.length > 0
}
/>
</Row>
<VariantAnalysisStats

View File

@@ -93,4 +93,17 @@ 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,
});
expect(screen.getByText("Export selected results")).toBeInTheDocument();
expect(
screen.getByText("Copy selected repositories as a list"),
).toBeInTheDocument();
});
});