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

search by publisher

上级 1327c91f
......@@ -12,6 +12,7 @@ import { IDisposable, empty, dispose, toDisposable } from 'vs/base/common/lifecy
import { Builder } from 'vs/base/browser/builder';
import { append, emmet as $, addClass, removeClass, finalHandler } from 'vs/base/browser/dom';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IRequestService } from 'vs/platform/request/common/request';
......@@ -23,6 +24,7 @@ import { RatingsWidget } from './extensionsWidgets';
import { EditorOptions } from 'vs/workbench/common/editor';
import { shell } from 'electron';
import product from 'vs/platform/product';
import { IExtensionsViewlet } from './extensions';
export class ExtensionEditor extends BaseEditor {
......@@ -30,7 +32,7 @@ export class ExtensionEditor extends BaseEditor {
private icon: HTMLElement;
private name: HTMLAnchorElement;
private publisher: HTMLElement;
private publisher: HTMLAnchorElement;
private installCount: HTMLElement;
private rating: HTMLAnchorElement;
private description: HTMLElement;
......@@ -47,7 +49,8 @@ export class ExtensionEditor extends BaseEditor {
@IExtensionGalleryService private galleryService: IExtensionGalleryService,
@IConfigurationService private configurationService: IConfigurationService,
@IInstantiationService private instantiationService: IInstantiationService,
@IRequestService private requestService: IRequestService
@IRequestService private requestService: IRequestService,
@IViewletService private viewletService: IViewletService
) {
super(ExtensionEditor.ID, telemetryService);
this._highlight = null;
......@@ -68,7 +71,8 @@ export class ExtensionEditor extends BaseEditor {
this.name.href = '#';
const subtitle = append(details, $('.subtitle'));
this.publisher = append(subtitle, $('span.publisher'));
this.publisher = append(subtitle, $<HTMLAnchorElement>('a.publisher'));
this.publisher.href = '#';
this.installCount = append(subtitle, $('span.install'));
this.rating = append(subtitle, $<HTMLAnchorElement>('a.rating'));
this.rating.href = '#';
......@@ -83,7 +87,7 @@ export class ExtensionEditor extends BaseEditor {
this.body.innerHTML = '';
let promise = TPromise.wrapError<void>('no readme');
let promise = TPromise.as(null);
const extension = input.extension;
this.icon.style.backgroundImage = `url("${ extension.iconUrl }")`;
......@@ -94,8 +98,13 @@ export class ExtensionEditor extends BaseEditor {
if (product.extensionsGallery) {
const extensionUrl = `${ product.extensionsGallery.itemUrl }?itemName=${ extension.publisher }.${ extension.name }`;
this.name.onclick = finalHandler(e => shell.openExternal(extensionUrl));
this.rating.onclick = finalHandler(e => shell.openExternal(`${ extensionUrl }#review-details`));
this.name.onclick = finalHandler(() => shell.openExternal(extensionUrl));
this.rating.onclick = finalHandler(() => shell.openExternal(`${ extensionUrl }#review-details`));
this.publisher.onclick = finalHandler(() => {
this.viewletService.openViewlet('workbench.viewlet.extensions', true)
.then(viewlet => viewlet as IExtensionsViewlet)
.done(viewlet => viewlet.search(`publisher:"${ extension.publisherDisplayName }"`, true));
});
}
const ratings = new RatingsWidget(this.rating, input.model, extension);
......@@ -108,13 +117,11 @@ export class ExtensionEditor extends BaseEditor {
.then(() => this.requestService.makeRequest({ url: extension.readmeUrl }))
.then(response => response.responseText)
.then(marked.parse)
.then<void>(html => this.body.innerHTML = html);
.then<void>(html => this.body.innerHTML = html)
.then(null, err => console.error(err))
.then(() => removeClass(this.body, 'loading'));
}
promise = promise
.then(null, err => console.error(err))
.then(() => removeClass(this.body, 'loading'));
this.transientDisposables.push(toDisposable(() => promise.cancel()));
return TPromise.as(null);
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {IViewlet} from 'vs/workbench/common/viewlet';
export interface IExtensionsViewlet extends IViewlet {
search(text: string, immediate?: boolean): void;
}
\ No newline at end of file
......@@ -23,12 +23,13 @@ import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Delegate, Renderer } from './extensionsList';
import { ExtensionsModel, IExtension } from './extensionsModel';
import { IExtensionsViewlet } from './extensions';
import { IExtensionManagementService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionsInput } from '../common/extensionsInput';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
export class ExtensionsViewlet extends Viewlet {
export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
static ID: string = 'workbench.viewlet.extensions';
......@@ -61,6 +62,7 @@ export class ExtensionsViewlet extends Viewlet {
const header = append(this.root, $('.header'));
this.searchBox = append(header, $<HTMLInputElement>('input.search-box'));
this.searchBox.type = 'search';
this.searchBox.placeholder = localize('searchExtensions', "Search Extensions in Marketplace");
this.extensionsBox = append(this.root, $('.extensions'));
......@@ -103,7 +105,7 @@ export class ExtensionsViewlet extends Viewlet {
if (visible) {
this.searchBox.focus();
this.searchBox.setSelectionRange(0,this.searchBox.value.length);
this.triggerSearch(0);
this.triggerSearch(true);
} else {
this.list.model = new SinglePagePagedModel([]);
}
......@@ -118,9 +120,14 @@ export class ExtensionsViewlet extends Viewlet {
this.list.layout(height - 38);
}
private triggerSearch(delay = 500): void {
search(text: string, immediate = false): void {
this.searchBox.value = text;
this.triggerSearch(immediate);
}
private triggerSearch(immediate = false): void {
const text = this.searchBox.value;
this.searchDelayer.trigger(() => this.doSearch(text), text ? delay : 0);
this.searchDelayer.trigger(() => this.doSearch(text), immediate || !text ? 0 : 500);
}
private doSearch(text: string = ''): TPromise<any> {
......@@ -145,7 +152,7 @@ export class ExtensionsViewlet extends Viewlet {
private onEscape(): void {
this.searchBox.value = '';
this.triggerSearch(0);
this.triggerSearch(true);
}
private onUpArrow(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册