Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Clone Git projects with SSH URI (eclipse-che#995)
Browse files Browse the repository at this point in the history
* Improve the UX when cloning Git projects with SSH uri

Signed-off-by: Vitaliy Gulyy <[email protected]>
  • Loading branch information
vitaliy-guliy authored and monaka committed Mar 6, 2021
1 parent 2db51fc commit 6f6bf30
Show file tree
Hide file tree
Showing 10 changed files with 587 additions and 406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ export class CheGithubMainImpl implements CheGithubMain {
}

async $uploadPublicSshKey(publicKey: string): Promise<void> {
await this.fetchToken();
try {
await this.fetchToken();
await this.uploadKey(publicKey);
} catch (error) {
console.error(error.message);
throw error;
}
}

async uploadKey(publicKey: string): Promise<void> {
await this.axiosInstance.post(
'https://api.github.com/user/keys',
{
Expand Down Expand Up @@ -76,6 +85,7 @@ export class CheGithubMainImpl implements CheGithubMain {
await this.oAuthUtils.authenticate(oAuthProvider, ['repo', 'user', 'write:public_key']);
this.token = await this.oAuthUtils.getToken(oAuthProvider);
};

if (await this.oAuthUtils.isAuthenticated(oAuthProvider)) {
try {
// Validate the GitHub token.
Expand Down
46 changes: 46 additions & 0 deletions plugins/ssh-plugin/src/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**********************************************************************
* Copyright (c) 2019-2021 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
***********************************************************************/

import * as theia from '@theia/plugin';

export const SSH_GENERATE_FOR_HOST: theia.CommandDescription = {
id: 'ssh:generate_for_host',
label: 'SSH: Generate Key For Particular Host...',
};

export const SSH_GENERATE: theia.CommandDescription = {
id: 'ssh:generate',
label: 'SSH: Generate Key...',
};

export const SSH_CREATE: theia.CommandDescription = {
id: 'ssh:create',
label: 'SSH: Create Key...',
};

export const SSH_DELETE: theia.CommandDescription = {
id: 'ssh:delete',
label: 'SSH: Delete Key...',
};

export const SSH_VIEW: theia.CommandDescription = {
id: 'ssh:view',
label: 'SSH: View Public Key...',
};

export const SSH_UPLOAD: theia.CommandDescription = {
id: 'ssh:upload',
label: 'SSH: Upload Private Key...',
};

export const SSH_ADD_TO_GITHUB: theia.CommandDescription = {
id: 'ssh:add_key_to_github',
label: 'SSH: Add Existing Key To GitHub...',
};
121 changes: 0 additions & 121 deletions plugins/ssh-plugin/src/node/ssh-key-manager.ts

This file was deleted.

Loading

0 comments on commit 6f6bf30

Please sign in to comment.