Skip to content

Commit

Permalink
add dev option to make it easier to create draft projects
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev authored and myieye committed Nov 27, 2024
1 parent 49672d3 commit c54f64d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/LexBoxApi/GraphQL/ProjectMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public async Task<CreateProjectResponse> 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);
Expand Down
3 changes: 2 additions & 1 deletion backend/LexBoxApi/Models/Project/CreateProjectInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public record CreateProjectInput(
RetentionPolicy RetentionPolicy,
bool IsConfidential,
Guid? ProjectManagerId,
Guid? OrgId
Guid? OrgId,
bool ForceDraft = false
);
1 change: 1 addition & 0 deletions frontend/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ input CreateProjectInput {
isConfidential: Boolean!
projectManagerId: UUID
orgId: UUID
forceDraft: Boolean! = false
}

input DateTimeOperationFilterInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,6 +48,7 @@
isConfidential: z.boolean().default(false),
orgId: z.string().trim()
});
let forceDraft = false;
//random guid
let projectId:string = crypto.randomUUID();
Expand All @@ -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)) {
Expand Down Expand Up @@ -329,6 +332,9 @@
<ProjectConfidentialityCombobox bind:value={$form.isConfidential} />
</div>

<DevContent>
<Checkbox label="Force draft project creation" bind:value={forceDraft}/>
</DevContent>
<FormError error={$message} />
<SubmitButton loading={$submitting}>
{#if data.user.canCreateProjects}
Expand Down

0 comments on commit c54f64d

Please sign in to comment.