Skip to content
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
2 changes: 1 addition & 1 deletion internal/viewer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"
)

//go:embed templates/*.html static/style.css static/session.js
//go:embed templates/*.html static/style.css static/session.js static/repos.js
var assets embed.FS

func StartServer(addr string) error {
Expand Down
5 changes: 1 addition & 4 deletions internal/viewer/server_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ func TestRenderTemplate_WithRepos(t *testing.T) {
`id="repository-search-input"`,
`id="repositories-table"`,
"data-repository-name",
`addEventListener("input"`,
"toLowerCase()",
"name.includes(query)",
"row.hidden",
`src="/static/repos.js"`,
} {
if !strings.Contains(body, required) {
t.Errorf("rendered repository page missing %q", required)
Expand Down
18 changes: 18 additions & 0 deletions internal/viewer/static/repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 alibaba/open-code-review Contributors

(() => {
const input = document.getElementById("repository-search-input");
const table = document.getElementById("repositories-table");
if (!input || !table) return;

const rows = table.querySelectorAll("tbody tr");
input.addEventListener("input", () => {
const query = input.value.trim().toLowerCase();
rows.forEach((row) => {
const nameCell = row.querySelector("[data-repository-name]");
const name = nameCell ? nameCell.textContent.trim().toLowerCase() : "";
row.hidden = !name.includes(query);
});
});
})();
18 changes: 1 addition & 17 deletions internal/viewer/templates/repos.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,7 @@ <h2>Repositories</h2>
{{end}}
</tbody>
</table>
<script>
(() => {
const input = document.getElementById("repository-search-input");
const table = document.getElementById("repositories-table");
if (!input || !table) return;

const rows = table.querySelectorAll("tbody tr");
input.addEventListener("input", () => {
const query = input.value.trim().toLowerCase();
rows.forEach((row) => {
const nameCell = row.querySelector("[data-repository-name]");
const name = nameCell ? nameCell.textContent.trim().toLowerCase() : "";
row.hidden = !name.includes(query);
});
});
})();
</script>
<script src="/static/repos.js"></script>
{{else}}
<p>No session data found. Run a code review first.</p>
{{end}}
Expand Down