10551 - Notebook UI: Added cell toolbar component (#10558)

* 10551 - Notebook UI: Added cell toolbar component, actions scaffolding, styles and theme colors. Removed markup for legacy, hidden hover buttons. Updated instaces of icon class: mask to masked-icon.

* Uncommented lines for CellToggleMoreActions so we can see how the ellipses currently work.

* Added EditCellAction which toggles between two icons.

* Cleaned up comments and removed some unused code.

* Copied DeleteCellAction into celltoolbarActions

* Connecting model and cell model to toolbar component for necessary context.

* Pass in cell + nb model from notebook component

* Adding context for EditCellAction so we can activate a cell via icon.

* Removed my copy of AddCellAction and simply referred to the existing one.

* Fixes to propogate cell model edit mode changes

* Added onCellModeChanged event registration to code.component.

* Moved cellToggleMoreActions into cellToolbarActions. Suppressing ellipses in code and textCell components.

* Fix adding cells

* Copied and modified ToggleMoreWidgetAction for use in cellToolbarActions. Instantiating cellToggleMoreActions and adding to toolbar.

* Removed unused markup, code and styles. Moved cell toolbar template into compoent.

* Removed double-click from textCell. Changed message to indicate where content goes - without it the cell does not have dimension and cannot be found by the user.

* Removed unused code file.

* Fixing my boo boo

* Updated AddCellAction with null coalescer. Set Promise to type: void.

Co-authored-by: chlafreniere <hichise@gmail.com>
This commit is contained in:
Hale Rankin
2020-05-29 18:27:36 -07:00
committed by GitHub
parent 98ce3c74e6
commit b2e0291a95
15 changed files with 298 additions and 352 deletions

View File

@@ -28,6 +28,7 @@ import { find, firstIndex } from 'vs/base/common/arrays';
import { INotebookEditor } from 'sql/workbench/services/notebook/browser/notebookService';
import { NotebookComponent } from 'sql/workbench/contrib/notebook/browser/notebook.component';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { CellContext } from 'sql/workbench/contrib/notebook/browser/cellViews/codeActions';
const msgLoading = localize('loading', "Loading kernels...");
const msgChanging = localize('changing', "Changing kernel...");
@@ -49,18 +50,29 @@ export class AddCellAction extends Action {
) {
super(id, label, cssClass);
}
public async run(context: INotebookEditor): Promise<any> {
//Add Cell after current selected cell.
public async run(context: INotebookEditor | CellContext): Promise<void> {
let index = 0;
if (context && context.cells) {
let notebookcomponent = context as NotebookComponent;
let id = notebookcomponent.activeCellId;
if (id) {
index = context.cells.findIndex(cell => cell.id === id);
index = index + 1;
if (context instanceof CellContext) {
if (context?.model?.cells) {
let activeCellId = context.model.activeCell.id;
if (activeCellId) {
index = context.model.cells.findIndex(cell => cell.id === activeCellId) + 1;
}
}
if (context?.model) {
context.model.addCell(this.cellType, index);
}
} else {
//Add Cell after current selected cell.
if (context?.cells) {
let notebookcomponent = context as NotebookComponent;
let id = notebookcomponent.activeCellId;
if (id) {
index = context.cells.findIndex(cell => cell.id === id) + 1;
}
}
context.addCell(this.cellType, index);
}
context.addCell(this.cellType, index);
}
}