Skip to content

Commit cc584f8

Browse files
authored
Merge pull request #2435 from cdr/issue-2328-customize-go-home
cli: add --home flag to customize "Go Home" button
2 parents f4ca413 + 71abff7 commit cc584f8

File tree

4 files changed

+69
-11
lines changed

4 files changed

+69
-11
lines changed

ci/dev/vscode.patch

+51-11
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,18 @@ index 0000000000000000000000000000000000000000..3fd94e050108d5c52ad8a104cb5e0484
494494
+../../../../../../src/node/proxy_agent.ts
495495
\ No newline at end of file
496496
diff --git a/src/vs/code/browser/workbench/workbench.ts b/src/vs/code/browser/workbench/workbench.ts
497-
index 0ef8b9dc81419b53b27cf111fb206d72ba56bada..e490cf7449623f96c780a65d538fad72cf9306e4 100644
497+
index 0ef8b9dc81419b53b27cf111fb206d72ba56bada..779971e2cc6e5394cdd4b079630238e80b352f33 100644
498498
--- a/src/vs/code/browser/workbench/workbench.ts
499499
+++ b/src/vs/code/browser/workbench/workbench.ts
500+
@@ -3,7 +3,7 @@
501+
* Licensed under the MIT License. See License.txt in the project root for license information.
502+
*--------------------------------------------------------------------------------------------*/
503+
504+
-import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, IHomeIndicator, IProductQualityChangeHandler, ISettingsSyncOptions } from 'vs/workbench/workbench.web.api';
505+
+import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, IProductQualityChangeHandler, ISettingsSyncOptions } from 'vs/workbench/workbench.web.api';
506+
import { URI, UriComponents } from 'vs/base/common/uri';
507+
import { Event, Emitter } from 'vs/base/common/event';
508+
import { generateUuid } from 'vs/base/common/uuid';
500509
@@ -17,6 +17,7 @@ import { isStandalone } from 'vs/base/browser/browser';
501510
import { localize } from 'vs/nls';
502511
import { Schemas } from 'vs/base/common/network';
@@ -592,6 +601,28 @@ index 0ef8b9dc81419b53b27cf111fb206d72ba56bada..e490cf7449623f96c780a65d538fad72
592601

