mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Added code to enable disable split cell icon (#17331)
* Added code to enable diable split cell icon * adding back the deleted code * refactored * minimized lines * simplified code * minor change * minor change * Addressed PR * Addressed PR * removing unused enum value
This commit is contained in:
@@ -17,7 +17,7 @@ import Severity from 'vs/base/common/severity';
|
||||
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { CellEditModes, MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
const moreActionsLabel = localize('moreActionsLabel', "More");
|
||||
|
||||
export class EditCellAction extends ToggleableAction {
|
||||
@@ -78,6 +78,11 @@ export class SplitCellAction extends CellActionBase {
|
||||
context.model?.splitCell(context.cell.cellType, this.notebookService, index);
|
||||
return Promise.resolve();
|
||||
}
|
||||
public setListener(context: CellContext) {
|
||||
this._register(context.cell.onCurrentEditModeChanged(currentMode => {
|
||||
this.enabled = currentMode === CellEditModes.WYSIWYG ? false : true;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export class MoveCellAction extends CellActionBase {
|
||||
|
||||
@@ -60,6 +60,8 @@ export class CellToolbarComponent {
|
||||
this._actionBar.context = context;
|
||||
|
||||
let splitCellButton = this.instantiationService.createInstance(SplitCellAction, 'notebook.SplitCellAtCursor', this.buttonSplitCell, 'masked-icon icon-split-cell');
|
||||
splitCellButton.setListener(context);
|
||||
splitCellButton.enabled = this.cellModel.cellType !== 'markdown';
|
||||
|
||||
let addCellsButton = this.instantiationService.createInstance(AddCellAction, 'notebook.AddCodeCell', localize('codeCellsPreview', "Add cell"), 'masked-pseudo code');
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
private _onTableUpdated = new Emitter<ITableUpdatedEvent>();
|
||||
private _onCellModeChanged = new Emitter<boolean>();
|
||||
private _onExecutionStateChanged = new Emitter<CellExecutionState>();
|
||||
private _onCurrentEditModeChanged = new Emitter<CellEditModes>();
|
||||
private _isTrusted: boolean;
|
||||
private _active: boolean;
|
||||
private _hover: boolean;
|
||||
@@ -382,6 +383,10 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
return this._onExecutionStateChanged.event;
|
||||
}
|
||||
|
||||
public get onCurrentEditModeChanged(): Event<CellEditModes> {
|
||||
return this._onCurrentEditModeChanged.event;
|
||||
}
|
||||
|
||||
private fireExecutionStateChanged(): void {
|
||||
this._onExecutionStateChanged.fire(this.executionState);
|
||||
}
|
||||
@@ -416,6 +421,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
public set showPreview(val: boolean) {
|
||||
this._showPreview = val;
|
||||
this._onCellPreviewChanged.fire(this._showPreview);
|
||||
this._onCurrentEditModeChanged.fire(this.currentMode);
|
||||
}
|
||||
|
||||
public get showMarkdown(): boolean {
|
||||
@@ -425,6 +431,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
public set showMarkdown(val: boolean) {
|
||||
this._showMarkdown = val;
|
||||
this._onCellMarkdownChanged.fire(this._showMarkdown);
|
||||
this._onCurrentEditModeChanged.fire(this.currentMode);
|
||||
}
|
||||
|
||||
public get defaultTextEditMode(): string {
|
||||
|
||||
@@ -540,6 +540,7 @@ export interface ICellModel {
|
||||
cellSourceChanged: boolean;
|
||||
readonly savedConnectionName: string | undefined;
|
||||
attachments: nb.ICellAttachments | undefined;
|
||||
readonly onCurrentEditModeChanged: Event<CellEditModes>;
|
||||
readonly currentMode: CellEditModes;
|
||||
/**
|
||||
* Adds image as an attachment to cell metadata
|
||||
|
||||
Reference in New Issue
Block a user