Add new file UI (#14773)

Adds a notebook or markdown file to a book's top level or a section by right click on Book Tree View
This commit is contained in:
Barbara Valdez
2021-03-30 18:44:52 -07:00
committed by GitHub
parent b774f09b6c
commit 8aa222d1c8
13 changed files with 428 additions and 247 deletions

View File

@@ -94,8 +94,18 @@ export const name = localize('name', "Name");
export const saveLocation = localize('saveLocation', "Save location");
export const contentFolder = localize('contentFolder', "Content folder (Optional)");
export const msgContentFolderError = localize('msgContentFolderError', "Content folder path does not exist");
export const msgSaveFolderError = localize('msgSaveFolderError', "Save location path does not exist");
export const msgSaveFolderError = localize('msgSaveFolderError', "Save location path does not exist.");
export function msgCreateBookWarningMsg(file: string): string { return localize('msgCreateBookWarningMsg', "Error while trying to access: {0}", file); }
// Add a notebook dialog constants
export const newNotebook = localize('newNotebook', "New Notebook (Preview)");
export const newMarkdown = localize('newMarkdown', "New Markdown (Preview)");
export const fileExtension = localize('fileExtension', "File Extension");
export const confirmOverwrite = localize('confirmOverwrite', "File already exists. Are you sure you want to overwrite this file?");
export const title = localize('title', "Title");
export const fileName = localize('fileName', "File Name");
export const msgInvalidSaveFolder = localize('msgInvalidSaveFolder', "Save location path is not valid.");
export function msgDuplicadFileName(file: string): string { return localize('msgDuplicadFileName', "File {0} already exists in the destination folder", file); }

View File

@@ -12,8 +12,8 @@ import * as azdata from 'azdata';
import * as crypto from 'crypto';
import { notebookLanguages, notebookConfigKey, pinnedBooksConfigKey, AUTHTYPE, INTEGRATED_AUTH, KNOX_ENDPOINT_PORT, KNOX_ENDPOINT_SERVER } from './constants';
import { IPrompter, IQuestion, QuestionTypes } from '../prompts/question';
import * as loc from '../common/localizedConstants';
import { BookTreeItemFormat, BookTreeItemType } from '../book/bookTreeItem';
import * as loc from './localizedConstants';
const localize = nls.loadMessageBundle();
@@ -488,11 +488,30 @@ export interface IBookNotebook {
notebookPath: string;
}
export enum FileExtension {
Markdown = '.md',
Notebook = '.ipynb'
}
//Confirmation message dialog
export async function confirmReplace(prompter: IPrompter): Promise<boolean> {
export async function confirmMessageDialog(prompter: IPrompter, msg: string): Promise<boolean> {
return await prompter.promptSingle<boolean>(<IQuestion>{
type: QuestionTypes.confirm,
message: loc.confirmReplace,
message: msg,
default: false
});
}
export async function selectFolder(): Promise<string | undefined> {
let uris = await vscode.window.showOpenDialog({
canSelectFiles: false,
canSelectMany: false,
canSelectFolders: true,
openLabel: loc.labelSelectFolder
});
if (uris?.length > 0) {
return uris[0].fsPath;
}
return undefined;
}