feat(webui): park model credential failures with a recovery link, add Model setup step, readiness badges, and move audit to the organisation
This commit is contained in:
1 parent
2fb0084d2c
commit
1a8b442acd
28 files changed
+131
-61
No files matched your search
@@ -360,14 +360,15 @@ func (q *Queries) SettleAlertDelivery(ctx context.Context, arg SettleAlertDelive
|
||||
}
|
||||
|
||||
const taskAlertInfo = `-- name: TaskAlertInfo :one
|
||||
SELECT org_id, title, workflow, park_class FROM tasks WHERE id = $1
|
||||
SELECT org_id, title, workflow, park_class, park_blocker FROM tasks WHERE id = $1
|
||||
`
|
||||
|
||||
type TaskAlertInfoRow struct {
|
||||
OrgID string
|
||||
Title string
|
||||
Workflow string
|
||||
ParkClass string
|
||||
OrgID string
|
||||
Title string
|
||||
Workflow string
|
||||
ParkClass string
|
||||
ParkBlocker string
|
||||
}
|
||||
|
||||
func (q *Queries) TaskAlertInfo(ctx context.Context, id int64) (TaskAlertInfoRow, error) {
|
||||
@@ -378,6 +379,7 @@ func (q *Queries) TaskAlertInfo(ctx context.Context, id int64) (TaskAlertInfoRow
|
||||
&i.Title,
|
||||
&i.Workflow,
|
||||
&i.ParkClass,
|
||||
&i.ParkBlocker,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
@@ -65,4 +65,4 @@ SELECT id, delivery_id, attempt, at, status_code, error
|
||||
FROM alert_delivery_attempts WHERE delivery_id = ANY(sqlc.arg(delivery_ids)::bigint[]) ORDER BY delivery_id, id;
|
||||
|
||||
-- name: TaskAlertInfo :one
|
||||
SELECT org_id, title, workflow, park_class FROM tasks WHERE id = $1;
|
||||
SELECT org_id, title, workflow, park_class, park_blocker FROM tasks WHERE id = $1;
|
||||
@@ -29,9 +29,11 @@ func recordTransition(ctx context.Context, q *postgresdb.Queries, p postgresdb.I
|
||||
}
|
||||
|
||||
// needsDecision reports whether a task in status, parked with class, is waiting
|
||||
// on an operator's decision.
|
||||
func needsDecision(status, class string) bool {
|
||||
return status == workflow.StatusWaitingApproval || (status == workflow.StatusParked && class == taskstate.ParkNeedsDecision)
|
||||
// on an operator's decision. A park that names a blocker waits on the operator
|
||||
// whatever its class, because only a fix to that setting lets a retry succeed.
|
||||
func needsDecision(status, class, blocker string) bool {
|
||||
return status == workflow.StatusWaitingApproval ||
|
||||
(status == workflow.StatusParked && (class == taskstate.ParkNeedsDecision || blocker != ""))
|
||||
}
|
||||
|
||||
// failed reports whether a task in status, parked with class, will not
|
||||
@@ -63,14 +65,10 @@ func syncTaskAlerts(ctx context.Context, q *postgresdb.Queries, p postgresdb.Ins
|
||||
return alert.Key{Org: org.OrgID(info.OrgID), Kind: kind, Subject: subject}
|
||||
}
|
||||
|
||||
if needsDecision(p.ToStatus, info.ParkClass) {
|
||||
body := name + " is waiting for approval or review."
|
||||
if p.ToStatus == workflow.StatusParked {
|
||||
body = name + " is parked and needs a decision."
|
||||
}
|
||||
if needsDecision(p.ToStatus, info.ParkClass, info.ParkBlocker) {
|
||||
_, err := raiseAlert(ctx, q, alert.Input{
|
||||
Key: key(alert.KindTaskNeedsDecision), Severity: alert.SeverityAction, Condition: true,
|
||||
Title: title, Body: body, Link: link,
|
||||
Title: title, Body: decisionBody(name, p.ToStatus, info.ParkBlocker), Link: link,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -90,6 +88,17 @@ func syncTaskAlerts(ctx context.Context, q *postgresdb.Queries, p postgresdb.Ins
|
||||
return nil
|
||||
}
|
||||
|
||||
// decisionBody says why a task waits on the operator.
|
||||
func decisionBody(name, status, blocker string) string {
|
||||
switch {
|
||||
case status != workflow.StatusParked:
|
||||
return name + " is waiting for approval or review."
|
||||
case blocker != "":
|
||||
return name + " is blocked by a missing setting."
|
||||
}
|
||||
return name + " is parked and needs a decision."
|
||||
}
|
||||
|
||||
// truncate shortens s to at most n runes, marking the cut with an ellipsis.
|
||||
func truncate(s string, n int) string {
|
||||
r := []rune(s)
|
||||
|
||||
Reference in new issue
Block a user