Skip to content
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

Fix the truncate and alignment problem for some admin tables #26042

Merged
merged 5 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/admin/emails/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
{{range .Emails}}
<tr>
<td><a href="{{AppSubUrl}}/{{.Name | PathEscape}}">{{.Name}}</a></td>
<td><span class="text truncate">{{.FullName}}</span></td>
<td><span class="text email">{{.Email}}</span></td>
<td class="gt-ellipsis gt-max-width-12rem">{{.FullName}}</td>
<td class="gt-ellipsis gt-max-width-12rem">{{.Email}}</td>
<td>{{if .IsPrimary}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
<td>
{{if .CanChange}}
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/packages/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
{{end}}
</td>
<td>{{.Package.Type.Name}}</td>
<td class="text truncate email">{{.Package.Name}}</td>
<td><a href="{{.FullWebLink}}" class="text truncate email">{{.Version.Version}}</a></td>
<td class="gt-ellipsis gt-max-width-12rem">{{.Package.Name}}</td>
<td class="gt-ellipsis gt-max-width-12rem"><a href="{{.FullWebLink}}">{{.Version.Version}}</a></td>
<td><a href="{{.Creator.HomeLink}}">{{.Creator.Name}}</a></td>
<td>
{{if .Repository}}
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/user/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<tr>
<td>{{.ID}}</td>
<td><a href="{{.HomeLink}}">{{.Name}}</a></td>
<td><span class="text truncate email">{{.Email}}</span></td>
<td class="gt-ellipsis gt-max-width-12rem">{{.Email}}</td>
<td>{{if .IsActive}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
<td>{{if .IsAdmin}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
<td>{{if .IsRestricted}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td>
Expand Down
45 changes: 10 additions & 35 deletions tests/integration/auth_ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,45 +226,20 @@ func TestLDAPUserSync(t *testing.T) {
addAuthSourceLDAP(t, "", "")
auth.SyncExternalUsers(context.Background(), true)

session := loginUser(t, "user1")
// Check if users exists
for _, u := range gitLDAPUsers {
req := NewRequest(t, "GET", "/admin/users?q="+u.UserName)
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)

tr := htmlDoc.doc.Find("table.table tbody tr")
if !assert.True(t, tr.Length() == 1) {
continue
}
tds := tr.Find("td")
if !assert.True(t, tds.Length() > 0) {
continue
}
assert.Equal(t, u.UserName, strings.TrimSpace(tds.Find("td:nth-child(2) a").Text()))
assert.Equal(t, u.Email, strings.TrimSpace(tds.Find("td:nth-child(3) span").Text()))
if u.IsAdmin {
assert.True(t, tds.Find("td:nth-child(5) svg").HasClass("octicon-check"))
} else {
assert.True(t, tds.Find("td:nth-child(5) svg").HasClass("octicon-x"))
}
if u.IsRestricted {
assert.True(t, tds.Find("td:nth-child(6) svg").HasClass("octicon-check"))
} else {
assert.True(t, tds.Find("td:nth-child(6) svg").HasClass("octicon-x"))
}
for _, gitLDAPUser := range gitLDAPUsers {
dbUser, err := user_model.GetUserByName(db.DefaultContext, gitLDAPUser.UserName)
assert.NoError(t, err)
assert.Equal(t, gitLDAPUser.UserName, dbUser.Name)
assert.Equal(t, gitLDAPUser.Email, dbUser.Email)
assert.Equal(t, gitLDAPUser.IsAdmin, dbUser.IsAdmin)
assert.Equal(t, gitLDAPUser.IsRestricted, dbUser.IsRestricted)
}

// Check if no users exist
for _, u := range otherLDAPUsers {
req := NewRequest(t, "GET", "/admin/users?q="+u.UserName)
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)

tr := htmlDoc.doc.Find("table.table tbody tr")
assert.True(t, tr.Length() == 0)
for _, otherLDAPUser := range otherLDAPUsers {
_, err := user_model.GetUserByName(db.DefaultContext, otherLDAPUser.UserName)
assert.True(t, user_model.IsErrUserNotExist(err))
}
}

Expand Down
4 changes: 0 additions & 4 deletions web_src/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
margin: 12px -1rem -1rem;
}

.admin.user table.table .email {
max-width: 200px;
}

.admin dl.admin-dl-horizontal {
padding: 1em;
margin: 0;
Expand Down
1 change: 1 addition & 0 deletions web_src/css/helpers.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Gitea's private styles use `g-` prefix.
text-overflow: ellipsis;
}

.gt-max-width-12rem { max-width: 12rem !important; }
.gt-max-width-24rem { max-width: 24rem !important; }

/* below class names match Tailwind CSS */
Expand Down