Disable Previous/Next buttons in first/last notebooks (#6390)

* hide first and last buttons

* added arrows to buttons

* removed extra methods
This commit is contained in:
Lucy Zhang
2019-07-17 14:39:35 -07:00
committed by GitHub
parent 9807e28a24
commit 089d7cb9f4

View File

@@ -55,7 +55,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Button } from 'sql/base/browser/ui/button/button'; import { Button } from 'sql/base/browser/ui/button/button';
import { attachButtonStyler } from 'sql/platform/theme/common/styler'; import { attachButtonStyler } from 'sql/platform/theme/common/styler';
import { isUndefinedOrNull } from 'vs/base/common/types'; import { isUndefinedOrNull } from 'vs/base/common/types';
import { Color } from 'vs/base/common/color';
export const NOTEBOOK_SELECTOR: string = 'notebook-component'; export const NOTEBOOK_SELECTOR: string = 'notebook-component';
@@ -445,13 +444,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
if (this.contextKeyService.getContextKeyValue('isDevelopment') && if (this.contextKeyService.getContextKeyValue('isDevelopment') &&
this.contextKeyService.getContextKeyValue('bookOpened') && this.contextKeyService.getContextKeyValue('bookOpened') &&
this._navProvider) { this._navProvider) {
this.addButton(localize('previousButtonLabel', "< Previous"),
() => this.previousPage());
this.addButton(localize('nextButtonLabel', "Next >"),
() => this.nextPage());
this._navProvider.getNavigation(this._notebookParams.notebookUri).then(result => { this._navProvider.getNavigation(this._notebookParams.notebookUri).then(result => {
this.navigationResult = result; this.navigationResult = result;
this.addButton(localize('previousButtonLabel', "< Previous"),
() => this.previousPage(), this.navigationResult.previous ? true : false);
this.addButton(localize('nextButtonLabel', "Next >"),
() => this.nextPage(), this.navigationResult.next ? true : false);
this.detectChanges(); this.detectChanges();
}, err => { }, err => {
console.log(err); console.log(err);
@@ -466,7 +464,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
return 'hidden'; return 'hidden';
} }
private addButton(label: string, onDidClick?: () => void): void { private addButton(label: string, onDidClick?: () => void, enabled?: boolean): void {
const container = DOM.append(this.bookNav.nativeElement, DOM.$('.dialog-message-button')); const container = DOM.append(this.bookNav.nativeElement, DOM.$('.dialog-message-button'));
let button = new Button(container); let button = new Button(container);
button.icon = ''; button.icon = '';
@@ -474,6 +472,9 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
if (onDidClick) { if (onDidClick) {
this._register(button.onDidClick(onDidClick)); this._register(button.onDidClick(onDidClick));
} }
if (!enabled) {
button.enabled = false;
}
} }
private actionItemProvider(action: Action): IActionViewItem { private actionItemProvider(action: Action): IActionViewItem {