Skip to content

Commit

Permalink
Show unique displayname context in the user share list entries
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Oct 7, 2020
1 parent 46afa77 commit 7d52b9a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
$sharedWith = $this->userManager->get($share->getSharedWith());
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
$result['share_with_displayname_unique'] = $sharedWith->getEMailAddress() && $sharedWith->getEMailAddress() !== '' ? $sharedWith->getEMailAddress() : $sharedWith->getUID();
$result['status'] = [];

$userStatuses = $this->userStatusManager->getUserStatuses([$share->getSharedWith()]);
Expand Down
7 changes: 5 additions & 2 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
:is-no-user="share.type !== SHARE_TYPES.SHARE_TYPE_USER"
:user="share.shareWith"
:display-name="share.shareWithDisplayName"
:tooltip-message="share.type === SHARE_TYPES.SHARE_TYPE_USER ? share.shareWith : ''"
:tooltip-message="''"
:menu-position="'left'"
:url="share.shareWithAvatar" />
<div v-tooltip.auto="tooltip" class="sharing-entry__desc">
<h5>{{ title }}</h5>
<h5>{{ title }}<span v-if="!isUnique" class="sharing-entry__desc-unique"> ({{ share.shareWithDisplayNameUnique }})</span></h5>
<p v-if="hasStatus">
<span>{{ share.status.icon || '' }}</span>
<span>{{ share.status.message || '' }}</span>
Expand Down Expand Up @@ -398,6 +398,9 @@ export default {
p {
color: var(--color-text-maxcontrast);
}
&-unique {
color: var(--color-text-maxcontrast);
}
}
&__actions {
margin-left: auto;
Expand Down
4 changes: 4 additions & 0 deletions apps/files_sharing/src/components/SharingEntrySimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export default {
type: String,
default: '',
},
isUnique: {
type: Boolean,
default: true,
},
},
}
Expand Down
4 changes: 4 additions & 0 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default {
type: Share,
default: null,
},
isUnique: {
type: Boolean,
default: true,
},
},

data() {
Expand Down
4 changes: 4 additions & 0 deletions apps/files_sharing/src/models/Share.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export default class Share {
|| this.#share.share_with
}

get shareWithDisplayNameUnique() {
return this.#share.share_with_displayname_unique || this.#share.share_with
}

/**
* Get the share with avatar if any
*
Expand Down
11 changes: 11 additions & 0 deletions apps/files_sharing/src/views/SharingList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
:key="share.id"
:file-info="fileInfo"
:share="share"
:is-unique="isUnique(share)"
@remove:share="removeShare" />
</ul>
</template>
Expand All @@ -34,6 +35,7 @@
// eslint-disable-next-line no-unused-vars
import Share from '../models/Share'
import SharingEntry from '../components/SharingEntry'
import ShareTypes from '../mixins/ShareTypes'
export default {
name: 'SharingList',
Expand All @@ -42,6 +44,8 @@ export default {
SharingEntry,
},
mixins: [ShareTypes],
props: {
fileInfo: {
type: Object,
Expand All @@ -59,6 +63,13 @@ export default {
hasShares() {
return this.shares.length === 0
},
isUnique() {
return (share) => {
return [...this.shares].filter((item) => {
return share.type === this.SHARE_TYPES.SHARE_TYPE_USER && share.shareWithDisplayName === item.shareWithDisplayName
}).length <= 1
}
},
},
methods: {
Expand Down

0 comments on commit 7d52b9a

Please sign in to comment.