提交 723c9734 编写于 作者: R Ramya Achutha Rao

Move workspace rec related logic to its own view

上级 ecc40ba7
...@@ -20,7 +20,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; ...@@ -20,7 +20,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ICommandService } from 'vs/platform/commands/common/commands'; import { ICommandService } from 'vs/platform/commands/common/commands';
import { append, $, toggleClass, addClass } from 'vs/base/browser/dom'; import { append, $, toggleClass } from 'vs/base/browser/dom';
import { PagedList } from 'vs/base/browser/ui/list/listPaging'; import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Delegate, Renderer } from 'vs/workbench/parts/extensions/browser/extensionsList'; import { Delegate, Renderer } from 'vs/workbench/parts/extensions/browser/extensionsList';
...@@ -47,15 +47,15 @@ export class ExtensionsListView extends ViewsViewletPanel { ...@@ -47,15 +47,15 @@ export class ExtensionsListView extends ViewsViewletPanel {
private messageBox: HTMLElement; private messageBox: HTMLElement;
private extensionsList: HTMLElement; private extensionsList: HTMLElement;
private badge: CountBadge; private badge: CountBadge;
private listActionBar: HTMLElement; protected badgeContainer: HTMLElement;
private list: PagedList<IExtension>; private list: PagedList<IExtension>;
constructor( constructor(
private options: IViewletViewOptions, private options: IViewletViewOptions,
@IMessageService private messageService: IMessageService, @IMessageService protected messageService: IMessageService,
@IKeybindingService keybindingService: IKeybindingService, @IKeybindingService keybindingService: IKeybindingService,
@IContextMenuService contextMenuService: IContextMenuService, @IContextMenuService contextMenuService: IContextMenuService,
@IInstantiationService private instantiationService: IInstantiationService, @IInstantiationService protected instantiationService: IInstantiationService,
@IListService private listService: IListService, @IListService private listService: IListService,
@IThemeService private themeService: IThemeService, @IThemeService private themeService: IThemeService,
@IContextKeyService private contextKeyService: IContextKeyService, @IContextKeyService private contextKeyService: IContextKeyService,
...@@ -76,23 +76,8 @@ export class ExtensionsListView extends ViewsViewletPanel { ...@@ -76,23 +76,8 @@ export class ExtensionsListView extends ViewsViewletPanel {
const titleDiv = append(container, $('div.title')); const titleDiv = append(container, $('div.title'));
append(titleDiv, $('span')).textContent = this.options.name; append(titleDiv, $('span')).textContent = this.options.name;
this.listActionBar = append(container, $('.list-actionbar-container')); this.badgeContainer = append(container, $('.count-badge-wrapper'));
const actionbar = new ActionBar(this.listActionBar, { this.badge = new CountBadge(this.badgeContainer);
animated: false
});
actionbar.addListener(EventType.RUN, ({ error }) => error && this.messageService.show(Severity.Error, error));
const installAllAction = this.instantiationService.createInstance(InstallWorkspaceRecommendedExtensionsAction, InstallWorkspaceRecommendedExtensionsAction.ID, InstallWorkspaceRecommendedExtensionsAction.LABEL);
const configureWorkspaceFolderAction = this.instantiationService.createInstance(ConfigureWorkspaceFolderRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction.ID, ConfigureWorkspaceFolderRecommendedExtensionsAction.LABEL);
installAllAction.class = 'octicon octicon-cloud-download';
configureWorkspaceFolderAction.class = 'octicon octicon-pencil';
actionbar.push([installAllAction], { icon: true, label: false });
actionbar.push([configureWorkspaceFolderAction], { icon: true, label: false });
this.disposables.push(actionbar);
this.badge = new CountBadge(append(container, $('.count-badge-wrapper')));
this.disposables.push(attachBadgeStyler(this.badge, this.themeService)); this.disposables.push(attachBadgeStyler(this.badge, this.themeService));
} }
...@@ -130,15 +115,8 @@ export class ExtensionsListView extends ViewsViewletPanel { ...@@ -130,15 +115,8 @@ export class ExtensionsListView extends ViewsViewletPanel {
} }
async show(query: string): TPromise<IPagedModel<IExtension>> { async show(query: string): TPromise<IPagedModel<IExtension>> {
addClass(this.listActionBar, 'hidden');
const model = await this.query(query); const model = await this.query(query);
this.setModel(model); this.setModel(model);
if (ExtensionsListView.isWorkspaceRecommendedExtensionsQuery(query)) {
this.setExpanded(model.length > 0);
toggleClass(this.listActionBar, 'hidden', model.length === 0);
}
return model; return model;
} }
...@@ -576,8 +554,32 @@ export class RecommendedExtensionsView extends ExtensionsListView { ...@@ -576,8 +554,32 @@ export class RecommendedExtensionsView extends ExtensionsListView {
export class WorkspaceRecommendedExtensionsView extends ExtensionsListView { export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
renderHeader(container: HTMLElement): void {
super.renderHeader(container);
const listActionBar = $('.list-actionbar-container');
container.insertBefore(listActionBar, this.badgeContainer);
const actionbar = new ActionBar(listActionBar, {
animated: false
});
actionbar.addListener(EventType.RUN, ({ error }) => error && this.messageService.show(Severity.Error, error));
const installAllAction = this.instantiationService.createInstance(InstallWorkspaceRecommendedExtensionsAction, InstallWorkspaceRecommendedExtensionsAction.ID, InstallWorkspaceRecommendedExtensionsAction.LABEL);
const configureWorkspaceFolderAction = this.instantiationService.createInstance(ConfigureWorkspaceFolderRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction.ID, ConfigureWorkspaceFolderRecommendedExtensionsAction.LABEL);
installAllAction.class = 'octicon octicon-cloud-download';
configureWorkspaceFolderAction.class = 'octicon octicon-pencil';
actionbar.push([installAllAction], { icon: true, label: false });
actionbar.push([configureWorkspaceFolderAction], { icon: true, label: false });
this.disposables.push(actionbar);
}
async show(query: string): TPromise<IPagedModel<IExtension>> { async show(query: string): TPromise<IPagedModel<IExtension>> {
return super.show('@recommended:workspace'); let model = await super.show('@recommended:workspace');
this.setExpanded(model.length > 0);
return model;
} }
showRecommendedLabel() { showRecommendedLabel() {
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
margin-right: 10px; margin-right: 10px;
} }
.extensions-viewlet > .extensions .list-actionbar-container.hidden,
.extensions-viewlet > .extensions .list-actionbar-container .monaco-action-bar .action-item.disabled { .extensions-viewlet > .extensions .list-actionbar-container .monaco-action-bar .action-item.disabled {
display: none; display: none;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册