Approval Gate

Inline confirmation card for AI agent actions with risk levels.

python 8 params

Preview

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):
        ...  # write to self.component; the re-render carries it

    @event_handler()
    def approve(self, value=None, **kwargs):
        ...  # write to self.component; the re-render carries it
my_template.html
django
{{ component }}

Events this component sends to the view: reject, approve.

Parameters

NameTypeDefault
messagestr''
riskstr'medium'
approve_eventstr — renames the event; identity is `name`'approve'
reject_eventstr — renames the event; identity is `name`'reject'
approve_labelstr'Approve'
reject_labelstr'Reject'
custom_classstr''
**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
FilePathNotes
moduledjust.components.components.approval_gateSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components-classes.cssDefines 9 of this component's classes at line 700, 702, 705, 706, 711, 712, 713, 714, 715. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_components/components.cssDefines 1 of this component's classes at line 2421. Override those rules, or the custom properties they read, in a stylesheet loaded after it.