Ask the user for permission to reload workspace

To make this a nicer experience for the user, we're adding a prompt
to let them know we're about to reload the workspace.
This commit is contained in:
Elena Tanasoiu
2023-03-21 11:01:19 +00:00
parent 7059802a25
commit 0368d537ad
2 changed files with 18 additions and 0 deletions

View File

@@ -295,10 +295,20 @@ export async function prepareCodeTour(): Promise<void> {
existsSync(toursFolderPath) &&
!isCodespacesTemplate()
) {
const answer = await showBinaryChoiceDialog(
"We've detected you're in the CodeQL Tour repo. We will need to open the workspace file to continue. Reload?",
);
if (!answer) {
return;
}
const tutorialWorkspaceUri = Uri.parse(tutorialWorkspacePath);
void extLogger.log(
`In prepareCodeTour() method, going to open the tutorial workspace file: ${tutorialWorkspacePath}`,
);
await commands.executeCommand("vscode.openFolder", tutorialWorkspaceUri);
}
}

View File

@@ -572,6 +572,9 @@ describe("isFolderAlreadyInWorkspace", () => {
describe("prepareCodeTour", () => {
let dir: tmp.DirResult;
let showInformationMessageSpy: jest.SpiedFunction<
typeof window.showInformationMessage
>;
beforeEach(() => {
dir = tmp.dirSync();
@@ -587,6 +590,10 @@ describe("prepareCodeTour", () => {
jest
.spyOn(workspace, "workspaceFolders", "get")
.mockReturnValue(mockWorkspaceFolders);
showInformationMessageSpy = jest
.spyOn(window, "showInformationMessage")
.mockResolvedValue({ title: "Yes" });
});
afterEach(() => {
@@ -610,6 +617,7 @@ describe("prepareCodeTour", () => {
await prepareCodeTour();
expect(showInformationMessageSpy).toHaveBeenCalled();
expect(commandSpy).toHaveBeenCalledWith(
"vscode.openFolder",
Uri.parse(tutorialWorkspacePath),