High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
{{ define "admin-roles" -}}
{{ template "admin-header" . }}
{{ template "breadcrumbs" dict "Root" . "Current" .Data.Title "Parents" (list (dict "Label" (.L.T "globals.terms.users") "URL" (URI "/admin/users") "CanLink" (.Data.Can "users:get"))) }}
{{- $d := .Data -}}
{{- $base := URI "/admin/users/roles" -}}
{{- if eq $d.Type "list" }}{{ $base = URI "/admin/users/roles/lists" }}{{ end -}}
<section class="roles" x-data="rolesView({ type: {{ ToJSON $d.Type }} })">
<header class="row page-header">
<div class="col-4">
<div class="hstack">
<h1 class="page-title">
{{ if eq $d.Type "list" }}{{ .L.T "users.listRoles" }}{{ else }}{{ .L.T "users.userRoles" }}{{ end }}
<span>({{ len $d.Roles }})</span>
</h1>
</div>
</div>
<div class="col-8 hstack justify-end buttons">
<form method="get" action="{{ $base }}" class="search-form">
{{- $d.Page.FormFields "query" -}}
<fieldset class="group">
<input name="query" aria-label="{{ .L.T "globals.buttons.search" }}" data-testid="query" placeholder="{{ .L.T "globals.buttons.search" }}" value="{{ $d.Page.Query }}" autofocus />
<button type="submit" class="outline external" data-testid="btn-query" aria-label="{{ .L.T "globals.buttons.search" }}">{{ Icon "search" }}</button>
</fieldset>
</form>
{{- if $d.Can "roles:manage" }}
<a href="{{ $base }}/new" class="button" data-variant="primary" data-testid="btn-new">
{{ Icon "plus" }} {{ .L.T "globals.buttons.new" }}
</a>
{{- end }}
</div>
</header>
<div class="card page-content has-table">
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>{{ $d.Page.SortLink $base "name" (.L.Tc "globals.terms.role" 1) }}</th>
<th>{{ $d.Page.SortLink $base "created_at" (.L.T "globals.fields.createdAt") }}</th>
<th>{{ $d.Page.SortLink $base "updated_at" (.L.T "globals.fields.updatedAt") }}</th>
<th class="actions align-right"></th>
</tr>
</thead>
<tbody>
{{- range $d.Roles }}
<tr data-testid="role-row" data-id="{{ .ID }}">
<td>
<div class="avatar">
{{ template "avatar-icon" dict "Kind" (printf "%s-role" $d.Type) "Name" .Name "Href" (printf "%s/%d" $base .ID) "Title" (printf "%s %s" ($.L.T "globals.buttons.view") .Name) }}
<a href="{{ $base }}/{{ .ID }}" class="avatar-label unstyled" {{ if eq .ID 1 }}style="font-weight: bold"{{ end}}>
{{ .Name }}
</a>
</div>
</td>
<td class="date-stack" data-label="{{ $.L.T "globals.fields.createdAt" }}">{{ NiceDate .CreatedAt }}</td>
<td class="date-stack" data-label="{{ $.L.T "globals.fields.updatedAt" }}">{{ NiceDate .UpdatedAt }}</td>
<td class="actions align-right">
{{- if $d.Can "roles:manage" }}
<ot-dropdown>
<button popovertarget="role-actions-{{ .ID }}" type="button" class="ghost more icon" aria-label="{{ $.L.T "globals.buttons.more" }}">
{{ Icon "more-vertical" }}
</button>
<menu popover id="role-actions-{{ .ID }}">
<a href="{{ $base }}/{{ .ID }}" role="menuitem" class="button ghost" data-testid="btn-edit">{{ Icon "edit-2" }} {{ $.L.T "globals.buttons.edit" }}</a>
<button type="button" role="menuitem" class="ghost" data-testid="btn-clone" :disabled="isLoading('roles')" @click.prevent="onCloneRole({{ .ID }}, {{ ToJSON .Name }})">{{ Icon "copy" }} {{ $.L.T "globals.buttons.clone" }}</button>
{{- if ne .ID 1 }}
<button type="button" role="menuitem" class="ghost" data-variant="danger" data-testid="btn-delete" :disabled="isLoading('roles')" @click.prevent="onDeleteRole({{ .ID }}, {{ ToJSON .Name }})">{{ Icon "trash-2" }} {{ $.L.T "globals.buttons.delete" }}</button>
{{- end }}
</menu>
</ot-dropdown>
{{- end }}
</td>
</tr>
{{- else }}
{{ template "empty-state" 4 }}
{{- end }}
</tbody>
</table>
</div>
</div>
</section>
<script type="module" src="{{ URI "/admin/static/js/views/roles.js" }}?v={{ .AssetVersion }}" defer></script>
{{ template "admin-footer" . -}}
{{ end }}