Skip to content

Commit

Permalink
Serve mock index.html and window.context (#12091)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Jul 10, 2020
1 parent 750c90f commit 58124b9
Show file tree
Hide file tree
Showing 23 changed files with 206 additions and 1,609 deletions.
2 changes: 1 addition & 1 deletion web/package.json
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"scripts": {
"test": "jest --testPathIgnorePatterns end-to-end --testPathIgnorePatterns regression integration",
"test:integration": "mocha ./src/integration/**/*.test.ts",
"test:integration": "NODE_NO_WARNINGS=1 mocha ./src/integration/**/*.test.ts",
"test:regression": "mocha './src/regression/**/*.test.ts'",
"test:regression:auth": "mocha ./src/regression/auth.test.ts",
"test:regression:codeintel": "mocha ./src/regression/codeintel.test.ts",
Expand Down
1 change: 1 addition & 0 deletions web/src/enterprise/codeintel/CodeIntelIndexPage.story.tsx
Expand Up @@ -7,6 +7,7 @@ import * as GQL from '../../../../shared/src/graphql/schema'
import * as H from 'history'
import React from 'react'
import webStyles from '../../SourcegraphWebApp.scss'
import { SourcegraphContext } from '../../jscontext'

window.context = {} as SourcegraphContext & SuiteFunction

Expand Down
Expand Up @@ -7,6 +7,7 @@ import * as GQL from '../../../../shared/src/graphql/schema'
import * as H from 'history'
import React from 'react'
import webStyles from '../../SourcegraphWebApp.scss'
import { SourcegraphContext } from '../../jscontext'

window.context = {} as SourcegraphContext & SuiteFunction

Expand Down
1 change: 1 addition & 0 deletions web/src/enterprise/codeintel/CodeIntelUploadPage.story.tsx
Expand Up @@ -7,6 +7,7 @@ import * as GQL from '../../../../shared/src/graphql/schema'
import * as H from 'history'
import React from 'react'
import webStyles from '../../SourcegraphWebApp.scss'
import { SourcegraphContext } from '../../jscontext'

window.context = {} as SourcegraphContext & SuiteFunction

Expand Down
Expand Up @@ -7,6 +7,7 @@ import * as GQL from '../../../../shared/src/graphql/schema'
import * as H from 'history'
import React from 'react'
import webStyles from '../../SourcegraphWebApp.scss'
import { SourcegraphContext } from '../../jscontext'

window.context = {} as SourcegraphContext & SuiteFunction

Expand Down
132 changes: 1 addition & 131 deletions web/src/globals.d.ts
Expand Up @@ -7,142 +7,12 @@ interface PageError {

interface Window {
pageError?: PageError
context: SourcegraphContext
context: import('./jscontext').SourcegraphContext
MonacoEnvironment: {
getWorkerUrl(moduleId: string, label: string): string
}
}

/**
* Represents user properties that are guaranteed to both (1) be set if the user is signed in,
* and (2) not change over a user session
*/
interface ImmutableUser {
readonly UID: number
}

type DeployType = 'kubernetes' | 'docker-container' | 'docker-compose' | 'pure-docker' | 'dev'

/**
* Defined in cmd/frontend/internal/app/jscontext/jscontext.go JSContext struct
*/
interface SourcegraphContext
extends Pick<Required<import('./schema/site.schema').SiteConfiguration>, 'experimentalFeatures'> {
xhrHeaders: { [key: string]: string }
csrfToken: string
userAgentIsBot: boolean

/**
* Whether the user is authenticated. Use authenticatedUser in ./auth.ts to obtain information about the user.
*/
readonly isAuthenticatedUser: boolean

readonly sentryDSN: string | null

/** Externally accessible URL for Sourcegraph (e.g., https://sourcegraph.com or http://localhost:3080). */
externalURL: string

/** URL path to image/font/etc. assets on server */
assetsRoot: string

version: string

/**
* Debug is whether debug mode is enabled.
*/
debug: boolean

sourcegraphDotComMode: boolean

/**
* siteID is the identifier of the Sourcegraph site.
*/
siteID: string

/** The GraphQL ID of the Sourcegraph site. */
siteGQLID: GQL.ID

/**
* Whether the site needs to be initialized.
*/
needsSiteInit: boolean

/**
* Emails support enabled
*/
emailEnabled: boolean

/**
* A subset of the site configuration. Not all fields are set.
*/
site: Pick<
import('./schema/site.schema').SiteConfiguration,
| 'auth.public'
| 'update.channel'
| 'campaigns.readAccess.enabled'
| 'disableNonCriticalTelemetry'
| 'permissions.backgroundSync'
>

/** Whether access tokens are enabled. */
accessTokensAllow: 'all-users-create' | 'site-admin-create' | 'none'

/** Whether the reset-password flow is enabled. */
resetPasswordEnabled: boolean

/**
* Likely running within a Docker container under a Mac host OS.
*/
likelyDockerOnMac: boolean

/**
* Whether or not the server needs to restart in order to apply a pending
* configuration change.
*/
needServerRestart: boolean

/**
* The kind of deployment.
*/
deployType: DeployType

/** Whether signup is allowed on the site. */
allowSignup: boolean

/** Authentication provider instances in site config. */
authProviders?: {
displayName: string
isBuiltin: boolean
authenticationURL?: string
}[]

/** Custom branding for the homepage and search icon. */
branding?: {
/** The URL of the favicon to be used for your instance */
favicon?: string

/** Override style for light themes */
light?: BrandAssets
/** Override style for dark themes */
dark?: BrandAssets

/** Prevents the icon in the top-left corner of the screen from spinning. */
disableSymbolSpin?: boolean

brandName: string
}

/** The publishable key for the billing service (Stripe). */
billingPublishableKey?: string
}

interface BrandAssets {
/** The URL to the logo used on the homepage */
logo?: string
/** The URL to the symbol used as the search icon */
symbol?: string
}

declare module '*.scss' {
const cssModule: string
export default cssModule
Expand Down

This file was deleted.

0 comments on commit 58124b9

Please sign in to comment.