Skip to content

Commit

Permalink
add checkbox & canInvite variable
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHo Park committed Jul 24, 2024
1 parent 2105dbb commit 0873003
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backend/LexBoxApi/GraphQL/ProjectMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<IQueryable<Project>> AddProjectMember(
{
throw NotFoundException.ForType<User>();
}
else
else if (input.canInvite)
{
var manager = loggedInContext.User;
await emailService.SendCreateAccountWithProjectEmail(
Expand All @@ -98,6 +98,10 @@ await emailService.SendCreateAccountWithProjectEmail(
projectName: project.Name);
throw new ProjectMemberInvitedByEmail("Invitation email sent");
}
else
{
throw NotFoundException.ForType<User>();
}
}
if (user.Projects.Any(p => p.ProjectId == input.ProjectId))
{
Expand Down
2 changes: 1 addition & 1 deletion backend/LexBoxApi/Models/Project/ProjectMemberInputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions frontend/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ input AddProjectMemberInput {
projectId: UUID!
usernameOrEmail: String!
role: ProjectRole!
canInvite: Boolean!
}

input AddProjectToOrgInput {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/components/modals/FormModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<slot name="extraActions" />
</svelte:fragment>
<svelte:fragment slot="actions" let:submitting>
<slot name="checkbox"/>
{#if !done}
<SubmitButton form="modalForm" variant={submitVariant} loading={submitting}>
<slot name="submitText" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
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({
usernameOrEmail: z.string().trim()
.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<typeof schema>;
$: form = formModal?.form();
Expand All @@ -30,6 +32,7 @@
projectId,
usernameOrEmail: $form.usernameOrEmail,
role: $form.role,
canInvite: $form.canInvite,
});
if (error?.byType('NotFoundError')) {
Expand Down Expand Up @@ -93,6 +96,15 @@
/>
{/if}
<ProjectRoleSelect bind:value={$form.role} error={errors.role} />
<span slot="checkbox">
<Checkbox
id="invite"
label={'Invite'}
variant="checkbox-warning"
labelColor="text-warning"
bind:value={$form.canInvite}
/>
</span>
<span slot="submitText">
{#if $form.usernameOrEmail.includes('@')}
{$t('project_page.add_user.submit_button_email')}
Expand Down

0 comments on commit 0873003

Please sign in to comment.