compositeBar: addComposite, removeComposite

This commit is contained in:
isidor 2018-02-22 16:14:08 +01:00
parent 08e2d7581e
commit ff5c1edc63
3 changed files with 14 additions and 20 deletions

View file

@ -96,15 +96,7 @@ export class ActivitybarPart extends Part {
if (location === 'sidebar') {
this.compositeBar.addComposite(this.viewletService.getViewlet(SEARCH_VIEW_ID));
} else {
let promise: TPromise<any> = TPromise.as(null);
const activeViewlet = this.viewletService.getActiveViewlet();
if (activeViewlet && activeViewlet.getId() === SEARCH_VIEW_ID) {
promise = this.viewletService.openViewlet(this.viewletService.getDefaultViewletId());
}
promise.then(() => {
this.compositeBar.removeComposite(SEARCH_VIEW_ID);
});
this.compositeBar.removeComposite(SEARCH_VIEW_ID);
}
}
}));

View file

@ -82,11 +82,21 @@ export class CompositeBar implements ICompositeBar {
}
public addComposite(compositeData: { id: string; name: string }): void {
// todo@isidor
if (this.options.composites.filter(c => c.id === compositeData.id).length) {
return;
}
this.options.composites.push(compositeData);
this.pin(compositeData.id);
}
public removeComposite(id: string): void {
// todo@isidor
if (this.options.composites.filter(c => c.id === id).length === 0) {
return;
}
this.options.composites = this.options.composites.filter(c => c.id !== id);
this.unpin(id);
}
public activateComposite(id: string): void {

View file

@ -119,15 +119,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
if (location === 'panel') {
this.compositeBar.addComposite(this.getPanel(SEARCH_VIEW_ID));
} else {
let promise: TPromise<any> = TPromise.as(null);
const activePanel = this.getActivePanel();
if (activePanel && activePanel.getId() === SEARCH_VIEW_ID) {
promise = this.openPanel(Registry.as<PanelRegistry>(PanelExtensions.Panels).getDefaultPanelId());
}
promise.then(() => {
this.compositeBar.removeComposite(SEARCH_VIEW_ID);
});
this.compositeBar.removeComposite(SEARCH_VIEW_ID);
}
}
}));