Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
UtkarshGupta-CS authored Aug 13, 2019
2 parents 8da78b6 + 8e28611 commit c93ebfa
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 78 deletions.
16 changes: 1 addition & 15 deletions src/vs/platform/telemetry/browser/workbenchCommonProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';

import * as Platform from 'vs/base/common/platform';
import * as uuid from 'vs/base/common/uuid';
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';

export async function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, machineId: string, remoteAuthority?: string): Promise<{ [name: string]: string | undefined }> {
const result: { [name: string]: string | undefined; } = Object.create(null);
Expand Down Expand Up @@ -69,18 +70,3 @@ export async function resolveWorkbenchCommonProperties(storageService: IStorageS
return result;
}

function cleanRemoteAuthority(remoteAuthority?: string): string {
if (!remoteAuthority) {
return 'none';
}

let ret = 'other';
// Whitelisted remote authorities
['ssh-remote', 'dev-container', 'attached-container', 'wsl'].forEach((res: string) => {
if (remoteAuthority!.indexOf(`${res}+`) === 0) {
ret = res;
}
});

return ret;
}
16 changes: 16 additions & 0 deletions src/vs/platform/telemetry/common/telemetryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ export function validateTelemetryData(data?: any): { properties: Properties, mea
};
}

export function cleanRemoteAuthority(remoteAuthority?: string): string {
if (!remoteAuthority) {
return 'none';
}

let ret = 'other';
// Whitelisted remote authorities
['ssh-remote', 'dev-container', 'attached-container', 'wsl'].forEach((res: string) => {
if (remoteAuthority!.indexOf(`${res}+`) === 0) {
ret = res;
}
});

return ret;
}

