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

Commit dc97541

Browse files
authored
cherry-pick 856e41e with resolved conflicts (#64228)
<!-- PR description tips: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e --> Cherry pick changes from https://github.com/sourcegraph/sourcegraph/pull/64227 into release branch ## Test plan tested via sg start with both: - export APPLIANCE_UPDATE_TARGET=http://www.google.com - export APPLIANCE_MENU_TARGET=http://www.warhammer.com <!-- REQUIRED; info at https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> ## Changelog <!-- OPTIONAL; info at https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c -->
1 parent e1e2029 commit dc97541

File tree

11 files changed

+42
-31
lines changed

11 files changed

+42
-31
lines changed

client/web/dev/utils/create-js-context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st
3535
accessTokensExpirationDaysOptions: [7, 14, 30, 60, 90],
3636
allowSignup: true,
3737
batchChangesEnabled: true,
38-
applianceManaged: false,
38+
applianceUpdateTarget: '',
39+
applianceMenuTarget: '',
3940
batchChangesDisableWebhooksWarning: false,
4041
batchChangesWebhookLogsEnabled: true,
4142
executorsEnabled: false,

client/web/src/enterprise/site-admin/SiteAdminSidebar.story.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const AdminSidebarItems: StoryFn = () => (
3838
batchChangesExecutionEnabled={true}
3939
batchChangesWebhookLogsEnabled={true}
4040
codeInsightsEnabled={true}
41-
applianceManaged={false}
41+
applianceUpdateTarget=""
4242
endUserOnboardingEnabled={false}
4343
/>
4444
<SiteAdminSidebar
@@ -49,7 +49,7 @@ export const AdminSidebarItems: StoryFn = () => (
4949
batchChangesExecutionEnabled={true}
5050
batchChangesWebhookLogsEnabled={true}
5151
codeInsightsEnabled={true}
52-
applianceManaged={false}
52+
applianceUpdateTarget=""
5353
endUserOnboardingEnabled={false}
5454
/>
5555
<SiteAdminSidebar
@@ -60,7 +60,7 @@ export const AdminSidebarItems: StoryFn = () => (
6060
batchChangesExecutionEnabled={false}
6161
batchChangesWebhookLogsEnabled={false}
6262
codeInsightsEnabled={true}
63-
applianceManaged={false}
63+
applianceUpdateTarget=""
6464
endUserOnboardingEnabled={false}
6565
/>
6666
<SiteAdminSidebar
@@ -71,7 +71,7 @@ export const AdminSidebarItems: StoryFn = () => (
7171
batchChangesExecutionEnabled={true}
7272
batchChangesWebhookLogsEnabled={true}
7373
codeInsightsEnabled={false}
74-
applianceManaged={false}
74+
applianceUpdateTarget=""
7575
endUserOnboardingEnabled={false}
7676
/>
7777
</Grid>

client/web/src/integration/jscontext.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st
2727
accessTokensExpirationDaysOptions: [7, 30, 60, 90],
2828
allowSignup: false,
2929
batchChangesEnabled: true,
30-
applianceManaged: false,
30+
applianceUpdateTarget: '',
31+
applianceMenuTarget: '',
3132
batchChangesDisableWebhooksWarning: false,
3233
batchChangesWebhookLogsEnabled: true,
3334
codeInsightsEnabled: true,

client/web/src/jscontext.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ export interface SourcegraphContext extends Pick<Required<SiteConfiguration>, 'e
199199
/**
200200
* Whether this sourcegraph instance is managed by Appliance
201201
*/
202-
applianceManaged: boolean
202+
applianceUpdateTarget: string
203+
applianceMenuTarget: string
203204

204205
/**
205206
* Whether Cody is enabled on this instance. Check

client/web/src/nav/UserNavItem.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ export const UserNavItem: FC<UserNavItemProps> = props => {
227227
Site admin
228228
</MenuLink>
229229
)}
230+
{authenticatedUser.siteAdmin && window.context.applianceMenuTarget !== '' && (
231+
<MenuLink as={Link} to={window.context.applianceMenuTarget}>
232+
Appliance
233+
</MenuLink>
234+
)}
230235
<MenuLink as={Link} to="/help" target="_blank" rel="noopener">
231236
Help <Icon aria-hidden={true} svgPath={mdiOpenInNew} />
232237
</MenuLink>

client/web/src/routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export const routes: RouteObject[] = [
268268
sideBarGroups={props.siteAdminSideBarGroups}
269269
overviewComponents={props.siteAdminOverviewComponents}
270270
codeInsightsEnabled={window.context.codeInsightsEnabled}
271-
applianceManaged={window.context.applianceManaged}
271+
applianceUpdateTarget={window.context.applianceUpdateTarget}
272272
telemetryRecorder={props.platformContext.telemetryRecorder}
273273
/>
274274
)}

client/web/src/site-admin/SiteAdminArea.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface SiteAdminAreaRouteContext
5959
overviewComponents: readonly React.ComponentType<React.PropsWithChildren<{}>>[]
6060

6161
codeInsightsEnabled: boolean
62-
applianceManaged: boolean
62+
applianceUpdateTarget: string
6363

6464
endUserOnboardingEnabled: boolean
6565
}
@@ -78,7 +78,7 @@ interface SiteAdminAreaProps
7878
authenticatedUser: AuthenticatedUser
7979
isSourcegraphDotCom: boolean
8080
codeInsightsEnabled: boolean
81-
applianceManaged: boolean
81+
applianceUpdateTarget: string
8282
}
8383

8484
const sourcegraphOperatorSiteAdminMaintenanceBlockItems = new Set([
@@ -144,7 +144,7 @@ const AuthenticatedSiteAdminArea: React.FunctionComponent<React.PropsWithChildre
144144
telemetryService: props.telemetryService,
145145
telemetryRecorder: props.telemetryRecorder,
146146
codeInsightsEnabled: props.codeInsightsEnabled,
147-
applianceManaged: props.applianceManaged,
147+
applianceUpdateTarget: props.applianceUpdateTarget,
148148
endUserOnboardingEnabled,
149149
}
150150

@@ -164,7 +164,7 @@ const AuthenticatedSiteAdminArea: React.FunctionComponent<React.PropsWithChildre
164164
batchChangesExecutionEnabled={props.batchChangesExecutionEnabled}
165165
batchChangesWebhookLogsEnabled={props.batchChangesWebhookLogsEnabled}
166166
codeInsightsEnabled={props.codeInsightsEnabled}
167-
applianceManaged={props.applianceManaged}
167+
applianceUpdateTarget={props.applianceUpdateTarget}
168168
endUserOnboardingEnabled={endUserOnboardingEnabled}
169169
/>
170170
<div className="flex-bounded">

client/web/src/site-admin/SiteAdminSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface SiteAdminSideBarGroupContext extends BatchChangesProps {
1515
isSourcegraphDotCom: boolean
1616
codeInsightsEnabled: boolean
1717
endUserOnboardingEnabled: boolean
18-
applianceManaged: boolean
18+
applianceUpdateTarget: string
1919
}
2020

2121
export interface SiteAdminSideBarGroup extends NavGroupDescriptor<SiteAdminSideBarGroupContext> {}

client/web/src/site-admin/sidebaritems.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ const maintenanceGroup: SiteAdminSideBarGroup = {
135135
{
136136
label: maintenanceGroupUpdatesItemLabel,
137137
to: '/site-admin/updates',
138-
condition: ({ applianceManaged }) => !applianceManaged,
138+
condition: ({ applianceUpdateTarget }) => applianceUpdateTarget === '',
139139
},
140140
{
141141
label: maintenanceGroupUpdatesItemLabel,
142-
to: '/appliance/updates',
143-
condition: ({ applianceManaged }) => applianceManaged,
142+
to: window.context.applianceUpdateTarget,
143+
condition: ({ applianceUpdateTarget }) => applianceUpdateTarget !== '',
144144
},
145145
{
146146
label: 'Documentation',

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,16 @@ type JSContext struct {
232232
CodeIntelAutoIndexingAllowGlobalPolicies bool `json:"codeIntelAutoIndexingAllowGlobalPolicies"`
233233
CodeIntelRankingDocumentReferenceCountsEnabled bool `json:"codeIntelRankingDocumentReferenceCountsEnabled"`
234234

235-
CodeInsightsEnabled bool `json:"codeInsightsEnabled"`
236-
ApplianceManaged bool `json:"applianceManaged"`
237-
CodeIntelligenceEnabled bool `json:"codeIntelligenceEnabled"`
238-
SearchContextsEnabled bool `json:"searchContextsEnabled"`
239-
NotebooksEnabled bool `json:"notebooksEnabled"`
240-
CodeMonitoringEnabled bool `json:"codeMonitoringEnabled"`
241-
SearchAggregationEnabled bool `json:"searchAggregationEnabled"`
242-
OwnEnabled bool `json:"ownEnabled"`
235+
CodeInsightsEnabled bool `json:"codeInsightsEnabled"`
236+
ApplianceUpdateTarget string `json:"applianceUpdateTarget"`
237+
ApplianceMenuTarget string `json:"applianceMenuTarget"`
238+
CodeIntelligenceEnabled bool `json:"codeIntelligenceEnabled"`
239+
SearchContextsEnabled bool `json:"searchContextsEnabled"`
240+
NotebooksEnabled bool `json:"notebooksEnabled"`
241+
CodeMonitoringEnabled bool `json:"codeMonitoringEnabled"`
242+
SearchAggregationEnabled bool `json:"searchAggregationEnabled"`
243+
OwnEnabled bool `json:"ownEnabled"`
244+
SearchJobsEnabled bool `json:"searchJobsEnabled"`
243245

244246
RedirectUnsupportedBrowser bool `json:"RedirectUnsupportedBrowser"`
245247

@@ -437,7 +439,8 @@ func NewJSContextFromRequest(req *http.Request, db database.DB) JSContext {
437439
CodyRequiresVerifiedEmail: siteResolver.RequiresVerifiedEmailForCody(ctx),
438440

439441
CodeSearchEnabledOnInstance: codeSearchLicensed,
440-
ApplianceManaged: conf.IsApplianceManaged(),
442+
ApplianceUpdateTarget: conf.ApplianceUpdateTarget(),
443+
ApplianceMenuTarget: conf.ApplianceMenuTarget(),
441444

442445
ExecutorsEnabled: conf.ExecutorsEnabled(),
443446
CodeIntelAutoIndexingEnabled: conf.CodeIntelAutoIndexingEnabled(),

internal/conf/computed.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log" //nolint:logging // TODO move all logging to sourcegraph/log
66
"os"
77
"slices"
8-
"strconv"
98
"strings"
109
"time"
1110

@@ -443,11 +442,12 @@ func AuthPrimaryLoginProvidersCount() int {
443442
return c
444443
}
445444

446-
func IsApplianceManaged() bool {
447-
if v, _ := strconv.ParseBool(os.Getenv("APPLIANCE_MANAGED")); v {
448-
return v
449-
}
450-
return false
445+
func ApplianceUpdateTarget() string {
446+
return os.Getenv("APPLIANCE_UPDATE_TARGET")
447+
}
448+
449+
func ApplianceMenuTarget() string {
450+
return os.Getenv("APPLIANCE_MENU_TARGET")
451451
}
452452

453453
// SearchSymbolsParallelism returns 20, or the site config

0 commit comments

Comments
 (0)