Skip to content

Commit 877b961

Browse files
committed
Show detailed message when login to sandbox fails to parse clipboard
This PR fixes #2367. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 8a4d85d commit 877b961

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/openshift/cluster.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,15 @@ export class Cluster extends OpenShiftItem {
348348
}
349349

350350
@vsCommand('openshift.explorer.login.clipboard')
351-
static async loginUsingClipboardInfo(): Promise<string | null> {
351+
static async loginUsingClipboardInfo(dashboardUrl: string): Promise<string | null> {
352352
const clipboard = await Cluster.readFromClipboard();
353353
if(!Cluster.ocLoginCommandMatches(clipboard)) {
354-
throw new VsCommandError('Cannot parse login command in clipboard.')
354+
const choice = await window.showErrorMessage('Cannot parse login command in clipboard. Please open cluster dashboard and select `Copy login command` from user name dropdown in the upper right corner. Copy full login command to clipboard. Switch back to VSCode window and press `Login to Sandbox` button again.',
355+
'Open Dashboard');
356+
if (choice === 'Open Dashboard') {
357+
await commands.executeCommand('vscode.open', Uri.parse(dashboardUrl));
358+
}
359+
return;
355360
}
356361
const url = Cluster.clusterURL(clipboard);
357362
const token = Cluster.getToken(clipboard);

src/webview/cluster/app/sandboxView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,9 @@ export default function addSandboxView(props): JSX.Element {
358358
const Provisioned = () => {
359359

360360
const handleLoginButton = () => {
361-
postMessage('sandboxLoginUsingDataInClipboard');
361+
postMessage('sandboxLoginUsingDataInClipboard', {url: currentState.consoleDashboard});
362362
};
363+
363364
return (
364365
<>
365366
{( currentState.action === 'sandboxPageProvisioned' ) && (

src/webview/cluster/clusterViewLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async function clusterEditorMessageListener (event: any ): Promise<any> {
174174
case 'sandboxLoginUsingDataInClipboard':
175175
const telemetryEventLoginToSandbox = new ExtCommandTelemetryEvent('openshift.explorer.addCluster.sandboxLoginUsingDataInClipboard');
176176
try {
177-
const result = await Cluster.loginUsingClipboardInfo();
177+
const result = await Cluster.loginUsingClipboardInfo(event.payload.url);
178178
if (result) vscode.window.showInformationMessage(`${result}`);
179179
telemetryEventLoginToSandbox.send();
180180
} catch (err) {

0 commit comments

Comments
 (0)