viewer: use permissions info

pull/465/head
Varun Patil 2023-03-09 16:55:18 -08:00
parent 0e5806fddb
commit a553e8f122
1 changed files with 13 additions and 7 deletions

View File

@ -37,7 +37,7 @@
<template #icon> <ShareIcon :size="24" /> </template> <template #icon> <ShareIcon :size="24" /> </template>
</NcActionButton> </NcActionButton>
<NcActionButton <NcActionButton
v-if="!routeIsPublic && !routeIsAlbum" v-if="!routeIsAlbum && canDelete"
:aria-label="t('memories', 'Delete')" :aria-label="t('memories', 'Delete')"
@click="deleteCurrent" @click="deleteCurrent"
:close-after-click="true" :close-after-click="true"
@ -46,7 +46,7 @@
<template #icon> <DeleteIcon :size="24" /> </template> <template #icon> <DeleteIcon :size="24" /> </template>
</NcActionButton> </NcActionButton>
<NcActionButton <NcActionButton
v-if="!routeIsPublic && routeIsAlbum" v-if="routeIsAlbum"
:aria-label="t('memories', 'Remove from album')" :aria-label="t('memories', 'Remove from album')"
@click="deleteCurrent" @click="deleteCurrent"
:close-after-click="true" :close-after-click="true"
@ -77,7 +77,7 @@
</template> </template>
</NcActionButton> </NcActionButton>
<NcActionButton <NcActionButton
v-if="canEdit && !routeIsPublic" v-if="canEdit"
:aria-label="t('memories', 'Edit')" :aria-label="t('memories', 'Edit')"
@click="openEditor" @click="openEditor"
:close-after-click="true" :close-after-click="true"
@ -132,7 +132,7 @@
</NcActionButton> </NcActionButton>
<NcActionButton <NcActionButton
:aria-label="t('memories', 'Edit metadata')" :aria-label="t('memories', 'Edit metadata')"
v-if="!routeIsPublic" v-if="canEdit"
@click="editMetadata" @click="editMetadata"
:close-after-click="true" :close-after-click="true"
> >
@ -334,15 +334,21 @@ export default defineComponent({
: null; : null;
}, },
/** Allow opening editor */ /** Show edit buttons */
canEdit(): boolean { canEdit(): boolean {
return ( return (
this.currentPhoto?.mimetype?.startsWith("image/") && this.currentPhoto?.mimetype?.startsWith("image/") &&
!this.currentPhoto.liveid !this.currentPhoto.liveid &&
this.currentPhoto.imageInfo?.permissions?.includes("U")
); );
}, },
/** Does the browser support native share API */ /** Show delete button */
canDelete(): boolean {
return this.currentPhoto?.imageInfo?.permissions?.includes("D");
},
/** Show share button */
canShare(): boolean { canShare(): boolean {
return "share" in navigator && this.currentPhoto && !this.isVideo; return "share" in navigator && this.currentPhoto && !this.isVideo;
}, },