feat: allow project selection when creating users
This commit is contained in:
1 parent
51eef30971
commit
87cb39c04c
2 files changed
+26
No files matched your search
@@ -123,6 +123,11 @@
|
|||||||
editUser.projects = checked ? [...current, key] : current.filter((project) => project !== key);
|
editUser.projects = checked ? [...current, key] : current.filter((project) => project !== key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleNewProject(key: string, checked: boolean): void {
|
||||||
|
const current = newUser.projects ?? [];
|
||||||
|
newUser.projects = checked ? [...current, key] : current.filter((project) => project !== key);
|
||||||
|
}
|
||||||
|
|
||||||
function projectLabel(key: string): string {
|
function projectLabel(key: string): string {
|
||||||
return projects?.find((project) => project.key === key)?.label ?? key;
|
return projects?.find((project) => project.key === key)?.label ?? key;
|
||||||
}
|
}
|
||||||
@@ -198,6 +203,21 @@
|
|||||||
{#if canAssignAdmin}<option value="admin">Admin</option>{/if}
|
{#if canAssignAdmin}<option value="admin">Admin</option>{/if}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
{#if projects && projects.length > 0}
|
||||||
|
<fieldset class="sc-user-projects">
|
||||||
|
<legend>Projects (none checked = all projects)</legend>
|
||||||
|
{#each projects as project (project.key)}
|
||||||
|
<label class="sc-user-project-option">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={(newUser.projects ?? []).includes(project.key)}
|
||||||
|
onchange={(event) => toggleNewProject(project.key, event.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
{project.label}
|
||||||
|
</label>
|
||||||
|
{/each}
|
||||||
|
</fieldset>
|
||||||
|
{/if}
|
||||||
<div class="sc-form-actions"><Button disabled={saving} type="submit">Add user</Button></div>
|
<div class="sc-form-actions"><Button disabled={saving} type="submit">Add user</Button></div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,12 @@ export interface UserCreateInput {
|
|||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
role?: UserRole;
|
role?: UserRole;
|
||||||
|
/**
|
||||||
|
* Project keys this new account is restricted to. An empty array means
|
||||||
|
* unrestricted; omitted when the host application does not expose project
|
||||||
|
* scoping.
|
||||||
|
*/
|
||||||
|
projects?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserUpdateInput {
|
export interface UserUpdateInput {
|
||||||
|
|||||||
Reference in new issue
Block a user