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

User typeahead enabled for non-admin project managers #1237

Merged
merged 19 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion frontend/src/lib/forms/UserTypeahead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
export let value: string;
export let debounceMs = 200;
export let isAdmin: boolean = false;
export let exclude: string[] = [];

let input = writable('');
$: $input = value;
Expand All @@ -23,6 +24,8 @@
[],
debounceMs);

$: filteredResults = $typeaheadResults.filter(user => !exclude.includes(user.id));
myieye marked this conversation as resolved.
Show resolved Hide resolved

const dispatch = createEventDispatcher<{
selectedUserId: string | null;
selectedUser: SingleUserTypeaheadResult | SingleUserICanSeeTypeaheadResult | null;
Expand Down Expand Up @@ -62,7 +65,7 @@
/>
<div class="overlay-content">
<ul class="menu p-0">
{#each $typeaheadResults as user}
{#each filteredResults as user}
<li class="p-0"><button class="whitespace-nowrap" on:click={() => {
setTimeout(() => {
if ('id' in user && user.id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
error={errors.usernameOrEmail}
on:selectedUser={(event) => populateUserProjects(event.detail)}
autofocus
exclude={org.members.map(m => m.user.id)}
/>
{:else}
<Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
{$t('project_page.add_user.add_button')}
</BadgeButton>

<AddProjectMember bind:this={addProjectMember} projectId={project.id} />
<AddProjectMember bind:this={addProjectMember} {project} />
<BulkAddProjectMembers projectId={project.id} />
</svelte:fragment>
<UserModal bind:this={userModal}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import { ProjectRole } from '$lib/gql/types';
import t from '$lib/i18n';
import { z } from 'zod';
import { _addProjectMember } from './+page';
import { _addProjectMember, type Project } from './+page';
import { useNotifications } from '$lib/notify';
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;
export let project: Project;
const schema = z.object({
usernameOrEmail: z.string().trim()
.min(1, $t('project_page.add_user.empty_user_field'))
Expand All @@ -31,7 +31,7 @@
if (initialUserId) selectedUserId = initialUserId;
const { response, formState } = await formModal.open(initialValue, async () => {
const { error } = await _addProjectMember({
projectId,
projectId: project.id,
usernameOrEmail: $form.usernameOrEmail ?? '',
userId: selectedUserId,
role: $form.role,
Expand Down Expand Up @@ -86,6 +86,7 @@
on:selectedUserId={({ detail }) => {
selectedUserId = detail;
}}
exclude={project.users.map(m => m.user.id)}
/>
<ProjectRoleSelect bind:value={$form.role} error={errors.role} />
<svelte:fragment slot="extraActions">
Expand Down
Loading