From 3c8facfe587ec998188810845e344eaf5e7210c3 Mon Sep 17 00:00:00 2001 From: Jeremy Wharton Date: Tue, 8 Nov 2022 21:16:02 -0600 Subject: [PATCH] satellite/console,web/satellite: always notify when adding project members Upon adding members to a project using the Add Team Member modal, users are now notified that only email addresses belonging to an account will receive a project invitation. This notification appears regardless of whether every submitted email corresponds to an account. Previously, users received an error message if any email address not attached to an account was submitted. Change-Id: Ia014c8311c1347e001b1c6c33de73ea61f20b0cb --- satellite/console/consoleweb/endpoints_test.go | 2 +- satellite/console/service.go | 15 +++++---------- .../src/components/modals/AddTeamMemberModal.vue | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/satellite/console/consoleweb/endpoints_test.go b/satellite/console/consoleweb/endpoints_test.go index fb4b51456..f8ff1b83c 100644 --- a/satellite/console/consoleweb/endpoints_test.go +++ b/satellite/console/consoleweb/endpoints_test.go @@ -548,7 +548,7 @@ func TestProjects(t *testing.T) { __typename } }`})) - require.Contains(t, body, "There is no account on this Satellite for the user(s) you have entered") + require.Contains(t, body, "addProjectMembers") require.Equal(t, http.StatusOK, resp.StatusCode) } diff --git a/satellite/console/service.go b/satellite/console/service.go index 8e3e58d29..45b82b461 100644 --- a/satellite/console/service.go +++ b/satellite/console/service.go @@ -1829,6 +1829,7 @@ func (s *Service) GenUpdateProject(ctx context.Context, projectID uuid.UUID, pro } // AddProjectMembers adds users by email to given project. +// Email addresses not belonging to a user are ignored. func (s *Service) AddProjectMembers(ctx context.Context, projectID uuid.UUID, emails []string) (users []*User, err error) { defer mon.Task()(&ctx)(&err) user, err := s.getUserAndAuditLog(ctx, "add project members", zap.String("projectID", projectID.String()), zap.Strings("emails", emails)) @@ -1840,21 +1841,15 @@ func (s *Service) AddProjectMembers(ctx context.Context, projectID uuid.UUID, em return nil, Error.Wrap(err) } - var userErr errs.Group - // collect user querying errors for _, email := range emails { user, err := s.store.Users().GetByEmail(ctx, email) - if err != nil { - userErr.Add(err) - continue + if err == nil { + users = append(users, user) + } else if !errs.Is(err, sql.ErrNoRows) { + return nil, Error.Wrap(err) } - users = append(users, user) - } - - if err = userErr.Err(); err != nil { - return nil, ErrValidation.New(teamMemberDoesNotExistErrMsg) } // add project members in transaction scope diff --git a/web/satellite/src/components/modals/AddTeamMemberModal.vue b/web/satellite/src/components/modals/AddTeamMemberModal.vue index d919302db..ea2bb2576 100644 --- a/web/satellite/src/components/modals/AddTeamMemberModal.vue +++ b/web/satellite/src/components/modals/AddTeamMemberModal.vue @@ -188,7 +188,7 @@ export default class AddTeamMemberModal extends Vue { return; } - await this.$notify.success('Members successfully added to project!'); + await this.$notify.notify(`The user(s) you've invited to your project will receive your invitation if they have an account on this satellite.`); this.$store.dispatch(PM_ACTIONS.SET_SEARCH_QUERY, ''); try {