diff --git a/backend/LexBoxApi/GraphQL/ProjectMutations.cs b/backend/LexBoxApi/GraphQL/ProjectMutations.cs index b481eb7c6..55e2b8ed5 100644 --- a/backend/LexBoxApi/GraphQL/ProjectMutations.cs +++ b/backend/LexBoxApi/GraphQL/ProjectMutations.cs @@ -40,14 +40,14 @@ public async Task CreateProject( ProjectService projectService, IEmailService emailService) { - if (!loggedInContext.User.IsAdmin) + if (!loggedInContext.User.IsAdmin || input.ForceDraft) //draft projects should always have a manager { // For non-admins we always implicitly set them as the project manager // Only admins can create empty projects or projects for other users input = input with { ProjectManagerId = loggedInContext.User.Id }; } - if (!permissionService.HasProjectCreatePermission()) + if (!permissionService.HasProjectCreatePermission() || input.ForceDraft) { if (!permissionService.HasProjectRequestPermission()) throw new ProjectCreatorsMustHaveEmail("Project creators must have a valid email address"); var draftProjectId = await projectService.CreateDraftProject(input); diff --git a/backend/LexBoxApi/Models/Project/CreateProjectInput.cs b/backend/LexBoxApi/Models/Project/CreateProjectInput.cs index 57ec07ed8..99ed92179 100644 --- a/backend/LexBoxApi/Models/Project/CreateProjectInput.cs +++ b/backend/LexBoxApi/Models/Project/CreateProjectInput.cs @@ -13,5 +13,6 @@ public record CreateProjectInput( RetentionPolicy RetentionPolicy, bool IsConfidential, Guid? ProjectManagerId, - Guid? OrgId + Guid? OrgId, + bool ForceDraft = false ); diff --git a/frontend/schema.graphql b/frontend/schema.graphql index 9a315d8c3..661b966e6 100644 --- a/frontend/schema.graphql +++ b/frontend/schema.graphql @@ -755,6 +755,7 @@ input CreateProjectInput { isConfidential: Boolean! projectManagerId: UUID orgId: UUID + forceDraft: Boolean! = false } input DateTimeOperationFilterInput { diff --git a/frontend/src/routes/(authenticated)/project/create/+page.svelte b/frontend/src/routes/(authenticated)/project/create/+page.svelte index a5cb73764..a651beca8 100644 --- a/frontend/src/routes/(authenticated)/project/create/+page.svelte +++ b/frontend/src/routes/(authenticated)/project/create/+page.svelte @@ -21,6 +21,7 @@ import { NewTabLinkRenderer } from '$lib/components/Markdown'; import Button from '$lib/forms/Button.svelte'; import {projectUrl} from '$lib/util/project'; + import DevContent from '$lib/layout/DevContent.svelte'; export let data; $: user = data.user; @@ -47,6 +48,7 @@ isConfidential: z.boolean().default(false), orgId: z.string().trim() }); + let forceDraft = false; //random guid let projectId:string = crypto.randomUUID(); @@ -61,6 +63,7 @@ isConfidential: $form.isConfidential, projectManagerId: requestingUser?.id, orgId: $form.orgId === '' ? null : $form.orgId, + forceDraft }); if (result.error) { if (result.error.byCode(DbErrorCode.Duplicate)) { @@ -329,6 +332,9 @@ + + + {#if data.user.canCreateProjects}