diff --git a/assets/swagger.json b/assets/swagger.json index e08625e82907c..7bd7db96c8b0a 100644 --- a/assets/swagger.json +++ b/assets/swagger.json @@ -5678,6 +5678,9 @@ "uiCssURL": { "type": "string" }, + "uiDefaultTheme": { + "type": "string" + }, "url": { "type": "string" }, diff --git a/docs/operator-manual/argocd-cm.yaml b/docs/operator-manual/argocd-cm.yaml index 00760415a48fd..763b41676c8b5 100644 --- a/docs/operator-manual/argocd-cm.yaml +++ b/docs/operator-manual/argocd-cm.yaml @@ -310,6 +310,14 @@ data: # - Files may also be loaded from remote locations via fully qualified URLs. ui.cssurl: "./custom/my-styles.css" + # The default theme for the UI. This theme will be applied when users first access the UI. + # Users can still change their theme preference, which will be stored in their browser localStorage. + # Valid values: "light", "dark", "auto" + # - "light": Light theme (default if not specified) + # - "dark": Dark theme + # - "auto": Automatically match the user's system preference + ui.defaulttheme: "auto" + # An optional user-defined banner message that's displayed at the top of every UI page. # Every time this is updated, it will clear a user's localStorage telling the UI to hide the banner forever. ui.bannercontent: "Hello there!" diff --git a/docs/operator-manual/ui-customization.md b/docs/operator-manual/ui-customization.md index 6569d1fa6b6be..83b738af70733 100644 --- a/docs/operator-manual/ui-customization.md +++ b/docs/operator-manual/ui-customization.md @@ -1,5 +1,19 @@ # UI Customization +## Default Theme + +You can configure the default theme for the ArgoCD UI by setting the `ui.defaulttheme` key in the [argocd-cm](argocd-cm-yaml.md) ConfigMap. + +The following configuration: +```yaml +ui.defaulttheme: "auto" +``` + +**Behavior:** +- First-time users will see the theme specified in `ui.defaulttheme` +- Existing users will continue to see their previously selected theme (stored in browser localStorage) +- Users can change their theme preference at any time, which will be persisted in their browser + ## Default Application Details View By default, the Application Details will show the `Tree` view. diff --git a/pkg/apiclient/settings/settings.pb.go b/pkg/apiclient/settings/settings.pb.go index ec1015c6f4b48..c15ca6342a500 100644 --- a/pkg/apiclient/settings/settings.pb.go +++ b/pkg/apiclient/settings/settings.pb.go @@ -99,6 +99,7 @@ type Settings struct { UiBannerPosition string `protobuf:"bytes,20,opt,name=uiBannerPosition,proto3" json:"uiBannerPosition,omitempty"` StatusBadgeRootUrl string `protobuf:"bytes,21,opt,name=statusBadgeRootUrl,proto3" json:"statusBadgeRootUrl,omitempty"` ExecEnabled bool `protobuf:"varint,22,opt,name=execEnabled,proto3" json:"execEnabled,omitempty"` + UiDefaultTheme string `protobuf:"bytes,30,opt,name=uiDefaultTheme,proto3" json:"uiDefaultTheme,omitempty"` ControllerNamespace string `protobuf:"bytes,23,opt,name=controllerNamespace,proto3" json:"controllerNamespace,omitempty"` AppsInAnyNamespaceEnabled bool `protobuf:"varint,24,opt,name=appsInAnyNamespaceEnabled,proto3" json:"appsInAnyNamespaceEnabled,omitempty"` ImpersonationEnabled bool `protobuf:"varint,25,opt,name=impersonationEnabled,proto3" json:"impersonationEnabled,omitempty"` @@ -298,6 +299,13 @@ func (m *Settings) GetExecEnabled() bool { return false } +func (m *Settings) GetUiDefaultTheme() string { + if m != nil { + return m.UiDefaultTheme + } + return "" +} + func (m *Settings) GetControllerNamespace() string { if m != nil { return m.ControllerNamespace @@ -780,90 +788,91 @@ func init() { func init() { proto.RegisterFile("server/settings/settings.proto", fileDescriptor_a480d494da040caa) } var fileDescriptor_a480d494da040caa = []byte{ - // 1318 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4d, 0x6f, 0x1b, 0x37, - 0x13, 0x86, 0x22, 0xc7, 0x96, 0xc6, 0xb1, 0x65, 0x33, 0x8e, 0xb3, 0xd1, 0x9b, 0xd8, 0x7a, 0x75, - 0x08, 0xd4, 0xa2, 0x5d, 0xc5, 0x36, 0xfa, 0x81, 0xa0, 0x41, 0x6b, 0x49, 0x41, 0xa2, 0xc6, 0x49, - 0x5c, 0x26, 0x4e, 0x81, 0x5e, 0x02, 0x7a, 0x77, 0x2a, 0x6d, 0xbd, 0x22, 0x17, 0x24, 0x57, 0x89, - 0x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0xd0, 0xb4, 0xf8, 0xe1, 0xa3, 0xee, 0xfd, 0xfd, 0x50, 0x0f, 0x91, - 0xeb, 0xa4, 0x93, 0xcc, 0xec, 0x51, 0xa1, 0x17, 0xf2, 0xf5, 0x09, 0x90, 0x59, 0x9f, 0x73, 0x4a, - 0xe4, 0xf1, 0xf9, 0xb6, 0xfe, 0xe4, 0xad, 0x6d, 0x1d, 0xcf, 0x9f, 0x76, 0x36, 0x40, 0x47, 0x83, - 0x9c, 0x6d, 0xec, 0xe7, 0x6a, 0x6b, 0xf7, 0xb7, 0x12, 0xd4, 0xd2, 0xfe, 0x7a, 0x86, 0x72, 0xec, - 0x39, 0x48, 0xbe, 0x84, 0xf2, 0x03, 0xd4, 0x64, 0x73, 0x66, 0x62, 0x33, 0x53, 0x6a, 0x7d, 0x7d, - 0x06, 0x6f, 0x5a, 0xdf, 0xff, 0xf9, 0xf7, 0x8f, 0x97, 0x08, 0x59, 0x33, 0x93, 0xf7, 0x78, 0x27, - 0x9b, 0x7a, 0xc9, 0x10, 0xe0, 0x01, 0x66, 0x5f, 0xf8, 0x45, 0x26, 0x1b, 0x33, 0x78, 0xa1, 0xd7, - 0x9b, 0x0d, 0xe3, 0xa1, 0x4e, 0xac, 0xa2, 0x87, 0x76, 0xd2, 0xe2, 0x9d, 0xee, 0xef, 0xd3, 0xad, - 0xd2, 0x1f, 0xd3, 0xad, 0xd2, 0x5f, 0xd3, 0xad, 0xd2, 0x37, 0x1f, 0xfd, 0xb7, 0x59, 0x3f, 0x2e, - 0xb5, 0xcc, 0xd8, 0xf1, 0xa2, 0x99, 0xcc, 0xf7, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x1a, - 0xe6, 0x75, 0x88, 0x0c, 0x00, 0x00, + // 1337 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14,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xd0, 0x4e, 0x5a, 0xbc, 0xd3, 0xfd, + 0x7d, 0xba, 0x55, 0xfa, 0x63, 0xba, 0x55, 0xfa, 0x7b, 0xba, 0x55, 0xfa, 0xee, 0x93, 0xff, 0xf7, + 0x4f, 0x10, 0x97, 0x5a, 0x66, 0xec, 0x78, 0x51, 0x4f, 0xf0, 0x7b, 0xff, 0x06, 0x00, 0x00, 0xff, + 0xff, 0xcc, 0xd4, 0xb7, 0x19, 0xb0, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1037,6 +1046,15 @@ func (m *Settings) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if len(m.UiDefaultTheme) > 0 { + i -= len(m.UiDefaultTheme) + copy(dAtA[i:], m.UiDefaultTheme) + i = encodeVarintSettings(dAtA, i, uint64(len(m.UiDefaultTheme))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xf2 + } if m.SyncWithReplaceAllowed { i-- if m.SyncWithReplaceAllowed { @@ -1872,6 +1890,10 @@ func (m *Settings) Size() (n int) { if m.SyncWithReplaceAllowed { n += 3 } + l = len(m.UiDefaultTheme) + if l > 0 { + n += 2 + l + sovSettings(uint64(l)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -3086,6 +3108,38 @@ func (m *Settings) Unmarshal(dAtA []byte) error { } } m.SyncWithReplaceAllowed = bool(v != 0) + case 30: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UiDefaultTheme", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSettings + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSettings + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSettings + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UiDefaultTheme = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSettings(dAtA[iNdEx:]) diff --git a/server/settings/settings.go b/server/settings/settings.go index db11a548f056d..4730112585b44 100644 --- a/server/settings/settings.go +++ b/server/settings/settings.go @@ -116,6 +116,7 @@ func (s *Server) Get(ctx context.Context, _ *settingspkg.SettingsQuery) (*settin UserLoginsDisabled: userLoginsDisabled, KustomizeVersions: kustomizeVersions, UiCssURL: argoCDSettings.UiCssURL, + UiDefaultTheme: argoCDSettings.UiDefaultTheme, TrackingMethod: trackingMethod, InstallationID: installationID, ExecEnabled: argoCDSettings.ExecEnabled, diff --git a/server/settings/settings.proto b/server/settings/settings.proto index 05ec4dab178fc..c5e03a26faf47 100644 --- a/server/settings/settings.proto +++ b/server/settings/settings.proto @@ -40,6 +40,7 @@ message Settings { string uiBannerPosition = 20; string statusBadgeRootUrl = 21; bool execEnabled = 22; + string uiDefaultTheme = 30; string controllerNamespace = 23; bool appsInAnyNamespaceEnabled = 24; bool impersonationEnabled = 25; diff --git a/server/settings/settings_test.go b/server/settings/settings_test.go index aba42865d4c7f..0f910bb554e69 100644 --- a/server/settings/settings_test.go +++ b/server/settings/settings_test.go @@ -114,4 +114,29 @@ func TestSettingsServer(t *testing.T) { assert.NotNil(t, resp.ResourceOverrides) assert.NotEmpty(t, resp.ResourceOverrides["*/*"]) }) + + t.Run("TestGetUiDefaultTheme", func(t *testing.T) { + settingsServer := newServer(map[string]string{ + "ui.defaulttheme": "dark", + }) + resp, err := settingsServer.Get(t.Context(), nil) + require.NoError(t, err) + assert.Equal(t, "dark", resp.UiDefaultTheme) + }) + + t.Run("TestGetUiDefaultThemeAuto", func(t *testing.T) { + settingsServer := newServer(map[string]string{ + "ui.defaulttheme": "auto", + }) + resp, err := settingsServer.Get(t.Context(), nil) + require.NoError(t, err) + assert.Equal(t, "auto", resp.UiDefaultTheme) + }) + + t.Run("TestGetUiDefaultThemeNotSet", func(t *testing.T) { + settingsServer := newServer(map[string]string{}) + resp, err := settingsServer.Get(t.Context(), nil) + require.NoError(t, err) + assert.Empty(t, resp.UiDefaultTheme) + }) } diff --git a/ui/src/app/app.tsx b/ui/src/app/app.tsx index 54434bc15e498..c4a7d9e469aca 100644 --- a/ui/src/app/app.tsx +++ b/ui/src/app/app.tsx @@ -122,6 +122,9 @@ export class App extends React.Component<{}, {popupProps: PopupProps; showVersio this.unauthorizedSubscription = subscription; }); const authSettings = await services.authService.settings(); + if (authSettings.uiDefaultTheme) { + services.viewPreferences.setBackendDefaultTheme(authSettings.uiDefaultTheme); + } const {trackingID, anonymizeUsers} = authSettings.googleAnalytics || {trackingID: '', anonymizeUsers: true}; const {loggedIn, username} = await services.users.get(); if (trackingID) { diff --git a/ui/src/app/shared/models.ts b/ui/src/app/shared/models.ts index 4a8f4f542d3b7..98220bce78bee 100644 --- a/ui/src/app/shared/models.ts +++ b/ui/src/app/shared/models.ts @@ -609,6 +609,7 @@ export interface AuthSettings { userLoginsDisabled: boolean; kustomizeVersions: string[]; uiCssURL: string; + uiDefaultTheme: string; uiBannerContent: string; uiBannerURL: string; uiBannerPermanent: boolean; diff --git a/ui/src/app/shared/services/view-preferences-service.ts b/ui/src/app/shared/services/view-preferences-service.ts index cff4aeb74b326..4a84d5e84f37f 100644 --- a/ui/src/app/shared/services/view-preferences-service.ts +++ b/ui/src/app/shared/services/view-preferences-service.ts @@ -204,6 +204,7 @@ const DEFAULT_PREFERENCES: ViewPreferences = { export class ViewPreferencesService { private preferencesSubj: BehaviorSubject; + private backendDefaultTheme: string = ''; public init() { if (!this.preferencesSubj) { @@ -214,6 +215,12 @@ export class ViewPreferencesService { } } + public setBackendDefaultTheme(theme: string) { + this.backendDefaultTheme = theme; + // Reload preferences with the new backend default + this.preferencesSubj.next(this.loadPreferences()); + } + public getPreferences(): Observable { return this.preferencesSubj; } @@ -239,6 +246,11 @@ export class ViewPreferencesService { } else { preferences = DEFAULT_PREFERENCES; } - return deepMerge(DEFAULT_PREFERENCES, preferences); + const merged = deepMerge(DEFAULT_PREFERENCES, preferences); + // If backend default theme is set and user hasn't explicitly set a theme, use backend default + if (this.backendDefaultTheme && (!preferencesStr || !JSON.parse(preferencesStr).theme)) { + merged.theme = this.backendDefaultTheme; + } + return merged; } } diff --git a/util/settings/settings.go b/util/settings/settings.go index 52b4dcca4b526..384e2f138d48d 100644 --- a/util/settings/settings.go +++ b/util/settings/settings.go @@ -115,6 +115,8 @@ type ArgoCDSettings struct { UiBannerPermanent bool `json:"uiBannerPermanent,omitempty"` //nolint:revive //FIXME(var-naming) // Position of UI Banner UiBannerPosition string `json:"uiBannerPosition,omitempty"` //nolint:revive //FIXME(var-naming) + // UiDefaultTheme holds the default theme for the UI (light, dark, auto) + UiDefaultTheme string `json:"uiDefaultTheme,omitempty"` //nolint:revive //FIXME(var-naming) // PasswordPattern for password regular expression PasswordPattern string `json:"passwordPattern,omitempty"` // BinaryUrls contains the URLs for downloading argocd binaries @@ -505,6 +507,8 @@ const ( settingUIBannerPermanentKey = "ui.bannerpermanent" // settingUIBannerPositionKey designates the key for the position of the banner settingUIBannerPositionKey = "ui.bannerposition" + // settingUIDefaultThemeKey designates the key for the default theme (light, dark, auto) + settingUIDefaultThemeKey = "ui.defaulttheme" // settingsBinaryUrlsKey designates the key for the argocd binary URLs settingsBinaryUrlsKey = "help.download" // settingsApplicationInstanceLabelKey is the key to configure injected app instance label key @@ -1473,6 +1477,7 @@ func updateSettingsFromConfigMap(settings *ArgoCDSettings, argoCDCM *corev1.Conf settings.UiBannerContent = argoCDCM.Data[settingUIBannerContentKey] settings.UiBannerPermanent = argoCDCM.Data[settingUIBannerPermanentKey] == "true" settings.UiBannerPosition = argoCDCM.Data[settingUIBannerPositionKey] + settings.UiDefaultTheme = argoCDCM.Data[settingUIDefaultThemeKey] settings.BinaryUrls = getDownloadBinaryUrlsFromConfigMap(argoCDCM) if err := ValidateExternalURL(argoCDCM.Data[settingURLKey]); err != nil { log.Warnf("Failed to validate URL in configmap: %v", err) diff --git a/util/settings/settings_test.go b/util/settings/settings_test.go index 30b694b43d037..b9adbeb87e98b 100644 --- a/util/settings/settings_test.go +++ b/util/settings/settings_test.go @@ -1017,6 +1017,44 @@ func TestSettingsManager_GetSettings(t *testing.T) { require.NoError(t, err) assert.Equal(t, time.Hour*10, s.UserSessionDuration) }) + t.Run("UiDefaultThemeNotProvided", func(t *testing.T) { + _, settingsManager := fixtures(t.Context(), map[string]string{}, func(secret *corev1.Secret) { + secret.Data["server.secretkey"] = []byte("test") + }) + s, err := settingsManager.GetSettings() + require.NoError(t, err) + assert.Empty(t, s.UiDefaultTheme) + }) + t.Run("UiDefaultThemeDark", func(t *testing.T) { + _, settingsManager := fixtures(t.Context(), map[string]string{ + "ui.defaulttheme": "dark", + }, func(secret *corev1.Secret) { + secret.Data["server.secretkey"] = []byte("test") + }) + s, err := settingsManager.GetSettings() + require.NoError(t, err) + assert.Equal(t, "dark", s.UiDefaultTheme) + }) + t.Run("UiDefaultThemeLight", func(t *testing.T) { + _, settingsManager := fixtures(t.Context(), map[string]string{ + "ui.defaulttheme": "light", + }, func(secret *corev1.Secret) { + secret.Data["server.secretkey"] = []byte("test") + }) + s, err := settingsManager.GetSettings() + require.NoError(t, err) + assert.Equal(t, "light", s.UiDefaultTheme) + }) + t.Run("UiDefaultThemeAuto", func(t *testing.T) { + _, settingsManager := fixtures(t.Context(), map[string]string{ + "ui.defaulttheme": "auto", + }, func(secret *corev1.Secret) { + secret.Data["server.secretkey"] = []byte("test") + }) + s, err := settingsManager.GetSettings() + require.NoError(t, err) + assert.Equal(t, "auto", s.UiDefaultTheme) + }) } func TestGetOIDCConfig(t *testing.T) {