Dark "Are you sure?" dialog on dark pages

rails-ujs confirmations (data-confirm) show a dark dialog in Gitea's colours while the page is dark,
instead of the browser's box drawn in the device's colours; OK carries on with the link, button or
form. Light pages keep the browser's box. RedmineDarkMode.confirm(message, onOk) does the same for
other scripts. The default mode is one setting (DEFAULT_MODE, Automatic).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-02 22:22:50 -05:00
1 parent ad2451129f
commit 885c4d2b3a
6 files changed
+120 -6

No files matched your search

+6 -3
View File
@@ -9,9 +9,12 @@
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module RedmineDarkMode
# A user's choice: follow the device (the default), or always light or dark
# A user's choice: follow the device, or always light or dark
MODES = %w[auto light dark].freeze
# Until someone chooses, Redmine follows their device
DEFAULT_MODE = 'auto'
def self.setup
UserPreference.prepend(RedmineDarkMode::UserPreferencePatch)
UserPreference.safe_attributes 'dark_mode'
@@ -20,9 +23,9 @@ module RedmineDarkMode
RedmineDarkMode::Hooks
end
# The mode for this user (anonymous users follow the device, or their browser's saved choice)
# The mode for this user: their choice, else the default (anonymous users: their browser's saved choice, else the default)
def self.mode_for(user)
mode = user&.logged? ? user.pref.dark_mode : nil
MODES.include?(mode) ? mode : 'auto'
MODES.include?(mode) ? mode : DEFAULT_MODE
end
end