Tweak issue/patch validation rules

Patches - title: mandatory, body: optional.
Issues - title and body: mandatory.
This commit is contained in:
Rūdolfs Ošiņš
2024-02-20 16:34:33 +00:00
parent 6ff0d52165
commit d4b246c72d
4 changed files with 13 additions and 4 deletions
+8 -3
View File
@@ -25,7 +25,10 @@
export let body: string = "";
export let embeds: Map<string, Embed> = new Map();
export let submitInProgress: boolean = false;
export let validateBody: boolean = true;
export let disallowEmptyBody: boolean = false;
export let isValid: () => boolean = () => {
return true;
};
let preview: boolean = false;
let selectionStart = 0;
@@ -178,7 +181,7 @@
</Button>
<Button
styleBorderRadius="0"
disabled={validateBody && !body}
disabled={!isValid()}
variant={preview ? "selected" : "not-selected"}
on:click={() => {
preview = true;
@@ -235,7 +238,9 @@
</Button>
<Button
variant="secondary"
disabled={(validateBody && !body) || submitInProgress}
disabled={!isValid() ||
submitInProgress ||
(disallowEmptyBody && body.length === 0)}
on:click={submit}>
{#if submitInProgress}
<Loading small noDelay />
+2
View File
@@ -542,6 +542,8 @@
<div slot="description">
{#if issueState !== "read"}
<ExtendedTextarea
isValid={() => newTitle.length > 0}
disallowEmptyBody
rawPath={rawPath(project.head)}
enableAttachments
embeds={parseEmbedIntoMap(issue.discussion[0].embeds)}
+2
View File
@@ -99,6 +99,8 @@
<svelte:fragment slot="description">
<ExtendedTextarea
rawPath={rawPath(project.head)}
disallowEmptyBody
isValid={() => issueTitle.length > 0}
enableAttachments
submitCaption="Submit"
placeholder="Write a description"
+1 -1
View File
@@ -766,7 +766,7 @@
<div class="revision-description">
{#if session && patchState !== "read" && latestEdit}
<ExtendedTextarea
validateBody={false}
isValid={() => patch.title.length > 0}
enableAttachments
embeds={parseEmbedIntoMap(latestEdit.embeds)}
rawPath={rawPath(patch.revisions[0].id)}