Skip to content

Commit bdf166b

Browse files
moved registryview loader dependency from component view
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
1 parent 9c29059 commit bdf166b

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

src/extension.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { WelcomePage } from './welcomePage';
3131
import { ComponentsTreeDataProvider } from './componentsView';
3232

3333
import fsx = require('fs-extra');
34-
import { getAllComponents } from './webview/devfile-registry/registryViewLoader';
3534

3635

3736
// eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -145,12 +144,6 @@ export async function activate(extensionContext: ExtensionContext): Promise<any>
145144

146145
void ComponentTypesView.instance.getAllComponents();
147146

148-
ComponentTypesView.instance.subject.subscribe((value: string) => {
149-
if (value === 'refresh') {
150-
getAllComponents('getAllComponents');
151-
}
152-
});
153-
154147
OdoImpl.Instance.loadWorkspaceComponents(null);
155148

156149
startTelemetry(extensionContext);

src/registriesView.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
import { StarterProject } from './odo/componentTypeDescription';
2424
import { vsCommand, VsCommandError } from './vscommand';
2525
import validator from 'validator';
26-
import RegistryViewLoader from './webview/devfile-registry/registryViewLoader';
2726
import { Command } from './odo/command';
2827
import { CliExitData } from './cli';
2928
import { Subject } from 'rxjs';
@@ -135,13 +134,8 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
135134
}).catch(() => {
136135
isError = true;
137136
}).finally(() => {
138-
if (isError) {
139-
if (this.subject.closed) {
140-
this.subject = new Subject<string>();
141-
this.getAllComponents();
142-
} else {
143-
this.subject.next('refresh');
144-
}
137+
if (isError && !this.subject.closed) {
138+
this.subject.next('refresh');
145139
}
146140
});
147141
});
@@ -300,7 +294,6 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
300294
ComponentTypesView.instance.addRegistry(newRegistry);
301295

302296
ComponentTypesView.instance.getAllComponents();
303-
RegistryViewLoader.refresh()
304297
}
305298

306299
@vsCommand('openshift.componentTypesView.registry.remove')
@@ -315,7 +308,6 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
315308
ComponentTypesView.instance.removeRegistry(registry);
316309
if (!isEdit) {
317310
ComponentTypesView.instance.getAllComponents();
318-
RegistryViewLoader.refresh();
319311
}
320312
}
321313
}
@@ -329,9 +321,4 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
329321
public static async openRegistryWebSite(registry: Registry): Promise<void> {
330322
await commands.executeCommand('vscode.open', Uri.parse(registry.URL));
331323
}
332-
333-
@vsCommand('openshift.componentTypesView.registry.openInView')
334-
public static async openRegistryInWebview(): Promise<void> {
335-
await RegistryViewLoader.loadView('Devfile Registry');
336-
}
337324
}

src/webview/devfile-registry/registryViewLoader.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export default class RegistryViewLoader {
105105
.replace('<!-- meta http-equiv="Content-Security-Policy" -->', meta);
106106
}
107107

108+
@vsCommand('openshift.componentTypesView.registry.openInView')
109+
public static async openRegistryInWebview(): Promise<void> {
110+
await RegistryViewLoader.loadView('Devfile Registry');
111+
}
112+
108113
@vsCommand('openshift.componentTypesView.registry.closeView')
109114
static async closeRegistryInWebview(): Promise<void> {
110115
panel?.dispose();
@@ -117,14 +122,21 @@ export default class RegistryViewLoader {
117122
}
118123
}
119124

120-
export function getAllComponents(eventActionName: string) {
125+
function getAllComponents(eventActionName: string) {
121126
const registries = ComponentTypesView.instance.getListOfRegistries();
122127
const componentDescriptions = ComponentTypesView.instance.getCompDescriptions();
123-
panel.webview.postMessage(
128+
panel?.webview.postMessage(
124129
{
125130
action: eventActionName,
126131
compDescriptions: Array.from(componentDescriptions),
127132
registries: registries
128133
}
129134
);
130135
}
136+
137+
ComponentTypesView.instance.subject.subscribe((value: string) => {
138+
if (value === 'refresh') {
139+
RegistryViewLoader.refresh();
140+
getAllComponents('getAllComponents');
141+
}
142+
});

0 commit comments

Comments
 (0)