generated from coulomb/repo-seed
advanced the review workflow
This commit is contained in:
@@ -280,7 +280,7 @@ def analysis_run_detail(
|
||||
<button type="submit">Approve</button>
|
||||
</form>
|
||||
</div>
|
||||
{render_candidate_graph(asdict(candidate_graph))}
|
||||
{render_candidate_graph(asdict(candidate_graph), repository_id, analysis_run_id)}
|
||||
</section>
|
||||
<section class="panel">
|
||||
<h2>Observed Facts</h2>
|
||||
@@ -308,7 +308,29 @@ def approve_candidate_graph_from_form(
|
||||
return RedirectResponse(f"/ui/repos/{repository_id}", status_code=303)
|
||||
|
||||
|
||||
def render_candidate_graph(graph: dict) -> str:
|
||||
@router.post(
|
||||
"/ui/repos/{repository_id}/analysis-runs/{analysis_run_id}"
|
||||
"/candidate-abilities/{candidate_ability_id}/reject"
|
||||
)
|
||||
def reject_candidate_ability_from_form(
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
candidate_ability_id: int,
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> RedirectResponse:
|
||||
service.reject_candidate_ability(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
candidate_ability_id,
|
||||
notes="Rejected from web UI",
|
||||
)
|
||||
return RedirectResponse(
|
||||
f"/ui/repos/{repository_id}/analysis-runs/{analysis_run_id}",
|
||||
status_code=303,
|
||||
)
|
||||
|
||||
|
||||
def render_candidate_graph(graph: dict, repository_id: int, analysis_run_id: int) -> str:
|
||||
abilities = graph.get("abilities", [])
|
||||
if not abilities:
|
||||
return '<p class="muted">No candidates generated.</p>'
|
||||
@@ -321,6 +343,7 @@ def render_candidate_graph(graph: dict) -> str:
|
||||
<strong>{escape(ability['name'])}</strong>
|
||||
<span class="pill">{escape(ability['status'])}</span>
|
||||
<span class="pill">{ability['confidence']:.2f}</span>
|
||||
{render_candidate_ability_actions(ability, repository_id, analysis_run_id)}
|
||||
<p class="muted">{escape(ability['description'])}</p>
|
||||
{render_sources(ability['source_refs'])}
|
||||
<ul>{capabilities}</ul>
|
||||
@@ -330,6 +353,24 @@ def render_candidate_graph(graph: dict) -> str:
|
||||
return f'<div class="tree"><ul>{"".join(items)}</ul></div>'
|
||||
|
||||
|
||||
def render_candidate_ability_actions(
|
||||
ability: dict,
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
) -> str:
|
||||
if ability["status"] != "candidate":
|
||||
return ""
|
||||
action = (
|
||||
f"/ui/repos/{repository_id}/analysis-runs/{analysis_run_id}"
|
||||
f"/candidate-abilities/{ability['id']}/reject"
|
||||
)
|
||||
return f"""
|
||||
<form style="display:inline" method="post" action="{action}">
|
||||
<button class="secondary" type="submit">Reject</button>
|
||||
</form>
|
||||
"""
|
||||
|
||||
|
||||
def render_candidate_capability(capability: dict) -> str:
|
||||
features = "".join(
|
||||
f'<li>{escape(feature["name"])} <span class="pill">{escape(feature["type"])}</span> <span class="source">{escape(feature["location"])}</span></li>'
|
||||
|
||||
Reference in New Issue
Block a user