UI - Markdown toolbar now behind preview flag (#10024)

* Adding enablePreviewFeatures check before showing the new toolbar.

* Removed unused code.

* Added hook to trigger onDidChangeConfiguration -- this makes the UI change after user has checked or unchecked, without having to restart the app.

* Initializing the component with the current config value of enablePreviewFeatures.
This commit is contained in:
Hale Rankin
2020-04-16 20:55:58 -07:00
committed by GitHub
parent 530ec8c19d
commit b568b8509d
3 changed files with 8 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
--> -->
<div style="overflow: hidden; width: 100%; height: 100%; display: flex; flex-flow: column" (mouseover)="hover=true" (mouseleave)="hover=false"> <div style="overflow: hidden; width: 100%; height: 100%; display: flex; flex-flow: column" (mouseover)="hover=true" (mouseleave)="hover=false">
<markdown-toolbar-component #markdownToolbar *ngIf="isEditMode" [cellModel]="cellModel"></markdown-toolbar-component> <markdown-toolbar-component #markdownToolbar *ngIf="previewFeaturesEnabled === true && isEditMode" [cellModel]="cellModel"></markdown-toolbar-component>
<div class="notebook-text" style="flex: 0 0 auto;"> <div class="notebook-text" style="flex: 0 0 auto;">
<code-component *ngIf="isEditMode" [cellModel]="cellModel" (onContentChanged)="handleContentChanged()" [model]="model" [activeCellId]="activeCellId"> <code-component *ngIf="isEditMode" [cellModel]="cellModel" (onContentChanged)="handleContentChanged()" [model]="model" [activeCellId]="activeCellId">
</code-component> </code-component>

View File

@@ -27,6 +27,7 @@ import { CellToggleMoreActions } from 'sql/workbench/contrib/notebook/browser/ce
import { CodeComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/code.component'; import { CodeComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/code.component';
import { NotebookRange, ICellEditorProvider } from 'sql/workbench/services/notebook/browser/notebookService'; import { NotebookRange, ICellEditorProvider } from 'sql/workbench/services/notebook/browser/notebookService';
import { IColorTheme } from 'vs/platform/theme/common/themeService'; import { IColorTheme } from 'vs/platform/theme/common/themeService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export const TEXT_SELECTOR: string = 'text-cell-component'; export const TEXT_SELECTOR: string = 'text-cell-component';
const USER_SELECT_CLASS = 'actionselect'; const USER_SELECT_CLASS = 'actionselect';
@@ -87,11 +88,13 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
private _hover: boolean; private _hover: boolean;
private markdownRenderer: NotebookMarkdownRenderer; private markdownRenderer: NotebookMarkdownRenderer;
private markdownResult: IMarkdownRenderResult; private markdownResult: IMarkdownRenderResult;
public previewFeaturesEnabled: boolean = false;
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(IInstantiationService) private _instantiationService: IInstantiationService, @Inject(IInstantiationService) private _instantiationService: IInstantiationService,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IConfigurationService) private _configurationService: IConfigurationService
) { ) {
super(); super();
this.isEditMode = true; this.isEditMode = true;
@@ -102,6 +105,9 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
this.markdownResult.dispose(); this.markdownResult.dispose();
} }
})); }));
this._register(this._configurationService.onDidChangeConfiguration(e => {
this.previewFeaturesEnabled = this._configurationService.getValue('workbench.enablePreviewFeatures');
}));
} }
public get cellEditors(): ICellEditorProvider[] { public get cellEditors(): ICellEditorProvider[] {
@@ -134,6 +140,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
} }
ngOnInit() { ngOnInit() {
this.previewFeaturesEnabled = this._configurationService.getValue('workbench.enablePreviewFeatures');
this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this)); this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
this.updateTheme(this.themeService.getColorTheme()); this.updateTheme(this.themeService.getColorTheme());
this._cellToggleMoreActions.onInit(this.moreActionsElementRef, this.model, this.cellModel); this._cellToggleMoreActions.onInit(this.moreActionsElementRef, this.model, this.cellModel);

View File

@@ -57,10 +57,8 @@ import { IColorTheme } from 'vs/platform/theme/common/themeService';
import { ICommandService } from 'vs/platform/commands/common/commands'; import { ICommandService } from 'vs/platform/commands/common/commands';
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
export const NOTEBOOK_SELECTOR: string = 'notebook-component'; export const NOTEBOOK_SELECTOR: string = 'notebook-component';
@Component({ @Component({
selector: NOTEBOOK_SELECTOR, selector: NOTEBOOK_SELECTOR,
templateUrl: decodeURI(require.toUrl('./notebook.component.html')) templateUrl: decodeURI(require.toUrl('./notebook.component.html'))