Skip to content

Commit

Permalink
Merge pull request #604 from nextcloud/enh/stable-1.6-avoid-guest-cre…
Browse files Browse the repository at this point in the history
…ation-for-existing-email

[Backport] Avoid guest creation modal if a user is suggested in the share search
  • Loading branch information
juliushaertl committed May 11, 2021
2 parents d9bca90 + 48732dc commit f16ee93
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
},
"dependencies": {
"@nextcloud/axios": "^1.5.0",
"@nextcloud/dialogs": "^3.1.2",
"@nextcloud/router": "^1.2.0",
"@nextcloud/vue": "^3.3.1",
"deep-equal": "^2.0.5",
Expand Down
11 changes: 10 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Vue from 'vue'

import GuestForm from './views/GuestForm.vue'
import Nextcloud from './mixins/Nextcloud'
import { showError } from '@nextcloud/dialogs'

Vue.mixin(Nextcloud)

Expand All @@ -25,7 +26,15 @@ const result = {
icon: 'icon-guests',
displayName: t('guests', 'Invite guest'),
handler: async self => {
return guestForm.populate(self.fileInfo, self.query)
const user = self.suggestions.find(s => s.isNoUser === false && s.shareType === 0)
return new Promise((resolve, reject) => {
if (user) {
showError(t('guests', 'A user with this ID or email address already exists'))
reject(new Error('Impossible to create guest, a user with this ID or email address already exists'))
} else {
resolve(guestForm.populate(self.fileInfo, self.query))
}
})
},
condition: self => {
return validate(self.query)
Expand Down

0 comments on commit f16ee93

Please sign in to comment.