Skip to content

Commit 1c2da6d

Browse files
committed
refactor: conditionally show coder getting started
This modifies the getting started patch changes to work with the new `--disable-getting-started-override`. The flag is false by default meaning the Coder getting started is shown. By passing the flag to code-server, it will not be shown.
1 parent a8ac88e commit 1c2da6d

File tree

1 file changed

+141
-10
lines changed

1 file changed

+141
-10
lines changed

patches/getting-started.diff

Lines changed: 141 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,41 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/welcomeGettingStarted/bro
22
===================================================================
33
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
44
+++ code-server/lib/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
5-
@@ -755,7 +755,13 @@ export class GettingStartedPage extends
5+
@@ -62,7 +62,7 @@ import { GettingStartedIndexList } from
6+
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
7+
import { KeyCode } from 'vs/base/common/keyCodes';
8+
import { getTelemetryLevel } from 'vs/platform/telemetry/common/telemetryUtils';
9+
-import { WorkbenchStateContext } from 'vs/workbench/common/contextkeys';
10+
+import { IsEnabledCoderGettingStarted, WorkbenchStateContext } from 'vs/workbench/common/contextkeys';
11+
import { OpenFolderViaWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
12+
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
13+
import { Toggle } from 'vs/base/browser/ui/toggle/toggle';
14+
@@ -753,11 +753,24 @@ export class GettingStartedPage extends
15+
onShowOnStartupChanged();
16+
}));
617

