You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/07/30 19:43:28 UTC
(tooling-trusted-release) branch main updated: Add a sketch of the UI for managing check result ignores
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new de950e6 Add a sketch of the UI for managing check result ignores
de950e6 is described below
commit de950e6fab6dff9a0138b3f06855c95c27ee7258
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Wed Jul 30 20:42:58 2025 +0100
Add a sketch of the UI for managing check result ignores
---
atr/routes/ignores.py | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
atr/routes/modules.py | 1 +
atr/routes/tokens.py | 19 +++++-
3 files changed, 187 insertions(+), 1 deletion(-)
diff --git a/atr/routes/ignores.py b/atr/routes/ignores.py
new file mode 100644
index 0000000..0582354
--- /dev/null
+++ b/atr/routes/ignores.py
@@ -0,0 +1,168 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Final
+
+import markupsafe
+import werkzeug.wrappers.response as response
+from htpy import (
+ Element,
+ button,
+ div,
+ form,
+ h1,
+ h2,
+ h3,
+ input,
+ p,
+ script,
+ table,
+ td,
+ th,
+ tr,
+)
+
+import atr.models.sql as sql
+import atr.routes as routes
+import atr.storage as storage
+import atr.template as template
+import atr.util as util
+
+# TODO: Port to TypeScript and move to static files
+_UPDATE_IGNORE_FORM: Final[str] = """
+document.querySelectorAll("table.page-details input.form-control").forEach(function (input) {
+ var row = input.closest("tr");
+ var updateBtn = row.querySelector("button.btn-primary");
+ function check() {
+ if (input.value !== input.dataset.value) {
+ updateBtn.classList.remove("disabled");
+ } else {
+ updateBtn.classList.add("disabled");
+ }
+ }
+ input.addEventListener("input", check);
+ check();
+});
+"""
+
+
+@routes.committer("/ignores/<committee_name>", methods=["GET", "POST"])
+async def ignores(session: routes.CommitterSession, committee_name: str) -> str | response.Response:
+ async with storage.read() as read:
+ ragp = read.as_general_public()
+ ignores = await ragp.checks.ignores(committee_name)
+
+ content = div[
+ h1["Ignored checks"],
+ p[f"Manage ignored checks for committee {committee_name}."],
+ _add_ignore(),
+ _existing_ignores(ignores),
+ _script(_UPDATE_IGNORE_FORM),
+ ]
+
+ return await template.render(
+ "blank.html",
+ title="Ignored checks",
+ description=f"Manage ignored checks for committee {committee_name}.",
+ content=content,
+ )
+
+
+def _check_result_ignore_card(cri: sql.CheckResultIgnore) -> Element:
+ card_header_h3 = h3(".mb-0")[f"{cri.id or ''} - {cri.asf_uid} - {util.format_datetime(cri.created)}"]
+
+ table_rows = []
+
+ def add_row(label: str, value: str | None) -> None:
+ nonlocal table_rows
+ if value is not None:
+ table_rows.append(
+ tr[
+ th[label],
+ td[input(".form-control.form-control-sm", data_value=value, value=value)],
+ td[
+ button(".btn.btn-primary.btn-sm.me-4.disabled")["Update"],
+ button(".btn.btn-danger.btn-sm")["Delete"],
+ ],
+ ]
+ )
+
+ add_row("Release", cri.release_glob)
+ add_row("Revision number (literal)", cri.revision_number)
+ add_row("Checker", cri.checker_glob)
+ add_row("Primary path", cri.primary_rel_path_glob)
+ add_row("Member path", cri.member_rel_path_glob)
+ add_row("Status (enum)", cri.status)
+ add_row("Message", cri.message_glob)
+
+ table_striped = table(".table.table-striped.table-bordered.page-details")[table_rows]
+
+ card = div(".card")[
+ div(".card-header")[card_header_h3],
+ div(".card-body")[table_striped, p[button(".btn.btn-danger.btn-sm")["Delete"]]],
+ ]
+
+ return card
+
+
+def _add_ignore() -> Element:
+ table_rows = []
+
+ def add_row(label: str) -> None:
+ nonlocal table_rows
+ table_rows.append(
+ tr[
+ th[label],
+ td[input(".form-control.form-control-sm")],
+ ]
+ )
+
+ add_row("Release")
+ add_row("Revision number (literal)")
+ add_row("Checker")
+ add_row("Primary path")
+ add_row("Member path")
+ add_row("Status (enum)")
+ add_row("Message")
+
+ table_striped = table(".table.table-striped.table-bordered")[table_rows]
+
+ return div[
+ h2["Add ignore"],
+ p["Add a new ignore for a check result."],
+ form(".atr-canary")[
+ table_striped,
+ button(".btn.btn-primary")["Add"],
+ ],
+ ]
+
+
+def _existing_ignores(ignores: list[sql.CheckResultIgnore]) -> Element:
+ return div[
+ h2["Existing ignores"],
+ [_check_result_ignore_card(cri) for cri in ignores],
+ ]
+
+
+def _script(text: str) -> Element:
+ return script[
+ markupsafe.Markup(f"""
+document.addEventListener("DOMContentLoaded", function () {{
+ {text}
+}});
+""")
+ ]
diff --git a/atr/routes/modules.py b/atr/routes/modules.py
index 8d47782..0f9c9e6 100644
--- a/atr/routes/modules.py
+++ b/atr/routes/modules.py
@@ -24,6 +24,7 @@ import atr.routes.download as download
import atr.routes.draft as draft
import atr.routes.file as file
import atr.routes.finish as finish
+import atr.routes.ignores as ignores
import atr.routes.keys as keys
import atr.routes.preview as preview
import atr.routes.projects as projects
diff --git a/atr/routes/tokens.py b/atr/routes/tokens.py
index f654981..8d57bfb 100644
--- a/atr/routes/tokens.py
+++ b/atr/routes/tokens.py
@@ -29,7 +29,23 @@ import werkzeug.datastructures as datastructures
import werkzeug.wrappers.response as response
import wtforms
import wtforms.fields.core as core
-from htpy import Element, code, div, form, h1, h2, p, pre, strong, table, tbody, td, th, thead, tr
+from htpy import (
+ Element,
+ code,
+ div,
+ form,
+ h1,
+ h2,
+ p,
+ pre,
+ strong,
+ table,
+ tbody,
+ td,
+ th,
+ thead,
+ tr,
+)
import atr.db as db
import atr.jwtoken as jwtoken
@@ -98,6 +114,7 @@ async def tokens(session: routes.CommitterSession) -> str | response.Response:
"Generate a JSON Web Token (JWT) to authenticate calls to ATR's private API routes. "
"Treat the token like a password and include it in the Authorization header "
"as a Bearer token when invoking the protected endpoints.",
+ # p["Example"],
],
issue_form_elem,
pre(id="jwt-output", class_="d-none mt-2 p-3 atr-word-wrap border rounded w-50"),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org