593602
// If no workspace is provided through the URL, check for config attribute from server
594603
if (!foundWorkspace) {
604+
@@ -465,13 +454,6 @@ class WindowIndicator implements IWindowIndicator {
605+
// Workspace Provider
606+
const workspaceProvider = new WorkspaceProvider(workspace, payload);
607+
608+
- // Home Indicator
609+
- const homeIndicator: IHomeIndicator = {
610+
- href: 'https://github.com/microsoft/vscode',
611+
- icon: 'code',
612+
- title: localize('home', "Home")
613+
- };
614+
-
615+
// Window indicator (unless connected to a remote)
616+
let windowIndicator: WindowIndicator | undefined = undefined;
617+
if (!workspaceProvider.hasRemote()) {
618+
@@ -515,7 +497,6 @@ class WindowIndicator implements IWindowIndicator {
619+
create(document.body, {
620+
...config,
621+
settingsSyncOptions,
622+
- homeIndicator,
623+
windowIndicator,
624+
productQualityChangeHandler,
625+
workspaceProvider,
595626
diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts
596627
index 409bb7e1960c9c06485a6f6d7f39b2efce451d56..f27b651c49ea3fc92b03e31eb64c1cf27c7e4433 100644
597628
--- a/src/vs/platform/environment/common/argv.ts
@@ -1468,10 +1499,10 @@ index 0000000000000000000000000000000000000000..56331ff1fc32bbd82e769aaecb551e42
14681499
+require('../../bootstrap-amd').load('vs/server/entry');
14691500
diff --git a/src/vs/server/ipc.d.ts b/src/vs/server/ipc.d.ts
14701501
new file mode 100644
1471-
index 0000000000000000000000000000000000000000..c8a613ac2db1ff154a49aa7b6da5f7d2af902ec7
1502+
index 0000000000000000000000000000000000000000..bf45e75aaf0dc8953ee6fee97fe02149879d3d72
14721503
--- /dev/null
14731504
+++ b/src/vs/server/ipc.d.ts
1474-
@@ -0,0 +1,133 @@
1505+
@@ -0,0 +1,139 @@
14751506
+/**
14761507
+ * External interfaces for integration into code-server over IPC. No vs imports
14771508
+ * should be made in this file.
@@ -1544,6 +1575,7 @@ index 0000000000000000000000000000000000000000..c8a613ac2db1ff154a49aa7b6da5f7d2
15441575
+
15451576
+ log?: string;
15461577
+ verbose?: boolean;
1578+
+ home?: string;
15471579
+
15481580
+ _: string[];
15491581
+}
@@ -1587,6 +1619,11 @@ index 0000000000000000000000000000000000000000..c8a613ac2db1ff154a49aa7b6da5f7d2
15871619
+ ['enableProposedApi', string],
15881620
+ ];
15891621
+ };
1622+
+ readonly homeIndicator?: {
1623+
+ href: string,
1624+
+ icon: string,
1625+
+ title: string,
1626+
+ },
15901627
+ };
15911628
+ readonly remoteUserDataUri: UriComponents;
15921629
+ readonly productConfiguration: {
@@ -3293,10 +3330,10 @@ index 0000000000000000000000000000000000000000..57213f92828fafefcab0e3c401a1e8ed
32933330
+}
32943331
diff --git a/src/vs/server/node/server.ts b/src/vs/server/node/server.ts
32953332
new file mode 100644
3296-
index 0000000000000000000000000000000000000000..5521d51a92d1b1e3469e890bae41277b560d08a2
3333+
index 0000000000000000000000000000000000000000..0f4d31a961be1c055163b0cf29d550d7af5146e6
32973334
--- /dev/null
32983335
+++ b/src/vs/server/node/server.ts
3299-
@@ -0,0 +1,302 @@
3336+
@@ -0,0 +1,308 @@
33003337
+import { field } from '@coder/logger';
33013338
+import * as fs from 'fs';
33023339
+import * as net from 'net';
@@ -3357,6 +3394,7 @@ index 0000000000000000000000000000000000000000..5521d51a92d1b1e3469e890bae41277b
33573394
+import { REMOTE_TERMINAL_CHANNEL_NAME } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
33583395
+import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from 'vs/workbench/services/remote/common/remoteAgentFileSystemChannel';
33593396
+import { RemoteExtensionLogFileName } from 'vs/workbench/services/remote/common/remoteAgentService';
3397+
+import { localize } from 'vs/nls';
33603398
+
33613399
+export class Vscode {
33623400
+ public readonly _onDidClientConnect = new Emitter<ClientConnectionEvent>();
@@ -3405,6 +3443,11 @@ index 0000000000000000000000000000000000000000..5521d51a92d1b1e3469e890bae41277b
34053443
+ ['enableProposedApi', JSON.stringify(options.args['enable-proposed-api'] || [])]
34063444
+ ],
34073445
+ },
3446+
+ homeIndicator: {
3447+
+ href: options.args.home || 'https://github.com/cdr/code-server',
3448+
+ icon: 'code',
3449+
+ title: localize('home', "Home"),
3450+
+ },
34083451
+ },
34093452
+ remoteUserDataUri: transformer.transformOutgoing(URI.file(environment.userDataPath)),
34103453
+ productConfiguration: product,
@@ -3859,16 +3902,13 @@ index 021af6e0f8983c492f9cdd048ba2dcae7640bc1d..4474a93beba03365709c3cda98b68213
38593902
module = module.with({ path: ensureSuffix(module.path, '.js') });
38603903
const response = await fetch(module.toString(true));
38613904
diff --git a/src/vs/workbench/browser/actions/navigationActions.ts b/src/vs/workbench/browser/actions/navigationActions.ts
3862-
index 7344a3a29b32f7b370b99bf0cfdc79a322195ff8..dc21396e83e2f53914447d3460c2ee1103ecb28e 100644
3905+
index 7344a3a29b32f7b370b99bf0cfdc79a322195ff8..46c900da7610d9ca6ddff4556b5d93b8dd58588c 100644
38633906
--- a/src/vs/workbench/browser/actions/navigationActions.ts
38643907
+++ b/src/vs/workbench/browser/actions/navigationActions.ts
3865-
@@ -310,4 +310,8 @@ actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusNextPart,
3866-
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusPreviousPart, { primary: KeyMod.Shift | KeyCode.F6 }), 'View: Focus Previous Part', CATEGORIES.View.value);
3908+
@@ -311,3 +311,6 @@ actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(FocusPreviousP
38673909

38683910
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
3869-
-workbenchRegistry.registerWorkbenchContribution(GoHomeContributor, LifecyclePhase.Ready);
3870-
+// See https://github.com/cdr/code-server/issues/2328
3871-
+// workbenchRegistry.registerWorkbenchContribution(GoHomeContributor, LifecyclePhase.Ready);
3911+
workbenchRegistry.registerWorkbenchContribution(GoHomeContributor, LifecyclePhase.Ready);
38723912
+export const _1 = workbenchRegistry;
38733913
+export const _2 = GoHomeContributor;
38743914
+export const _3 = LifecyclePhase.Ready;

doc/FAQ.md

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- [Heartbeat File](#heartbeat-file)
2424
- [Healthz endpoint](#healthz-endpoint)
2525
- [How does the config file work?](#how-does-the-config-file-work)
26+
- [How do I customize the "Go Home" button?](#how-do-i-customize-the-go-home-button)
2627
- [Isn't an install script piped into sh insecure?](#isnt-an-install-script-piped-into-sh-insecure)
2728
- [How do I make my keyboard shortcuts work?](#how-do-i-make-my-keyboard-shortcuts-work)
2829
- [Differences compared to Theia?](#differences-compared-to-theia)
@@ -297,6 +298,16 @@ The `--config` flag or `$CODE_SERVER_CONFIG` can be used to change the config fi
297298

298299
The default location also respects `$XDG_CONFIG_HOME`.
299300

301+
## How do I customize the "Go Home" button?
302+
303+
You can pass a URL to the `--home` flag like this:
304+
305+
```
306+
code-server --home=https://my-website.com
307+
```
308+
309+
Or you can define it in the config file with `home`.
310+
300311
## Isn't an install script piped into sh insecure?
301312

302313
Please give

src/node/cli.ts

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface Args extends VsArgs {
5757
"new-window"?: boolean
5858

5959
link?: OptionalString
60+
home?: string
6061
}
6162

6263
interface Option<T> {
@@ -201,6 +202,10 @@ const options: Options<Required<Args>> = {
201202
`,
202203
beta: true,
203204
},
205+
home: {
206+
type: "string",
207+
description: "Set a custom link for the 'Go Home' button in the Application Menu",
208+
},
204209
}
205210

206211
export const optionDescriptions = (): string[] => {

test/cli.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe("parser", () => {
5555
"--log",
5656
"error",
5757
"--help",
58+
"--home=http://localhost:8080/",
5859
"--open",
5960
"--socket=mumble",
6061
"3",
@@ -85,6 +86,7 @@ describe("parser", () => {
8586
"extra-builtin-extensions-dir": [path.resolve("bazzle")],
8687
"extra-extensions-dir": [path.resolve("nozzle")],
8788
help: true,
89+
home: "http://localhost:8080/",
8890
host: "0.0.0.0",
8991
json: true,
9092
log: "error",

0 commit comments

Comments
 (0)