1.9 KiB · text History e0979f3
{# A cooldown/suspend dropdown. `action` cooldown|suspend, `label`, `target`
   the user id, `post_id` set when acting from the queue (the answer is the
   queue item, `#flags-<post>`), else the user (`#user-<id>`); `mode`,
   `durations` (suspensions), `cooldowns`. #}
{% set swap_target = ("#flags-" ~ post_id) if post_id else ("#user-" ~ target) %}
{% set cooldown = action == 'cooldown' %}
<details class="dropdown">
  <summary class="btn btn-ghost btn-xs list-none {% if cooldown %}text-warning{% else %}text-error{% endif %}">{{ label }}…</summary>
  <form hx-post="/admin/users/{{ target }}/{{ action }}" hx-target="{{ swap_target }}" hx-select="unset" hx-swap="outerHTML"
        class="dropdown-content z-20 mt-1 w-64 space-y-2 rounded-box border border-base-300 bg-base-100 p-3 shadow-lg">
    <input type="hidden" name="mode" value="{{ mode }}">
    {% if post_id %}<input type="hidden" name="post" value="{{ post_id }}">{% endif %}
    <p class="text-xs opacity-70">{% if cooldown %}Read-only for a while (at most 90 days): can read; can't post, reply, react or flag.{% else %}Can't sign in; signed out of every browser and device now.{% endif %}</p>
    <input name="reason" class="input input-bordered input-xs w-full" placeholder="Reason (they see it)" {% if cooldown %}required{% endif %}>
    <select name="duration" class="select select-bordered select-xs w-full">
      {% for v, l in (cooldowns if cooldown else durations) %}<option value="{{ v }}" {% if v == "168h" %}selected{% endif %}>{{ l }}</option>{% endfor %}
    </select>
    {% if cooldown %}<input name="custom" class="input input-bordered input-xs w-full" placeholder="Custom: 12h, 5d, 2w (≤ 90 days)" pattern="\s*[0-9]+\s*[hdw]\s*" title="A number then h, d or w">{% endif %}
    <div class="flex justify-end"><button class="btn btn-xs {% if cooldown %}btn-warning{% else %}btn-error{% endif %}" type="submit">{{ label }}</button></div>
  </form>
</details>