Skip to content

Commit c9c6da1

Browse files
committed
Rebase and clean up
Signed-off-by: Jessica He <jhe@redhat.com>
1 parent 686c96e commit c9c6da1

File tree

7 files changed

+57
-50
lines changed

7 files changed

+57
-50
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
"onView:openshiftProjectExplorer",
216216
"onView:extension.vsKubernetesExplorer",
217217
"onView:openshiftComponentTypesView",
218-
"onView:kubernetes.cloudExplorer",
218+
"onView:kubernetes.cloudExplorer",
219219
"onCommand:openshift.welcome",
220220
"onCommand:openshift.getStarted",
221221
"onCommand:openshift.about",
@@ -800,12 +800,12 @@
800800
},
801801
{
802802
"command": "openshift.sandbox.open.dashboard",
803-
"title": "Open Console",
803+
"title": "Open Developer Console",
804804
"category": "OpenShift"
805805
},
806806
{
807807
"command": "openshift.sandbox.signup",
808-
"title": "Signup for Sandbox",
808+
"title": "Provision OpenShift Developer Sandbox",
809809
"category": "OpenShift"
810810
}
811811
],

src/cloud-provider/redhat-cloud-provider.ts renamed to src/cloudProvider/redhatCloudProvider.ts

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import * as vscode from 'vscode';
77
import { vsCommand } from '../vscommand';
88
import { createSandboxAPI, SBSignupResponse } from '../openshift/sandbox';
99
import ClusterViewLoader from '../webview/cluster/clusterViewLoader';
10+
import path = require('path');
1011

1112
const sandboxAPI = createSandboxAPI();
1213

13-
class RedHatCloudItem extends vscode.TreeItem{
14+
class RedHatCloudItem extends vscode.TreeItem {
1415

1516
}
1617

@@ -23,7 +24,7 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
2324
}
2425

2526
getChildren(element?: RedHatCloudItem): vscode.ProviderResult<RedHatCloudItem[]> {
26-
if(!element){
27+
if (!element) {
2728
return this.getTopLevelItems();
2829
}
2930
return [];
@@ -39,23 +40,17 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
3940

4041
private async getTopLevelItems(): Promise<RedHatCloudItem[]> {
4142
const sessionCheck = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: false });
42-
if(sessionCheck) {
43-
const sandboxItem = await this.buildSandboxItem();
44-
sandboxItem.iconPath
45-
const openshiftLocal = new RedHatCloudItem('OpenShift Local');
46-
openshiftLocal.tooltip = 'OpenShift Local'
47-
openshiftLocal.command = {
48-
command:'openshift.local.open.setup',
49-
title: 'Install OpenShift Local',
50-
}
51-
return [sandboxItem,openshiftLocal];
43+
if (sessionCheck) {
44+
const sandboxItem = await this.buildDevSandboxItem();
45+
const openshiftLocalItem = this.buildOpenshiftLocalItem();
46+
return [sandboxItem, openshiftLocalItem];
5247
}
5348
const loginItem = new RedHatCloudItem('Sign in to Red Hat');
5449
loginItem.iconPath = new vscode.ThemeIcon('account');
5550
loginItem.tooltip = 'Sign in to Red Hat';
5651
loginItem.command = {
57-
command: 'cloud.redhat.login',
58-
title: 'Sign in to Red Hat',
52+
command: 'cloud.redhat.login',
53+
title: 'Sign in to Red Hat',
5954
}
6055

6156
const signUpItem = new RedHatCloudItem('Create Red Hat Account');
@@ -67,31 +62,45 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
6762
tooltip: 'Create Red Hat Account'
6863
}
6964
return [loginItem, signUpItem];
70-
7165
}
7266

