Skip to content
Snippets Groups Projects
Commit 1cfd4bac authored by Lansana DIOMANDE's avatar Lansana DIOMANDE
Browse files

refactor: connect uri handler with choose mission workir and connection

parent eeb6aca3
No related branches found
No related tags found
2 merge requests!14feat: added mounted, .bashrc, .zshrc, added tests, added keycloak tests,!8feat(extension): login, open in devcontainer, automaticly save code, open briefing, publish extension
Deadlock Theia projet basé sur notre propre image de Theia https://git.e-biz.fr/deadlock-public/theia.
Plusieurs éléments ajoutés à l'image de base :
......
import { link } from 'fs';
import { url } from 'inspector';
import * as vscode from 'vscode';
import { OPEN_GETTING_STARTED_COMMAND } from '../theia/command';
import { CHOOSE_MISSION_WORKDIR_COMMAND } from './commandHandler';
import ExtensionStore from './extensionStore';
import KeycloakOAuth2DeviceFlowConnection from './keycloakOAuth2DeviceFlowConnection';
export default class Controller {
static launchMission(missionId: string | null) {
private connection: KeycloakOAuth2DeviceFlowConnection;
constructor() {
this.connection = new KeycloakOAuth2DeviceFlowConnection(
'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/auth/device',
'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/token',
);
}
openBrowserWithUrl(url: string) {
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url));
}
async launchMission(missionId: string | null) {
if (missionId) {
vscode.window.showInformationMessage(`vous lancez la mission ${missionId}`);
const extensionStore = ExtensionStore.getInstance();
const hadMissionWorkdir = extensionStore.getMissionWorkdir() !== undefined;
if (!hadMissionWorkdir) {
await vscode.commands.executeCommand(CHOOSE_MISSION_WORKDIR_COMMAND.cmd);
}
const isConnected = (await extensionStore.getAccessToken()) !== undefined;
console.log('accesToke: ' + extensionStore.getAccessToken());
//TODO: Connection
if (!isConnected) {
const { accessToken, refreshToken } = await this.connection.getToken({ openLink: this.openBrowserWithUrl });
console.log('VOICI LES TOKENS');
console.log(accessToken, refreshToken);
}
vscode.commands.executeCommand(OPEN_GETTING_STARTED_COMMAND.cmd);
}
}
}
......@@ -28,8 +28,7 @@ export const userConfig = new UserConfigTheia();
export async function activate(context: vscode.ExtensionContext) {
vscode.window.showInformationMessage('Bienvenue sur Deadlock!');
ExtensionStore.createInstance(context);
new KeycloakOAuth2DeviceFlowConnectionTest().run();
const controller = new Controller();
vscode.window.registerUriHandler({
handleUri(uri: vscode.Uri) {
......@@ -38,7 +37,7 @@ export async function activate(context: vscode.ExtensionContext) {
switch (action) {
case 'open-challenge':
Controller.launchMission(queryParams.get('missionId'));
controller.launchMission(queryParams.get('missionId'));
break;
default:
......@@ -50,23 +49,16 @@ export async function activate(context: vscode.ExtensionContext) {
initViews(context.extensionUri);
initCommandHandlers();
await vscode.commands.executeCommand(OPEN_BRIEFING_COMMAND.cmd);
// @ts-ignore
const deadlockPanelProvider = new DepNodeProvider(vscode.workspace.rootPath);
vscode.window.registerTreeDataProvider('deadlockPanel', deadlockPanelProvider);
new keycloakOAuth2DeviceFlowConnectionTest().run();
try {
await userConfig.init();
vscode.commands.executeCommand('setContext', 'user.authenticated', false);
} catch (e) {
error('Cannot init userConfig');
}
await vscode.commands.executeCommand(OPEN_BRIEFING_COMMAND.cmd);
MetadataProvider.loadPathsToEnvVariables();
MetadataProvider.loadPathsToJson(`${SERVICES_PATHS_PATH}`);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment