Add Notebook Views dropdown (#16228)

This adds the entry point to NVs. It is currently hidden behind a feature flag, which can be enabled in the settings.
This commit is contained in:
Daniel Grajeda
2021-08-03 22:15:11 -06:00
committed by GitHub
parent da7585eb44
commit e2dd257fa9
13 changed files with 349 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import { Range } from 'vs/editor/common/core/range';
import { IEditorPane } from 'vs/workbench/common/editor';
import { INotebookInput } from 'sql/workbench/services/notebook/browser/interface';
import { INotebookShowOptions } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { NotebookViewsExtension } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViewsExtension';
export const SERVICE_ID = 'sqlNotebookService';
export const INotebookService = createDecorator<INotebookService>(SERVICE_ID);
@@ -210,6 +211,7 @@ export interface INotebookEditor {
readonly cellEditors: ICellEditorProvider[];
readonly modelReady: Promise<INotebookModel>;
readonly model: INotebookModel | null;
readonly views: NotebookViewsExtension | null;
isDirty(): boolean;
isActive(): boolean;
isVisible(): boolean;

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ICellModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { ICellModel, INotebookModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { Event } from 'vs/base/common/event';
export type CellChangeEventType = 'hide' | 'insert' | 'active';
@@ -62,3 +62,16 @@ export interface INotebookViewMetadata {
export interface INotebookViewCellMetadata {
views: INotebookViewCell[];
}
export interface INotebookViews {
onViewDeleted: Event<void>;
notebook: INotebookModel;
createNewView(name?: string): INotebookView;
removeView(guid: string): void;
generateDefaultViewName(): string;
getViews(): INotebookView[];
getActiveView(): INotebookView;
setActiveView(view: INotebookView): void;
viewNameIsTaken(name: string): boolean;
}

View File

@@ -9,9 +9,9 @@ import { Emitter, Event } from 'vs/base/common/event';
import { localize } from 'vs/nls';
import { NotebookViewModel } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViewModel';
import { NotebookExtension } from 'sql/workbench/services/notebook/browser/models/notebookExtension';
import { INotebookView, INotebookViewCell, INotebookViewCellMetadata, INotebookViewMetadata } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViews';
import { INotebookView, INotebookViewCell, INotebookViewCellMetadata, INotebookViewMetadata, INotebookViews } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViews';
export class NotebookViewsExtension extends NotebookExtension<INotebookViewMetadata, INotebookViewCellMetadata> {
export class NotebookViewsExtension extends NotebookExtension<INotebookViewMetadata, INotebookViewCellMetadata> implements INotebookViews {
static readonly defaultViewName = localize('notebookView.untitledView', "Untitled View");
readonly maxNameIterationAttempts = 100;