-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Instance-wide (global) info banner and maintenance mode #36571
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b53ba46
feat: implement instance-wide informational banner
bircni dacd194
fixup! feat: implement instance-wide informational banner
bircni 824d846
refactor: Refactor instance notice banner to remove level and icon ha…
bircni b92f648
feat: add dismiss functionality to instance notice banner
bircni d82c0ee
refactor: remove instance notice level handling and related localization
bircni 1a3056d
fixup! refactor: remove instance notice level handling and related lo…
bircni c55997b
refactor
wxiaoguang 05f39be
fix test
wxiaoguang 1ffc65d
Merge branch 'main' into feature/maintenance-mode
wxiaoguang e364022
fine tune
wxiaoguang 8b92582
fix layout
wxiaoguang 7631bb3
fine tune
wxiaoguang 5dba1ce
fine tune
wxiaoguang f96a307
fine tune
wxiaoguang 24c7bef
fine tune layout
wxiaoguang e038afe
Merge branch 'main' into feature/maintenance-mode
wxiaoguang c8a5327
refactor
wxiaoguang 14bc38c
support maintenance mode
wxiaoguang f90dd8d
clean up
wxiaoguang e55750e
rename
wxiaoguang b038a7f
Merge branch 'main' into feature/maintenance-mode
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package setting | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "code.gitea.io/gitea/modules/setting/config" | ||
| ) | ||
|
|
||
| // WebBannerType fields are directly used in templates, | ||
| // do remember to update the template if you change the fields | ||
| type WebBannerType struct { | ||
| DisplayEnabled bool | ||
| ContentMessage string | ||
| StartTimeUnix int64 | ||
| EndTimeUnix int64 | ||
| } | ||
|
|
||
| func (b WebBannerType) ShouldDisplay() bool { | ||
| if !b.DisplayEnabled || b.ContentMessage == "" { | ||
| return false | ||
| } | ||
| now := time.Now().Unix() | ||
| if b.StartTimeUnix > 0 && now < b.StartTimeUnix { | ||
| return false | ||
| } | ||
| if b.EndTimeUnix > 0 && now > b.EndTimeUnix { | ||
| return false | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| type MaintenanceModeType struct { | ||
| AdminWebAccessOnly bool | ||
| StartTimeUnix int64 | ||
| EndTimeUnix int64 | ||
| } | ||
|
|
||
| func (m MaintenanceModeType) IsActive() bool { | ||
| if !m.AdminWebAccessOnly { | ||
| return false | ||
| } | ||
| now := time.Now().Unix() | ||
| if m.StartTimeUnix > 0 && now < m.StartTimeUnix { | ||
| return false | ||
| } | ||
| if m.EndTimeUnix > 0 && now > m.EndTimeUnix { | ||
| return false | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| type InstanceStruct struct { | ||
| WebBanner *config.Option[WebBannerType] | ||
| MaintenanceMode *config.Option[MaintenanceModeType] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.