Skip to content

Commit 0849262

Browse files
authored
Merge pull request #24880 from nextcloud/backport/stable19/23017
2 parents 1dc3f0f + fc667af commit 0849262

15 files changed

Lines changed: 96 additions & 28 deletions

File tree

apps/files_sharing/js/dist/files_sharing_tab.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
226226
$sharedWith = $this->userManager->get($share->getSharedWith());
227227
$result['share_with'] = $share->getSharedWith();
228228
$result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
229+
$result['share_with_displayname_unique'] = $sharedWith !== null ? (
230+
$sharedWith->getEMailAddress() !== '' ? $sharedWith->getEMailAddress() : $sharedWith->getUID()
231+
) : $share->getSharedWith();
229232
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
230233
$group = $this->groupManager->get($share->getSharedWith());
231234
$result['share_with'] = $share->getSharedWith();

apps/files_sharing/src/components/SharingEntry.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
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
</div>
3535
<Actions
3636
menu-align="right"
@@ -384,6 +384,9 @@ export default {
384384
p {
385385
color: var(--color-text-maxcontrast);
386386
}
387+
&-unique {
388+
color: var(--color-text-maxcontrast);
389+
}
387390
}
388391
&__actions {
389392
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/components/SharingInput.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,27 @@ export default {
240240
// if there is a condition specified, filter it
241241
const externalResults = this.externalResults.filter(result => !result.condition || result.condition(this))
242242
243-
this.suggestions = exactSuggestions.concat(suggestions).concat(externalResults).concat(lookupEntry)
243+
const allSuggestions = exactSuggestions.concat(suggestions).concat(externalResults).concat(lookupEntry)
244+
245+
// Count occurances of display names in order to provide a distinguishable description if needed
246+
const nameCounts = allSuggestions.reduce((nameCounts, result) => {
247+
if (!result.displayName) {
248+
return nameCounts
249+
}
250+
if (!nameCounts[result.displayName]) {
251+
nameCounts[result.displayName] = 0
252+
}
253+
nameCounts[result.displayName]++
254+
return nameCounts
255+
}, {})
256+
257+
this.suggestions = allSuggestions.map(item => {
258+
// Make sure that items with duplicate displayName get the shareWith applied as a description
259+
if (nameCounts[item.displayName] > 1 && !item.desc) {
260+
return { ...item, desc: item.shareWithDisplayNameUnique }
261+
}
262+
return item
263+
})
244264
245265
this.loading = false
246266
console.info('suggestions', this.suggestions)
@@ -393,6 +413,7 @@ export default {
393413
isNoUser: result.value.shareType !== this.SHARE_TYPES.SHARE_TYPE_USER,
394414
displayName: result.name || result.label,
395415
desc,
416+
shareWithDisplayNameUnique: result.shareWithDisplayNameUnique || '',
396417
icon: this.shareTypeToIcon(result.value.shareType),
397418
}
398419
},

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
@@ -576,6 +576,7 @@ public function dataGetShare() {
576576
'share_type' => \OCP\Share::SHARE_TYPE_USER,
577577
'share_with' => 'userId',
578578
'share_with_displayname' => 'userDisplay',
579+
'share_with_displayname_unique' => 'userId@example.com',
579580
'uid_owner' => 'initiatorId',
580581
'displayname_owner' => 'initiatorDisplay',
581582
'item_type' => 'file',
@@ -773,6 +774,7 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) {
773774
$user = $this->getMockBuilder(IUser::class)->getMock();
774775
$user->method('getUID')->willReturn('userId');
775776
$user->method('getDisplayName')->willReturn('userDisplay');
777+
$user->method('getEMailAddress')->willReturn('userId@example.com');
776778

777779
$group = $this->getMockBuilder('OCP\IGroup')->getMock();
778780
$group->method('getGID')->willReturn('groupId');
@@ -3427,6 +3429,8 @@ public function dataFormatShare() {
34273429
$initiator->method('getDisplayName')->willReturn('initiatorDN');
34283430
$recipient = $this->getMockBuilder(IUser::class)->getMock();
34293431
$recipient->method('getDisplayName')->willReturn('recipientDN');
3432+
$recipient->method('getEmailAddress')->willReturn('recipient');
3433+
34303434

34313435
$result = [];
34323436

@@ -3466,6 +3470,7 @@ public function dataFormatShare() {
34663470
'file_target' => 'myTarget',
34673471
'share_with' => 'recipient',
34683472
'share_with_displayname' => 'recipient',
3473+
'share_with_displayname_unique' => 'recipient',
34693474
'note' => 'personal note',
34703475
'label' => null,
34713476
'mail_send' => 0,
@@ -3502,6 +3507,7 @@ public function dataFormatShare() {
35023507
'file_target' => 'myTarget',
35033508
'share_with' => 'recipient',
35043509
'share_with_displayname' => 'recipientDN',
3510+
'share_with_displayname_unique' => 'recipient',
35053511
'mail_send' => 0,
35063512
'mimetype' => 'myMimeType',
35073513
'has_preview' => false,
@@ -3552,6 +3558,7 @@ public function dataFormatShare() {
35523558
'file_target' => 'myTarget',
35533559
'share_with' => 'recipient',
35543560
'share_with_displayname' => 'recipient',
3561+
'share_with_displayname_unique' => 'recipient',
35553562
'mail_send' => 0,
35563563
'mimetype' => 'myMimeType',
35573564
'has_preview' => false,
@@ -3598,6 +3605,7 @@ public function dataFormatShare() {
35983605
'file_target' => 'myTarget',
35993606
'share_with' => 'recipient',
36003607
'share_with_displayname' => 'recipient',
3608+
'share_with_displayname_unique' => 'recipient',
36013609
'mail_send' => 0,
36023610
'mimetype' => 'myMimeType',
36033611
'has_preview' => false,
@@ -4145,6 +4153,7 @@ public function dataFormatShare() {
41454153
'file_target' => 'myTarget',
41464154
'share_with' => 'recipient',
41474155
'share_with_displayname' => 'recipient',
4156+
'share_with_displayname_unique' => 'recipient',
41484157
'mail_send' => 0,
41494158
'mimetype' => 'mimeWithPreview',
41504159
'has_preview' => true,

0 commit comments

Comments
 (0)