guest role; guide section ticking
This commit is contained in:
@@ -225,6 +225,17 @@
|
||||
<p class="text-muted" style="font-size: 0.85rem; margin: 0 0 0.5rem 0">
|
||||
Select which actions this role can perform
|
||||
</p>
|
||||
<!-- The guest role is everyone who is not signed in, so what it may
|
||||
hold is bounded: reads, plus the few writes a plugin has
|
||||
declared safe to do anonymously. The rest are disabled here
|
||||
rather than refused on save, so the limit is visible while the
|
||||
decision is being made. -->
|
||||
<p v-if="editingRole?.isguest" class="guest-note">
|
||||
This role is <strong>everyone who is not signed in</strong>.
|
||||
Anything ticked here is readable by anybody who can reach this
|
||||
site, with no account and no name in the audit log. Greyed-out
|
||||
permissions cannot be given to guests at all.
|
||||
</p>
|
||||
<div class="permissions-grid">
|
||||
<div v-for="(perms, category) in permissionsGrouped" :key="category" class="permission-category">
|
||||
<div class="category-header">
|
||||
@@ -239,10 +250,14 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="category-perms">
|
||||
<label v-for="p in perms" :key="p.name" class="checkbox-label perm-item">
|
||||
<label v-for="p in perms" :key="p.name" class="checkbox-label perm-item"
|
||||
:class="{ 'perm-blocked': !mayGrant(p.name) }"
|
||||
:title="mayGrant(p.name) ? null
|
||||
: 'A guest cannot be given this. Reading is grantable; a write has to be declared safe to do without an account.'">
|
||||
<input
|
||||
type="checkbox"
|
||||
:value="p.name"
|
||||
:disabled="!mayGrant(p.name)"
|
||||
v-model="roleForm.permissions"
|
||||
>
|
||||
{{ p.description }}
|
||||
@@ -382,19 +397,33 @@ function formatCategory(cat) {
|
||||
return cat.charAt(0).toUpperCase() + cat.slice(1)
|
||||
}
|
||||
|
||||
// Which permissions this role is allowed to hold at all. Only the guest role
|
||||
// is bounded; the API sends the list it will accept, so the grid and the server
|
||||
// cannot disagree about it.
|
||||
function mayGrant(name) {
|
||||
if (!editingRole.value?.isguest) return true
|
||||
const grantable = editingRole.value?.grantable
|
||||
return Array.isArray(grantable) ? grantable.includes(name) : false
|
||||
}
|
||||
|
||||
function isCategoryFullySelected(category) {
|
||||
const catPerms = permissionsGrouped.value[category] || []
|
||||
const catPerms = (permissionsGrouped.value[category] || [])
|
||||
.filter(p => mayGrant(p.name))
|
||||
return catPerms.length > 0 && catPerms.every(p => roleForm.permissions.includes(p.name))
|
||||
}
|
||||
|
||||
function isCategoryPartiallySelected(category) {
|
||||
const catPerms = permissionsGrouped.value[category] || []
|
||||
const catPerms = (permissionsGrouped.value[category] || [])
|
||||
.filter(p => mayGrant(p.name))
|
||||
const selected = catPerms.filter(p => roleForm.permissions.includes(p.name))
|
||||
return selected.length > 0 && selected.length < catPerms.length
|
||||
}
|
||||
|
||||
function toggleCategory(category, checked) {
|
||||
const catPerms = permissionsGrouped.value[category] || []
|
||||
// Ticking a whole category must not try to grant a guest something the API
|
||||
// will refuse - the header checkbox would then look broken.
|
||||
const catPerms = (permissionsGrouped.value[category] || [])
|
||||
.filter(p => mayGrant(p.name))
|
||||
const permNames = catPerms.map(p => p.name)
|
||||
|
||||
if (checked) {
|
||||
@@ -780,4 +809,13 @@ onMounted(loadData)
|
||||
font-size: 0.85rem;
|
||||
padding: 0.25rem 0;
|
||||
}
|
||||
|
||||
.perm-blocked { opacity: 0.45; cursor: not-allowed; }
|
||||
.guest-note {
|
||||
font-size: 0.85rem;
|
||||
color: var(--warning);
|
||||
border-left: 3px solid var(--warning);
|
||||
padding-left: 0.6rem;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user