Skip to content

Commit 4179205

Browse files
dgolovinJessicaJHee
authored andcommitted
Allow Cluster editor open on crc or sandbox page
Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 538eb14 commit 4179205

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

src/cloud-provider/redhat-cloud-provider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
100100

101101
@vsCommand('openshift.local.open.setup')
102102
static async openCrCWizard(): Promise<void> {
103-
const webViewPanel: vscode.WebviewPanel = await ClusterViewLoader.loadView('Add OpenShift Cluster');
104-
await webViewPanel.webview.postMessage({data: {param:'crc'}});
103+
await ClusterViewLoader.loadView('Add OpenShift Cluster', 'crc');
105104
}
106105

107106
@vsCommand('cloud.redhat.login', false)
@@ -124,7 +123,6 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
124123
{
125124
return vscode.commands.executeCommand('vscode.open', sandboxStatus.consoleURL);
126125
}
127-
128126
}
129127

130128
private static async getSandboxSignupStatus() : Promise<SBSignupResponse | undefined> {

src/webview/@types/windows/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface VscodeAPI {
1313

1414
interface Window {
1515
cmdText?: string;
16+
startingPage?: string;
1617
vscodeApi: VscodeAPI;
1718
acquireVsCodeApi: () => VscodeAPI;
1819
}

src/webview/cluster/app/cluster.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default function Header() {
5555
const [showWizard, setShowWizard] = React.useState('');
5656
const [crcLatest, setCrcLatest] = React.useState('');
5757
const [crcOpenShift, setCrcOpenShift] = React.useState('');
58+
const [showWizard, setShowWizard] = React.useState(window.startingPage);
5859

5960
window.onmessage = (event: any) => {
6061
if (['crc', 'sandbox'].includes(event.data.param)) {

src/webview/cluster/app/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<html lang="en">
33
<head>
44
<base href="%BASE_URL%" />
5+
<script>
6+
window.startingPage = '%STARTING_PAGE%';
7+
</script>
58
<meta charset="UTF-8" />
69
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
710
<title>Config View</title>

src/webview/cluster/clusterViewLoader.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export default class ClusterViewLoader {
322322
}
323323

324324
// eslint-disable-next-line @typescript-eslint/require-await
325-
static async loadView(title: string): Promise<vscode.WebviewPanel> {
325+
static async loadView(title: string, initialPage: 'crc' | 'sandbox' | '' = ''): Promise<vscode.WebviewPanel> {
326326
const localResourceRoot = vscode.Uri.file(path.join(ClusterViewLoader.extensionPath, 'out', 'clusterViewer'));
327327
if (panel) {
328328
// If we already have a panel, show it in the target column
@@ -372,5 +372,4 @@ export default class ClusterViewLoader {
372372
}
373373
}
374374
}
375-
376375
}

0 commit comments

Comments
 (0)