This commit is contained in:
Nathan 2023-03-31 09:59:32 -07:00 коммит произвёл GitHub
Родитель 6079f4cdef
Коммит 1837ada30e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 12 добавлений и 11 удалений

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

@ -168,7 +168,8 @@
{
"command": "staticWebApps.createSwaConfigFile",
"title": "%staticWebApps.createSwaConfigFile%",
"category": "Azure Static Web Apps"
"category": "Azure Static Web Apps",
"enablement": "!isWeb"
},
{
"command": "staticWebApps.deleteEnvironment",

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

@ -11,8 +11,8 @@ import { localize } from '../utils/localize';
import { selectWorkspaceFolder } from '../utils/workspaceUtils';
export async function createSwaConfigFile(context: IActionContext): Promise<void> {
const destPath: string = await selectWorkspaceFolder(context, localize('selectConfigFileLocation', 'Select location to create "{0}"', configFileName));
const configFilePath: URI = Utils.joinPath(URI.parse(destPath), configFileName);
const destPath: URI = await selectWorkspaceFolder(context, localize('selectConfigFileLocation', 'Select location to create "{0}"', configFileName));
const configFilePath: URI = Utils.joinPath(destPath, configFileName);
if (await AzExtFsExtra.pathExists(configFilePath)) {
const configFileExists: string = localize('configFileExists', 'Static Web App configuration file "{0}" already exists.', configFilePath.fsPath);

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

@ -22,7 +22,7 @@ export function getSingleRootFsPath(): Uri | undefined {
return workspace.workspaceFolders && workspace.workspaceFolders.length === 1 ? workspace.workspaceFolders[0].uri : undefined;
}
export async function selectWorkspaceFolder(context: IActionContext, placeHolder: string, getSubPath?: (f: WorkspaceFolder) => string | undefined | Promise<string | undefined>): Promise<string> {
export async function selectWorkspaceFolder(context: IActionContext, placeHolder: string, getSubPath?: (f: WorkspaceFolder) => string | undefined | Promise<string | undefined>): Promise<Uri> {
return await selectWorkspaceItem(
context,
placeHolder,
@ -36,22 +36,22 @@ export async function selectWorkspaceFolder(context: IActionContext, placeHolder
getSubPath);
}
export async function selectWorkspaceItem(context: IActionContext, placeHolder: string, options: OpenDialogOptions, getSubPath?: (f: WorkspaceFolder) => string | undefined | Promise<string | undefined>): Promise<string> {
export async function selectWorkspaceItem(context: IActionContext, placeHolder: string, options: OpenDialogOptions, getSubPath?: (f: WorkspaceFolder) => string | undefined | Promise<string | undefined>): Promise<Uri> {
const folders: readonly WorkspaceFolder[] = workspace.workspaceFolders || [];
const folderPicks: IAzureQuickPickItem<string | undefined>[] = await Promise.all(folders.map(async (f: WorkspaceFolder) => {
const folderPicks: IAzureQuickPickItem<Uri | undefined>[] = await Promise.all(folders.map(async (f: WorkspaceFolder) => {
let subpath: string | undefined;
if (getSubPath) {
subpath = await getSubPath(f);
}
const fsPath: string = subpath ? path.join(f.uri.fsPath, subpath) : f.uri.fsPath;
return { label: path.basename(fsPath), description: fsPath, data: fsPath };
const uri: Uri = subpath ? Uri.joinPath(f.uri, subpath) : f.uri;
return { label: path.basename(uri.fsPath), description: uri.fsPath, data: uri };
}));
folderPicks.push({ label: localize('browse', '$(file-directory) Browse...'), description: '', data: undefined });
const folder: IAzureQuickPickItem<string | undefined> = await context.ui.showQuickPick(folderPicks, { placeHolder });
const folder: IAzureQuickPickItem<Uri | undefined> = await context.ui.showQuickPick(folderPicks, { placeHolder });
return folder.data ? folder.data : (await context.ui.showOpenDialog(options))[0].fsPath;
return folder.data ? folder.data : (await context.ui.showOpenDialog(options))[0];
}
export async function tryGetWorkspaceFolder(context: IActionContext): Promise<WorkspaceFolder | undefined> {
@ -65,7 +65,7 @@ export async function tryGetWorkspaceFolder(context: IActionContext): Promise<Wo
const selectAppFolder: string = 'selectAppFolder';
const folder = await selectWorkspaceFolder(context, localize(selectAppFolder, 'Select folder with your app'));
context.telemetry.properties.noWorkspaceResult = 'multiRootProject';
return workspace.getWorkspaceFolder(Uri.parse(folder));
return workspace.getWorkspaceFolder(folder);
}
}