aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-10-07 12:32:16 +0200
committerJulius Härtl <jus@bitgrid.net>2021-01-05 10:06:32 +0100
commit0d0cc44ccd59c816f1d1c79807fafe7b8d82b011 (patch)
tree660d8b12e6cf3b5d7a8aabcd78745c0cb09b5068
parentd77b3345b2ce435f219881417014b75c5a65b381 (diff)
downloadnextcloud-server-0d0cc44ccd59c816f1d1c79807fafe7b8d82b011.tar.gz
nextcloud-server-0d0cc44ccd59c816f1d1c79807fafe7b8d82b011.zip
Show unique displayname context in the user share list entries
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php3
-rw-r--r--apps/files_sharing/src/components/SharingEntry.vue5
-rw-r--r--apps/files_sharing/src/components/SharingEntrySimple.vue4
-rw-r--r--apps/files_sharing/src/mixins/SharesMixin.js4
-rw-r--r--apps/files_sharing/src/models/Share.js4
-rw-r--r--apps/files_sharing/src/views/SharingList.vue11
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php9
7 files changed, 39 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index cdbacafb751..3ae9d4bd492 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -226,6 +226,9 @@ class ShareAPIController extends OCSController {
$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 !== null ? (
+ $sharedWith->getEMailAddress() !== '' ? $sharedWith->getEMailAddress() : $sharedWith->getUID()
+ ) : $share->getSharedWith();
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$group = $this->groupManager->get($share->getSharedWith());
$result['share_with'] = $share->getSharedWith();
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue
index e08c4facc9f..7a422bfbe00 100644
--- a/apps/files_sharing/src/components/SharingEntry.vue
+++ b/apps/files_sharing/src/components/SharingEntry.vue
@@ -30,7 +30,7 @@
: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>
</div>
<Actions
menu-align="right"
@@ -384,6 +384,9 @@ export default {
p {
color: var(--color-text-maxcontrast);
}
+ &-unique {
+ color: var(--color-text-maxcontrast);
+ }
}
&__actions {
margin-left: auto;
diff --git a/apps/files_sharing/src/components/SharingEntrySimple.vue b/apps/files_sharing/src/components/SharingEntrySimple.vue
index 5cdce17bf0c..de545a497a8 100644
--- a/apps/files_sharing/src/components/SharingEntrySimple.vue
+++ b/apps/files_sharing/src/components/SharingEntrySimple.vue
@@ -64,6 +64,10 @@ export default {
type: String,
default: '',
},
+ isUnique: {
+ type: Boolean,
+ default: true,
+ },
},
}
diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js
index 6bcf9fc79f7..e5f6a88d8b7 100644
--- a/apps/files_sharing/src/mixins/SharesMixin.js
+++ b/apps/files_sharing/src/mixins/SharesMixin.js
@@ -42,6 +42,10 @@ export default {
type: Share,
default: null,
},
+ isUnique: {
+ type: Boolean,
+ default: true,
+ },
},
data() {
diff --git a/apps/files_sharing/src/models/Share.js b/apps/files_sharing/src/models/Share.js
index 92ea314071f..eb406a6015c 100644
--- a/apps/files_sharing/src/models/Share.js
+++ b/apps/files_sharing/src/models/Share.js
@@ -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
*
diff --git a/apps/files_sharing/src/views/SharingList.vue b/apps/files_sharing/src/views/SharingList.vue
index b8f12f6ef15..5c2a21c8bf8 100644
--- a/apps/files_sharing/src/views/SharingList.vue
+++ b/apps/files_sharing/src/views/SharingList.vue
@@ -26,6 +26,7 @@
:key="share.id"
:file-info="fileInfo"
:share="share"
+ :is-unique="isUnique(share)"
@remove:share="removeShare" />
</ul>
</template>
@@ -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',
@@ -42,6 +44,8 @@ export default {
SharingEntry,
},
+ mixins: [ShareTypes],
+
props: {
fileInfo: {
type: Object,
@@ -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: {
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 69b3166effc..ca66006a417 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -576,6 +576,7 @@ class ShareAPIControllerTest extends TestCase {
'share_type' => \OCP\Share::SHARE_TYPE_USER,
'share_with' => 'userId',
'share_with_displayname' => 'userDisplay',
+ 'share_with_displayname_unique' => 'userId@example.com',
'uid_owner' => 'initiatorId',
'displayname_owner' => 'initiatorDisplay',
'item_type' => 'file',
@@ -773,6 +774,7 @@ class ShareAPIControllerTest extends TestCase {
$user = $this->getMockBuilder(IUser::class)->getMock();
$user->method('getUID')->willReturn('userId');
$user->method('getDisplayName')->willReturn('userDisplay');
+ $user->method('getEMailAddress')->willReturn('userId@example.com');
$group = $this->getMockBuilder('OCP\IGroup')->getMock();
$group->method('getGID')->willReturn('groupId');
@@ -3427,6 +3429,8 @@ class ShareAPIControllerTest extends TestCase {
$initiator->method('getDisplayName')->willReturn('initiatorDN');
$recipient = $this->getMockBuilder(IUser::class)->getMock();
$recipient->method('getDisplayName')->willReturn('recipientDN');
+ $recipient->method('getEmailAddress')->willReturn('recipient');
+
$result = [];
@@ -3466,6 +3470,7 @@ class ShareAPIControllerTest extends TestCase {
'file_target' => 'myTarget',
'share_with' => 'recipient',
'share_with_displayname' => 'recipient',
+ 'share_with_displayname_unique' => 'recipient',
'note' => 'personal note',
'label' => null,
'mail_send' => 0,
@@ -3502,6 +3507,7 @@ class ShareAPIControllerTest extends TestCase {
'file_target' => 'myTarget',
'share_with' => 'recipient',
'share_with_displayname' => 'recipientDN',
+ 'share_with_displayname_unique' => 'recipient',
'mail_send' => 0,
'mimetype' => 'myMimeType',
'has_preview' => false,
@@ -3552,6 +3558,7 @@ class ShareAPIControllerTest extends TestCase {
'file_target' => 'myTarget',
'share_with' => 'recipient',
'share_with_displayname' => 'recipient',
+ 'share_with_displayname_unique' => 'recipient',
'mail_send' => 0,
'mimetype' => 'myMimeType',
'has_preview' => false,
@@ -3598,6 +3605,7 @@ class ShareAPIControllerTest extends TestCase {
'file_target' => 'myTarget',
'share_with' => 'recipient',
'share_with_displayname' => 'recipient',
+ 'share_with_displayname_unique' => 'recipient',
'mail_send' => 0,
'mimetype' => 'myMimeType',
'has_preview' => false,
@@ -4145,6 +4153,7 @@ class ShareAPIControllerTest extends TestCase {
'file_target' => 'myTarget',
'share_with' => 'recipient',
'share_with_displayname' => 'recipient',
+ 'share_with_displayname_unique' => 'recipient',
'mail_send' => 0,
'mimetype' => 'mimeWithPreview',
'has_preview' => true,