UI: Add permission checks for labels #98

This commit is contained in:
Timo Volkmann 2021-10-21 11:15:14 +02:00
parent 9f19551adf
commit ab910b6f57
5 changed files with 20 additions and 3 deletions

View file

@ -47,6 +47,7 @@
<v-icon>bookmark</v-icon>
</v-btn>
<v-btn
v-if="hasPermission(aclResources.ResourceLabels, aclActions.ActionDelete)"
fab dark small
color="remove"
:title="$gettext('Delete')"

View file

@ -19,7 +19,7 @@
@save="renameLabel(props.item.Label)"
>
{{ props.item.Label.Name }}
<template #input>
<template v-if="hasPermission(aclResources.ResourceLabels, aclActions.ActionUpdate)" #input>
<v-text-field
v-model="props.item.Label.Name"
:rules="[nameRule]"
@ -40,24 +40,27 @@
<v-icon color="secondary-dark">search</v-icon>
</v-btn>
<v-btn v-else-if="props.item.Uncertainty < 100 && props.item.LabelSrc === 'manual'" icon
:disabled="!hasPermission(aclResources.ResourcePhotos, aclActions.ActionUpdate)"
small flat :ripple="false"
class="action-delete" title="Delete"
@click.stop.prevent="removeLabel(props.item.Label)">
<v-icon color="secondary-dark">delete</v-icon>
</v-btn>
<v-btn v-else-if="props.item.Uncertainty < 100" icon small flat :ripple="false"
:disabled="!hasPermission(aclResources.ResourcePhotos, aclActions.ActionUpdate)"
class="action-remove" title="Remove"
@click.stop.prevent="removeLabel(props.item.Label)">
<v-icon color="secondary-dark">remove</v-icon>
</v-btn>
<v-btn v-else icon small flat :ripple="false"
:disabled="!hasPermission(aclResources.ResourcePhotos, aclActions.ActionUpdate)"
class="action-on" title="Activate"
@click.stop.prevent="activateLabel(props.item.Label)">
<v-icon color="secondary-dark">add</v-icon>
</v-btn>
</td>
</template>
<template v-if="!disabled" #footer>
<template v-if="!disabled && hasPermission(aclResources.ResourcePhotos, aclActions.ActionUpdate) && hasPermission(aclResources.ResourceLabels, aclActions.ActionCreate)" #footer>
<td>
<v-text-field
v-model="newLabel"

View file

@ -115,7 +115,7 @@
<span v-else>
<v-icon>edit</v-icon>
</span>
<template #input>
<template v-if="hasPermission(aclResources.ResourceLabels, aclActions.ActionUpdate)" #input>
<v-text-field
v-model="label.Name"
:rules="[titleRule]"

View file

@ -312,6 +312,15 @@ export default [
path: "/labels",
component: Labels,
meta: { title: $gettext("Labels"), auth: true },
beforeEnter: (to, from, next) => {
if (
hasPermission(aclResources.ResourceLabels, aclActions.ActionSearch, aclActions.ActionRead)
) {
next();
} else {
next({ name: "home" });
}
},
},
{
name: "people",

View file

@ -47,4 +47,8 @@ var Permissions = ACL{
ResourceSettings: Roles{
RoleAdmin: Actions{ActionDefault: true},
},
ResourceLabels: Roles{
RoleAdmin: Actions{ActionDefault: true},
RoleMember: Actions{ActionSearch: true, ActionRead: true},
},
}