Archived
1
0

Add authed context key

This commit is contained in:
Asher 2021-05-03 15:00:54 -05:00
parent 9fe459a0f3
commit e7a527514a
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
3 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import { URI } from 'vs/base/common/uri';
import { Options } from 'vs/ipc'; import { Options } from 'vs/ipc';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
@ -173,6 +174,10 @@ export const initialize = async (services: ServiceCollection): Promise<void> =>
if (theme) { if (theme) {
localStorage.setItem('colorThemeData', theme); localStorage.setItem('colorThemeData', theme);
} }
// Use to show or hide logout commands and menu options.
const contextKeyService = (services.get(IContextKeyService) as IContextKeyService);
contextKeyService.createKey('code-server.authed', options.authed);
}; };
export interface Query { export interface Query {

View File

@ -3,6 +3,7 @@ import { Request, Router } from "express"
import { promises as fs } from "fs" import { promises as fs } from "fs"
import * as path from "path" import * as path from "path"
import qs from "qs" import qs from "qs"
import * as ipc from "../../../typings/ipc"
import { Emitter } from "../../common/emitter" import { Emitter } from "../../common/emitter"
import { HttpCode, HttpError } from "../../common/http" import { HttpCode, HttpError } from "../../common/http"
import { getFirstString } from "../../common/util" import { getFirstString } from "../../common/util"
@ -39,12 +40,13 @@ router.get("/", async (req, res) => {
options.productConfiguration.codeServerVersion = version options.productConfiguration.codeServerVersion = version
res.send( res.send(
replaceTemplates( replaceTemplates<ipc.Options>(
req, req,
// Uncomment prod blocks if not in development. TODO: Would this be // Uncomment prod blocks if not in development. TODO: Would this be
// better as a build step? Or maintain two HTML files again? // better as a build step? Or maintain two HTML files again?
commit !== "development" ? content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "") : content, commit !== "development" ? content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "") : content,
{ {
authed: req.args.auth !== "none",
disableTelemetry: !!req.args["disable-telemetry"], disableTelemetry: !!req.args["disable-telemetry"],
disableUpdateCheck: !!req.args["disable-update-check"], disableUpdateCheck: !!req.args["disable-update-check"],
}, },

1
typings/ipc.d.ts vendored
View File

@ -6,6 +6,7 @@
* The second is a symlink to the first. * The second is a symlink to the first.
*/ */
export interface Options { export interface Options {
authed: boolean
base: string base: string
disableTelemetry: boolean disableTelemetry: boolean
disableUpdateCheck: boolean disableUpdateCheck: boolean