Use long running notification when creating a project (#600)

This commit is contained in:
Eric Jizba 2018-09-18 09:55:04 -07:00 коммит произвёл GitHub
Родитель 7e55c25961
Коммит 0c0829d4d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 27 добавлений и 19 удалений

Просмотреть файл

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as fse from 'fs-extra';
import { QuickPickItem, QuickPickOptions } from 'vscode';
import { ProgressLocation, QuickPickItem, QuickPickOptions, window } from 'vscode';
import { IActionContext } from 'vscode-azureextensionui';
import { ProjectLanguage, projectLanguageSetting, ProjectRuntime } from '../../constants';
import { ext } from '../../extensionVariables';
@ -55,20 +55,31 @@ export async function createNewProject(
}
actionContext.properties.projectLanguage = language;
const projectCreator: ProjectCreatorBase = getProjectCreator(language, functionAppPath, actionContext);
await projectCreator.addNonVSCodeFiles();
await window.withProgress({ location: ProgressLocation.Notification, title: localize('creating', 'Creating new project...') }, async () => {
// tslint:disable-next-line:no-non-null-assertion
functionAppPath = functionAppPath!;
// tslint:disable-next-line:no-non-null-assertion
language = language!;
await initProjectForVSCode(actionContext, ext.ui, ext.outputChannel, functionAppPath, language, runtime, projectCreator);
const projectCreator: ProjectCreatorBase = getProjectCreator(language, functionAppPath, actionContext);
await projectCreator.addNonVSCodeFiles();
if (await gitUtils.isGitInstalled(functionAppPath) && !await gitUtils.isInsideRepo(functionAppPath)) {
await gitUtils.gitInit(ext.outputChannel, functionAppPath);
}
await initProjectForVSCode(actionContext, ext.ui, ext.outputChannel, functionAppPath, language, runtime, projectCreator);
if (templateId) {
await createFunction(actionContext, functionAppPath, templateId, functionName, caseSensitiveFunctionSettings, <ProjectLanguage>language, <ProjectRuntime>runtime);
}
if (await gitUtils.isGitInstalled(functionAppPath) && !await gitUtils.isInsideRepo(functionAppPath)) {
await gitUtils.gitInit(ext.outputChannel, functionAppPath);
}
await validateFuncCoreToolsInstalled();
if (templateId) {
await createFunction(actionContext, functionAppPath, templateId, functionName, caseSensitiveFunctionSettings, <ProjectLanguage>language, <ProjectRuntime>runtime);
}
});
// don't wait
window.showInformationMessage(localize('finishedCreating', 'Finished creating project.'));
// don't wait
// tslint:disable-next-line:no-floating-promises
validateFuncCoreToolsInstalled();
if (openFolder) {
await workspaceUtil.ensureFolderIsOpen(functionAppPath, actionContext);

Просмотреть файл

@ -30,7 +30,6 @@ export async function initProjectForVSCode(actionContext: IActionContext, ui: IA
}
telemetryProperties.projectLanguage = language;
outputChannel.show();
outputChannel.appendLine(localize('usingLanguage', 'Using "{0}" as the project language...', language));
if (!projectCreator) {

Просмотреть файл

@ -35,7 +35,11 @@ export async function validateFunctionProjects(actionContext: IActionContext, ui
} else {
actionContext.properties.isInitialized = 'false';
if (await promptToInitializeProject(ui, folderPath)) {
await initProjectForVSCode(actionContext, ui, outputChannel, folderPath);
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: localize('creating', 'Initializing project...') }, async () => {
await initProjectForVSCode(actionContext, ui, outputChannel, folderPath);
});
// don't wait
vscode.window.showInformationMessage(localize('finishedInit', 'Finished initializing project.'));
}
}
}

Просмотреть файл

@ -13,7 +13,6 @@ import { DialogResponses, IActionContext, TestUserInput } from 'vscode-azureexte
import { createNewProject } from '../src/commands/createNewProject/createNewProject';
import { deploySubpathSetting, extensionPrefix, ProjectLanguage } from '../src/constants';
import { ext } from '../src/extensionVariables';
import { funcToolsInstalled } from '../src/funcCoreTools/validateFuncCoreToolsInstalled';
import * as fsUtil from '../src/utils/fs';
import { validateSetting, validateVSCodeProjectFiles } from './initProjectForVSCode.test';
@ -150,11 +149,6 @@ suite('Create New Project Tests', async function (this: ISuiteCallbackContext):
});
async function testCreateNewProject(projectPath: string, language: string, previewLanguage: boolean, ...inputs: (string | undefined)[]): Promise<void> {
// Setup common inputs
if (!(await funcToolsInstalled())) {
inputs.push(DialogResponses.skipForNow.title);
}
if (!previewLanguage) {
inputs.unshift(language); // Specify the function name
}