73-
private async buildSandboxItem() {
74-
const signupStatus = await RedHatTreeDataProvier.getSandboxSignupStatus()
67+
private async buildDevSandboxItem() {
68+
const signupStatus = await RedHatTreeDataProvier.getSandboxSignupStatus();
7569
const sandboxItem = new RedHatCloudItem('Developer Sandbox');
76-
sandboxItem.tooltip = 'Developer Sandbox'
77-
70+
sandboxItem.tooltip = 'Get 30-days free access to a shared OpenShift and Kubernetes cluster.';
71+
sandboxItem.iconPath = vscode.Uri.file(path.join(__dirname, '..', '..', '..', 'images', 'title', 'logo.svg'));
7872
if (!signupStatus) {
7973
sandboxItem.contextValue = 'openshift.sandbox.status.none';
8074
}
8175
else if (signupStatus.status.ready) {
8276
sandboxItem.contextValue = 'openshift.sandbox.status.ready';
8377
}
78+
sandboxItem.command = {
79+
command: 'openshift.sandbox.open.setup',
80+
title: 'Set up Developer Sandbox',
81+
}
8482
return sandboxItem;
8583
}
8684

85+
private buildOpenshiftLocalItem() {
86+
const openshiftLocalItem = new RedHatCloudItem('Openshift Local');
87+
openshiftLocalItem.tooltip = 'Provision OpenShift 4 cluster to your local computer.';
88+
openshiftLocalItem.iconPath = new vscode.ThemeIcon('vm');
89+
openshiftLocalItem.command = {
90+
command: 'openshift.local.open.setup',
91+
title: 'Install OpenShift Local',
92+
}
93+
return openshiftLocalItem;
94+
}
95+
8796
@vsCommand('openshift.sandbox.signup')
88-
static async signupForSandbox() : Promise<string> {
97+
static async signupForSandbox(): Promise<string> {
8998
const authSession = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: false });
90-
if(authSession){
99+
if (authSession) {
91100
// eslint-disable-next-line dot-notation
92101
const signupResponse = await sandboxAPI.signUp(authSession['idToken'] as string);
93-
if( !signupResponse ){
94-
return 'Sign up request for OpenShift Sandbox failed, please try again.'
102+
if (!signupResponse) {
103+
return 'Sign up request for OpenShift Sandbox failed, please try again.';
95104
}
96105
await RedHatTreeDataProvier.refreshView();
97106

@@ -100,13 +109,20 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
100109

101110
@vsCommand('openshift.local.open.setup')
102111
static async openCrCWizard(): Promise<void> {
103-
await ClusterViewLoader.loadView('Add OpenShift Cluster', 'crc');
112+
const webViewPanel: vscode.WebviewPanel = await ClusterViewLoader.loadView('Add OpenShift Cluster');
113+
await webViewPanel.webview.postMessage({ action: 'openCluster', param: 'crc' });
114+
}
115+
116+
@vsCommand('openshift.sandbox.open.setup')
117+
static async openSandboxWizard(): Promise<void> {
118+
const webViewPanel: vscode.WebviewPanel = await ClusterViewLoader.loadView('Add OpenShift Cluster');
119+
await webViewPanel.webview.postMessage({ action: 'openCluster', param: 'sandbox' });
104120
}
105121

106122
@vsCommand('cloud.redhat.login', false)
107123
static async loginToRedHatCloud(): Promise<void> {
108-
const session = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: true });
109-
if(session ){
124+
const session = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: true });
125+
if (session) {
110126
await RedHatTreeDataProvier.refreshView();
111127
}
112128
}
@@ -119,36 +135,33 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
119135
@vsCommand('openshift.sandbox.open.dashboard', false)
120136
static async openDashboard(): Promise<void> {
121137
const sandboxStatus = await RedHatTreeDataProvier.getSandboxSignupStatus();
122-
if(sandboxStatus)
123-
{
138+
if (sandboxStatus) {
124139
return vscode.commands.executeCommand('vscode.open', sandboxStatus.consoleURL);
125140
}
126141
}
127142

128-
private static async getSandboxSignupStatus() : Promise<SBSignupResponse | undefined> {
143+
private static async getSandboxSignupStatus(): Promise<SBSignupResponse | undefined> {
129144
const authSession = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: false });
130-
if(authSession) {
145+
if (authSession) {
131146
// eslint-disable-next-line dot-notation
132147
return await sandboxAPI.getSignUpStatus(authSession['idToken'] as string);
133148
}
134-
return undefined
149+
return undefined;
135150
}
136151
private static async refreshView() {
137152
const cloudExplorer = await k8s.extension.cloudExplorer.v1;
138153
if (cloudExplorer.available) {
139154
cloudExplorer.api.refresh();
140155
}
141156
}
142-
143157
}
144158

145159
class RedHatCloudProvider implements k8s.CloudExplorerV1.CloudProvider {
146160
getKubeconfigYaml(cluster: any): Promise<string> {
147161
throw new Error('Method not implemented.');
148162
}
149-
readonly cloudName = 'Red Hat OpenShift'
163+
readonly cloudName = 'Red Hat OpenShift';
150164
readonly treeDataProvider = new RedHatTreeDataProvier();
151-
152165
}
153166

154167
export const REDHAT_CLOUD_PROVIDER = new RedHatCloudProvider();

src/extension.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
workspace
1717
} from 'vscode';
1818
import * as k8s from 'vscode-kubernetes-tools-api';
19-
import { REDHAT_CLOUD_PROVIDER } from './cloud-provider/redhat-cloud-provider';
19+
import { REDHAT_CLOUD_PROVIDER } from './cloudProvider/redhatCloudProvider';
2020
import { ComponentsTreeDataProvider } from './componentsView';
2121
import { DebugSessionsView } from './debug';
2222
import { OpenShiftExplorer } from './explorer';
@@ -58,12 +58,11 @@ async function verifyBundledBinaries(): Promise<{ odoPath: string, ocPath: strin
5858
};
5959
}
6060

61-
async function registerCloudProvider(): Promise<void> {
62-
const cloudProvider = await k8s.extension.cloudExplorer.v1
61+
async function registerKubernetesCloudProvider(): Promise<void> {
62+
const cloudProvider = await k8s.extension.cloudExplorer.v1;
6363
if (cloudProvider.available) {
64-
cloudProvider.api.registerCloudProvider(REDHAT_CLOUD_PROVIDER)
64+
cloudProvider.api.registerCloudProvider(REDHAT_CLOUD_PROVIDER);
6565
}
66-
6766
}
6867

6968
export async function activate(extensionContext: ExtensionContext): Promise<unknown> {
@@ -201,7 +200,7 @@ export async function activate(extensionContext: ExtensionContext): Promise<unkn
201200

202201
await ComponentTypesView.instance.getAllComponents();
203202

204-
await registerCloudProvider();
203+
await registerKubernetesCloudProvider();
205204

206205
startTelemetry(extensionContext);
207206
await verifyBinariesInRemoteContainer();

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

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

1414
interface Window {
1515
cmdText?: string;
16-
startingPage?: string;
1716
vscodeApi: VscodeAPI;
1817
acquireVsCodeApi: () => VscodeAPI;
19-
}
18+
}

src/webview/cluster/app/cluster.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ 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);
5958

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

src/webview/cluster/app/index.html

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

src/webview/cluster/clusterViewLoader.ts

Lines changed: 1 addition & 1 deletion
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, initialPage: 'crc' | 'sandbox' | '' = ''): Promise<vscode.WebviewPanel> {
325+
static async loadView(title: string): 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

0 commit comments

Comments
 (0)