Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<!-- org, title -->
<template #subtitle>
<template v-if="isReadOnly">
<span v-html="formattedSubtitle" />

Check warning on line 51 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'v-html' directive can lead to XSS attack
</template>
<template v-else>
<input id="contact-title"
Expand Down Expand Up @@ -88,7 +88,7 @@
<IconAccount :size="20" />
</template>
</ActionButton>
<ActionLink v-for="emailAddress in emailAddressList"

Check warning on line 91 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Variable 'emailAddress' is already declared in the upper scope
:key="emailAddress"
class="quick-action"
:href="'mailto:' + emailAddress">
Expand Down Expand Up @@ -143,7 +143,7 @@
@click="updateContact" />

<!-- edit and save buttons -->
<template v-if="!addressbookIsReadOnly">
<template v-if="canModifyCard">
<NcButton v-if="!editMode"
:type="isMobile ? 'secondary' : 'tertiary'"
@click="editMode = true">
Expand Down Expand Up @@ -197,7 +197,7 @@
</template>
{{ excludeFromBirthdayLabel }}
</ActionButton>
<ActionButton v-if="!addressbookIsReadOnly"
<ActionButton v-if="canDeleteCard"
@click="deleteContact">
<template #icon>
<IconDelete :size="20" />
Expand Down Expand Up @@ -526,12 +526,20 @@
return this.hasFilesResources || this.hasTalkResources || this.hasCalendarResources || this.hasDeckResources
},
/**
* The address book is read-only (e.g. shared with me).
* True if the contact is in the system address book
*
* @return {boolean}
*/
addressbookIsReadOnly() {
return this.contact.addressbook?.readOnly
canModifyCard() {
return this.contact.addressbook?.canModifyCard
},
/**
* True if the contact is in the system address book
*
* @return {boolean}
*/
canDeleteCard() {
return this.contact.addressbook?.canDeleteCard
},

/**
Expand All @@ -540,7 +548,7 @@
* @return {boolean}
*/
isReadOnly() {
return this.addressbookIsReadOnly || !this.editMode
return !this.canModifyCard || !this.editMode
},

isDataValid() {
Expand All @@ -553,7 +561,7 @@
* @return {object | boolean}
*/
warning() {
if (this.addressbookIsReadOnly) {
if (this.canModifyCard === false) {
return {
icon: EyeCircleIcon,
classes: [],
Expand Down Expand Up @@ -991,7 +999,7 @@
/**
* Update this.localContact and set this.fixed
*
* @param {Contact} contact the contact to clone

Check warning on line 1002 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'Contact' is undefined
*/
async updateLocalContact(contact) {
// create empty contact and copy inner data
Expand Down Expand Up @@ -1042,7 +1050,7 @@
/**
* Should display the property
*
* @param {Property} property the property to check

Check warning on line 1053 in src/components/ContactDetails.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'Property' is undefined
* @return {boolean}
*/
canDisplay(property) {
Expand Down
7 changes: 7 additions & 0 deletions src/store/addressbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const addressbookModel = {
contacts: {},
url: '',
readOnly: false,
canCreateCard: false,
canModifyCard: false,
canDeleteCard: false,
writeProps: false,
dav: false,
}

Expand All @@ -44,6 +48,9 @@ export function mapDavCollectionToAddressbook(addressbook) {
owner: addressbook.owner,
readOnly: addressbook.readOnly === true,
writeProps: addressbook.currentUserPrivilegeSet.includes('{DAV:}write-properties') === true,
canCreateCard: addressbook.currentUserPrivilegeSet.includes('{DAV:}bind') || addressbook.currentUserPrivilegeSet.includes('{DAV:}write') || addressbook.currentUserPrivilegeSet.includes('{DAV:}all') === true,
canModifyCard: addressbook.currentUserPrivilegeSet.includes('{DAV:}write-content') || addressbook.currentUserPrivilegeSet.includes('{DAV:}write') || addressbook.currentUserPrivilegeSet.includes('{DAV:}all') === true,
canDeleteCard: addressbook.currentUserPrivilegeSet.includes('{DAV:}unbind') || addressbook.currentUserPrivilegeSet.includes('{DAV:}write') || addressbook.currentUserPrivilegeSet.includes('{DAV:}all') === true,
url: addressbook.url,
dav: addressbook,
shares: addressbook.shares
Expand Down
Loading