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

combined install action

上级 e42b24c6
......@@ -241,3 +241,51 @@ export class UninstallAction extends Action {
this.disposables = dispose(this.disposables);
}
}
export class CombinedInstallAction extends Action {
private installAction: InstallAction;
private uninstallAction: UninstallAction;
private disposables: IDisposable[] = [];
constructor(private model: ExtensionsModel, private extension: IExtension) {
super('extensions.combinedInstall', '', '', false);
this.installAction = new InstallAction(model, extension);
this.uninstallAction = new UninstallAction(model, extension);
this.disposables.push(this.installAction, this.uninstallAction);
this.disposables.push(this.installAction.addListener2(Action.ENABLED, () => this.update()));
this.disposables.push(this.uninstallAction.addListener2(Action.ENABLED, () => this.update()));
this.update();
}
private update(): void {
if (this.installAction.enabled) {
this.enabled = true;
this.label = this.installAction.label;
this.class = this.installAction.class;
} else if (this.uninstallAction.enabled) {
this.enabled = true;
this.label = this.uninstallAction.label;
this.class = this.uninstallAction.class;
} else {
this.enabled = false;
}
}
run(): TPromise<any> {
if (this.installAction.enabled) {
return this.installAction.run();
} else if (this.uninstallAction.enabled) {
return this.uninstallAction.run();
}
return TPromise.as(null);
}
dispose(): void {
super.dispose();
this.disposables = dispose(this.disposables);
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IDelegate } from 'vs/base/browser/ui/list/list';
import { IPagedRenderer } from 'vs/base/browser/ui/list/listPaging';
import { IExtension, ExtensionsModel } from './extensionsModel';
import { InstallAction, UninstallAction } from './extensionsActions';
import { CombinedInstallAction } from './extensionsActions';
export interface ITemplateData {
extension: IExtension;
......@@ -89,13 +89,9 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
data.description.textContent = extension.description;
data.actionbar.clear();
const installAction = new InstallAction(this.model, extension);
const installAction = new CombinedInstallAction(this.model, extension);
data.actionbar.push(installAction, actionOptions);
data.disposables.push(installAction);
const uninstallAction = new UninstallAction(this.model, extension);
data.actionbar.push(uninstallAction, actionOptions);
data.disposables.push(uninstallAction);
}
disposeTemplate(data: ITemplateData): void {
......
......@@ -122,8 +122,7 @@ export class ExtensionsModel {
const installedById = index(this.installed, e => e.local.id);
this.installed = result.map(local => {
const id = local.path;
const extension = installedById[id] || new Extension(this.stateProvider, local);
const extension = installedById[local.id] || new Extension(this.stateProvider, local);
extension.local = local;
return extension;
});
......@@ -241,11 +240,11 @@ export class ExtensionsModel {
}
private getExtensionState(extension: Extension): ExtensionState {
if (this.installed.indexOf(extension) > -1) {
if (this.installed.some(e => e === extension || (e.gallery && extension.gallery && e.gallery.id === extension.gallery.id))) {
return ExtensionState.Installed;
}
if (this.installing.some(e => e.extension === extension)) {
if (extension.gallery && this.installing.some(e => e.extension.gallery.id === extension.gallery.id)) {
return ExtensionState.Installing;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册