Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
deadlock-desktop
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-desktop
Commits
6a7dc8ed
Commit
6a7dc8ed
authored
3 years ago
by
Christian ZHENG
Browse files
Options
Downloads
Patches
Plain Diff
feat(login): add persistence
parent
cb1c0c6a
No related branches found
No related tags found
2 merge requests
!14
feat: added mounted, .bashrc, .zshrc, added tests, added keycloak tests
,
!8
feat(extension): login, open in devcontainer, automaticly save code, open briefing, publish extension
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
deadlock-plugins/deadlock-extension/src/core/extensionStore.ts
+46
-8
46 additions, 8 deletions
...ock-plugins/deadlock-extension/src/core/extensionStore.ts
with
46 additions
and
8 deletions
deadlock-plugins/deadlock-extension/src/core/extensionStore.ts
+
46
−
8
View file @
6a7dc8ed
import
{
Memento
,
ExtensionContext
}
from
'
vscode
'
;
import
{
ExtensionContext
,
Memento
,
SecretStorage
,
window
}
from
'
vscode
'
;
import
{
log
}
from
'
../recorder/utils
'
;
export
type
GlobalStorageType
=
Memento
&
{
setKeysForSync
(
keys
:
readonly
string
[]):
void
};
...
...
@@ -6,9 +7,11 @@ export default class ExtensionStore {
private
static
instance
:
ExtensionStore
;
private
globalStorage
:
GlobalStorageType
;
private
secretStorage
:
SecretStorage
;
private
constructor
(
globalStorage
:
GlobalStorageType
)
{
this
.
globalStorage
=
globalStorage
;
private
constructor
(
context
:
ExtensionContext
)
{
this
.
globalStorage
=
context
.
globalState
;
this
.
secretStorage
=
context
.
secrets
;
}
public
static
getInstance
():
ExtensionStore
{
...
...
@@ -24,18 +27,53 @@ export default class ExtensionStore {
return
ExtensionStore
.
instance
;
}
ExtensionStore
.
instance
=
new
ExtensionStore
(
context
.
globalState
);
ExtensionStore
.
instance
=
new
ExtensionStore
(
context
);
}
public
getMissionWorkdir
():
string
|
undefined
{
getMissionWorkdir
():
string
|
undefined
{
return
this
.
globalStorage
.
get
<
string
>
(
StoreKey
.
MissionWorkDirKey
);
}
public
setMissionWorkdir
(
path
:
string
):
Thenable
<
void
>
{
return
this
.
globalStorage
.
update
(
StoreKey
.
MissionWorkDirKey
,
path
);
setMissionWorkdir
(
path
:
string
)
{
this
.
globalStorage
.
update
(
StoreKey
.
MissionWorkDirKey
,
path
);
window
.
showInformationMessage
(
`Nouveau dossier de stockage des missions:
${
path
}
`
);
}
public
async
getAccessToken
()
{
return
this
.
_readSecret
(
StoreKey
.
AccessTokenKey
);
}
public
async
getRefreshToken
()
{
return
this
.
_readSecret
(
StoreKey
.
RefreshTokenKey
);
}
public
async
setAccessToken
(
accessToken
:
string
)
{
if
(
!
accessToken
)
{
log
(
'
Attempt to store undefined access token
'
);
return
;
}
return
this
.
_storeSecret
(
StoreKey
.
AccessTokenKey
,
accessToken
);
}
public
async
setRefreshToken
(
refreshToken
:
string
)
{
if
(
!
refreshToken
)
{
log
(
'
Attempt to store undefined refresh token
'
);
return
;
}
return
this
.
_storeSecret
(
StoreKey
.
RefreshTokenKey
,
refreshToken
);
}
private
async
_storeSecret
(
key
:
StoreKey
,
value
:
string
)
{
this
.
secretStorage
.
store
(
key
,
value
);
}
private
async
_readSecret
(
key
:
StoreKey
)
{
return
this
.
secretStorage
.
get
(
key
);
}
}
enum
StoreKey
{
MissionWorkDirKey
=
'
mission-workdir-key
'
,
MissionWorkDirKey
=
'
mission-wordir-key
'
,
AccessTokenKey
=
'
access-token-key
'
,
RefreshTokenKey
=
'
refresh-token-key
'
,
}
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