From 3ff4f9435d6f45de56dc542a7e666084d03c5439 Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Thu, 6 Feb 2025 08:31:16 +0000 Subject: [PATCH 1/6] Add a "No data available" message to be displayed when the list has no data. --- templates/admin/auth/list.tmpl | 1 + templates/admin/emails/list.tmpl | 1 + templates/admin/notice.tmpl | 1 + templates/admin/org/list.tmpl | 1 + templates/admin/packages/list.tmpl | 1 + templates/admin/repo/list.tmpl | 1 + templates/admin/user/list.tmpl | 1 + templates/shared/no_results_found.tmpl | 5 +++++ 8 files changed, 12 insertions(+) create mode 100644 templates/shared/no_results_found.tmpl diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index 7931014b1a519..a0e1a1abaad9c 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -31,6 +31,7 @@ {{svg "octicon-pencil"}} {{end}} + {{template "shared/no_results_found" (dict "rst" .Sources "colspan" 7)}} diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index 0dc1fb9d03fe3..ffa12415e3080 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -68,6 +68,7 @@ {{end}} + {{template "shared/no_results_found" (dict "rst" .Emails "colspan" 6)}} diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index fd475d7157eac..14b4df2ec445a 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -25,6 +25,7 @@ {{svg "octicon-note" 16}} {{end}} + {{template "shared/no_results_found" (dict "rst" .Notices "colspan" 6)}} {{if .Notices}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index d5e09939c5324..72f2591467006 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -67,6 +67,7 @@ {{svg "octicon-pencil"}} {{end}} + {{template "shared/no_results_found" (dict "rst" .Users "colspan" 7)}} diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl index 08c11442bca9a..1dc96d049dcc6 100644 --- a/templates/admin/packages/list.tmpl +++ b/templates/admin/packages/list.tmpl @@ -75,6 +75,7 @@ {{svg "octicon-trash"}} {{end}} + {{template "shared/no_results_found" (dict "rst" .PackageDescriptors "colspan" 10)}} diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index 08fd893e76bee..b337e35516879 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -87,6 +87,7 @@ {{svg "octicon-trash"}} {{end}} + {{template "shared/no_results_found" (dict "rst" .Repos "colspan" 12)}} diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index 7e4c8854f5fda..af1aa2467c8a3 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -110,6 +110,7 @@ {{end}} + {{template "shared/no_results_found" (dict "rst" .Users "colspan" 9)}} diff --git a/templates/shared/no_results_found.tmpl b/templates/shared/no_results_found.tmpl new file mode 100644 index 0000000000000..4c13744283d45 --- /dev/null +++ b/templates/shared/no_results_found.tmpl @@ -0,0 +1,5 @@ +{{if not .rst}} + + {{ctx.Locale.Tr "no_results_found"}} + +{{end}} From c1e010f4a42e0837571fb3a6afbbe72e917ee884 Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Fri, 7 Feb 2025 00:14:06 +0000 Subject: [PATCH 2/6] fix --- templates/admin/auth/list.tmpl | 2 +- templates/admin/emails/list.tmpl | 2 +- templates/admin/notice.tmpl | 2 +- templates/admin/org/list.tmpl | 2 +- templates/admin/packages/list.tmpl | 2 +- templates/admin/repo/list.tmpl | 2 +- templates/admin/user/list.tmpl | 2 +- templates/shared/no_results_found.tmpl | 4 ++-- tests/integration/auth_ldap_test.go | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index a0e1a1abaad9c..8adf95ab228ca 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -31,7 +31,7 @@ {{svg "octicon-pencil"}} {{end}} - {{template "shared/no_results_found" (dict "rst" .Sources "colspan" 7)}} + {{template "shared/no_results_found" (dict "results" .Sources "colspan" 7)}} diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index ffa12415e3080..b600e4faf12bd 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -68,7 +68,7 @@ {{end}} - {{template "shared/no_results_found" (dict "rst" .Emails "colspan" 6)}} + {{template "shared/no_results_found" (dict "results" .Emails "colspan" 6)}} diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index 14b4df2ec445a..b08bb8189a41e 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -25,7 +25,7 @@ {{svg "octicon-note" 16}} {{end}} - {{template "shared/no_results_found" (dict "rst" .Notices "colspan" 6)}} + {{template "shared/no_results_found" (dict "results" .Notices "colspan" 6)}} {{if .Notices}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index 72f2591467006..0d15f36d156a7 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -67,7 +67,7 @@ {{svg "octicon-pencil"}} {{end}} - {{template "shared/no_results_found" (dict "rst" .Users "colspan" 7)}} + {{template "shared/no_results_found" (dict "results" .Users "colspan" 7)}} diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl index 1dc96d049dcc6..35890a13e7db4 100644 --- a/templates/admin/packages/list.tmpl +++ b/templates/admin/packages/list.tmpl @@ -75,7 +75,7 @@ {{svg "octicon-trash"}} {{end}} - {{template "shared/no_results_found" (dict "rst" .PackageDescriptors "colspan" 10)}} + {{template "shared/no_results_found" (dict "results" .PackageDescriptors "colspan" 10)}} diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index b337e35516879..d02c516af7995 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -87,7 +87,7 @@ {{svg "octicon-trash"}} {{end}} - {{template "shared/no_results_found" (dict "rst" .Repos "colspan" 12)}} + {{template "shared/no_results_found" (dict "results" .Repos "colspan" 12)}} diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index af1aa2467c8a3..a5576dc44706e 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -110,7 +110,7 @@ {{end}} - {{template "shared/no_results_found" (dict "rst" .Users "colspan" 9)}} + {{template "shared/no_results_found" (dict "results" .Users "colspan" 9)}} diff --git a/templates/shared/no_results_found.tmpl b/templates/shared/no_results_found.tmpl index 4c13744283d45..ea5e346a8d843 100644 --- a/templates/shared/no_results_found.tmpl +++ b/templates/shared/no_results_found.tmpl @@ -1,5 +1,5 @@ -{{if not .rst}} - +{{if not .results}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} diff --git a/tests/integration/auth_ldap_test.go b/tests/integration/auth_ldap_test.go index 5c50fd0288615..0599c43805d8a 100644 --- a/tests/integration/auth_ldap_test.go +++ b/tests/integration/auth_ldap_test.go @@ -279,7 +279,7 @@ func TestLDAPUserSyncWithEmptyUsernameAttribute(t *testing.T) { htmlDoc := NewHTMLParser(t, resp.Body) - tr := htmlDoc.doc.Find("table.table tbody tr") + tr := htmlDoc.doc.Find("table.table tbody tr:not(.no-results-row)") assert.Equal(t, 0, tr.Length()) } From 7f96c663bd60d6892e66adbee7560c5cbebed84c Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Sat, 8 Feb 2025 00:47:05 +0000 Subject: [PATCH 3/6] fix --- templates/admin/auth/list.tmpl | 3 ++- templates/admin/emails/list.tmpl | 3 ++- templates/admin/notice.tmpl | 3 ++- templates/admin/org/list.tmpl | 3 ++- templates/admin/packages/list.tmpl | 3 ++- templates/admin/repo/list.tmpl | 3 ++- templates/admin/user/list.tmpl | 3 ++- templates/shared/no_results_found.tmpl | 5 ----- 8 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 templates/shared/no_results_found.tmpl diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index 8adf95ab228ca..ef2105d913dd4 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -30,8 +30,9 @@ {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-pencil"}} + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .Sources "colspan" 7)}} diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index b600e4faf12bd..366d1ca885afb 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -67,8 +67,9 @@ >{{svg "octicon-trash"}} + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .Emails "colspan" 6)}} diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index b08bb8189a41e..db2e21893989c 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -24,8 +24,9 @@ {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-note" 16}} + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .Notices "colspan" 6)}} {{if .Notices}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index 0d15f36d156a7..d16452fb22c6c 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -66,8 +66,9 @@ {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-pencil"}} + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .Users "colspan" 7)}} diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl index 35890a13e7db4..2b6f12ac951b5 100644 --- a/templates/admin/packages/list.tmpl +++ b/templates/admin/packages/list.tmpl @@ -74,8 +74,9 @@ {{DateUtils.AbsoluteShort .Version.CreatedUnix}} {{svg "octicon-trash"}} + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .PackageDescriptors "colspan" 10)}} diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index d02c516af7995..d5d0614fa13ee 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -86,8 +86,9 @@ {{DateUtils.AbsoluteShort .CreatedUnix}} {{svg "octicon-trash"}} + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .Repos "colspan" 12)}} diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index a5576dc44706e..eb3f6cd72045e 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -109,8 +109,9 @@ + {{else}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} - {{template "shared/no_results_found" (dict "results" .Users "colspan" 9)}} diff --git a/templates/shared/no_results_found.tmpl b/templates/shared/no_results_found.tmpl deleted file mode 100644 index ea5e346a8d843..0000000000000 --- a/templates/shared/no_results_found.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{if not .results}} - - {{ctx.Locale.Tr "no_results_found"}} - -{{end}} From 650fd7d8294e0b0e60673c94a6e606c6c049fbd4 Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Sat, 8 Feb 2025 01:20:44 +0000 Subject: [PATCH 4/6] fix --- templates/admin/notice.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index db2e21893989c..10a906b7eabfe 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -25,7 +25,7 @@ {{svg "octicon-note" 16}} {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} {{if .Notices}} From 32dc7dc8aacdb7e062101dbfbb9b1344adaf2f88 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 8 Feb 2025 22:20:54 +0800 Subject: [PATCH 5/6] Update templates/admin/repo/list.tmpl --- templates/admin/repo/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index d5d0614fa13ee..762013af47fcd 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -87,7 +87,7 @@ {{svg "octicon-trash"}} {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} From 6e9811488fb1c587115c0d9f8780737a781278d5 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 8 Feb 2025 22:22:37 +0800 Subject: [PATCH 6/6] Apply suggestions from code review --- templates/admin/auth/list.tmpl | 2 +- templates/admin/emails/list.tmpl | 2 +- templates/admin/notice.tmpl | 2 +- templates/admin/org/list.tmpl | 2 +- templates/admin/packages/list.tmpl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index ef2105d913dd4..a1e72b742f2ea 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -31,7 +31,7 @@ {{svg "octicon-pencil"}} {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index 366d1ca885afb..b4335aeeec9f2 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -68,7 +68,7 @@ {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index 10a906b7eabfe..a4c9dc53fb160 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -25,7 +25,7 @@ {{svg "octicon-note" 16}} {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} {{if .Notices}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index d16452fb22c6c..137c42b45d610 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -67,7 +67,7 @@ {{svg "octicon-pencil"}} {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}} diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl index 2b6f12ac951b5..0c6889b599d38 100644 --- a/templates/admin/packages/list.tmpl +++ b/templates/admin/packages/list.tmpl @@ -75,7 +75,7 @@ {{svg "octicon-trash"}} {{else}} - {{ctx.Locale.Tr "no_results_found"}} + {{ctx.Locale.Tr "no_results_found"}} {{end}}