Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add checkbox for invite user when adding project member #966

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia
"add_button": "Add/Invite Member",
"modal_title": "Add or invite a Member to this project",
"submit_button": "Add Member",
"invite_checkbox": "Invite",
"empty_user_field": "Please enter an email address or login",
"submit_button_email": "Add or invite Member",
"project_not_found": "Project not found. Please refresh the page.",
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 @@ -69,7 +72,7 @@
{$t('project_page.add_user.add_button')}
</BadgeButton>

<FormModal bind:this={formModal} {schema} let:errors>
<FormModal bind:this={formModal} {schema} let:errors --justify-actions="end">
<span slot="title">
{$t('project_page.add_user.modal_title')}
<SupHelp helpLink={helpLinks.addProjectMember} />
Expand All @@ -93,11 +96,16 @@
/>
{/if}
<ProjectRoleSelect bind:value={$form.role} error={errors.role} />
<svelte:fragment slot="extraActions">
<Checkbox
id="invite"
label={$t('project_page.add_user.invite_checkbox')}
variant="checkbox-warning"
labelColor="text-warning"
bind:value={$form.canInvite}
/>
</svelte:fragment>
<span slot="submitText">
{#if $form.usernameOrEmail.includes('@')}
{$t('project_page.add_user.submit_button_email')}
{:else}
{$t('project_page.add_user.submit_button')}
{/if}
{$t('project_page.add_user.submit_button')}
</span>
</FormModal>
Loading