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

extension viewlet actions

上级 62d8d4c2
......@@ -53,6 +53,12 @@
margin-right: 0.3em;
}
.monaco-action-bar .action-label.octicon {
font-size: 15px;
line-height: 35px;
text-align: center;
}
.monaco-action-bar .action-item.disabled .action-label,
.monaco-action-bar .action-item.disabled .action-label:hover {
opacity: 0.4;
......
......@@ -20,7 +20,7 @@ import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } fro
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { VIEWLET_ID, IExtensionsWorkbenchService } from './extensions';
import { ExtensionsWorkbenchService } from './extensionsWorkbenchService';
import { OpenExtensionsViewletAction, ListOutdatedExtensionsAction } from './extensionsActions';
import { OpenExtensionsViewletAction, ListOutdatedExtensionsAction, ShowExtensionRecommendationsAction, ShowPopularExtensionsAction } from './extensionsActions';
import { ExtensionsInput } from './extensionsInput';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { ExtensionEditor } from './extensionEditor';
......@@ -94,3 +94,9 @@ actionRegistry.registerWorkbenchAction(openViewletActionDescriptor, 'View: Show
const listOutdatedActionDescriptor = new SyncActionDescriptor(ListOutdatedExtensionsAction, ListOutdatedExtensionsAction.ID, ListOutdatedExtensionsAction.LABEL);
actionRegistry.registerWorkbenchAction(listOutdatedActionDescriptor, 'Extensions: Show Outdated Extensions', ExtensionsLabel);
const recommendationsActionDescriptor = new SyncActionDescriptor(ShowExtensionRecommendationsAction, ShowExtensionRecommendationsAction.ID, ShowExtensionRecommendationsAction.LABEL);
actionRegistry.registerWorkbenchAction(recommendationsActionDescriptor, `Extensions: ${ ShowExtensionRecommendationsAction.LABEL }`, ExtensionsLabel);
const popularActionDescriptor = new SyncActionDescriptor(ShowPopularExtensionsAction, ShowPopularExtensionsAction.ID, ShowPopularExtensionsAction.LABEL);
actionRegistry.registerWorkbenchAction(popularActionDescriptor, `Extensions: ${ ShowPopularExtensionsAction.LABEL }`, ExtensionsLabel);
......@@ -251,3 +251,57 @@ export class ListOutdatedExtensionsAction extends Action {
return true;
}
}
export class ShowPopularExtensionsAction extends Action {
static ID = 'workbench.extensions.action.showPopularExtensions';
static LABEL = localize('showPopularExtensions', "Show Popular Extensions");
constructor(
id: string,
label: string,
@IViewletService private viewletService: IViewletService
) {
super(id, label, 'show-popular-extensions octicon octicon-flame', true);
}
run(): TPromise<void> {
return this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => {
viewlet.search('@popular', true);
viewlet.focus();
});
}
protected isEnabled(): boolean {
return true;
}
}
export class ShowExtensionRecommendationsAction extends Action {
static ID = 'workbench.extensions.action.showExtensionRecommendations';
static LABEL = localize('showExtensionRecommendations', "Show Extension Recommendations");
constructor(
id: string,
label: string,
@IViewletService private viewletService: IViewletService
) {
super(id, label, 'show-extension-recommendations octicon octicon-gift', true);
}
run(): TPromise<void> {
return this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => {
viewlet.search('@recommended', true);
viewlet.focus();
});
}
protected isEnabled(): boolean {
return true;
}
}
......@@ -13,6 +13,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Builder, Dimension } from 'vs/base/browser/builder';
import { onUnexpectedError } from 'vs/base/common/errors';
import { mapEvent, filterEvent } from 'vs/base/common/event';
import { IAction } from 'vs/base/common/actions';
import { domEvent } from 'vs/base/browser/event';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
......@@ -25,6 +26,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { Delegate, Renderer } from './extensionsList';
import { IExtensionsWorkbenchService, IExtension } from './extensions';
import { IExtensionsViewlet } from './extensions';
import { ShowExtensionRecommendationsAction, ShowPopularExtensionsAction } from './extensionsActions';
import { IExtensionManagementService, IExtensionGalleryService, SortBy } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionsInput } from './extensionsInput';
import { IProgressService } from 'vs/platform/progress/common/progress';
......@@ -113,6 +115,13 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
this.list.layout(height - 38);
}
getActions(): IAction[] {
return [
this.instantiationService.createInstance(ShowPopularExtensionsAction, ShowPopularExtensionsAction.ID, ShowPopularExtensionsAction.LABEL),
this.instantiationService.createInstance(ShowExtensionRecommendationsAction, ShowExtensionRecommendationsAction.ID, ShowExtensionRecommendationsAction.LABEL)
];
}
search(text: string, immediate = false): void {
this.searchBox.value = text;
this.triggerSearch(immediate);
......
......@@ -133,4 +133,10 @@
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNCIgaGVpZ2h0PSIxNCIgdmlld0JveD0iMiAyIDE0IDE0IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDIgMiAxNCAxNCI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTkgMTZjLTMuODYgMC03LTMuMTQtNy03czMuMTQtNyA3LTdjMy44NTkgMCA3IDMuMTQxIDcgN3MtMy4xNDEgNy03IDd6bTAtMTIuNmMtMy4wODggMC01LjYgMi41MTMtNS42IDUuNnMyLjUxMiA1LjYgNS42IDUuNiA1LjYtMi41MTIgNS42LTUuNi0yLjUxMi01LjYtNS42LTUuNnptMy44NiA3LjFsLTMuMTYtMS44OTZ2LTMuODA0aC0xLjR2NC41OTZsMy44NCAyLjMwNS43Mi0xLjIwMXoiLz48L3N2Zz4=");
background-position: center center;
background-repeat: no-repeat;
}
\ No newline at end of file
}
/*.show-extension-recommendations.octicon {
font-size: 16px;
line-height: 35px;
text-align: center;
}*/
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册