From ca8ba6dabe206f492ff866aac3480edab627c601 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Tue, 5 Sep 2017 17:18:26 +0100 Subject: [PATCH 1/5] Fix incorrect checking of contact name --- .../ide/share/controllers/ShareProjectModalController.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee index 86588d54b2..5ede187dce 100644 --- a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee +++ b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee @@ -39,7 +39,7 @@ define [ $scope.autocompleteContacts = data.contacts or [] for contact in $scope.autocompleteContacts if contact.type == "user" - if contact.last_name == "" and contact.first_name = contact.email.split("@")[0] + if contact.last_name and contact.first_name == contact.email.split("@")[0] # User has not set their proper name so use email as canonical display property contact.display = contact.email else From 79566a9214f97d3b2ab34b5e20dd65eeff14871e Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 6 Sep 2017 11:39:30 +0100 Subject: [PATCH 2/5] Prevent autocomplete on suggestions that don't match The behaviour of the ngTagsInput directive is somewhat counter-intuitive - typing part of a suggested email will appear as though it matches but pressing enter will not input the suggestion, but the current typed value. Disabling add on enter will still allow enter to select the selection, but prevents selection of the partially typed email/name. --- services/web/app/views/project/editor/share.pug | 1 + 1 file changed, 1 insertion(+) diff --git a/services/web/app/views/project/editor/share.pug b/services/web/app/views/project/editor/share.pug index 32e0404afc..11e1145863 100644 --- a/services/web/app/views/project/editor/share.pug +++ b/services/web/app/views/project/editor/share.pug @@ -71,6 +71,7 @@ script(type='text/ng-template', id='shareProjectModalTemplate') focus-on="open" display-property="display" add-on-paste="true" + add-on-enter="false" replace-spaces-with-dashes="false" type="email" ) From 320466a4f7259f72be1b60a3df6d14189d418e88 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 6 Sep 2017 13:47:45 +0100 Subject: [PATCH 3/5] Catch invalid email address and show specific error message --- services/web/app/views/project/editor/share.pug | 2 ++ .../share/controllers/ShareProjectModalController.coffee | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/web/app/views/project/editor/share.pug b/services/web/app/views/project/editor/share.pug index 11e1145863..ae59185b9d 100644 --- a/services/web/app/views/project/editor/share.pug +++ b/services/web/app/views/project/editor/share.pug @@ -147,6 +147,8 @@ script(type='text/ng-template', id='shareProjectModalTemplate') | #{translate("cannot_invite_non_user")} span(ng-switch-when="cannot_invite_self") | #{translate("cannot_invite_self")} + span(ng-switch-when="invalid_email") + | #{translate("invalid_email")} span(ng-switch-default) | #{translate("generic_something_went_wrong")} button.btn.btn-default( diff --git a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee index 5ede187dce..2cf6aaa8ec 100644 --- a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee +++ b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee @@ -127,10 +127,13 @@ define [ # with new collaborator information. addNextMember() , 0 - .catch () -> + .catch (err) -> $scope.state.inflight = false $scope.state.error = true - $scope.state.errorReason = null + if (err.status? and err.status == 400) + $scope.state.errorReason = 'invalid_email' + else + $scope.state.errorReason = null $timeout addMembers, 50 # Give email list a chance to update From b7713439bf7d3b2b2cd56663579197053c34b721 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 7 Sep 2017 11:30:20 +0100 Subject: [PATCH 4/5] Bring back comparsion erroneously removed --- .../ide/share/controllers/ShareProjectModalController.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee index 2cf6aaa8ec..97d445e47f 100644 --- a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee +++ b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee @@ -39,7 +39,7 @@ define [ $scope.autocompleteContacts = data.contacts or [] for contact in $scope.autocompleteContacts if contact.type == "user" - if contact.last_name and contact.first_name == contact.email.split("@")[0] + if contact.last_name == "" and contact.first_name == contact.email.split("@")[0] # User has not set their proper name so use email as canonical display property contact.display = contact.email else From 624802c28e5f113427396c8bd4e042c0eac3cd79 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 7 Sep 2017 11:30:42 +0100 Subject: [PATCH 5/5] Remove unnecessary parens --- .../ide/share/controllers/ShareProjectModalController.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee index 97d445e47f..3c72fdbb05 100644 --- a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee +++ b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee @@ -130,7 +130,7 @@ define [ .catch (err) -> $scope.state.inflight = false $scope.state.error = true - if (err.status? and err.status == 400) + if err.status? and err.status == 400 $scope.state.errorReason = 'invalid_email' else $scope.state.errorReason = null