Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
deadlock-theia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
deadlock-public
deadlock-theia
Commits
b2c8b380
Commit
b2c8b380
authored
Apr 13, 2022
by
Christian ZHENG
Browse files
Options
Downloads
Patches
Plain Diff
refactor(storage): move code & fix minor bugs
parent
65da8502
No related branches found
No related tags found
2 merge requests
!16
feat: publish extension on marketplace with ci
,
!15
feat(Sprint1): add authentication + directory picking + redirection link
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
deadlock-plugins/deadlock-extension/src/core/commandHandler.ts
+8
-25
8 additions, 25 deletions
...ock-plugins/deadlock-extension/src/core/commandHandler.ts
deadlock-plugins/deadlock-extension/src/core/controller.ts
+24
-6
24 additions, 6 deletions
deadlock-plugins/deadlock-extension/src/core/controller.ts
with
32 additions
and
31 deletions
deadlock-plugins/deadlock-extension/src/core/commandHandler.ts
+
8
−
25
View file @
b2c8b380
import
{
commands
,
Uri
,
window
}
from
'
vscode
'
;
import
{
commands
}
from
'
vscode
'
;
import
{
Command
}
from
'
../theia/command
'
;
import
Controller
from
'
./controller
'
;
import
ExtensionStore
from
'
./extensionStore
'
;
export
class
CommandHandler
{
private
extensionStore
:
ExtensionStore
;
constructor
(
private
parent
:
Controller
)
{
constructor
(
private
controller
:
Controller
)
{
this
.
extensionStore
=
ExtensionStore
.
getInstance
();
this
.
initCommandHandler
();
}
initCommandHandler
()
{
commands
.
registerCommand
(
CHOOSE_MISSION_WORKDIR_COMMAND
.
cmd
,
this
.
chooseMissionWorkdir
.
bind
(
this
));
commands
.
registerCommand
(
AUTHENTICATE_COMMAND
.
cmd
,
this
.
parent
.
authenticate
.
bind
(
this
.
parent
));
commands
.
registerCommand
(
CLEAR_COMMAND
.
cmd
,
this
.
parent
.
clear
.
bind
(
this
.
parent
));
}
async
chooseMissionWorkdir
()
{
const
actualMissionWorkDir
=
this
.
extensionStore
.
getMissionWorkdir
();
const
folderUri
=
await
window
.
showOpenDialog
({
defaultUri
:
actualMissionWorkDir
?
Uri
.
file
(
actualMissionWorkDir
)
:
undefined
,
canSelectFolders
:
true
,
canSelectFiles
:
false
,
title
:
'
Choisis le dossier qui contiendra tes missions
'
,
});
if
(
!
folderUri
)
{
if
(
this
.
extensionStore
.
getMissionWorkdir
())
{
return
;
}
this
.
chooseMissionWorkdir
();
}
else
{
this
.
extensionStore
.
setMissionWorkdir
(
folderUri
[
0
].
path
);
}
commands
.
registerCommand
(
CHOOSE_MISSION_WORKDIR_COMMAND
.
cmd
,
this
.
controller
.
chooseMissionWorkdir
.
bind
(
this
.
controller
),
);
commands
.
registerCommand
(
AUTHENTICATE_COMMAND
.
cmd
,
this
.
controller
.
authenticate
.
bind
(
this
.
controller
));
commands
.
registerCommand
(
CLEAR_COMMAND
.
cmd
,
this
.
controller
.
clear
.
bind
(
this
.
controller
));
}
}
...
...
This diff is collapsed.
Click to expand it.
deadlock-plugins/deadlock-extension/src/core/controller.ts
+
24
−
6
View file @
b2c8b380
...
...
@@ -12,6 +12,7 @@ export default class Controller {
private
commandHandler
:
CommandHandler
;
private
briefingView
:
BriefingView
;
private
gettingStartedView
:
GettingStartedView
;
private
extensionStore
:
ExtensionStore
;
constructor
(
private
context
:
vscode
.
ExtensionContext
)
{
this
.
briefingView
=
new
BriefingView
();
this
.
gettingStartedView
=
new
GettingStartedView
(
context
.
extensionUri
);
...
...
@@ -21,6 +22,7 @@ export default class Controller {
KEYCLOAK_TOKEN_CREATE_URL
,
KEYCLOAK_USER_INFO_URL
,
);
this
.
extensionStore
=
ExtensionStore
.
getInstance
();
this
.
init
();
}
...
...
@@ -45,7 +47,25 @@ export default class Controller {
const
exensionStorage
=
ExtensionStore
.
getInstance
();
this
.
gettingStartedView
.
isAlreadyConnected
=
!!
(
await
exensionStorage
.
getAccessToken
());
}
async
chooseMissionWorkdir
()
{
const
actualMissionWorkDir
=
this
.
extensionStore
.
getMissionWorkdir
();
const
folderUri
=
await
vscode
.
window
.
showOpenDialog
({
defaultUri
:
actualMissionWorkDir
?
vscode
.
Uri
.
file
(
actualMissionWorkDir
)
:
undefined
,
canSelectFolders
:
true
,
canSelectFiles
:
false
,
title
:
'
Choisis le dossier qui contiendra tes missions
'
,
});
if
(
!
folderUri
)
{
if
(
this
.
extensionStore
.
getMissionWorkdir
())
{
return
;
}
this
.
chooseMissionWorkdir
();
}
else
{
this
.
extensionStore
.
setMissionWorkdir
(
folderUri
[
0
].
path
);
}
}
public
async
clear
()
{
const
exensionStorage
=
ExtensionStore
.
getInstance
();
await
exensionStorage
.
clear
();
...
...
@@ -57,9 +77,8 @@ export default class Controller {
// The answer might be 'yes' because when the student is already authenticated, the log in button should be disabled.
await
this
.
connection
.
registerDevice
();
const
tokens
=
await
this
.
connection
.
getToken
({
openLink
:
Controller
.
openBrowserWithUrl
});
const
exensionStorage
=
ExtensionStore
.
getInstance
();
await
exensionStorage
.
setAccessToken
(
tokens
.
accessToken
);
await
exensionStorage
.
setRefreshToken
(
tokens
.
refreshToken
);
await
this
.
extensionStore
.
setAccessToken
(
tokens
.
accessToken
);
await
this
.
extensionStore
.
setRefreshToken
(
tokens
.
refreshToken
);
this
.
gettingStartedView
.
isAlreadyConnected
=
true
;
}
public
static
openBrowserWithUrl
(
url
:
string
)
{
...
...
@@ -69,13 +88,12 @@ export default class Controller {
public
async
launchMission
(
missionId
:
string
|
null
)
{
if
(
missionId
)
{
vscode
.
window
.
showInformationMessage
(
`vous lancez la mission
${
missionId
}
`
);
const
extensionStore
=
ExtensionStore
.
getInstance
();
const
hadMissionWorkdir
=
extensionStore
.
getMissionWorkdir
()
!==
undefined
;
const
hadMissionWorkdir
=
this
.
extensionStore
.
getMissionWorkdir
()
!==
undefined
;
if
(
!
hadMissionWorkdir
)
{
await
vscode
.
commands
.
executeCommand
(
CHOOSE_MISSION_WORKDIR_COMMAND
.
cmd
);
}
const
hadBeenConnected
=
(
await
extensionStore
.
getAccessToken
())
!==
undefined
;
const
hadBeenConnected
=
(
await
this
.
extensionStore
.
getAccessToken
())
!==
undefined
;
if
(
!
hadBeenConnected
)
{
this
.
authenticate
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment