提交 1a19cd4d 编写于 作者: A Alex Ross

Fix Forwarded Ports view visibility for some remotes

上级 fd13e449
......@@ -30,11 +30,11 @@ export interface IViewletViewOptions extends IViewPaneOptions {
export abstract class FilterViewPaneContainer extends ViewPaneContainer {
private constantViewDescriptors: Map<string, IViewDescriptor> = new Map();
private allViews: Map<string, Map<string, IViewDescriptor>> = new Map();
private filterValue: string | undefined;
private filterValue: string[] | undefined;
constructor(
viewletId: string,
onDidChangeFilterValue: Event<string>,
onDidChangeFilterValue: Event<string[]>,
@IConfigurationService configurationService: IConfigurationService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@ITelemetryService telemetryService: ITelemetryService,
......@@ -67,7 +67,7 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
this.allViews.set(filterOnValue, new Map());
}
this.allViews.get(filterOnValue)!.set(descriptor.id, descriptor);
if (filterOnValue !== this.filterValue) {
if (this.filterValue && !this.filterValue.includes(filterOnValue)) {
this.viewsModel.setVisible(descriptor.id, false);
}
});
......@@ -79,7 +79,7 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
protected abstract getFilterOn(viewDescriptor: IViewDescriptor): string | undefined;
private onFilterChanged(newFilterValue: string) {
private onFilterChanged(newFilterValue: string[]) {
if (this.allViews.size === 0) {
this.updateAllViews(this.viewsModel.viewDescriptors);
}
......@@ -107,18 +107,32 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
return result;
}
private getViewsForTarget(target: string): IViewDescriptor[] {
return this.allViews.has(target) ? Array.from(this.allViews.get(target)!.values()) : [];
private getViewsForTarget(target: string[]): IViewDescriptor[] {
const views: IViewDescriptor[] = [];
for (let i = 0; i < target.length; i++) {
if (this.allViews.has(target[i])) {
views.push(...Array.from(this.allViews.get(target[i])!.values()));
}
}
return views;
}
private getViewsNotForTarget(target: string): IViewDescriptor[] {
private getViewsNotForTarget(target: string[]): IViewDescriptor[] {
const iterable = this.allViews.keys();
let key = iterable.next();
let views: IViewDescriptor[] = [];
while (!key.done) {
if (key.value !== target) {
views = views.concat(this.getViewsForTarget(key.value));
let isForTarget: boolean = false;
target.forEach(value => {
if (key.value === value) {
isForTarget = true;
}
});
if (!isForTarget) {
views = views.concat(this.getViewsForTarget([key.value]));
}
key = iterable.next();
}
return views;
......
......@@ -51,23 +51,25 @@ export class SwitchRemoteViewItem extends SelectActionViewItem {
if (this.optionsItems.length > 0) {
let index = 0;
const remoteAuthority = environmentService.configuration.remoteAuthority;
const explorerType: string | undefined = remoteAuthority ? remoteAuthority.split('+')[0] :
this.storageService.get(REMOTE_EXPLORER_TYPE_KEY, StorageScope.WORKSPACE) ?? this.storageService.get(REMOTE_EXPLORER_TYPE_KEY, StorageScope.GLOBAL);
if (explorerType) {
const explorerType: string[] | undefined = remoteAuthority ? [remoteAuthority.split('+')[0]] :
this.storageService.get(REMOTE_EXPLORER_TYPE_KEY, StorageScope.WORKSPACE)?.split(',') ?? this.storageService.get(REMOTE_EXPLORER_TYPE_KEY, StorageScope.GLOBAL)?.split(',');
if (explorerType !== undefined) {
index = this.getOptionIndexForExplorerType(optionsItems, explorerType);
}
this.select(index);
remoteExplorerService.targetType = optionsItems[index].authority[0];
remoteExplorerService.targetType = optionsItems[index].authority;
}
}
private getOptionIndexForExplorerType(optionsItems: IRemoteSelectItem[], explorerType: string): number {
private getOptionIndexForExplorerType(optionsItems: IRemoteSelectItem[], explorerType: string[]): number {
let index = 0;
for (let optionIterator = 0; (optionIterator < this.optionsItems.length) && (index === 0); optionIterator++) {
for (let authorityIterator = 0; authorityIterator < optionsItems[optionIterator].authority.length; authorityIterator++) {
if (optionsItems[optionIterator].authority[authorityIterator] === explorerType) {
index = optionIterator;
break;
for (let i = 0; i < explorerType.length; i++) {
if (optionsItems[optionIterator].authority[authorityIterator] === explorerType[i]) {
index = optionIterator;
break;
}
}
}
}
......@@ -110,6 +112,6 @@ export class SwitchRemoteAction extends Action {
}
public async run(item: IRemoteSelectItem): Promise<any> {
this.remoteExplorerService.targetType = item.authority[0];
this.remoteExplorerService.targetType = item.authority;
}
}
......@@ -278,13 +278,18 @@ abstract class HelpItemBase implements IHelpItem {
async handleClick() {
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
if (remoteAuthority && startsWith(remoteAuthority, this.remoteExplorerService.targetType)) {
for (let value of this.values) {
if (value.remoteAuthority) {
for (let authority of value.remoteAuthority) {
if (startsWith(remoteAuthority, authority)) {
await this.takeAction(value.extensionDescription, value.url);
return;
if (!remoteAuthority) {
return;
}
for (let i = 0; i < this.remoteExplorerService.targetType.length; i++) {
if (startsWith(remoteAuthority, this.remoteExplorerService.targetType[i])) {
for (let value of this.values) {
if (value.remoteAuthority) {
for (let authority of value.remoteAuthority) {
if (startsWith(remoteAuthority, authority)) {
await this.takeAction(value.extensionDescription, value.url);
return;
}
}
}
}
......
......@@ -223,8 +223,8 @@ export class TunnelModel extends Disposable {
export interface IRemoteExplorerService {
_serviceBrand: undefined;
onDidChangeTargetType: Event<string>;
targetType: string;
onDidChangeTargetType: Event<string[]>;
targetType: string[];
readonly tunnelModel: TunnelModel;
onDidChangeEditable: Event<ITunnelItem | undefined>;
setEditable(tunnelItem: ITunnelItem | undefined, data: IEditableData | null): void;
......@@ -238,9 +238,9 @@ export interface IRemoteExplorerService {
class RemoteExplorerService implements IRemoteExplorerService {
public _serviceBrand: undefined;
private _targetType: string = '';
private readonly _onDidChangeTargetType: Emitter<string> = new Emitter<string>();
public readonly onDidChangeTargetType: Event<string> = this._onDidChangeTargetType.event;
private _targetType: string[] = [];
private readonly _onDidChangeTargetType: Emitter<string[]> = new Emitter<string[]>();
public readonly onDidChangeTargetType: Event<string[]> = this._onDidChangeTargetType.event;
private _tunnelModel: TunnelModel;
private _editable: { tunnelItem: ITunnelItem | undefined, data: IEditableData } | undefined;
private readonly _onDidChangeEditable: Emitter<ITunnelItem | undefined> = new Emitter();
......@@ -254,15 +254,18 @@ class RemoteExplorerService implements IRemoteExplorerService {
this._tunnelModel = new TunnelModel(tunnelService, storageService, configurationService);
}
set targetType(name: string) {
if (this._targetType !== name) {
set targetType(name: string[]) {
// Can just compare the first element of the array since there are no target overlaps
const current: string = this._targetType.length > 0 ? this._targetType[0] : '';
const newName: string = name.length > 0 ? name[0] : '';
if (current !== newName) {
this._targetType = name;
this.storageService.store(REMOTE_EXPLORER_TYPE_KEY, this._targetType, StorageScope.WORKSPACE);
this.storageService.store(REMOTE_EXPLORER_TYPE_KEY, this._targetType, StorageScope.GLOBAL);
this.storageService.store(REMOTE_EXPLORER_TYPE_KEY, this._targetType.toString(), StorageScope.WORKSPACE);
this.storageService.store(REMOTE_EXPLORER_TYPE_KEY, this._targetType.toString(), StorageScope.GLOBAL);
this._onDidChangeTargetType.fire(this._targetType);
}
}
get targetType(): string {
get targetType(): string[] {
return this._targetType;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册