Skip to content
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
2 changes: 1 addition & 1 deletion backend/LexBoxApi/GraphQL/ProjectMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public async Task<BulkAddProjectMembersResult> BulkAddProjectMembers(
Username = username,
Name = name,
Email = email,
LocalizationCode = "en", // TODO: input.Locale,
LocalizationCode = input.Locale,
Salt = salt,
PasswordHash = PasswordHashing.HashPassword(input.PasswordHash, salt, true),
PasswordStrength = 0, // Shared password, so always considered strength 0, we don't call Zxcvbn here
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 @@ -4,6 +4,6 @@ namespace LexBoxApi.Models.Project;

public record AddProjectMemberInput(Guid ProjectId, string? UsernameOrEmail, Guid? UserId, ProjectRole Role, bool canInvite);

public record BulkAddProjectMembersInput(Guid ProjectId, string[] Usernames, ProjectRole Role, string PasswordHash);
public record BulkAddProjectMembersInput(Guid ProjectId, string[] Usernames, ProjectRole Role, string PasswordHash, string Locale = User.DefaultLocalizationCode);

public record ChangeProjectMemberRoleInput(Guid ProjectId, Guid UserId, ProjectRole Role);
1 change: 1 addition & 0 deletions frontend/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ input BulkAddProjectMembersInput {
usernames: [String!]!
role: ProjectRole!
passwordHash: String!
locale: String! = "en"
}

input ChangeOrgMemberRoleInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@
</BadgeButton>

<AddProjectMember bind:this={addProjectMember} {project} />
<BulkAddProjectMembers projectId={project.id} />
<BulkAddProjectMembers projectId={project.id} userLocale={user.locale} />
{/snippet}
<UserModal bind:this={userModal} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ export async function _addProjectMember(input: AddProjectMemberInput): $OpResult
return result;
}

// public record BulkAddProjectMembersInput(Guid ProjectId, string[] Usernames, ProjectRole Role, string PasswordHash);

export async function _bulkAddProjectMembers(input: BulkAddProjectMembersInput): $OpResult<BulkAddProjectMembersMutation> {
//language=GraphQL
const result = await getClient()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import {BadgeButton, MemberBadge} from '$lib/components/Badges';
import {DialogResponse, FormModal, type FormSubmitReturn} from '$lib/components/modals';
import {Input, TextArea, isEmail, passwordFormRules} from '$lib/forms';
import {DisplayLanguageSelect, Input, TextArea, isEmail, passwordFormRules} from '$lib/forms';
import {ProjectRole, type BulkAddProjectMembersResult} from '$lib/gql/types';
import t from '$lib/i18n';
import {z} from 'zod';
Expand All @@ -25,12 +25,14 @@

interface Props {
projectId: string;
userLocale: string;
}

const { projectId }: Props = $props();
const { projectId, userLocale }: Props = $props();
const schema = z.object({
usernamesText: z.string().trim().min(1, $t('project_page.bulk_add_members.empty_user_field')),
password: passwordFormRules($t),
locale: z.string().trim().min(2).default(userLocale),

Check warning on line 35 in frontend/src/routes/(authenticated)/project/[project_code]/BulkAddProjectMembers.svelte

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontend/src/routes/(authenticated)/project/[project_code]/BulkAddProjectMembers.svelte#L35

[svelte/valid-compile] This reference only captures the initial value of `userLocale`. Did you mean to reference it inside a closure instead? https://svelte.dev/e/state_referenced_locally(state_referenced_locally)
});

let formModal: FormModal<typeof schema> | undefined = $state();
Expand Down Expand Up @@ -76,6 +78,7 @@
usernames,
//todo allow setting users as Observer
role: ProjectRole.Editor, // Managers not allowed to have shared passwords
locale: state.locale.currentValue,
});

const invalidEmailError = error?.byType('InvalidEmailError');
Expand Down Expand Up @@ -121,6 +124,7 @@
error={errors.password}
/>
<PasswordStrengthMeter password={$form!.password} scoreOverride={0} />
<DisplayLanguageSelect bind:value={$form!.locale} />
<div class="contents usernames">
<TextArea
id="usernamesText"
Expand Down
Loading