diff --git a/client/web/dev/utils/create-js-context.ts b/client/web/dev/utils/create-js-context.ts index 06e749fbb7015..e85bb802fb4b8 100644 --- a/client/web/dev/utils/create-js-context.ts +++ b/client/web/dev/utils/create-js-context.ts @@ -35,7 +35,8 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st accessTokensExpirationDaysOptions: [7, 14, 30, 60, 90], allowSignup: true, batchChangesEnabled: true, - applianceManaged: false, + applianceUpdateTarget: '', + applianceMenuTarget: '', batchChangesDisableWebhooksWarning: false, batchChangesWebhookLogsEnabled: true, executorsEnabled: false, diff --git a/client/web/src/enterprise/site-admin/SiteAdminSidebar.story.tsx b/client/web/src/enterprise/site-admin/SiteAdminSidebar.story.tsx index 0d83fc1494054..1528f87a81279 100644 --- a/client/web/src/enterprise/site-admin/SiteAdminSidebar.story.tsx +++ b/client/web/src/enterprise/site-admin/SiteAdminSidebar.story.tsx @@ -38,7 +38,7 @@ export const AdminSidebarItems: StoryFn = () => ( batchChangesExecutionEnabled={true} batchChangesWebhookLogsEnabled={true} codeInsightsEnabled={true} - applianceManaged={false} + applianceUpdateTarget="" endUserOnboardingEnabled={false} /> ( batchChangesExecutionEnabled={true} batchChangesWebhookLogsEnabled={true} codeInsightsEnabled={true} - applianceManaged={false} + applianceUpdateTarget="" endUserOnboardingEnabled={false} /> ( batchChangesExecutionEnabled={false} batchChangesWebhookLogsEnabled={false} codeInsightsEnabled={true} - applianceManaged={false} + applianceUpdateTarget="" endUserOnboardingEnabled={false} /> ( batchChangesExecutionEnabled={true} batchChangesWebhookLogsEnabled={true} codeInsightsEnabled={false} - applianceManaged={false} + applianceUpdateTarget="" endUserOnboardingEnabled={false} /> diff --git a/client/web/src/integration/jscontext.ts b/client/web/src/integration/jscontext.ts index 472aef8e2d5ef..119073ac11a14 100644 --- a/client/web/src/integration/jscontext.ts +++ b/client/web/src/integration/jscontext.ts @@ -27,7 +27,8 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st accessTokensExpirationDaysOptions: [7, 30, 60, 90], allowSignup: false, batchChangesEnabled: true, - applianceManaged: false, + applianceUpdateTarget: '', + applianceMenuTarget: '', batchChangesDisableWebhooksWarning: false, batchChangesWebhookLogsEnabled: true, codeInsightsEnabled: true, diff --git a/client/web/src/jscontext.ts b/client/web/src/jscontext.ts index dedc427617c6d..d7a4ec3625306 100644 --- a/client/web/src/jscontext.ts +++ b/client/web/src/jscontext.ts @@ -199,7 +199,8 @@ export interface SourcegraphContext extends Pick, 'e /** * Whether this sourcegraph instance is managed by Appliance */ - applianceManaged: boolean + applianceUpdateTarget: string + applianceMenuTarget: string /** * Whether Cody is enabled on this instance. Check diff --git a/client/web/src/nav/UserNavItem.tsx b/client/web/src/nav/UserNavItem.tsx index 88c8d30f3d578..5c174c5b7b8af 100644 --- a/client/web/src/nav/UserNavItem.tsx +++ b/client/web/src/nav/UserNavItem.tsx @@ -227,6 +227,11 @@ export const UserNavItem: FC = props => { Site admin )} + {authenticatedUser.siteAdmin && window.context.applianceMenuTarget !== '' && ( + + Appliance + + )} Help diff --git a/client/web/src/routes.tsx b/client/web/src/routes.tsx index 76ebc06d11c01..c4d9a5a3a40c9 100644 --- a/client/web/src/routes.tsx +++ b/client/web/src/routes.tsx @@ -268,7 +268,7 @@ export const routes: RouteObject[] = [ sideBarGroups={props.siteAdminSideBarGroups} overviewComponents={props.siteAdminOverviewComponents} codeInsightsEnabled={window.context.codeInsightsEnabled} - applianceManaged={window.context.applianceManaged} + applianceUpdateTarget={window.context.applianceUpdateTarget} telemetryRecorder={props.platformContext.telemetryRecorder} /> )} diff --git a/client/web/src/site-admin/SiteAdminArea.tsx b/client/web/src/site-admin/SiteAdminArea.tsx index 2b024468d6dff..333b2c3f5cb50 100644 --- a/client/web/src/site-admin/SiteAdminArea.tsx +++ b/client/web/src/site-admin/SiteAdminArea.tsx @@ -59,7 +59,7 @@ export interface SiteAdminAreaRouteContext overviewComponents: readonly React.ComponentType>[] codeInsightsEnabled: boolean - applianceManaged: boolean + applianceUpdateTarget: string endUserOnboardingEnabled: boolean } @@ -78,7 +78,7 @@ interface SiteAdminAreaProps authenticatedUser: AuthenticatedUser isSourcegraphDotCom: boolean codeInsightsEnabled: boolean - applianceManaged: boolean + applianceUpdateTarget: string } const sourcegraphOperatorSiteAdminMaintenanceBlockItems = new Set([ @@ -144,7 +144,7 @@ const AuthenticatedSiteAdminArea: React.FunctionComponent
diff --git a/client/web/src/site-admin/SiteAdminSidebar.tsx b/client/web/src/site-admin/SiteAdminSidebar.tsx index 0e7b00800b2a3..1f8704036f501 100644 --- a/client/web/src/site-admin/SiteAdminSidebar.tsx +++ b/client/web/src/site-admin/SiteAdminSidebar.tsx @@ -15,7 +15,7 @@ export interface SiteAdminSideBarGroupContext extends BatchChangesProps { isSourcegraphDotCom: boolean codeInsightsEnabled: boolean endUserOnboardingEnabled: boolean - applianceManaged: boolean + applianceUpdateTarget: string } export interface SiteAdminSideBarGroup extends NavGroupDescriptor {} diff --git a/client/web/src/site-admin/sidebaritems.ts b/client/web/src/site-admin/sidebaritems.ts index 02c4873b0104f..1e3ff9e010b4c 100644 --- a/client/web/src/site-admin/sidebaritems.ts +++ b/client/web/src/site-admin/sidebaritems.ts @@ -135,12 +135,12 @@ const maintenanceGroup: SiteAdminSideBarGroup = { { label: maintenanceGroupUpdatesItemLabel, to: '/site-admin/updates', - condition: ({ applianceManaged }) => !applianceManaged, + condition: ({ applianceUpdateTarget }) => applianceUpdateTarget === '', }, { label: maintenanceGroupUpdatesItemLabel, - to: '/appliance/updates', - condition: ({ applianceManaged }) => applianceManaged, + to: window.context.applianceUpdateTarget, + condition: ({ applianceUpdateTarget }) => applianceUpdateTarget !== '', }, { label: 'Documentation', diff --git a/cmd/frontend/internal/app/jscontext/jscontext.go b/cmd/frontend/internal/app/jscontext/jscontext.go index b63991b9e2634..5645ead7408e2 100644 --- a/cmd/frontend/internal/app/jscontext/jscontext.go +++ b/cmd/frontend/internal/app/jscontext/jscontext.go @@ -232,14 +232,16 @@ type JSContext struct { CodeIntelAutoIndexingAllowGlobalPolicies bool `json:"codeIntelAutoIndexingAllowGlobalPolicies"` CodeIntelRankingDocumentReferenceCountsEnabled bool `json:"codeIntelRankingDocumentReferenceCountsEnabled"` - CodeInsightsEnabled bool `json:"codeInsightsEnabled"` - ApplianceManaged bool `json:"applianceManaged"` - CodeIntelligenceEnabled bool `json:"codeIntelligenceEnabled"` - SearchContextsEnabled bool `json:"searchContextsEnabled"` - NotebooksEnabled bool `json:"notebooksEnabled"` - CodeMonitoringEnabled bool `json:"codeMonitoringEnabled"` - SearchAggregationEnabled bool `json:"searchAggregationEnabled"` - OwnEnabled bool `json:"ownEnabled"` + CodeInsightsEnabled bool `json:"codeInsightsEnabled"` + ApplianceUpdateTarget string `json:"applianceUpdateTarget"` + ApplianceMenuTarget string `json:"applianceMenuTarget"` + CodeIntelligenceEnabled bool `json:"codeIntelligenceEnabled"` + SearchContextsEnabled bool `json:"searchContextsEnabled"` + NotebooksEnabled bool `json:"notebooksEnabled"` + CodeMonitoringEnabled bool `json:"codeMonitoringEnabled"` + SearchAggregationEnabled bool `json:"searchAggregationEnabled"` + OwnEnabled bool `json:"ownEnabled"` + SearchJobsEnabled bool `json:"searchJobsEnabled"` RedirectUnsupportedBrowser bool `json:"RedirectUnsupportedBrowser"` @@ -437,7 +439,8 @@ func NewJSContextFromRequest(req *http.Request, db database.DB) JSContext { CodyRequiresVerifiedEmail: siteResolver.RequiresVerifiedEmailForCody(ctx), CodeSearchEnabledOnInstance: codeSearchLicensed, - ApplianceManaged: conf.IsApplianceManaged(), + ApplianceUpdateTarget: conf.ApplianceUpdateTarget(), + ApplianceMenuTarget: conf.ApplianceMenuTarget(), ExecutorsEnabled: conf.ExecutorsEnabled(), CodeIntelAutoIndexingEnabled: conf.CodeIntelAutoIndexingEnabled(), diff --git a/internal/conf/computed.go b/internal/conf/computed.go index e5da6a47cb98f..bf870de0f9fb8 100644 --- a/internal/conf/computed.go +++ b/internal/conf/computed.go @@ -5,7 +5,6 @@ import ( "log" //nolint:logging // TODO move all logging to sourcegraph/log "os" "slices" - "strconv" "strings" "time" @@ -443,11 +442,12 @@ func AuthPrimaryLoginProvidersCount() int { return c } -func IsApplianceManaged() bool { - if v, _ := strconv.ParseBool(os.Getenv("APPLIANCE_MANAGED")); v { - return v - } - return false +func ApplianceUpdateTarget() string { + return os.Getenv("APPLIANCE_UPDATE_TARGET") +} + +func ApplianceMenuTarget() string { + return os.Getenv("APPLIANCE_MENU_TARGET") } // SearchSymbolsParallelism returns 20, or the site config