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:
Lucy Zhang
2021-10-15 05:19:14 -07:00
committed by GitHub
parent 58d5f317d3
commit e315115f00
8 changed files with 38 additions and 21 deletions

View File

@@ -86,6 +86,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
public previewFeaturesEnabled: boolean = false;
public doubleClickEditEnabled: boolean;
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(
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@@ -481,12 +483,15 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
{ element: kernelContainer },
{ element: attachToContainer },
{ 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 {
let kernelContainer = document.createElement('div');
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 },
{ element: kernelContainer },
{ element: attachToContainer },
{ action: this._trustedAction },
{ action: this._runAllCellsAction },
{ action: clearResultsButton },
{ action: collapseCellsAction },
]);
if (this._showToolbarActions) {
this._actionBar.addAction(this._trustedAction);
this._actionBar.addAction(clearResultsButton);
this._actionBar.addAction(collapseCellsAction);
}
}
}
@@ -589,12 +597,14 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
* the primary array to the end of the toolbar.
*/
private fillInActionsForCurrentContext(): void {
let primary: IAction[] = [];
let secondary: IAction[] = [];
let notebookBarMenu = this.menuService.createMenu(MenuId.NotebookToolbar, this.contextKeyService);
let groups = notebookBarMenu.getActions({ arg: null, shouldForwardArgs: true });
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
this.addPrimaryContributedActions(primary);
if (this._showToolbarActions) {
let primary: IAction[] = [];
let secondary: IAction[] = [];
let notebookBarMenu = this.menuService.createMenu(MenuId.NotebookToolbar, this.contextKeyService);
let groups = notebookBarMenu.getActions({ arg: null, shouldForwardArgs: true });
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
this.addPrimaryContributedActions(primary);
}
}
private detectChanges(): void {