Skip to content

Commit 23a2fe7

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

File tree

7 files changed

+56
-50
lines changed

7 files changed

+56
-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: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ClusterViewLoader from '../webview/cluster/clusterViewLoader';
1010

1111
const sandboxAPI = createSandboxAPI();
1212

13-
class RedHatCloudItem extends vscode.TreeItem{
13+
class RedHatCloudItem extends vscode.TreeItem {
1414

1515
}
1616

@@ -23,7 +23,7 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
2323
}
2424

2525
getChildren(element?: RedHatCloudItem): vscode.ProviderResult<RedHatCloudItem[]> {
26-
if(!element){
26+
if (!element) {
2727
return this.getTopLevelItems();
2828
}
2929
return [];
@@ -39,23 +39,17 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
3939

4040
private async getTopLevelItems(): Promise<RedHatCloudItem[]> {
4141
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];
42+
if (sessionCheck) {
43+
const sandboxItem = await this.buildDevSandboxItem();
44+
const openshiftLocalItem = this.buildOpenshiftLocalItem();
45+
return [sandboxItem, openshiftLocalItem];
5246
}
5347
const loginItem = new RedHatCloudItem('Sign in to Red Hat');
5448
loginItem.iconPath = new vscode.ThemeIcon('account');
5549
loginItem.tooltip = 'Sign in to Red Hat';
5650
loginItem.command = {
57-
command: 'cloud.redhat.login',
58-
title: 'Sign in to Red Hat',
51+
command: 'cloud.redhat.login',
52+
title: 'Sign in to Red Hat',
5953
}
6054

6155
const signUpItem = new RedHatCloudItem('Create Red Hat Account');
@@ -67,31 +61,45 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
6761
tooltip: 'Create Red Hat Account'
6862
}
6963
return [loginItem, signUpItem];
70-
7164
}
7265

73-
private async buildSandboxItem() {
74-
const signupStatus = await RedHatTreeDataProvier.getSandboxSignupStatus()
66+
private async buildDevSandboxItem() {
67+
const signupStatus = await RedHatTreeDataProvier.getSandboxSignupStatus();
7568
const sandboxItem = new RedHatCloudItem('Developer Sandbox');
76-
sandboxItem.tooltip = 'Developer Sandbox'
77-
69+
sandboxItem.tooltip = 'Get 30-days free access to a shared OpenShift and Kubernetes cluster.';
70+
sandboxItem.iconPath = new vscode.ThemeIcon('vm');
7871
if (!signupStatus) {
7972
sandboxItem.contextValue = 'openshift.sandbox.status.none';
8073
}
8174
else if (signupStatus.status.ready) {
8275
sandboxItem.contextValue = 'openshift.sandbox.status.ready';
8376
}
77+
sandboxItem.command = {
78+
command: 'openshift.sandbox.open.setup',
79+
title: 'Set up Developer Sandbox',
80+
}
8481
return sandboxItem;
8582
}
8683

84+
private buildOpenshiftLocalItem() {
85+
const openshiftLocalItem = new RedHatCloudItem('Openshift Local');
86+
openshiftLocalItem.tooltip = 'Provision OpenShift 4 cluster to your local computer.';
87+
openshiftLocalItem.iconPath = new vscode.ThemeIcon('symbol-folder');
88+
openshiftLocalItem.command = {
89+
command: 'openshift.local.open.setup',
90+
title: 'Install OpenShift Local',
91+
}
92+
return openshiftLocalItem;
93+
}
94+
8795
@vsCommand('openshift.sandbox.signup')
88-
static async signupForSandbox() : Promise<string> {
96+
static async signupForSandbox(): Promise<string> {
8997
const authSession = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: false });
90-
if(authSession){
98+
if (authSession) {
9199
// eslint-disable-next-line dot-notation
92100
const signupResponse = await sandboxAPI.signUp(authSession['idToken'] as string);
93-
if( !signupResponse ){
94-
return 'Sign up request for OpenShift Sandbox failed, please try again.'
101+
if (!signupResponse) {
102+
return 'Sign up request for OpenShift Sandbox failed, please try again.';
95103
}
96104
await RedHatTreeDataProvier.refreshView();
97105

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

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

106121
@vsCommand('cloud.redhat.login', false)
107122
static async loginToRedHatCloud(): Promise<void> {
108-
const session = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: true });
109-
if(session ){
123+
const session = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: true });
124+
if (session) {
110125
await RedHatTreeDataProvier.refreshView();
111126
}
112127
}
@@ -119,36 +134,33 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
119134
@vsCommand('openshift.sandbox.open.dashboard', false)
120135
static async openDashboard(): Promise<void> {
121136
const sandboxStatus = await RedHatTreeDataProvier.getSandboxSignupStatus();
122-
if(sandboxStatus)
123-
{
137+
if (sandboxStatus) {
124138
return vscode.commands.executeCommand('vscode.open', sandboxStatus.consoleURL);
125139
}
126140
}
127141

128-
private static async getSandboxSignupStatus() : Promise<SBSignupResponse | undefined> {
142+
private static async getSandboxSignupStatus(): Promise<SBSignupResponse | undefined> {
129143
const authSession = await vscode.authentication.getSession('redhat-account-auth', ['openid'], { createIfNone: false });
130-
if(authSession) {
144+
if (authSession) {
131145
// eslint-disable-next-line dot-notation
132146
return await sandboxAPI.getSignUpStatus(authSession['idToken'] as string);
133147
}
134-
return undefined
148+
return undefined;
135149
}
136150
private static async refreshView() {
137151
const cloudExplorer = await k8s.extension.cloudExplorer.v1;
138152
if (cloudExplorer.available) {
139153
cloudExplorer.api.refresh();
140154
}
141155
}
142-
143156
}
144157

145158
class RedHatCloudProvider implements k8s.CloudExplorerV1.CloudProvider {
146159
getKubeconfigYaml(cluster: any): Promise<string> {
147160
throw new Error('Method not implemented.');
148161
}
149-
readonly cloudName = 'Red Hat OpenShift'
162+
readonly cloudName = 'Red Hat OpenShift';
150163
readonly treeDataProvider = new RedHatTreeDataProvier();
151-
152164
}
153165

154166
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)