Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show preview tag on extention page if extension is in preview #36261

Merged
merged 1 commit into from Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -152,6 +152,7 @@ export interface IGalleryExtension {
assets: IGalleryExtensionAssets;
properties: IGalleryExtensionProperties;
telemetryData: any;
preview: boolean;
}

export interface IGalleryMetadata {
Expand Down Expand Up @@ -308,4 +309,4 @@ export interface IExtensionTipsService {

export const ExtensionsLabel = localize('extensions', "Extensions");
export const ExtensionsChannelId = 'extensions';
export const PreferencesLabel = localize('preferences', "Preferences");
export const PreferencesLabel = localize('preferences', "Preferences");
Expand Up @@ -55,6 +55,7 @@ interface IRawGalleryExtension {
publisher: { displayName: string, publisherId: string, publisherName: string; };
versions: IRawGalleryExtensionVersion[];
statistics: IRawGalleryExtensionStatistics[];
flags: string;
}

interface IRawGalleryQueryResult {
Expand Down Expand Up @@ -233,6 +234,10 @@ function getEngine(version: IRawGalleryExtensionVersion): string {
return (values.length > 0 && values[0].value) || '';
}

function getIsPreview(flags: string): boolean {
return flags.indexOf('preview') !== -1;
}

function toExtension(galleryExtension: IRawGalleryExtension, extensionsGalleryUrl: string, index: number, query: Query, querySource?: string): IGalleryExtension {
const [version] = galleryExtension.versions;
const assets = {
Expand Down Expand Up @@ -274,7 +279,8 @@ function toExtension(galleryExtension: IRawGalleryExtension, extensionsGalleryUr
index: ((query.pageNumber - 1) * query.pageSize) + index,
searchText: query.searchText,
querySource
}
},
preview: getIsPreview(galleryExtension.flags)
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/vs/workbench/parts/extensions/browser/extensionEditor.ts
Expand Up @@ -155,6 +155,7 @@ export class ExtensionEditor extends BaseEditor {
private icon: HTMLImageElement;
private name: HTMLElement;
private identifier: HTMLElement;
private preview: HTMLElement;
private license: HTMLElement;
private publisher: HTMLElement;
private installCount: HTMLElement;
Expand Down Expand Up @@ -220,6 +221,7 @@ export class ExtensionEditor extends BaseEditor {
const title = append(details, $('.title'));
this.name = append(title, $('span.name.clickable', { title: localize('name', "Extension name") }));
this.identifier = append(title, $('span.identifier', { title: localize('extension id', "Extension identifier") }));
this.preview = append(title, $('span.preview', { title: localize('preview', "Preview") }));

const subtitle = append(details, $('.subtitle'));
this.publisher = append(subtitle, $('span.publisher.clickable', { title: localize('publisher', "Publisher name") }));
Expand Down Expand Up @@ -285,6 +287,11 @@ export class ExtensionEditor extends BaseEditor {

this.name.textContent = extension.displayName;
this.identifier.textContent = extension.id;
if (extension.preview) {
this.preview.textContent = localize('preview', "Preview");
} else {
this.preview.textContent = null;
}

this.publisher.textContent = extension.publisherDisplayName;
this.description.textContent = extension.description;
Expand Down
Expand Up @@ -58,6 +58,14 @@
white-space: nowrap;
}

.extension-editor > .header > .details > .title > .preview {
background: rgb(214, 63, 38);
font-size: 14px;
margin-left: 10px;
padding: 0px 4px;
border-radius: 4px;
}

.extension-editor > .header > .details > .subtitle {
padding-top: 10px;
white-space: nowrap;
Expand Down Expand Up @@ -310,4 +318,4 @@
font-size: 90%;
font-weight: 600;
opacity: 0.6;
}
}
3 changes: 2 additions & 1 deletion src/vs/workbench/parts/extensions/common/extensions.ts
Expand Up @@ -46,6 +46,7 @@ export interface IExtension {
disabledForWorkspace: boolean;
dependencies: string[];
telemetryData: any;
preview: boolean;
getManifest(): TPromise<IExtensionManifest>;
getReadme(): TPromise<string>;
getChangelog(): TPromise<string>;
Expand Down Expand Up @@ -87,4 +88,4 @@ export const ConfigurationKey = 'extensions';
export interface IExtensionsConfiguration {
autoUpdate: boolean;
ignoreRecommendations: boolean;
}
}
Expand Up @@ -172,6 +172,10 @@ class Extension implements IExtension {
}
}

get preview(): boolean {
return this.gallery ? this.gallery.preview : false;
}

getManifest(): TPromise<IExtensionManifest> {
if (this.gallery) {
return this.galleryService.getManifest(this.gallery);
Expand Down Expand Up @@ -907,4 +911,4 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
this.syncDelayer.cancel();
this.disposables = dispose(this.disposables);
}
}
}