mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Hide notebook toolbar icons in diff editor (#17303)
* hide notebook toolbar icons in diff editor * move showActions to notebookInput * make showActions readonly
This commit is contained in:
@@ -24,8 +24,8 @@ export class DiffNotebookInput extends SideBySideEditorInput {
|
|||||||
@INotebookService notebookService: INotebookService,
|
@INotebookService notebookService: INotebookService,
|
||||||
@ILogService logService: ILogService
|
@ILogService logService: ILogService
|
||||||
) {
|
) {
|
||||||
let originalInput = instantiationService.createInstance(FileNotebookInput, diffInput.primary.getName(), diffInput.primary.resource, diffInput.originalInput as FileEditorInput);
|
let originalInput = instantiationService.createInstance(FileNotebookInput, diffInput.primary.getName(), diffInput.primary.resource, diffInput.originalInput as FileEditorInput, false);
|
||||||
let modifiedInput = instantiationService.createInstance(FileNotebookInput, diffInput.secondary.getName(), diffInput.secondary.resource, diffInput.modifiedInput as FileEditorInput);
|
let modifiedInput = instantiationService.createInstance(FileNotebookInput, diffInput.secondary.getName(), diffInput.secondary.resource, diffInput.modifiedInput as FileEditorInput, false);
|
||||||
super(title, diffInput.getTitle(), modifiedInput, originalInput);
|
super(title, diffInput.getTitle(), modifiedInput, originalInput);
|
||||||
this._notebookService = notebookService;
|
this._notebookService = notebookService;
|
||||||
this._logService = logService;
|
this._logService = logService;
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ export class FileNotebookInput extends NotebookInput {
|
|||||||
title: string,
|
title: string,
|
||||||
resource: URI,
|
resource: URI,
|
||||||
textInput: FileEditorInput,
|
textInput: FileEditorInput,
|
||||||
|
showActions: boolean,
|
||||||
@ITextModelService textModelService: ITextModelService,
|
@ITextModelService textModelService: ITextModelService,
|
||||||
@IInstantiationService instantiationService: IInstantiationService,
|
@IInstantiationService instantiationService: IInstantiationService,
|
||||||
@INotebookService notebookService: INotebookService,
|
@INotebookService notebookService: INotebookService,
|
||||||
@IExtensionService extensionService: IExtensionService
|
@IExtensionService extensionService: IExtensionService
|
||||||
) {
|
) {
|
||||||
super(title, resource, textInput, textModelService, instantiationService, notebookService, extensionService);
|
super(title, resource, textInput, showActions, textModelService, instantiationService, notebookService, extensionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override get textInput(): FileEditorInput {
|
public override get textInput(): FileEditorInput {
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
|
|||||||
constructor(private _title: string,
|
constructor(private _title: string,
|
||||||
private _resource: URI,
|
private _resource: URI,
|
||||||
private _textInput: TextInput,
|
private _textInput: TextInput,
|
||||||
|
private _showActions: boolean,
|
||||||
@ITextModelService private textModelService: ITextModelService,
|
@ITextModelService private textModelService: ITextModelService,
|
||||||
@IInstantiationService private instantiationService: IInstantiationService,
|
@IInstantiationService private instantiationService: IInstantiationService,
|
||||||
@INotebookService private notebookService: INotebookService,
|
@INotebookService private notebookService: INotebookService,
|
||||||
@@ -515,6 +516,10 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
|
|||||||
return this.textInput.matches(otherInput);
|
return this.textInput.matches(otherInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get showActions(): boolean {
|
||||||
|
return this._showActions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NotebookEditorContentLoader implements IContentLoader {
|
export class NotebookEditorContentLoader implements IContentLoader {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export class NotebookEditorInputAssociation implements ILanguageAssociation {
|
|||||||
|
|
||||||
convertInput(activeEditor: IEditorInput): NotebookInput | DiffNotebookInput | undefined {
|
convertInput(activeEditor: IEditorInput): NotebookInput | DiffNotebookInput | undefined {
|
||||||
if (activeEditor instanceof FileEditorInput) {
|
if (activeEditor instanceof FileEditorInput) {
|
||||||
return this.instantiationService.createInstance(FileNotebookInput, activeEditor.getName(), activeEditor.resource, activeEditor);
|
return this.instantiationService.createInstance(FileNotebookInput, activeEditor.getName(), activeEditor.resource, activeEditor, true);
|
||||||
} else if (activeEditor instanceof UntitledTextEditorInput) {
|
} else if (activeEditor instanceof UntitledTextEditorInput) {
|
||||||
return this.instantiationService.createInstance(UntitledNotebookInput, activeEditor.getName(), activeEditor.resource, activeEditor);
|
return this.instantiationService.createInstance(UntitledNotebookInput, activeEditor.getName(), activeEditor.resource, activeEditor);
|
||||||
} else if (activeEditor instanceof DiffEditorInput) {
|
} else if (activeEditor instanceof DiffEditorInput) {
|
||||||
@@ -65,7 +65,7 @@ export class FileNoteBookEditorInputSerializer implements IEditorInputSerializer
|
|||||||
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): FileNotebookInput | undefined {
|
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): FileNotebookInput | undefined {
|
||||||
const factory = editorInputFactoryRegistry.getEditorInputSerializer(FILE_EDITOR_INPUT_ID);
|
const factory = editorInputFactoryRegistry.getEditorInputSerializer(FILE_EDITOR_INPUT_ID);
|
||||||
const fileEditorInput = factory.deserialize(instantiationService, serializedEditorInput) as FileEditorInput;
|
const fileEditorInput = factory.deserialize(instantiationService, serializedEditorInput) as FileEditorInput;
|
||||||
return instantiationService.createInstance(FileNotebookInput, fileEditorInput.getName(), fileEditorInput.resource, fileEditorInput);
|
return instantiationService.createInstance(FileNotebookInput, fileEditorInput.getName(), fileEditorInput.resource, fileEditorInput, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
canSerialize(): boolean { // we can always serialize notebooks
|
canSerialize(): boolean { // we can always serialize notebooks
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export class UntitledNotebookInput extends NotebookInput {
|
|||||||
@INotebookService notebookService: INotebookService,
|
@INotebookService notebookService: INotebookService,
|
||||||
@IExtensionService extensionService: IExtensionService
|
@IExtensionService extensionService: IExtensionService
|
||||||
) {
|
) {
|
||||||
super(title, resource, textInput, textModelService, instantiationService, notebookService, extensionService);
|
super(title, resource, textInput, true, textModelService, instantiationService, notebookService, extensionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override get textInput(): UntitledTextEditorInput {
|
public override get textInput(): UntitledTextEditorInput {
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
public previewFeaturesEnabled: boolean = false;
|
public previewFeaturesEnabled: boolean = false;
|
||||||
public doubleClickEditEnabled: boolean;
|
public doubleClickEditEnabled: boolean;
|
||||||
private _onScroll = new Emitter<void>();
|
private _onScroll = new Emitter<void>();
|
||||||
|
// Don't show the right hand toolbar actions if the notebook is created in a diff editor.
|
||||||
|
private _showToolbarActions: boolean = this._notebookParams.input.showActions;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||||
@@ -481,12 +483,15 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
{ element: kernelContainer },
|
{ element: kernelContainer },
|
||||||
{ element: attachToContainer },
|
{ element: attachToContainer },
|
||||||
{ element: spacerElement },
|
{ element: spacerElement },
|
||||||
{ element: viewsDropdownContainer },
|
|
||||||
{ action: collapseCellsAction },
|
|
||||||
{ action: clearResultsButton },
|
|
||||||
{ action: this._trustedAction },
|
|
||||||
{ action: runParametersAction },
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (this._showToolbarActions) {
|
||||||
|
this._actionBar.addElement(viewsDropdownContainer);
|
||||||
|
this._actionBar.addAction(collapseCellsAction);
|
||||||
|
this._actionBar.addAction(clearResultsButton);
|
||||||
|
this._actionBar.addAction(this._trustedAction);
|
||||||
|
this._actionBar.addAction(runParametersAction);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let kernelContainer = document.createElement('div');
|
let kernelContainer = document.createElement('div');
|
||||||
let kernelDropdown = this.instantiationService.createInstance(KernelsDropdown, kernelContainer, this.contextViewService, this.modelReady);
|
let kernelDropdown = this.instantiationService.createInstance(KernelsDropdown, kernelContainer, this.contextViewService, this.modelReady);
|
||||||
@@ -523,11 +528,14 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
{ action: addTextCellButton },
|
{ action: addTextCellButton },
|
||||||
{ element: kernelContainer },
|
{ element: kernelContainer },
|
||||||
{ element: attachToContainer },
|
{ element: attachToContainer },
|
||||||
{ action: this._trustedAction },
|
|
||||||
{ action: this._runAllCellsAction },
|
{ action: this._runAllCellsAction },
|
||||||
{ action: clearResultsButton },
|
|
||||||
{ action: collapseCellsAction },
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (this._showToolbarActions) {
|
||||||
|
this._actionBar.addAction(this._trustedAction);
|
||||||
|
this._actionBar.addAction(clearResultsButton);
|
||||||
|
this._actionBar.addAction(collapseCellsAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,6 +597,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
* the primary array to the end of the toolbar.
|
* the primary array to the end of the toolbar.
|
||||||
*/
|
*/
|
||||||
private fillInActionsForCurrentContext(): void {
|
private fillInActionsForCurrentContext(): void {
|
||||||
|
if (this._showToolbarActions) {
|
||||||
let primary: IAction[] = [];
|
let primary: IAction[] = [];
|
||||||
let secondary: IAction[] = [];
|
let secondary: IAction[] = [];
|
||||||
let notebookBarMenu = this.menuService.createMenu(MenuId.NotebookToolbar, this.contextKeyService);
|
let notebookBarMenu = this.menuService.createMenu(MenuId.NotebookToolbar, this.contextKeyService);
|
||||||
@@ -596,6 +605,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||||
this.addPrimaryContributedActions(primary);
|
this.addPrimaryContributedActions(primary);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private detectChanges(): void {
|
private detectChanges(): void {
|
||||||
if (!(this._changeRef['destroyed'])) {
|
if (!(this._changeRef['destroyed'])) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ suite('Notebook Input', function (): void {
|
|||||||
test('File Notebook Input', async function (): Promise<void> {
|
test('File Notebook Input', async function (): Promise<void> {
|
||||||
let fileUri = URI.from({ scheme: Schemas.file, path: 'TestPath' });
|
let fileUri = URI.from({ scheme: Schemas.file, path: 'TestPath' });
|
||||||
let fileNotebookInput = new FileNotebookInput(
|
let fileNotebookInput = new FileNotebookInput(
|
||||||
testTitle, fileUri, undefined,
|
testTitle, fileUri, undefined, true,
|
||||||
undefined, instantiationService, mockNotebookService.object, mockExtensionService.object);
|
undefined, instantiationService, mockNotebookService.object, mockExtensionService.object);
|
||||||
|
|
||||||
let inputId = fileNotebookInput.typeId;
|
let inputId = fileNotebookInput.typeId;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export interface INotebookInput {
|
|||||||
readonly contentLoader: IContentLoader;
|
readonly contentLoader: IContentLoader;
|
||||||
readonly standardKernels: IStandardKernelWithProvider[];
|
readonly standardKernels: IStandardKernelWithProvider[];
|
||||||
readonly providersLoaded: Promise<void>;
|
readonly providersLoaded: Promise<void>;
|
||||||
|
readonly showActions: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isINotebookInput(value: any): value is INotebookInput {
|
export function isINotebookInput(value: any): value is INotebookInput {
|
||||||
|
|||||||
Reference in New Issue
Block a user