Angular Individual Service Injection - Decouple bootstrap service (#1457)

* change services to be individually injected into angular

* messing around with injection

* change angular bootstrapping to factory style

* formatting

* formatting

* fix imports

* fix build errors

* fix testsw

* fix tests

* fix compile errors
This commit is contained in:
Anthony Dresser
2018-05-23 16:51:02 -07:00
committed by GitHub
parent cd0f9b71c5
commit 1359354387
68 changed files with 1011 additions and 1116 deletions

View File

@@ -24,8 +24,8 @@ import * as actions from 'sql/parts/grid/views/gridActions';
import * as Services from 'sql/parts/grid/services/sharedServices';
import * as GridContentEvents from 'sql/parts/grid/common/gridContentEvents';
import { ResultsVisibleContext, ResultsGridFocussedContext, ResultsMessagesFocussedContext, QueryEditorVisibleContext } from 'sql/parts/query/common/queryContext';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { error } from 'sql/base/common/log';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IAction } from 'vs/base/common/actions';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
@@ -35,6 +35,8 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { AutoColumnSize } from 'sql/base/browser/ui/table/plugins/autoSizeColumns.plugin';
import { DragCellSelectionModel } from 'sql/base/browser/ui/table/plugins/dragCellSelectionModel.plugin';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
export abstract class GridParentComponent {
@@ -63,9 +65,6 @@ export abstract class GridParentComponent {
// FIELDS
// Service for interaction with the IQueryModel
protected dataService: DataService;
protected keybindingService: IKeybindingService;
protected scopedContextKeyService: IContextKeyService;
protected contextMenuService: IContextMenuService;
protected actionProvider: actions.GridActionProvider;
protected toDispose: IDisposable[];
@@ -114,7 +113,12 @@ export abstract class GridParentComponent {
constructor(
protected _el: ElementRef,
protected _cd: ChangeDetectorRef,
protected _bootstrapService: IBootstrapService
protected contextMenuService: IContextMenuService,
protected keybindingService: IKeybindingService,
protected contextKeyService: IContextKeyService,
protected configurationService: IConfigurationService,
protected clipboardService: IClipboardService,
protected queryEditorService: IQueryEditorService
) {
this.toDispose = [];
}
@@ -122,8 +126,8 @@ export abstract class GridParentComponent {
protected baseInit(): void {
const self = this;
this.initShortcutsBase();
if (this._bootstrapService.configurationService) {
let sqlConfig = this._bootstrapService.configurationService.getValue('sql');
if (this.configurationService) {
let sqlConfig = this.configurationService.getValue('sql');
if (sqlConfig) {
this._messageActive = sqlConfig['messagesDefaultOpen'];
}
@@ -181,10 +185,7 @@ export abstract class GridParentComponent {
}
});
this.contextMenuService = this._bootstrapService.contextMenuService;
this.keybindingService = this._bootstrapService.keybindingService;
this.bindKeys(this._bootstrapService.contextKeyService);
this.bindKeys(this.contextKeyService);
}
/*
@@ -201,7 +202,7 @@ export abstract class GridParentComponent {
this.queryEditorVisible = QueryEditorVisibleContext.bindTo(contextKeyService);
this.queryEditorVisible.set(true);
let gridContextKeyService = this._bootstrapService.contextKeyService.createScoped(this._el.nativeElement);
let gridContextKeyService = this.contextKeyService.createScoped(this._el.nativeElement);
this.toDispose.push(gridContextKeyService);
this.resultsVisibleContextKey = ResultsVisibleContext.bindTo(gridContextKeyService);
this.resultsVisibleContextKey.set(true);
@@ -246,7 +247,7 @@ export abstract class GridParentComponent {
private copySelection(): void {
let messageText = this.getMessageText();
if (messageText.length > 0) {
this._bootstrapService.clipboardService.writeText(messageText);
this.clipboardService.writeText(messageText);
} else {
let activeGrid = this.activeGrid;
let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges();
@@ -269,7 +270,7 @@ export abstract class GridParentComponent {
messageText = this.getMessageText();
}
if (messageText.length > 0) {
this._bootstrapService.clipboardService.writeText(messageText);
this.clipboardService.writeText(messageText);
}
}
@@ -533,7 +534,7 @@ export abstract class GridParentComponent {
private handleQueryPlanLink(cellRef: string, value: string): void {
const self = this;
$(cellRef).children('.xmlLink').click(function (): void {
self._bootstrapService.queryEditorService.newQueryPlanEditor(value);
self.queryEditorService.newQueryPlanEditor(value);
});
}