Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 345a06a

Browse files
authored
chore(plg): add useEmbeddedUI site config param (#63442)
Adds `dotcom.codyProConfig.useEmbeddedUI` site config param. This param defines whether the Cody Pro subscription and team management UI should be served from the connected instance running in the dotcom mode. The default value is `false`. This change allows us to enable the SSC proxy on the instance without enabling the new embedded Cody Pro UI. Previously whether the embedded Cody Pro UI is enabled was defined by the `dotcom.codyProConfig` being set, which prevented us from enabling the SSC proxy without enabling the embedded UI: > Whether the SSC proxy is enabled is [defined based on `dotcom.codyProConfig`](https://github.com/sourcegraph/sourcegraph/blob/41fb56d619b82ee7f896a2e8aaf5937782731660/cmd/frontend/internal/ssc/ssc_proxy.go#L227-L231) being set in the site config. This value is also partially [propagated](https://github.com/sourcegraph/sourcegraph/blob/41fb56d619b82ee7f896a2e8aaf5937782731660/cmd/frontend/internal/app/jscontext/jscontext.go#L481) to the frontend via jscontext. And the frontend [uses this value](https://github.com/sourcegraph/sourcegraph/blob/41fb56d619b82ee7f896a2e8aaf5937782731660/client/web/src/cody/util.ts#L8-L18) to define whether to use new embedded UI or not. For more details see [this Slack thread](https://sourcegraph.slack.com/archives/C05PC7AKFQV/p1719010292837099?thread_ts=1719000927.962429&cid=C05PC7AKFQV). <!-- 💡 To write a useful PR description, make sure that your description covers: - WHAT this PR is changing: - How was it PREVIOUSLY. - How it will be from NOW on. - WHY this PR is needed. - CONTEXT, i.e. to which initiative, project or RFC it belongs. The structure of the description doesn't matter as much as covering these points, so use your best judgement based on your context. Learn how to write good pull request description: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e?pvs=4 --> ## Test plan - CI - Tested manually: - Run Sourcegraoh instance locally in dotcom mode - Set `dotcom.codyProConfig` in the site config - Type `context. frontendCodyProConfig` that it returns the [correct values from the site config](https://github.com/sourcegraph/sourcegraph/blob/184da4ce4ae21ca7a47c310a701356de2043d6b5/cmd/frontend/internal/app/jscontext/jscontext.go#L711-L715) <!-- All pull requests REQUIRE a test plan: https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> ## Changelog <!-- 1. Ensure your pull request title is formatted as: $type($domain): $what 2. Add bullet list items for each additional detail you want to cover (see example below) 3. You can edit this after the pull request was merged, as long as release shipping it hasn't been promoted to the public. 4. For more information, please see this how-to https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c? Audience: TS/CSE > Customers > Teammates (in that order). Cheat sheet: $type = chore|fix|feat $domain: source|search|ci|release|plg|cody|local|... --> <!-- Example: Title: fix(search): parse quotes with the appropriate context Changelog section: ## Changelog - When a quote is used with regexp pattern type, then ... - Refactored underlying code. -->
1 parent abe9ef1 commit 345a06a

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

client/web/src/cody/util.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export const manageSubscriptionRedirectURL = `${
1313
* for managing their Cody Pro subscription information.
1414
*/
1515
export function isEmbeddedCodyProUIEnabled(): boolean {
16-
return !!(window.context?.frontendCodyProConfig as { stripePublishableKey: string } | undefined)
17-
?.stripePublishableKey
16+
return !!window.context.frontendCodyProConfig?.useEmbeddedUI
1817
}
1918

2019
/**

client/web/src/jscontext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ export interface SourcegraphContext extends Pick<Required<SiteConfiguration>, 'e
314314
frontendCodyProConfig?: {
315315
stripePublishableKey: string
316316
sscBaseUrl: string
317+
useEmbeddedUI: boolean
317318
}
318319
}
319320

cmd/frontend/internal/app/jscontext/jscontext.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ type LicenseInfo struct {
153153
type FrontendCodyProConfig struct {
154154
StripePublishableKey string `json:"stripePublishableKey"`
155155
SscBaseUrl string `json:"sscBaseUrl"`
156+
UseEmbeddedUI bool `json:"useEmbeddedUI"`
156157
}
157158

158159
// JSContext is made available to JavaScript code via the
@@ -710,5 +711,6 @@ func makeFrontendCodyProConfig(config *schema.CodyProConfig) *FrontendCodyProCon
710711
return &FrontendCodyProConfig{
711712
StripePublishableKey: config.StripePublishableKey,
712713
SscBaseUrl: config.SscBaseUrl,
714+
UseEmbeddedUI: config.UseEmbeddedUI,
713715
}
714716
}

schema/schema.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/site.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,11 @@
22792279
"type": "string",
22802280
"default": "https://accounts.sourcegraph.com/cody",
22812281
"description": "The base URL of the Self-Serve Cody site."
2282+
},
2283+
"useEmbeddedUI": {
2284+
"type": "boolean",
2285+
"default": false,
2286+
"description": "Whether Cody Pro UI is served from sourcegraph.com. If false, users are directed to https://accounts.sourcegraph.com/cody to manage their Cody Pro subscription."
22822287
}
22832288
}
22842289
}

0 commit comments

Comments
 (0)