From 3b923cc56b23b1328c51b2ff9d227696411f5691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:36:15 +0200 Subject: [PATCH] fix: show different message when resource was already shared with the exact search term --- core/js/sharedialogview.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 8b10b3779917..369afe8c8dbe 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -206,6 +206,8 @@ function (result) { $loading.addClass('hidden'); $loading.removeClass('inlineblock'); + var alreadyShared = false; + if (result.ocs.meta.statuscode == 100) { var users = result.ocs.data.exact.users.concat(result.ocs.data.users); var groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups); @@ -249,6 +251,9 @@ for (j = 0; j < usersLength; j++) { if (users[j].value.shareWith === share.share_with) { users.splice(j, 1); + if (trimmedSearch === share.share_with) { + alreadyShared = true; + } break; } } @@ -257,6 +262,9 @@ for (j = 0; j < groupsLength; j++) { if (groups[j].value.shareWith === share.share_with) { groups.splice(j, 1); + if (trimmedSearch === share.share_with) { + alreadyShared = true; + } break; } } @@ -265,6 +273,9 @@ for (j = 0; j < remotesLength; j++) { if (remotes[j].value.shareWith === share.share_with) { remotes.splice(j, 1); + if (trimmedSearch === share.share_with) { + alreadyShared = true; + } break; } } @@ -330,6 +341,12 @@ if (!view.configModel.get('allowGroupSharing')) { title = t('core', 'No users found for {search}', {search: $('.shareWithField').val()}); } + if (alreadyShared) { + title = t('core', 'User or group already shared with.') + if (!view.configModel.get('allowGroupSharing')) { + title = t('core', 'User already shared with.') + } + } var suggestStarts = OC.getCapabilities().files_sharing.search_min_length; if (suggestStarts > $('.shareWithField').val().length) { title = title + '. ' + n(