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

Appearance settings

Commit 9622830

Browse filesBrowse files
authored
Disable "Show Local" button, add --disable-file-uploads option and add file operation trace level logs (coder#6557)
1 parent 26a3437 commit 9622830
Copy full SHA for 9622830

8 files changed

+369-39Lines changed: 369 additions & 39 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patches/display-language.diff‎

Copy file name to clipboardExpand all lines: patches/display-language.diff
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
220220
import { CharCode } from 'vs/base/common/charCode';
221221
import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
222222
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
223-
@@ -344,6 +345,8 @@ export class WebClientServer {
223+
@@ -345,6 +346,8 @@ export class WebClientServer {
224224
callbackRoute: this._callbackRoute
225225
};
226226

@@ -229,7 +229,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
229229
const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
230230
const values: { [key: string]: string } = {
231231
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
232-
@@ -352,6 +355,7 @@ export class WebClientServer {
232+
@@ -353,6 +356,7 @@ export class WebClientServer {
233233
WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${!nlsBaseUrl.endsWith('/') ? '/' : ''}${this._productService.commit}/${this._productService.version}/` : ''),
234234
BASE: base,
235235
VS_BASE: vscodeBase,
@@ -241,22 +241,26 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
241241
===================================================================
242242
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
243243
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
244-
@@ -17,6 +17,7 @@ export const serverOptions: OptionDescri
244+
@@ -17,8 +17,9 @@ export const serverOptions: OptionDescri
245245
'disable-update-check': { type: 'boolean' },
246246
'auth': { type: 'string' },
247247
'disable-file-downloads': { type: 'boolean' },
248+
'disable-file-uploads': { type: 'boolean' },
248249
+ 'locale': { type: 'string' },
249250

250251
/* ----- server setup ----- */
251252

252-
@@ -99,6 +100,7 @@ export interface ServerParsedArgs {
253+
'host': { type: 'string', cat: 'o', args: 'ip-address', description: nls.localize('host', "The host name or IP address the server should listen to. If not set, defaults to 'localhost'.") },
254+
@@ -100,8 +100,9 @@ export interface ServerParsedArgs {
253255
'disable-update-check'?: boolean;
254256
'auth'?: string
255257
'disable-file-downloads'?: boolean;
258+
'disable-file-uploads'?: boolean;
256259
+ 'locale'?: string
257260

258261
/* ----- server setup ----- */
259262

263+
host?: string;
260264
Index: code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts
261265
===================================================================
262266
--- code-server.orig/lib/vscode/src/vs/workbench/workbench.web.main.ts
Collapse file
+198-14Lines changed: 198 additions & 14 deletions
Large diffs are not rendered by default.
Collapse file

‎patches/getting-started.diff‎

Copy file name to clipboardExpand all lines: patches/getting-started.diff
+23-13Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
135135
===================================================================
136136
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
137137
+++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
138-
@@ -286,6 +286,11 @@ export interface IWorkbenchConstructionO
138+
@@ -291,6 +291,11 @@ export interface IWorkbenchConstructionO
139139
*/
140-
readonly isEnabledFileDownloads?: boolean
140+
readonly isEnabledFileUploads?: boolean
141141

142142
+ /**
143143
+ * Whether to use Coder's custom Getting Started text.
@@ -151,8 +151,8 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
151151
===================================================================
152152
--- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
153153
+++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
154-
@@ -39,6 +39,11 @@ export interface IBrowserWorkbenchEnviro
155-
readonly isEnabledFileDownloads?: boolean;
154+
@@ -44,6 +44,11 @@ export interface IBrowserWorkbenchEnviro
155+
readonly isEnabledFileUploads?: boolean;
156156

157157
/**
158158
+ * Enable Coder's custom getting started text.
@@ -163,8 +163,8 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
163163
* Gets whether a resolver extension is expected for the environment.
164164
*/
165165
readonly expectsResolverExtension: boolean;
166-
@@ -123,6 +128,13 @@ export class BrowserWorkbenchEnvironment
167-
return this.options.isEnabledFileDownloads;
166+
@@ -135,6 +140,13 @@ export class BrowserWorkbenchEnvironment
167+
return this.options.isEnabledFileUploads;
168168
}
169169

170170
+ get isEnabledCoderGettingStarted(): boolean {
@@ -181,34 +181,40 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
181181
===================================================================
182182
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
183183
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
184-
@@ -18,6 +18,7 @@ export const serverOptions: OptionDescri
184+
@@ -18,8 +18,9 @@ export const serverOptions: OptionDescri
185185
'auth': { type: 'string' },
186186
'disable-file-downloads': { type: 'boolean' },
187+
'disable-file-uploads': { type: 'boolean' },
187188
'locale': { type: 'string' },
188189
+ 'disable-getting-started-override': { type: 'boolean' },
189190

190191
/* ----- server setup ----- */
191192

192-
@@ -101,6 +102,7 @@ export interface ServerParsedArgs {
193+
'host': { type: 'string', cat: 'o', args: 'ip-address', description: nls.localize('host', "The host name or IP address the server should listen to. If not set, defaults to 'localhost'.") },
194+
@@ -102,8 +103,9 @@ export interface ServerParsedArgs {
193195
'auth'?: string
194196
'disable-file-downloads'?: boolean;
197+
'disable-file-uploads'?: boolean;
195198
'locale'?: string
196199
+ 'disable-getting-started-override'?: boolean,
197200

198201
/* ----- server setup ----- */
199202

203+
host?: string;
200204
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
201205
===================================================================
202206
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
203207
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
204-
@@ -335,6 +335,7 @@ export class WebClientServer {
208+
@@ -335,8 +335,9 @@ export class WebClientServer {
205209
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
206210
userDataPath: this._environmentService.userDataPath,
207211
isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
212+
isEnabledFileUploads: !this._environmentService.args['disable-file-uploads'],
208213
+ isEnabledCoderGettingStarted: !this._environmentService.args['disable-getting-started-override'],
209214
_wrapWebWorkerExtHostInIframe,
210215
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
211216
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
217+
enableWorkspaceTrust: !this._environmentService.args['disable-workspace-trust'],
212218
Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts
213219
===================================================================
214220
--- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts
@@ -217,28 +223,32 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts
217223
import { Disposable } from 'vs/base/common/lifecycle';
218224
import { IContextKeyService, IContextKey, setConstant as setConstantContextKey } from 'vs/platform/contextkey/common/contextkey';
219225
import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext } from 'vs/platform/contextkey/common/contextkeys';
220-
-import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, IsEnabledFileDownloads, ActiveEditorCanToggleReadonlyContext, applyAvailableEditorIds, MaximizedEditorGroupContext, TitleBarVisibleContext, TitleBarStyleContext } from 'vs/workbench/common/contextkeys';
221-
+import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, IsEnabledFileDownloads, IsEnabledCoderGettingStarted, ActiveEditorCanToggleReadonlyContext, applyAvailableEditorIds, MaximizedEditorGroupContext, TitleBarVisibleContext, TitleBarStyleContext } from 'vs/workbench/common/contextkeys';
226+
-import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, ActiveEditorCanToggleReadonlyContext, applyAvailableEditorIds ,MaximizedEditorGroupContext, TitleBarVisibleContext, TitleBarStyleContext, IsEnabledFileDownloads, IsEnabledFileUploads } from 'vs/workbench/common/contextkeys';
227+
+import { SplitEditorsVertically, InEditorZenModeContext, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, ActiveEditorCanToggleReadonlyContext, applyAvailableEditorIds, MaximizedEditorGroupContext, TitleBarVisibleContext, TitleBarStyleContext, IsEnabledFileDownloads, IsEnabledFileUploads, IsEnabledCoderGettingStarted, } from 'vs/workbench/common/contextkeys';
222228
import { TEXT_DIFF_EDITOR_ID, EditorInputCapabilities, SIDE_BY_SIDE_EDITOR_ID, EditorResourceAccessor, SideBySideEditor } from 'vs/workbench/common/editor';
223229
import { trackFocus, addDisposableListener, EventType, onDidRegisterWindow } from 'vs/base/browser/dom';
224230
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
225-
@@ -221,6 +221,7 @@ export class WorkbenchContextKeysHandler
231+
@@ -221,8 +221,9 @@ export class WorkbenchContextKeysHandler
226232

227233
// code-server
228234
IsEnabledFileDownloads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileDownloads ?? true)
235+
IsEnabledFileUploads.bindTo(this.contextKeyService).set(this.environmentService.isEnabledFileUploads ?? true)
229236
+ IsEnabledCoderGettingStarted.bindTo(this.contextKeyService).set(this.environmentService.isEnabledCoderGettingStarted ?? true)
230237

231238
this.registerListeners();
232239
}
240+
233241
Index: code-server/lib/vscode/src/vs/workbench/common/contextkeys.ts
234242
===================================================================
235243
--- code-server.orig/lib/vscode/src/vs/workbench/common/contextkeys.ts
236244
+++ code-server/lib/vscode/src/vs/workbench/common/contextkeys.ts
237-
@@ -40,6 +40,7 @@ export const HasWebFileSystemAccess = ne
245+
@@ -40,8 +40,9 @@ export const HasWebFileSystemAccess = ne
238246
export const EmbedderIdentifierContext = new RawContextKey<string | undefined>('embedderIdentifier', undefined, localize('embedderIdentifier', 'The identifier of the embedder according to the product service, if one is defined'));
239247

240248
export const IsEnabledFileDownloads = new RawContextKey<boolean>('isEnabledFileDownloads', true, true);
249+
export const IsEnabledFileUploads = new RawContextKey<boolean>('isEnabledFileUploads', true, true);
241250
+export const IsEnabledCoderGettingStarted = new RawContextKey<boolean>('isEnabledCoderGettingStarted', true, true);
242251

243252
//#endregion
244253

254+
Collapse file

‎patches/series‎

Copy file name to clipboardExpand all lines: patches/series
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ unique-db.diff
1313
local-storage.diff
1414
service-worker.diff
1515
sourcemaps.diff
16-
disable-downloads.diff
16+
external-file-actions.diff
1717
telemetry.diff
1818
display-language.diff
1919
cli-window-open.diff
Collapse file

‎src/node/cli.ts‎

Copy file name to clipboardExpand all lines: src/node/cli.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface UserProvidedCodeArgs {
4848
"github-auth"?: string
4949
"disable-update-check"?: boolean
5050
"disable-file-downloads"?: boolean
51+
"disable-file-uploads"?: boolean
5152
"disable-workspace-trust"?: boolean
5253
"disable-getting-started-override"?: boolean
5354
"disable-proxy"?: boolean
@@ -170,6 +171,10 @@ export const options: Options<Required<UserProvidedArgs>> = {
170171
description:
171172
"Disable file downloads from Code. This can also be set with CS_DISABLE_FILE_DOWNLOADS set to 'true' or '1'.",
172173
},
174+
"disable-file-uploads": {
175+
type: "boolean",
176+
description: "Disable file uploads.",
177+
},
173178
"disable-workspace-trust": {
174179
type: "boolean",
175180
description: "Disable Workspace Trust feature. This switch only affects the current session.",
Collapse file

‎test/e2e/downloads.test.ts‎

Copy file name to clipboardExpand all lines: test/e2e/downloads.test.ts
+67-1Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,41 @@ describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
2323

2424
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(true)
2525
})
26+
27+
test("should see the 'Show Local' button on Save As", async ({ codeServerPage }) => {
28+
// Setup
29+
const workspaceDir = await codeServerPage.workspaceDir
30+
const fileName = "unique-file-save-as.txt"
31+
const tmpFilePath = path.join(workspaceDir, fileName)
32+
await fs.writeFile(tmpFilePath, "Hello World")
33+
34+
// Action
35+
await codeServerPage.page.waitForSelector(`text=${fileName}`)
36+
37+
await codeServerPage.openFile(fileName)
38+
await codeServerPage.page.click(".tab")
39+
await codeServerPage.navigateMenus(["File", "Auto Save"])
40+
await codeServerPage.page.keyboard.type("Making some edits.")
41+
await codeServerPage.navigateMenus(["File", "Save As..."])
42+
await codeServerPage.page.waitForSelector(".quick-input-widget")
43+
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
44+
})
45+
46+
test("should see the 'Show Local' button on Save File", async ({ codeServerPage }) => {
47+
// Action
48+
await codeServerPage.navigateMenus(["File", "New Text File"])
49+
await codeServerPage.waitForTab("Untitled-1")
50+
await codeServerPage.navigateMenus(["File", "Save"])
51+
await codeServerPage.page.waitForSelector(".quick-input-widget")
52+
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
53+
})
54+
55+
test("should see the 'Show Local' button on Save Workspace As", async ({ codeServerPage }) => {
56+
// Action
57+
await codeServerPage.navigateMenus(["File", "Save Workspace As..."])
58+
await codeServerPage.page.waitForSelector(".quick-input-widget")
59+
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
60+
})
2661
})
2762

2863
describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-downloads"], {}, async () => {
@@ -35,7 +70,7 @@ describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-d
3570
// Setup
3671
const workspaceDir = await codeServerPage.workspaceDir
3772
const tmpFilePath = path.join(workspaceDir, "unique-file.txt")
38-
await fs.writeFile(tmpFilePath, "hello world")
73+
await fs.writeFile(tmpFilePath, "Hello World")
3974

4075
// Action
4176
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
@@ -45,4 +80,35 @@ describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-d
4580

4681
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(false)
4782
})
83+
84+
test("should not see the 'Show Local' button on Save as", async ({ codeServerPage }) => {
85+
// Setup
86+
const workspaceDir = await codeServerPage.workspaceDir
87+
const fileName = "unique-file-save-as.txt"
88+
const tmpFilePath = path.join(workspaceDir, fileName)
89+
await fs.writeFile(tmpFilePath, "Hello World")
90+
91+
// Action
92+
await codeServerPage.page.waitForSelector(`text=${fileName}`)
93+
await codeServerPage.openFile(fileName)
94+
await codeServerPage.page.click(".tab")
95+
await codeServerPage.navigateMenus(["File", "Save As..."])
96+
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
97+
})
98+
99+
test("should not see the 'Show Local' button on Save File", async ({ codeServerPage }) => {
100+
// Action
101+
await codeServerPage.navigateMenus(["File", "New Text File"])
102+
await codeServerPage.waitForTab("Untitled-1")
103+
await codeServerPage.navigateMenus(["File", "Save"])
104+
await codeServerPage.page.waitForSelector(".quick-input-widget")
105+
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
106+
})
107+
108+
test("should not see the 'Show Local' button on Save Workspace As", async ({ codeServerPage }) => {
109+
// Action
110+
await codeServerPage.navigateMenus(["File", "Save Workspace As..."])
111+
await codeServerPage.page.waitForSelector(".quick-input-widget")
112+
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
113+
})
48114
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.