Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/registriesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
return {
label: element.name,
contextValue: ContextType.DEVFILE_REGISTRY,
tooltip: `Devfile Registry\nName: ${element.name}\nURL: ${element.name}`,
tooltip: `Devfile Registry\nName: ${element.name}\nURL: ${element.url}`,
collapsibleState: TreeItemCollapsibleState.None,
iconPath: new vscode.ThemeIcon('note')
};
}

addRegistry(newRegistry: Registry): void {
if(!this.registries){
this.registries = [];
}
this.registries.push(newRegistry);
this.refresh(false);
this.reveal(newRegistry);
Expand Down Expand Up @@ -243,7 +246,7 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
if (!validator.matches(trimmedValue, '^[a-zA-Z0-9]+$')) {
return 'Registry name can have only alphabet characters and numbers';
}
if (registries.find((registry) => registry.name !== registryContext?.name && registry.name === value)) {
if (registries?.find((registry) => registry.name !== registryContext?.name && registry.name === value)) {
return `Registry name '${value}' is already used`;
}
},
Expand All @@ -261,7 +264,7 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
if (!validator.isURL(trimmedValue)) {
return 'Entered URL is invalid';
}
if (registries.find((registry) => registry.name !== registryContext?.name && registry.url === value)) {
if (registries?.find((registry) => registry.name !== registryContext?.name && registry.url === value)) {
return `Registry with entered URL '${value}' already exists`;
}
},
Expand Down Expand Up @@ -289,7 +292,7 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
*/

if (registryContext) {
const notChangedRegisty = registries.find((registry) => registry.name === regName && registry.url === regURL && registry.secure === (secure === 'Yes'));
const notChangedRegisty = registries?.find((registry) => registry.name === regName && registry.url === regURL && registry.secure === (secure === 'Yes'));
if (notChangedRegisty) {
return null;
}
Expand Down
5 changes: 4 additions & 1 deletion src/webview/devfile-registry/app/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const Home: React.FC<DefaultProps> = ({ }) => {
if (message.data.action === 'getAllComponents') {
if (message.data.errorMessage && message.data.errorMessage.length > 0) {
setError(message.data.errorMessage);
setCompDescriptions([]);
setRegistries([]);
setFilteredcompDescriptions([]);
} else {
setError('');
if (message.data.registries.length === 1) {
Expand Down Expand Up @@ -126,7 +129,7 @@ export const Home: React.FC<DefaultProps> = ({ }) => {
/>
}
<HomeItem compDescriptions={filteredcompDescriptions} />
{error?.length > 0 ? <ErrorPage message='Devfiles not downloaded properly' /> : null}
{error?.length > 0 ? <ErrorPage message={error} /> : null}
</>
:
error?.length > 0 ? <ErrorPage message={error} /> : <LoadScreen />
Expand Down
31 changes: 20 additions & 11 deletions src/webview/devfile-registry/registryViewLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,27 @@ export default class RegistryViewLoader {

function getAllComponents(eventActionName: string, url?: string, error?: string) {
let registries = ComponentTypesView.instance.getListOfRegistries();
if (url && url.length > 0) {
registries = registries.filter((registry: Registry) => registry.url === url);
}
const componentDescriptions = ComponentTypesView.instance.getCompDescriptions();
panel?.webview.postMessage(
{
action: eventActionName,
compDescriptions: Array.from(componentDescriptions),
registries: registries,
errorMessage: error
if (!registries || registries.length === 0) {
panel?.webview.postMessage(
{
action: eventActionName,
errorMessage: 'No Devfile registries configured'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msivasubramaniaan Instead of showing the Devfile Webview with this message, we can just load the Error Notification of VSCode saying No devfile registry is accessible.

}
);
} else {
if (url && url.length > 0) {
registries = registries.filter((registry: Registry) => registry.url === url);
}
);
const componentDescriptions = ComponentTypesView.instance.getCompDescriptions();
panel?.webview.postMessage(
{
action: eventActionName,
compDescriptions: Array.from(componentDescriptions),
registries: registries,
errorMessage: error
}
);
}
}

ComponentTypesView.instance.subject.subscribe((value: string) => {
Expand Down