Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70eb79b

Browse files
authored
Add default URL and autologin settings (#380)
1 parent733fbbf commit70eb79b

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
##Unreleased
44

5+
###Added
6+
7+
- Default URL setting that takes precedence over CODER_URL.
8+
- Autologin setting that automatically initiates login when the extension
9+
activates using either the default URL or CODER_URL.
10+
511
##[v1.3.5](https://github.com/coder/vscode-coder/releases/tag/v1.3.5) (2024-10-16)
612

713
###Fixed

‎package.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@
9797
"markdownDescription":"If not set, will inherit from the `no_proxy` or `NO_PROXY` environment variables. `http.proxySupport` must be set to `on` or `off`, otherwise VS Code will override the proxy agent set by the plugin.",
9898
"type":"string",
9999
"default":""
100+
},
101+
"coder.defaultUrl": {
102+
"markdownDescription":"This will be shown in the URL prompt, along with the CODER_URL environment variable if set, for the user to select when logging in.",
103+
"type":"string",
104+
"default":""
105+
},
106+
"coder.autologin": {
107+
"markdownDescription":"Automatically log into the default URL when the extension is activated. coder.defaultUrl is preferred, otherwise the CODER_URL environment variable will be used. This setting has no effect if neither is set.",
108+
"type":"boolean",
109+
"default":false
100110
}
101111
}
102112
},

‎src/commands.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ export class Commands {
7878
* CODER_URL or enter a new one. Undefined means the user aborted.
7979
*/
8080
privateasyncaskURL(selection?:string):Promise<string|undefined>{
81+
constdefaultURL=vscode.workspace.getConfiguration().get<string>("coder.defaultUrl")??""
8182
constquickPick=vscode.window.createQuickPick()
82-
quickPick.value=selection||process.env.CODER_URL||""
83+
quickPick.value=selection||defaultURL||process.env.CODER_URL||""
8384
quickPick.placeholder="https://example.coder.com"
8485
quickPick.title="Enter the URL of your Coder deployment."
8586

8687
// Initial items.
87-
quickPick.items=this.storage.withUrlHistory(process.env.CODER_URL).map((url)=>({
88+
quickPick.items=this.storage.withUrlHistory(defaultURL,process.env.CODER_URL).map((url)=>({
8889
alwaysShow:true,
8990
label:url,
9091
}))
@@ -93,7 +94,7 @@ export class Commands {
9394
// an option in case the user wants to connect to something that is not in
9495
// the list.
9596
quickPick.onDidChangeValue((value)=>{
96-
quickPick.items=this.storage.withUrlHistory(process.env.CODER_URL,value).map((url)=>({
97+
quickPick.items=this.storage.withUrlHistory(defaultURL,process.env.CODER_URL,value).map((url)=>({
9798
alwaysShow:true,
9899
label:url,
99100
}))
@@ -111,8 +112,8 @@ export class Commands {
111112

112113
/**
113114
* Ask the user for the URL if it was not provided, letting them choose from a
114-
* list of recent URLs or CODER_URL or enter a new one, and normalizes the
115-
* returned URL. Undefined means the user aborted.
115+
* list of recent URLs orthe default URL orCODER_URL or enter a new one, and
116+
*normalizes thereturned URL. Undefined means the user aborted.
116117
*/
117118
publicasyncmaybeAskUrl(providedUrl:string|undefined|null,lastUsedUrl?:string):Promise<string|undefined>{
118119
leturl=providedUrl||(awaitthis.askURL(lastUsedUrl))
@@ -134,7 +135,8 @@ export class Commands {
134135

135136
/**
136137
* Log into the provided deployment. If the deployment URL is not specified,
137-
* ask for it first with a menu showing recent URLs and CODER_URL, if set.
138+
* ask for it first with a menu showing recent URLs along with the default URL
139+
* and CODER_URL, if those are set.
138140
*/
139141
publicasynclogin(...args:string[]):Promise<void>{
140142
// Destructure would be nice but VS Code can pass undefined which errors.

‎src/extension.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,14 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
215215
}else{
216216
storage.writeToCoderOutputChannel("Not currently logged in")
217217
vscode.commands.executeCommand("setContext","coder.loaded",true)
218+
219+
// Handle autologin, if not already logged in.
220+
constcfg=vscode.workspace.getConfiguration()
221+
if(cfg.get("coder.autologin")===true){
222+
constdefaultUrl=cfg.get("coder.defaultUrl")||process.env.CODER_URL
223+
if(defaultUrl){
224+
vscode.commands.executeCommand("coder.login",defaultUrl)
225+
}
226+
}
218227
}
219228
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp