Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
"onCommand:openshift.component.watch.terminate",
"onCommand:openshift.component.watch.showLog",
"onCommand:openshift.component.deployRootWorkspaceFolder",
"onCommand:openshift.componentTypesView.registry.closeView",
"onCommand:openshift.catalog.listComponents",
"onCommand:openshift.catalog.listServices",
"onCommand:openshift.url.create",
Expand Down Expand Up @@ -873,6 +874,11 @@
"title": "Remove",
"category": "OpenSift"
},
{
"command": "openshift.componentTypesView.registry.edit",
"title": "Edit",
"category": "OpenSift"
},
{
"command": "openshift.componentTypesView.registry.openInBrowser",
"title": "Open in Browser",
Expand Down Expand Up @@ -1159,6 +1165,10 @@
"command": "openshift.componentTypesView.registry.remove",
"when": "false"
},
{
"command": "openshift.componentTypesView.registry.edit",
"when": "false"
},
{
"command": "openshift.componentTypesView.registry.openInView",
"when": "false"
Expand Down Expand Up @@ -1549,6 +1559,11 @@
"command": "openshift.component.revealInExplorer",
"when": "view == openshiftComponentsView && viewItem == openshift.component"
},
{
"command": "openshift.componentTypesView.registry.edit",
"when": "view == openshiftComponentTypesView && viewItem == devfileRegistry && viewItem != DefaultdevfileRegistry",
"group": "1@0"
},
{
"command": "openshift.componentTypesView.registry.remove",
"when": "view == openshiftComponentTypesView && viewItem == devfileRegistry && viewItem != DefaultdevfileRegistry",
Expand Down
26 changes: 19 additions & 7 deletions src/componentTypesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import {
TreeDataProvider,
TreeItem,
Expand Down Expand Up @@ -173,10 +173,11 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
}

@vsCommand('openshift.componentTypesView.registry.add')
public static async addRegistryCmd(): Promise<void> {
public static async addRegistryCmd(registryContext: Registry): Promise<void> {
// ask for registry
const regName = await window.showInputBox({
prompt: 'Provide registry name to display in the view',
value: registryContext?.Name,
prompt: registryContext ? 'Edit registry name' : 'Provide registry name to display in the view',
Comment thread
msivasubramaniaan marked this conversation as resolved.
placeHolder: 'Registry Name',
validateInput: async (value) => {
const trimmedValue = value.trim();
Expand All @@ -197,15 +198,16 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {

const regURL = await window.showInputBox({
ignoreFocusOut: true,
prompt: 'Provide registry URL to display in the view',
value: registryContext?.URL,
prompt: registryContext ? 'Edit registry URL' : 'Provide registry URL to display in the view',
placeHolder: 'Registry URL',
validateInput: async (value) => {
const trimmedValue = value.trim();
if (!validator.isURL(trimmedValue)) {
return 'Entered URL is invalid';
}
const registries = await ComponentTypesView.instance.getRegistries();
if (registries.find((registry) => registry.URL === value)) {
if (!registryContext && registries.find((registry) => registry.URL === value)) {
Comment thread
msivasubramaniaan marked this conversation as resolved.
Outdated
return `Registry with entered URL '${value}' already exists`;
}
},
Expand All @@ -230,8 +232,8 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
}

@vsCommand('openshift.componentTypesView.registry.remove')
public static async removeRegistry(registry: Registry): Promise<void> {
const yesNo = await window.showInformationMessage(
public static async removeRegistry(registry: Registry, isEdit?: boolean): Promise<void> {
const yesNo = isEdit ? 'Yes' : await window.showInformationMessage(
`Remove registry '${registry.Name}'?`,
'Yes',
'No',
Expand All @@ -242,6 +244,16 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
}
}

@vsCommand('openshift.componentTypesView.registry.edit')
public static async editRegistry(registry: Registry): Promise<void> {
await vscode.commands.executeCommand('openshift.componentTypesView.registry.closeView');
const addRegistryFlag = await vscode.commands.executeCommand('openshift.componentTypesView.registry.add', registry);
if (null !== addRegistryFlag) {
await vscode.commands.executeCommand('openshift.componentTypesView.registry.remove', registry, true);
vscode.commands.executeCommand('openshift.componentTypesView.registry.openInView');
}
}

@vsCommand('openshift.componentTypesView.registry.openInBrowser')
public static async openRegistryWebSite(registry: Registry): Promise<void> {
await commands.executeCommand('vscode.open', Uri.parse(registry.URL));
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export async function activate(extensionContext: ExtensionContext): Promise<any>
'./k8s/console',
'./oc',
'./componentTypesView',
'./componentsView'
'./componentsView',
'./webview/devfile-registry/registryViewLoader'
)),
commands.registerCommand('clusters.openshift.useProject', (context) =>
commands.executeCommand('extension.vsKubernetesUseNamespace', context),
Expand Down
7 changes: 6 additions & 1 deletion src/webview/devfile-registry/registryViewLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { stringify } from 'yaml';
import { ComponentTypesView } from '../../componentTypesView';
import { StarterProject } from '../../odo/componentTypeDescription';
import { DevfileComponentType } from '../../odo/componentType';
import { vsCommand } from '../../vscommand';

let panel: vscode.WebviewPanel;
let compDescriptions = new Set<any>();
Expand Down Expand Up @@ -85,7 +86,6 @@ async function devfileRegistryViewerMessageListener(event: any): Promise<any> {
break;
}
}

export default class RegistryViewLoader {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
static get extensionPath() {
Expand Down Expand Up @@ -135,4 +135,9 @@ export default class RegistryViewLoader {
.replace('%BASE_URL%', `${reactAppUri}`)
.replace('<!-- meta http-equiv="Content-Security-Policy" -->', meta);
}

@vsCommand('openshift.componentTypesView.registry.closeView')
static async closeRegistryInWebview(): Promise<void> {
panel?.dispose();
}
}