mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 16:51:55 +00:00
feat(appliance): Change site-admin updates button to point to Appliance based on env var (#64167)
<!-- PR description tips: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e --> This PR resolves [REL-300](https://linear.app/sourcegraph/issue/REL-300/put-update-redirect-into-current-sourcegraph-admin-panel). We point the Update button in the SiteAdmin sidebar to point to a different URL (Currently appliance localhost port, needs to be changed) based on the `APPLIANCE_MANAGED` env var. Most of the PR is tracking types / config down to the backend. There, a simple function checks for the existence of this env var and if it exists returns it's value. I may have updated extra unnecessary types (not certain) but I was following the compiler. Second commit is just updating the storybook type values We'll need another PR to the Helm chart to activate the env var once we want to switch people over to pointing to the appliance maintenance UI. @DaedalusG brought up the good point that even when managed by Appliance, the Upgrades page still provides valuable information to administrators, and so we may or may not actually want to leave this the way it is. TODO: - [ ] Change the URL that is pointed to when the env var is active (listed in a comment) ## Test plan <!-- REQUIRED; info at https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> Tested manually ## Changelog <!-- OPTIONAL; info at https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c --> - **feat(appliance): change update endpoint based on env var** - **misc: add type to storybook** --------- Co-authored-by: Craig Furman <craig.furman@sourcegraph.com>
This commit is contained in:
parent
a2f39bf302
commit
c1ff60f082
@ -35,6 +35,7 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st
|
||||
accessTokensExpirationDaysOptions: [7, 14, 30, 60, 90],
|
||||
allowSignup: true,
|
||||
batchChangesEnabled: true,
|
||||
applianceManaged: false,
|
||||
batchChangesDisableWebhooksWarning: false,
|
||||
batchChangesWebhookLogsEnabled: true,
|
||||
executorsEnabled: false,
|
||||
|
||||
@ -34,6 +34,7 @@ export const AdminSidebarItems: StoryFn = () => (
|
||||
batchChangesExecutionEnabled={true}
|
||||
batchChangesWebhookLogsEnabled={true}
|
||||
codeInsightsEnabled={true}
|
||||
applianceManaged={false}
|
||||
endUserOnboardingEnabled={false}
|
||||
/>
|
||||
<SiteAdminSidebar
|
||||
@ -44,6 +45,7 @@ export const AdminSidebarItems: StoryFn = () => (
|
||||
batchChangesExecutionEnabled={true}
|
||||
batchChangesWebhookLogsEnabled={true}
|
||||
codeInsightsEnabled={true}
|
||||
applianceManaged={false}
|
||||
endUserOnboardingEnabled={false}
|
||||
/>
|
||||
<SiteAdminSidebar
|
||||
@ -54,6 +56,7 @@ export const AdminSidebarItems: StoryFn = () => (
|
||||
batchChangesExecutionEnabled={false}
|
||||
batchChangesWebhookLogsEnabled={false}
|
||||
codeInsightsEnabled={true}
|
||||
applianceManaged={false}
|
||||
endUserOnboardingEnabled={false}
|
||||
/>
|
||||
<SiteAdminSidebar
|
||||
@ -64,6 +67,7 @@ export const AdminSidebarItems: StoryFn = () => (
|
||||
batchChangesExecutionEnabled={true}
|
||||
batchChangesWebhookLogsEnabled={true}
|
||||
codeInsightsEnabled={false}
|
||||
applianceManaged={false}
|
||||
endUserOnboardingEnabled={false}
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
@ -27,6 +27,7 @@ export const createJsContext = ({ sourcegraphBaseUrl }: { sourcegraphBaseUrl: st
|
||||
accessTokensExpirationDaysOptions: [7, 30, 60, 90],
|
||||
allowSignup: false,
|
||||
batchChangesEnabled: true,
|
||||
applianceManaged: false,
|
||||
batchChangesDisableWebhooksWarning: false,
|
||||
batchChangesWebhookLogsEnabled: true,
|
||||
codeInsightsEnabled: true,
|
||||
|
||||
@ -196,6 +196,11 @@ export interface SourcegraphContext extends Pick<Required<SiteConfiguration>, 'e
|
||||
|
||||
batchChangesWebhookLogsEnabled: boolean
|
||||
|
||||
/**
|
||||
* Whether this sourcegraph instance is managed by Appliance
|
||||
*/
|
||||
applianceManaged: boolean
|
||||
|
||||
/**
|
||||
* Whether Cody is enabled on this instance. Check
|
||||
* {@link SourcegraphContext.codyEnabledForCurrentUser} to see whether Cody is enabled for the
|
||||
|
||||
@ -299,6 +299,7 @@ export const routes: RouteObject[] = [
|
||||
sideBarGroups={props.siteAdminSideBarGroups}
|
||||
overviewComponents={props.siteAdminOverviewComponents}
|
||||
codeInsightsEnabled={window.context.codeInsightsEnabled}
|
||||
applianceManaged={window.context.applianceManaged}
|
||||
telemetryRecorder={props.platformContext.telemetryRecorder}
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -59,6 +59,7 @@ export interface SiteAdminAreaRouteContext
|
||||
overviewComponents: readonly React.ComponentType<React.PropsWithChildren<{}>>[]
|
||||
|
||||
codeInsightsEnabled: boolean
|
||||
applianceManaged: boolean
|
||||
|
||||
endUserOnboardingEnabled: boolean
|
||||
}
|
||||
@ -77,6 +78,7 @@ interface SiteAdminAreaProps
|
||||
authenticatedUser: AuthenticatedUser
|
||||
isSourcegraphDotCom: boolean
|
||||
codeInsightsEnabled: boolean
|
||||
applianceManaged: boolean
|
||||
}
|
||||
|
||||
const sourcegraphOperatorSiteAdminMaintenanceBlockItems = new Set([
|
||||
@ -142,6 +144,7 @@ const AuthenticatedSiteAdminArea: React.FunctionComponent<React.PropsWithChildre
|
||||
telemetryService: props.telemetryService,
|
||||
telemetryRecorder: props.telemetryRecorder,
|
||||
codeInsightsEnabled: props.codeInsightsEnabled,
|
||||
applianceManaged: props.applianceManaged,
|
||||
endUserOnboardingEnabled,
|
||||
}
|
||||
|
||||
@ -161,6 +164,7 @@ const AuthenticatedSiteAdminArea: React.FunctionComponent<React.PropsWithChildre
|
||||
batchChangesExecutionEnabled={props.batchChangesExecutionEnabled}
|
||||
batchChangesWebhookLogsEnabled={props.batchChangesWebhookLogsEnabled}
|
||||
codeInsightsEnabled={props.codeInsightsEnabled}
|
||||
applianceManaged={props.applianceManaged}
|
||||
endUserOnboardingEnabled={endUserOnboardingEnabled}
|
||||
/>
|
||||
<div className="flex-bounded">
|
||||
|
||||
@ -15,6 +15,7 @@ export interface SiteAdminSideBarGroupContext extends BatchChangesProps {
|
||||
isSourcegraphDotCom: boolean
|
||||
codeInsightsEnabled: boolean
|
||||
endUserOnboardingEnabled: boolean
|
||||
applianceManaged: boolean
|
||||
}
|
||||
|
||||
export interface SiteAdminSideBarGroup extends NavGroupDescriptor<SiteAdminSideBarGroupContext> {}
|
||||
|
||||
@ -135,6 +135,12 @@ const maintenanceGroup: SiteAdminSideBarGroup = {
|
||||
{
|
||||
label: maintenanceGroupUpdatesItemLabel,
|
||||
to: '/site-admin/updates',
|
||||
condition: ({ applianceManaged }) => !applianceManaged,
|
||||
},
|
||||
{
|
||||
label: maintenanceGroupUpdatesItemLabel,
|
||||
to: '/appliance/updates',
|
||||
condition: ({ applianceManaged }) => applianceManaged,
|
||||
},
|
||||
{
|
||||
label: 'Documentation',
|
||||
|
||||
@ -233,6 +233,7 @@ type JSContext struct {
|
||||
CodeIntelRankingDocumentReferenceCountsEnabled bool `json:"codeIntelRankingDocumentReferenceCountsEnabled"`
|
||||
|
||||
CodeInsightsEnabled bool `json:"codeInsightsEnabled"`
|
||||
ApplianceManaged bool `json:"applianceManaged"`
|
||||
CodeIntelligenceEnabled bool `json:"codeIntelligenceEnabled"`
|
||||
SearchContextsEnabled bool `json:"searchContextsEnabled"`
|
||||
NotebooksEnabled bool `json:"notebooksEnabled"`
|
||||
@ -436,6 +437,7 @@ func NewJSContextFromRequest(req *http.Request, db database.DB) JSContext {
|
||||
CodyRequiresVerifiedEmail: siteResolver.RequiresVerifiedEmailForCody(ctx),
|
||||
|
||||
CodeSearchEnabledOnInstance: codeSearchLicensed,
|
||||
ApplianceManaged: conf.IsApplianceManaged(),
|
||||
|
||||
ExecutorsEnabled: conf.ExecutorsEnabled(),
|
||||
CodeIntelAutoIndexingEnabled: conf.CodeIntelAutoIndexingEnabled(),
|
||||
|
||||
@ -4,7 +4,9 @@ import (
|
||||
"encoding/hex"
|
||||
stdlog "log" //nolint:logging // TODO move all logging to sourcegraph/log
|
||||
"net/url"
|
||||
"os"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -533,6 +535,13 @@ func AuthPrimaryLoginProvidersCount() int {
|
||||
return c
|
||||
}
|
||||
|
||||
func IsApplianceManaged() bool {
|
||||
if v, _ := strconv.ParseBool(os.Getenv("APPLIANCE_MANAGED")); v {
|
||||
return v
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SearchSymbolsParallelism returns 20, or the site config
|
||||
// "debug.search.symbolsParallelism" value if configured.
|
||||
func SearchSymbolsParallelism() int {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user