diff --git a/backend/LexBoxApi/GraphQL/ProjectMutations.cs b/backend/LexBoxApi/GraphQL/ProjectMutations.cs index b682e5703..0db94cac1 100644 --- a/backend/LexBoxApi/GraphQL/ProjectMutations.cs +++ b/backend/LexBoxApi/GraphQL/ProjectMutations.cs @@ -69,7 +69,8 @@ public record CreateProjectResponse(Guid? Id, CreateProjectResult Result); [UseMutationConvention] [UseFirstOrDefault] [UseProjection] - public async Task> AddProjectMember(IPermissionService permissionService, + public async Task> AddProjectMember( + IPermissionService permissionService, LoggedInContext loggedInContext, AddProjectMemberInput input, LexBoxDbContext dbContext, @@ -87,12 +88,16 @@ public async Task> AddProjectMember(IPermissionService permi { throw NotFoundException.ForType(); } - else + else if (input.canInvite) { var manager = loggedInContext.User; await emailService.SendCreateAccountEmail(email, input.ProjectId, input.Role, manager.Name, project.Name); throw new ProjectMemberInvitedByEmail("Invitation email sent"); } + else + { + throw NotFoundException.ForType(); + } } if (user.Projects.Any(p => p.ProjectId == input.ProjectId)) { diff --git a/backend/LexBoxApi/Models/Project/ProjectMemberInputs.cs b/backend/LexBoxApi/Models/Project/ProjectMemberInputs.cs index 13a787fba..80bd60be4 100644 --- a/backend/LexBoxApi/Models/Project/ProjectMemberInputs.cs +++ b/backend/LexBoxApi/Models/Project/ProjectMemberInputs.cs @@ -3,7 +3,7 @@ namespace LexBoxApi.Models.Project; -public record AddProjectMemberInput(Guid ProjectId, string UsernameOrEmail, ProjectRole Role); +public record AddProjectMemberInput(Guid ProjectId, string UsernameOrEmail, ProjectRole Role, bool canInvite); public record BulkAddProjectMembersInput(Guid? ProjectId, string[] Usernames, ProjectRole Role, string PasswordHash); diff --git a/frontend/schema.graphql b/frontend/schema.graphql index 2f5792744..7b164cf4c 100644 --- a/frontend/schema.graphql +++ b/frontend/schema.graphql @@ -506,6 +506,7 @@ input AddProjectMemberInput { projectId: UUID! usernameOrEmail: String! role: ProjectRole! + canInvite: Boolean! } input AddProjectToOrgInput { diff --git a/frontend/src/lib/components/modals/FormModal.svelte b/frontend/src/lib/components/modals/FormModal.svelte index e9e51f7bf..2795c4253 100644 --- a/frontend/src/lib/components/modals/FormModal.svelte +++ b/frontend/src/lib/components/modals/FormModal.svelte @@ -97,6 +97,7 @@ + {#if !done} diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/AddProjectMember.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/AddProjectMember.svelte index 629edf610..993363473 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/AddProjectMember.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/AddProjectMember.svelte @@ -10,6 +10,7 @@ import { page } from '$app/stores' import UserTypeahead from '$lib/forms/UserTypeahead.svelte'; import { SupHelp, helpLinks } from '$lib/components/help'; + import Checkbox from '$lib/forms/Checkbox.svelte'; export let projectId: string; const schema = z.object({ @@ -17,6 +18,7 @@ .min(1, $t('project_page.add_user.empty_user_field')) .refine((value) => !value.includes('@') || isEmail(value), { message: $t('form.invalid_email') }), role: z.enum([ProjectRole.Editor, ProjectRole.Manager]).default(ProjectRole.Editor), + canInvite: z.boolean().default(false), }); let formModal: FormModal; $: form = formModal?.form(); @@ -30,6 +32,7 @@ projectId, usernameOrEmail: $form.usernameOrEmail, role: $form.role, + canInvite: $form.canInvite, }); if (error?.byType('NotFoundError')) { @@ -93,6 +96,15 @@ /> {/if} + + + {#if $form.usernameOrEmail.includes('@')} {$t('project_page.add_user.submit_button_email')}