7-
const header = $('.header', {},
18+
- const header = $('.header', {},
19+
+ let header = $('.header', {},
820
$('h1.product-name.caption', {}, this.productService.nameLong),
9-
- $('p.subtitle.description', {}, localize({ key: 'gettingStarted.editingEvolved', comment: ['Shown as subtitle on the Welcome page.'] }, "Editing evolved"))
10-
+ $('p.subtitle.description.coder', {},
11-
+ "Using code-server on a team?",
12-
+ ),
13-
+ $('p.subtitle.description.coder-coder', {},
14-
+ "Check out: ",
15-
+ $('a', { href: "https://github.com/coder/coder" }, "coder/coder")
16-
+ ),
21+
$('p.subtitle.description', {}, localize({ key: 'gettingStarted.editingEvolved', comment: ['Shown as subtitle on the Welcome page.'] }, "Editing evolved"))
1722
);
1823

24+
+ if (this.contextService.contextMatchesRules(IsEnabledCoderGettingStarted)) {
25+
+ header = $('.header', {},
26+
+ $('h1.product-name.caption', {}, this.productService.nameLong),
27+
+ $('p.subtitle.description.coder', {},
28+
+ "Using code-server on a team?",
29+
+ ),
30+
+ $('p.subtitle.description.coder-coder', {},
31+
+ "Check out: ",
32+
+ $('a', { href: "https://github.com/coder/coder" }, "coder/coder")
33+
+ ),
34+
+ );
35+
+ }
36+
+
1937

38+
const leftColumn = $('.categories-column.categories-column-left', {},);
39+
const rightColumn = $('.categories-column.categories-column-right', {},);
2040
Index: code-server/lib/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/media/gettingStarted.css
2141
===================================================================
2242
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/media/gettingStarted.css
@@ -37,3 +57,114 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/welcomeGettingStarted/bro
3757
.monaco-workbench.hc-black .part.editor>.content .gettingStartedContainer .subtitle,
3858
.monaco-workbench.hc-light .part.editor>.content .gettingStartedContainer .subtitle {
3959
font-weight: 200;
60+
Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
61+
===================================================================
62+
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
63+
+++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
64+
@@ -276,6 +276,11 @@ export interface IWorkbenchConstructionO
65+
*/
66+
readonly isEnabledFileDownloads?: boolean
67+
68+
+ /**
69+
+ * Whether to use Coder's custom Getting Started text.
70+
+ */
71+
+ readonly isEnabledCoderGettingStarted?: boolean
72+
+
73+
//#endregion
74+
75+
76+
Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
77+
===================================================================
78+
--- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
79+
+++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
80+
@@ -36,6 +36,11 @@ export interface IBrowserWorkbenchEnviro
81+
* Enable downloading files via menu actions.
82+
*/
83+
readonly isEnabledFileDownloads?: boolean;
84+
+
85+
+ /**
86+
+ * Enable Coder's custom getting started text.
87+
+ */
88+
+ readonly isEnabledCoderGettingStarted?: boolean;
89+
}
90+
91+
export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvironmentService {
92+
@@ -74,6 +79,13 @@ export class BrowserWorkbenchEnvironment
93+
return this.options.isEnabledFileDownloads;
94+
}
95+
96+
+ get isEnabledCoderGettingStarted(): boolean {
97+
+ if (typeof this.options.isEnabledCoderGettingStarted === "undefined") {
98+
+ throw new Error('isEnabledCoderGettingStarted was not provided to the browser');
99+
+ }
100+
+ return this.options.isEnabledCoderGettingStarted;
101+
+ }
102+
+
103+
@memoize
104+
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
105+
106+
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
107+
===================================================================
108+
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
109+
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
110+
@@ -16,6 +16,7 @@ export const serverOptions: OptionDescri
111+
'auth': { type: 'string' },
112+
'disable-file-downloads': { type: 'boolean' },
113+
'locale': { type: 'string' },
114+
+ 'disable-getting-started-override': { type: 'boolean' },
115+
116+
/* ----- server setup ----- */
117+
118+
@@ -98,6 +99,7 @@ export interface ServerParsedArgs {
119+
'auth'?: string
120+
'disable-file-downloads'?: boolean;
121+
'locale'?: string
122+
+ 'disable-getting-started-override': { type: 'boolean' },
123+
124+
/* ----- server setup ----- */
125+
126+
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
127+
===================================================================
128+
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
129+
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
130+
@@ -308,6 +308,7 @@ export class WebClientServer {
131+
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
132+
userDataPath: this._environmentService.userDataPath,
133+
isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
134+
+ isEnabledCoderGettingStarted: !this._environmentService.args['disable-getting-started-override'],
135+
_wrapWebWorkerExtHostInIframe,
136+
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
137+
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
138+
Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts
139+
===================================================================
140+
--- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts
141+
+++ code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts
142+
@@ -7,7 +7,7 @@ import { Event } from 'vs/base/common/ev
143+
import { Disposable } from 'vs/base/common/lifecycle';
144+
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
145+
import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext } from 'vs/platform/contextkey/common/contextkeys';
146+
-import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, EditorTabsVisibleContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, IsEnabledFileDownloads } from 'vs/workbench/common/contextkeys';
147+
+import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, EditorTabsVisibleContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, IsEnabledFileDownloads, IsEnabledCoderGettingStarted } from 'vs/workbench/common/contextkeys';
148+
import { TEXT_DIFF_EDITOR_ID, EditorInputCapabilities, SIDE_BY_SIDE_EDITOR_ID, DEFAULT_EDITOR_ASSOCIATION } from 'vs/workbench/common/editor';
149+
import { trackFocus, addDisposableListener, EventType } from 'vs/base/browser/dom';
150+
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
151+
@@ -204,6 +204,7 @@ export class WorkbenchContextKeysHandler
152+
153+
// code-server
154+
IsEnabledFileDownloads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileDownloads ?? true)
155+
+ IsEnabledCoderGettingStarted.bindTo(this.contextKeyService).set(this.environmentService.isEnabledCoderGettingStarted ?? true)
156+
157+
this.registerListeners();
158+
}
159+
Index: code-server/lib/vscode/src/vs/workbench/common/contextkeys.ts
160+
===================================================================
161+
--- code-server.orig/lib/vscode/src/vs/workbench/common/contextkeys.ts
162+
+++ code-server/lib/vscode/src/vs/workbench/common/contextkeys.ts
163+
@@ -33,6 +33,7 @@ export const IsFullscreenContext = new R
164+
export const HasWebFileSystemAccess = new RawContextKey<boolean>('hasWebFileSystemAccess', false, true); // Support for FileSystemAccess web APIs (https://wicg.github.io/file-system-access)
165+
166+
export const IsEnabledFileDownloads = new RawContextKey<boolean>('isEnabledFileDownloads', true, true);
167+
+export const IsEnabledCoderGettingStarted = new RawContextKey<boolean>('isEnabledCoderGettingStarted', true, true);
168+
169+
//#endregion
170+

0 commit comments

Comments
 (0)