137 lines
7.6 KiB
Django/Jinja
137 lines
7.6 KiB
Django/Jinja
{% extends "base.html.jinja" %}
|
|
|
|
{% block content %}
|
|
<section class="max-w-2xl mx-auto px-4 py-12">
|
|
<div class="flex items-center justify-between mb-8">
|
|
<h1 class="text-2xl font-bold">Account Settings</h1>
|
|
<a href="/dashboard" class="text-sm text-gray-500 hover:text-gray-700">← Dashboard</a>
|
|
</div>
|
|
|
|
{% if error %}
|
|
<div class="mb-6 p-3 bg-red-50 border border-red-200 rounded-md text-sm text-red-700">
|
|
{{ error }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# Username #}
|
|
<div class="mb-12">
|
|
<h2 class="text-sm font-semibold text-gray-500 uppercase tracking-wide mb-4">Username</h2>
|
|
<form method="POST" action="/settings/account/username" class="flex gap-2">
|
|
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
|
|
<input type="text" name="username" value="{{ user.username }}"
|
|
class="flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-900">
|
|
<button type="submit" class="px-4 py-2 text-sm bg-gray-900 text-white rounded-md hover:bg-gray-800 whitespace-nowrap">
|
|
Update
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
{# Emails #}
|
|
<div class="mb-12">
|
|
<h2 class="text-sm font-semibold text-gray-500 uppercase tracking-wide mb-4">Email addresses</h2>
|
|
<div class="space-y-2 mb-4">
|
|
{% for email in user.emails %}
|
|
<div class="flex items-center justify-between px-4 py-3 border border-gray-200 rounded-lg">
|
|
<div class="flex items-center gap-2">
|
|
<span class="text-sm text-gray-900">{{ email.email }}</span>
|
|
{% if email.verified %}
|
|
<span class="text-xs text-green-700 bg-green-100 px-1.5 py-0.5 rounded">verified</span>
|
|
{% else %}
|
|
<span class="text-xs text-yellow-700 bg-yellow-100 px-1.5 py-0.5 rounded">unverified</span>
|
|
{% endif %}
|
|
</div>
|
|
<form method="POST" action="/settings/account/emails/remove">
|
|
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
|
|
<input type="hidden" name="email" value="{{ email.email }}">
|
|
<button type="submit" class="text-xs text-red-600 hover:text-red-800">Remove</button>
|
|
</form>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
<form method="POST" action="/settings/account/emails" class="flex gap-2">
|
|
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
|
|
<input type="email" name="email" placeholder="new@example.com"
|
|
class="flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-900">
|
|
<button type="submit" class="px-4 py-2 text-sm bg-gray-900 text-white rounded-md hover:bg-gray-800 whitespace-nowrap">
|
|
Add email
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
{# Change password #}
|
|
<div class="mb-12">
|
|
<h2 class="text-sm font-semibold text-gray-500 uppercase tracking-wide mb-4">Change password</h2>
|
|
<form method="POST" action="/settings/account/password" class="space-y-3">
|
|
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
|
|
<div>
|
|
<label class="block text-sm text-gray-700 mb-1">Current password</label>
|
|
<input type="password" name="current_password" required
|
|
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-900">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm text-gray-700 mb-1">New password</label>
|
|
<input type="password" name="new_password" required
|
|
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-900">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm text-gray-700 mb-1">Confirm new password</label>
|
|
<input type="password" name="new_password_confirm" required
|
|
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-gray-900">
|
|
</div>
|
|
<button type="submit" class="px-4 py-2 text-sm bg-gray-900 text-white rounded-md hover:bg-gray-800">
|
|
Change password
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
{# Notification preferences #}
|
|
<div class="mb-12">
|
|
<h2 class="text-sm font-semibold text-gray-500 uppercase tracking-wide mb-4">Notification preferences</h2>
|
|
<p class="text-sm text-gray-500 mb-4">Choose which events trigger notifications on each channel.</p>
|
|
<div class="border border-gray-200 rounded-lg overflow-hidden">
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr class="bg-gray-50 border-b border-gray-200">
|
|
<th class="text-left px-4 py-3 font-medium text-gray-700">Event</th>
|
|
<th class="text-center px-4 py-3 font-medium text-gray-700 w-24">CLI</th>
|
|
<th class="text-center px-4 py-3 font-medium text-gray-700 w-24">Slack</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
{% set event_types = [
|
|
{"key": "NOTIFICATION_TYPE_RELEASE_ANNOTATED", "label": "Release annotated"},
|
|
{"key": "NOTIFICATION_TYPE_RELEASE_STARTED", "label": "Release started"},
|
|
{"key": "NOTIFICATION_TYPE_RELEASE_SUCCEEDED", "label": "Release succeeded"},
|
|
{"key": "NOTIFICATION_TYPE_RELEASE_FAILED", "label": "Release failed"},
|
|
] %}
|
|
{% set channels = [
|
|
{"key": "NOTIFICATION_CHANNEL_CLI", "label": "CLI"},
|
|
{"key": "NOTIFICATION_CHANNEL_SLACK", "label": "Slack"},
|
|
] %}
|
|
{% for event in event_types %}
|
|
<tr>
|
|
<td class="px-4 py-3 text-gray-700">{{ event.label }}</td>
|
|
{% for ch in channels %}
|
|
{% set pref_key = event.key ~ "|" ~ ch.key %}
|
|
{% set is_enabled = pref_key in enabled_prefs %}
|
|
<td class="text-center px-4 py-3">
|
|
<form method="POST" action="/settings/account/notifications" class="inline">
|
|
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
|
|
<input type="hidden" name="notification_type" value="{{ event.key }}">
|
|
<input type="hidden" name="channel" value="{{ ch.key }}">
|
|
<input type="hidden" name="enabled" value="{{ 'false' if is_enabled else 'true' }}">
|
|
<button type="submit" class="w-8 h-5 rounded-full relative transition-colors {{ 'bg-gray-900' if is_enabled else 'bg-gray-300' }}" title="{{ 'Disable' if is_enabled else 'Enable' }} {{ event.label | lower }} via {{ ch.label }}">
|
|
<span class="block w-3.5 h-3.5 rounded-full bg-white shadow-sm absolute top-0.5 transition-all {{ 'left-[calc(100%-1.125rem)]' if is_enabled else 'left-0.5' }}"></span>
|
|
</button>
|
|
</form>
|
|
</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
{% endblock %}
|