Skip to content

Commit bcae605

Browse files
committed
Show unique displayname context in the user share list entries
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 5712d59 commit bcae605

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-2
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
235235
$sharedWith = $this->userManager->get($share->getSharedWith());
236236
$result['share_with'] = $share->getSharedWith();
237237
$result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
238+
$result['share_with_displayname_unique'] = $sharedWith !== null ? (
239+
$sharedWith->getEMailAddress() !== '' ? $sharedWith->getEMailAddress() : $sharedWith->getUID()
240+
) : $share->getSharedWith();
238241
$result['status'] = [];
239242

240243
$userStatuses = $this->userStatusManager->getUserStatuses([$share->getSharedWith()]);

apps/files_sharing/src/components/SharingEntry.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
:is-no-user="share.type !== SHARE_TYPES.SHARE_TYPE_USER"
2727
:user="share.shareWith"
2828
:display-name="share.shareWithDisplayName"
29-
:tooltip-message="share.type === SHARE_TYPES.SHARE_TYPE_USER ? share.shareWith : ''"
29+
:tooltip-message="''"
3030
:menu-position="'left'"
3131
:url="share.shareWithAvatar" />
3232
<div v-tooltip.auto="tooltip" class="sharing-entry__desc">
33-
<h5>{{ title }}</h5>
33+
<h5>{{ title }}<span v-if="!isUnique" class="sharing-entry__desc-unique"> ({{ share.shareWithDisplayNameUnique }})</span></h5>
3434
<p v-if="hasStatus">
3535
<span>{{ share.status.icon || '' }}</span>
3636
<span>{{ share.status.message || '' }}</span>
@@ -398,6 +398,9 @@ export default {
398398
p {
399399
color: var(--color-text-maxcontrast);
400400
}
401+
&-unique {
402+
color: var(--color-text-maxcontrast);
403+
}
401404
}
402405
&__actions {
403406
margin-left: auto;

apps/files_sharing/src/components/SharingEntrySimple.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default {
6464
type: String,
6565
default: '',
6666
},
67+
isUnique: {
68+
type: Boolean,
69+
default: true,
70+
},
6771
},
6872
6973
}

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export default {
4242
type: Share,
4343
default: null,
4444
},
45+
isUnique: {
46+
type: Boolean,
47+
default: true,
48+
},
4549
},
4650

4751
data() {

apps/files_sharing/src/models/Share.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ export default class Share {
150150
|| this.#share.share_with
151151
}
152152

153+
get shareWithDisplayNameUnique() {
154+
return this.#share.share_with_displayname_unique || this.#share.share_with
155+
}
156+
153157
/**
154158
* Get the share with avatar if any
155159
*

apps/files_sharing/src/views/SharingList.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
:key="share.id"
2727
:file-info="fileInfo"
2828
:share="share"
29+
:is-unique="isUnique(share)"
2930
@remove:share="removeShare" />
3031
</ul>
3132
</template>
@@ -34,6 +35,7 @@
3435
// eslint-disable-next-line no-unused-vars
3536
import Share from '../models/Share'
3637
import SharingEntry from '../components/SharingEntry'
38+
import ShareTypes from '../mixins/ShareTypes'
3739
3840
export default {
3941
name: 'SharingList',
@@ -42,6 +44,8 @@ export default {
4244
SharingEntry,
4345
},
4446
47+
mixins: [ShareTypes],
48+
4549
props: {
4650
fileInfo: {
4751
type: Object,
@@ -59,6 +63,13 @@ export default {
5963
hasShares() {
6064
return this.shares.length === 0
6165
},
66+
isUnique() {
67+
return (share) => {
68+
return [...this.shares].filter((item) => {
69+
return share.type === this.SHARE_TYPES.SHARE_TYPE_USER && share.shareWithDisplayName === item.shareWithDisplayName
70+
}).length <= 1
71+
}
72+
},
6273
},
6374
6475
methods: {

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ public function dataGetShare() {
583583
'share_type' => IShare::TYPE_USER,
584584
'share_with' => 'userId',
585585
'share_with_displayname' => 'userDisplay',
586+
'share_with_displayname_unique' => 'userId@example.com',
586587
'uid_owner' => 'initiatorId',
587588
'displayname_owner' => 'initiatorDisplay',
588589
'item_type' => 'file',
@@ -782,6 +783,7 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) {
782783
$user = $this->getMockBuilder(IUser::class)->getMock();
783784
$user->method('getUID')->willReturn('userId');
784785
$user->method('getDisplayName')->willReturn('userDisplay');
786+
$user->method('getEMailAddress')->willReturn('userId@example.com');
785787

786788
$group = $this->getMockBuilder('OCP\IGroup')->getMock();
787789
$group->method('getGID')->willReturn('groupId');
@@ -3440,6 +3442,8 @@ public function dataFormatShare() {
34403442
$initiator->method('getDisplayName')->willReturn('initiatorDN');
34413443
$recipient = $this->getMockBuilder(IUser::class)->getMock();
34423444
$recipient->method('getDisplayName')->willReturn('recipientDN');
3445+
$recipient->method('getEmailAddress')->willReturn('recipient');
3446+
34433447

34443448
$result = [];
34453449

@@ -3479,6 +3483,7 @@ public function dataFormatShare() {
34793483
'file_target' => 'myTarget',
34803484
'share_with' => 'recipient',
34813485
'share_with_displayname' => 'recipient',
3486+
'share_with_displayname_unique' => 'recipient',
34823487
'note' => 'personal note',
34833488
'label' => null,
34843489
'mail_send' => 0,
@@ -3516,6 +3521,7 @@ public function dataFormatShare() {
35163521
'file_target' => 'myTarget',
35173522
'share_with' => 'recipient',
35183523
'share_with_displayname' => 'recipientDN',
3524+
'share_with_displayname_unique' => 'recipient',
35193525
'mail_send' => 0,
35203526
'mimetype' => 'myMimeType',
35213527
'has_preview' => false,
@@ -3567,6 +3573,7 @@ public function dataFormatShare() {
35673573
'file_target' => 'myTarget',
35683574
'share_with' => 'recipient',
35693575
'share_with_displayname' => 'recipient',
3576+
'share_with_displayname_unique' => 'recipient',
35703577
'mail_send' => 0,
35713578
'mimetype' => 'myMimeType',
35723579
'has_preview' => false,
@@ -3614,6 +3621,7 @@ public function dataFormatShare() {
36143621
'file_target' => 'myTarget',
36153622
'share_with' => 'recipient',
36163623
'share_with_displayname' => 'recipient',
3624+
'share_with_displayname_unique' => 'recipient',
36173625
'mail_send' => 0,
36183626
'mimetype' => 'myMimeType',
36193627
'has_preview' => false,
@@ -4162,6 +4170,7 @@ public function dataFormatShare() {
41624170
'file_target' => 'myTarget',
41634171
'share_with' => 'recipient',
41644172
'share_with_displayname' => 'recipient',
4173+
'share_with_displayname_unique' => 'recipient',
41654174
'mail_send' => 0,
41664175
'mimetype' => 'mimeWithPreview',
41674176
'has_preview' => true,

0 commit comments

Comments
 (0)