mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-24 10:46:10 +01:00
feat(ui): highlight user mention in comments and commit messages
This commit is contained in:
parent
bd42f677b4
commit
634519e891
|
@ -26,6 +26,7 @@
|
|||
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
|
||||
</style>
|
||||
</noscript>
|
||||
{{template "shared/user/mention_highlight" .}}
|
||||
{{template "base/head_opengraph" .}}
|
||||
{{template "base/head_style" .}}
|
||||
{{template "custom/header" .}}
|
||||
|
|
14
templates/shared/user/mention_highlight.tmpl
Normal file
14
templates/shared/user/mention_highlight.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
{{if .IsSigned}}
|
||||
<style>
|
||||
.comment,
|
||||
.commit-summary,
|
||||
.commit-body {
|
||||
.mention[href="{{AppSubUrl}}/{{.SignedUser.Name}}" i] {
|
||||
background-color: var(--color-primary-alpha-30);
|
||||
color: var(--color-primary-dark-2);
|
||||
border-radius: 5px;
|
||||
padding: 1px 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{{end}}
|
21
tests/integration/mention_test.go
Normal file
21
tests/integration/mention_test.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestHeadMentionCSS(t *testing.T) {
|
||||
userSession := loginUser(t, "user2")
|
||||
resp := userSession.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
|
||||
assert.Contains(t, resp.Body.String(), `.mention[href="/user2" i]`)
|
||||
|
||||
guestSession := emptyTestSession(t)
|
||||
resp = guestSession.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
|
||||
assert.NotContains(t, resp.Body.String(), `.mention[href="`)
|
||||
}
|
Loading…
Reference in a new issue