Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add theme global configuration from admin UI #35558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
lunny wants to merge 4 commits into go-gitea:main
base: main
Choose a base branch
Loading
from lunny:lunny/add_theme_configuration

Conversation

@lunny
Copy link
Member

@lunny lunny commented Oct 1, 2025

screenshots:

image

@lunny lunny added this to the 1.26.0 milestone Oct 1, 2025
@lunny lunny added the type/enhancement An improvement of existing functionality label Oct 1, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 1, 2025
@github-actions github-actions bot added modifies/translation modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Oct 1, 2025

.admin .ui.table.segment.dropdown-container {
overflow: visible; /* allow dropdown menus to extend beyond container boundaries */
}
Copy link
Member

@silverwind silverwind Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which problematic overflow: hidden in the ancestors is causing this? Can we possibly remove it?

Copy link
Contributor

It seems that Golang developers are really good at copying & pasting code and flood the code base with garbage .......

func (u *User) AfterLoad() {
if u.Theme == "" {
u.Theme = setting.UI.DefaultTheme
u.Theme = setting.Config().Theme.DefaultTheme.Value(context.Background())
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not use context.Background(), as always.

And the AfterLoad could be completely removed, if you have read the code.

The UserThemeName used by templates is already able to handle empty theme name correctly


func RenderEntryIconHTML(renderedIconPool *RenderedIconPool, entry *EntryInfo) template.HTML {
if setting.UI.FileIconTheme == "material" {
if setting.Config().Theme.DefaultFileIconTheme.Value(context.Background()) == "material" {
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No context.Background() please

I have spent enough time on cleaning up the rubbishes like

You have reviewed and approved those.

If you don't agree that "context.Background()" should be avoided, just tell me and BLOCK my PRs.

AllowedReactions: setting.UI.Reactions,
CustomEmojis: setting.UI.CustomEmojis,
DefaultTheme: setting.Config().Theme.DefaultTheme.Value(ctx),
DefaultFileIconTheme: setting.Config().Theme.DefaultFileIconTheme.Value(ctx),
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why it needs to be exposed.

What's the real use case? Who need it? If it is important, why no test to make sure it is a stable API?


func initThemes() {
availableThemes = nil
defaultTheme := setting.Config().Theme.DefaultTheme.Value(context.Background())
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initThemes is called in "once", but defaultTheme can be dynamically changed now, so how could the logic be right for a changed "default theme"?

Comment on lines +228 to +234
defer func() {
err := system_model.SetSettings(t.Context(), map[string]string{
setting.Config().Theme.DefaultFileIconTheme.DynKey(): "basic",
})
assert.NoError(t, err)
config.GetDynGetter().InvalidateCache()
}()
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure what you are doing?

defer test.MockVariableValue(&setting.UI.FileIconTheme, "basic")() means "use basic theme" for this test, and revert it after this test.

But your "defer" is only executed after the test?

for (const el of elAdminConfig.querySelectorAll('.js-theme-config-dropdown')) {
fomanticQuery(el).dropdown({
async onChange(value: string, _text: string, _$item: any) {
if (!value) return;
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why !value would happen?

Comment on lines +32 to +33
const configKey = this.getAttribute('data-config-key');
if (!configKey) return;
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why !configKey would happen?

}

// Handle theme config dropdowns
for (const el of elAdminConfig.querySelectorAll('.js-theme-config-dropdown')) {
Copy link
Contributor

@wxiaoguang wxiaoguang Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, every time you introduce a "system setting config option", then you will copy&paste another tens of lines code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@silverwind silverwind silverwind left review comments

@wxiaoguang wxiaoguang wxiaoguang left review comments

Assignees

No one assigned

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/translation type/enhancement An improvement of existing functionality

Projects

None yet

Milestone

1.26.0

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /