Approval Gate
Inline confirmation card for AI agent actions with risk levels.
Preview
Medium Risk
Usage
views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import ApprovalGate
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = ApprovalGate()
@event_handler()
def reject(self, value=None, **kwargs):
pass # your app acts on 'reject'; no component state moves
@event_handler()
def approve(self, value=None, **kwargs):
pass # your app acts on 'approve'; no component state movesmy_template.html
django
{{ component }}Events this component sends to the view: reject, approve.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| message | str | '' | Description of the action requiring approval |
| risk | str | 'medium' | Risk level (low, medium, high, critical) |
| approve_event | str — renames the event; identity is `name` | 'approve' | djust event fired on approval |
| reject_event | str — renames the event; identity is `name` | 'reject' | djust event fired on rejection |
| approve_label | str | 'Approve' | Label for approve button (default: "Approve") |
| reject_label | str | 'Reject' | Label for reject button (default: "Reject") |
| custom_class | str | '' | Additional CSS classes |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.approval_gate | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components-classes.css | Defines 9 of this component's classes at line 702, 704, 707, 708, 713, 714, 715, 716, 717. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_components/components.css | Defines 1 of this component's classes at line 2524. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |