Skip to content

Commit

Permalink
batches: surface batch change rollout window in JSContext (sourcegrap…
Browse files Browse the repository at this point in the history
…h#50471)

sourcegraph#48217 and sourcegraph#48963 require the `batchChangesRolloutWindows` configuration
to be available in the frontend.
This PR surfaces the value via the `jscontext` object preloaded when the
UI starts.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
* Start up a Sourcegraph instance with `sg start batches`
* If the rollout window is configured in the Site Config, then logging
`window.context` should include the configured values in the
`batchChangesRolloutWindows` field.
![CleanShot 2023-04-07 at 12 50
12@2x](https://user-images.githubusercontent.com/25608335/230604199-adecb401-29fe-4cd5-b94f-f4f5d7da157d.png)

* If not, the value of `batchChangesRolloutWindows` will be null.
![CleanShot 2023-04-07 at 12 49
46@2x](https://user-images.githubusercontent.com/25608335/230604227-c1013cf0-19a5-462f-81f9-20c5883e1f48.png)
  • Loading branch information
BolajiOlajide committed Apr 12, 2023
1 parent 185c154 commit 3b1c5fc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/web/dev/utils/create-js-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st
},
embeddingsEnabled: false,
primaryLoginProvidersCount: 5,
batchChangesRolloutWindows: null,
// Site-config overrides default JS context
...siteConfig,
}
Expand Down
1 change: 1 addition & 0 deletions client/web/src/integration/jscontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st
localFilePickerAvailable: false,
srcServeGitUrl: 'http://127.0.0.1:3434',
primaryLoginProvidersCount: 5,
batchChangesRolloutWindows: null,
})
4 changes: 3 additions & 1 deletion client/web/src/jscontext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthenticatedUser } from '@sourcegraph/shared/src/auth'
import { SiteConfiguration } from '@sourcegraph/shared/src/schema/site.schema'
import { SiteConfiguration, BatchChangeRolloutWindow } from '@sourcegraph/shared/src/schema/site.schema'

import { TemporarySettingsResult } from './graphql-operations'

Expand Down Expand Up @@ -183,6 +183,8 @@ export interface SourcegraphContext extends Pick<Required<SiteConfiguration>, 'e

batchChangesWebhookLogsEnabled: boolean

batchChangesRolloutWindows: BatchChangeRolloutWindow[] | null

/** Whether executors are enabled on the site. */
executorsEnabled: boolean

Expand Down
8 changes: 5 additions & 3 deletions cmd/frontend/internal/app/jscontext/jscontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ type JSContext struct {

Branding *schema.Branding `json:"branding"`

BatchChangesEnabled bool `json:"batchChangesEnabled"`
BatchChangesDisableWebhooksWarning bool `json:"batchChangesDisableWebhooksWarning"`
BatchChangesWebhookLogsEnabled bool `json:"batchChangesWebhookLogsEnabled"`
BatchChangesEnabled bool `json:"batchChangesEnabled"`
BatchChangesDisableWebhooksWarning bool `json:"batchChangesDisableWebhooksWarning"`
BatchChangesWebhookLogsEnabled bool `json:"batchChangesWebhookLogsEnabled"`
BatchChangesRolloutWindows *[]*schema.BatchChangeRolloutWindow `json:"batchChangesRolloutWindows"`

ExecutorsEnabled bool `json:"executorsEnabled"`
CodeIntelAutoIndexingEnabled bool `json:"codeIntelAutoIndexingEnabled"`
Expand Down Expand Up @@ -353,6 +354,7 @@ func NewJSContextFromRequest(req *http.Request, db database.DB) JSContext {
BatchChangesEnabled: enterprise.BatchChangesEnabledForUser(ctx, db) == nil,
BatchChangesDisableWebhooksWarning: conf.Get().BatchChangesDisableWebhooksWarning,
BatchChangesWebhookLogsEnabled: webhooks.LoggingEnabled(conf.Get()),
BatchChangesRolloutWindows: conf.Get().BatchChangesRolloutWindows,

ExecutorsEnabled: conf.ExecutorsEnabled(),
CodeIntelAutoIndexingEnabled: conf.CodeIntelAutoIndexingEnabled(),
Expand Down

0 comments on commit 3b1c5fc

Please sign in to comment.