function flatten(obj: any, result: { [key: string]: any }, order: number = 0, prefix?: string): void {
if (!obj) {
return;
Expand Down
17 changes: 1 addition & 16 deletions src/vs/platform/telemetry/node/workbenchCommonProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
import { instanceStorageKey, firstSessionDateStorageKey, lastSessionDateStorageKey } from 'vs/platform/telemetry/common/telemetry';
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';

export async function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, machineId: string, installSourcePath: string, remoteAuthority?: string): Promise<{ [name: string]: string | undefined }> {
const result = await resolveCommonProperties(commit, version, machineId, installSourcePath);
Expand All @@ -30,19 +31,3 @@ export async function resolveWorkbenchCommonProperties(storageService: IStorageS

return result;
}

function cleanRemoteAuthority(remoteAuthority?: string): string {
if (!remoteAuthority) {
return 'none';
}

let ret = 'other';
// Whitelisted remote authorities
['ssh-remote', 'dev-container', 'wsl'].forEach((res: string) => {
if (remoteAuthority!.indexOf(`${res}+`) === 0) {
ret = res;
}
});

return ret;
}
13 changes: 6 additions & 7 deletions src/vs/workbench/contrib/extensions/browser/extensionsViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class UnknownExtensionRenderer implements IListRenderer<ITreeNode<IExtens

class OpenExtensionAction extends Action {

private _extensionData: IExtensionData;
private _extensionData: IExtensionData | undefined;

constructor(@IExtensionsWorkbenchService private readonly extensionsWorkdbenchService: IExtensionsWorkbenchService) {
super('extensions.action.openExtension', '');
Expand All @@ -166,12 +166,11 @@ class OpenExtensionAction extends Action {
this._extensionData = extension;
}

public get extensionData(): IExtensionData {
return this._extensionData;
}

run(sideByside: boolean): Promise<any> {
return this.extensionsWorkdbenchService.open(this.extensionData.extension, sideByside);
if (this._extensionData) {
return this.extensionsWorkdbenchService.open(this._extensionData.extension, sideByside);
}
return Promise.resolve();
}
}

Expand Down Expand Up @@ -263,4 +262,4 @@ export class ExtensionData implements IExtensionData {
}
return null;
}
}
}
76 changes: 44 additions & 32 deletions src/vs/workbench/contrib/extensions/browser/extensionsViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ class ExtensionListViewWarning extends Error { }
export class ExtensionsListView extends ViewletPanel {

protected readonly server: IExtensionManagementServer | undefined;
private messageContainer: HTMLElement;
private messageSeverityIcon: HTMLElement;
private messageBox: HTMLElement;
private extensionsList: HTMLElement;
private badge: CountBadge;
protected badgeContainer: HTMLElement;
private list: WorkbenchPagedList<IExtension> | null;
private queryRequest: { query: string, request: CancelablePromise<IPagedModel<IExtension>> } | null;
private bodyTemplate: {
messageContainer: HTMLElement;
messageSeverityIcon: HTMLElement;
messageBox: HTMLElement;
extensionsList: HTMLElement;
} | undefined;
private badge: CountBadge | undefined;
private list: WorkbenchPagedList<IExtension> | null = null;
private queryRequest: { query: string, request: CancelablePromise<IPagedModel<IExtension>> } | null = null;

constructor(
options: ExtensionsListViewOptions,
Expand Down Expand Up @@ -111,20 +112,19 @@ export class ExtensionsListView extends ViewletPanel {
addClass(container, 'extension-view-header');
super.renderHeader(container);

this.badgeContainer = append(container, $('.count-badge-wrapper'));
this.badge = new CountBadge(this.badgeContainer);
this.badge = new CountBadge(append(container, $('.count-badge-wrapper')));
this._register(attachBadgeStyler(this.badge, this.themeService));
}

renderBody(container: HTMLElement): void {
this.extensionsList = append(container, $('.extensions-list'));
this.messageContainer = append(container, $('.message-container'));
this.messageSeverityIcon = append(this.messageContainer, $(''));
this.messageBox = append(this.messageContainer, $('.message'));
const extensionsList = append(container, $('.extensions-list'));
const messageContainer = append(container, $('.message-container'));
const messageSeverityIcon = append(messageContainer, $(''));
const messageBox = append(messageContainer, $('.message'));
const delegate = new Delegate();
const extensionsViewState = new ExtensionsViewState();
const renderer = this.instantiationService.createInstance(Renderer, extensionsViewState);
this.list = this.instantiationService.createInstance(WorkbenchPagedList, this.extensionsList, delegate, [renderer], {
this.list = this.instantiationService.createInstance(WorkbenchPagedList, extensionsList, delegate, [renderer], {
ariaLabel: localize('extensions', "Extensions"),
multipleSelectionSupport: false,
setRowLineHeight: false,
Expand All @@ -144,10 +144,19 @@ export class ExtensionsListView extends ViewletPanel {
.map(e => e.elements[0])
.filter(e => !!e)
.on(this.pin, this));

this.bodyTemplate = {
extensionsList,
messageBox,
messageContainer,
messageSeverityIcon
};
}

protected layoutBody(height: number, width: number): void {
this.extensionsList.style.height = height + 'px';
if (this.bodyTemplate) {
this.bodyTemplate.extensionsList.style.height = height + 'px';
}
if (this.list) {
this.list.layout(height, width);
}
Expand Down Expand Up @@ -479,7 +488,7 @@ export class ExtensionsListView extends ViewletPanel {

}

private _searchExperiments: Promise<IExperiment[]>;
private _searchExperiments: Promise<IExperiment[]> | undefined;
private getSearchExperiments(): Promise<IExperiment[]> {
if (!this._searchExperiments) {
this._searchExperiments = this.experimentService.getExperimentsByType(ExperimentActionType.ExtensionSearchResults);
Expand Down Expand Up @@ -690,24 +699,27 @@ export class ExtensionsListView extends ViewletPanel {
this.list.scrollTop = 0;
const count = this.count();

toggleClass(this.extensionsList, 'hidden', count === 0);
toggleClass(this.messageContainer, 'hidden', count > 0);
this.badge.setCount(count);
if (this.bodyTemplate && this.badge) {

if (count === 0 && this.isBodyVisible()) {
if (error) {
if (error instanceof ExtensionListViewWarning) {
this.messageSeverityIcon.className = SeverityIcon.className(Severity.Warning);
this.messageBox.textContent = getErrorMessage(error);
toggleClass(this.bodyTemplate.extensionsList, 'hidden', count === 0);
toggleClass(this.bodyTemplate.messageContainer, 'hidden', count > 0);
this.badge.setCount(count);

if (count === 0 && this.isBodyVisible()) {
if (error) {
if (error instanceof ExtensionListViewWarning) {
this.bodyTemplate.messageSeverityIcon.className = SeverityIcon.className(Severity.Warning);
this.bodyTemplate.messageBox.textContent = getErrorMessage(error);
} else {
this.bodyTemplate.messageSeverityIcon.className = SeverityIcon.className(Severity.Error);
this.bodyTemplate.messageBox.textContent = localize('error', "Error while loading extensions. {0}", getErrorMessage(error));
}
} else {
this.messageSeverityIcon.className = SeverityIcon.className(Severity.Error);
this.messageBox.textContent = localize('error', "Error while loading extensions. {0}", getErrorMessage(error));
this.bodyTemplate.messageSeverityIcon.className = '';
this.bodyTemplate.messageBox.textContent = localize('no extensions found', "No extensions found.");
}
} else {
this.messageSeverityIcon.className = '';
this.messageBox.textContent = localize('no extensions found', "No extensions found.");
alert(this.bodyTemplate.messageBox.textContent);
}
alert(this.messageBox.textContent);
}
}
}
Expand Down Expand Up @@ -949,7 +961,7 @@ export class RecommendedExtensionsView extends ExtensionsListView {

export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
private readonly recommendedExtensionsQuery = '@recommended:workspace';
private installAllAction: InstallWorkspaceRecommendedExtensionsAction;
private installAllAction: InstallWorkspaceRecommendedExtensionsAction | undefined;

renderBody(container: HTMLElement): void {
super.renderBody(container);
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/contrib/extensions/browser/extensionsWidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import { Emitter, Event } from 'vs/base/common/event';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

export abstract class ExtensionWidget extends Disposable implements IExtensionContainer {
private _extension: IExtension;
get extension(): IExtension { return this._extension; }
set extension(extension: IExtension) { this._extension = extension; this.update(); }
private _extension: IExtension | null = null;
get extension(): IExtension | null { return this._extension; }
set extension(extension: IExtension | null) { this._extension = extension; this.update(); }
update(): void { this.render(); }
abstract render(): void;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ export class RecommendationWidget extends ExtensionWidget {
private element?: HTMLElement;
private readonly disposables = this._register(new DisposableStore());

private _tooltip: string;
private _tooltip: string = '';
get tooltip(): string { return this._tooltip; }
set tooltip(tooltip: string) {
if (this._tooltip !== tooltip) {
Expand Down Expand Up @@ -314,4 +314,4 @@ class RemoteBadge extends Disposable {
updateTitle();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
private readonly _onChange: Emitter<IExtension | undefined> = new Emitter<IExtension | undefined>();
get onChange(): Event<IExtension | undefined> { return this._onChange.event; }

private _extensionAllowedBadgeProviders: string[];
private _extensionAllowedBadgeProviders: string[] | undefined;
private installing: IExtension[] = [];

constructor(
Expand Down Expand Up @@ -1096,12 +1096,12 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
}


private _ignoredAutoUpdateExtensions: string[];
private _ignoredAutoUpdateExtensions: string[] | undefined;
private get ignoredAutoUpdateExtensions(): string[] {
if (!this._ignoredAutoUpdateExtensions) {
this._ignoredAutoUpdateExtensions = JSON.parse(this.storageService.get('extensions.ignoredAutoUpdateExtension', StorageScope.GLOBAL, '[]') || '[]');
}
return this._ignoredAutoUpdateExtensions;
return this._ignoredAutoUpdateExtensions!;
}

private set ignoredAutoUpdateExtensions(extensionIds: string[]) {
Expand Down

0 comments on commit c93ebfa

Please sign in to comment.