提交 aec58061 编写于 作者: J Joao Moreno

scm: fix actions context

上级 b36a855c
......@@ -173,6 +173,13 @@ export abstract class Composite extends Component implements IComposite {
return null;
}
/**
* Provide a context to be passed to the toolbar.
*/
getActionsContext(): any {
return null;
}
/**
* Returns the instance of IActionRunner to use with this composite for the
* composite tool bar.
......
......@@ -342,6 +342,9 @@ export abstract class CompositePart<T extends Composite> extends Part {
primaryActions.push(...this.getActions());
secondaryActions.push(...this.getSecondaryActions());
// Update context
this.toolBar.context = this.actionsContextProvider();
// Return fn to set into toolbar
return this.toolBar.setActions(prepareActions(primaryActions), prepareActions(secondaryActions));
}
......@@ -438,6 +441,16 @@ export abstract class CompositePart<T extends Composite> extends Part {
return null;
}
protected actionsContextProvider(): any {
// Check Active Composite
if (this.activeComposite) {
return this.activeComposite.getActionsContext();
}
return null;
}
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('.content'));
......
......@@ -1072,9 +1072,6 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
}
}
// private contributedViews: PersistentContributableViewsModel;
// private contributedViewDisposables: IDisposable[] = [];
constructor(
@IPartService partService: IPartService,
@ITelemetryService telemetryService: ITelemetryService,
......@@ -1217,4 +1214,10 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService);
}
getActionsContext(): any {
if (this.visibleRepositories.length === 1) {
return this.repositories[0].provider;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册