mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-09 21:50:30 +08:00
Allow disabling of attachments in comments with reason
[squash] Use shorthand property
This commit is contained in:
committed by
Sebastian Martinez
parent
d35920b8cb
commit
049b2b15df
@@ -35,7 +35,8 @@
|
||||
editComment?: (body: string, embeds: Embed[]) => Promise<void>;
|
||||
reactOnComment?: (authors: Author[], reaction: string) => Promise<void>;
|
||||
styleWidth?: string;
|
||||
allowAttachments?: boolean;
|
||||
// See `ExtendedTextarea`
|
||||
disableAttachments?: boolean | string;
|
||||
}
|
||||
|
||||
/* eslint-disable prefer-const */
|
||||
@@ -56,7 +57,7 @@
|
||||
reactOnComment,
|
||||
styleWidth,
|
||||
emptyBodyTooltip,
|
||||
allowAttachments = true,
|
||||
disableAttachments,
|
||||
}: Props = $props();
|
||||
/* eslint-enable prefer-const */
|
||||
|
||||
@@ -195,7 +196,7 @@
|
||||
{embeds}
|
||||
{disallowEmptyBody}
|
||||
{emptyBodyTooltip}
|
||||
{allowAttachments}
|
||||
{disableAttachments}
|
||||
borderVariant="ghost"
|
||||
submitInProgress={state === "submit"}
|
||||
submitCaption="Save"
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
onclose?: () => void;
|
||||
onexpand?: () => void;
|
||||
disallowEmptyBody?: boolean;
|
||||
// See `ExtendedTextarea`
|
||||
disableAttachments?: boolean | string;
|
||||
}
|
||||
|
||||
/* eslint-disable prefer-const */
|
||||
@@ -23,6 +25,7 @@
|
||||
onclose,
|
||||
onexpand,
|
||||
disallowEmptyBody = false,
|
||||
disableAttachments,
|
||||
}: Props = $props();
|
||||
/* eslint-enable prefer-const */
|
||||
|
||||
@@ -58,6 +61,7 @@
|
||||
state = "collapsed";
|
||||
}
|
||||
}}
|
||||
{disableAttachments}
|
||||
submit={async ({ comment, embeds }) => {
|
||||
try {
|
||||
state = "submit";
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
) => Promise<void>;
|
||||
// Defaults to `true`.
|
||||
canReply?: boolean;
|
||||
// See `ExtendedTextarea`.
|
||||
disableAttachments?: boolean | string;
|
||||
repoDelegates: Author[];
|
||||
rid: string;
|
||||
threads: Thread<CodeLocation>[];
|
||||
@@ -504,6 +506,7 @@
|
||||
}}
|
||||
focus
|
||||
placeholder="Leave a comment"
|
||||
disableAttachments={codeComments.disableAttachments}
|
||||
submit={async (body, embeds) => {
|
||||
if (selection?.codeLocation) {
|
||||
try {
|
||||
|
||||
@@ -39,7 +39,11 @@
|
||||
embeds: Map<string, Embed>;
|
||||
}) => Promise<void>;
|
||||
close: () => void;
|
||||
allowAttachments?: boolean;
|
||||
// If true, adding attachments through drag-and-drop is disabled and there
|
||||
// is no "Attach" button. If a string is provided, the "Attach" button is
|
||||
// visible but disabled and uses the string as the title to indicate the
|
||||
// reason for disabling. Defaults to `false`
|
||||
disableAttachments?: boolean | string;
|
||||
}
|
||||
|
||||
/* eslint-disable prefer-const */
|
||||
@@ -63,10 +67,15 @@
|
||||
borderVariant = "float",
|
||||
submit,
|
||||
close,
|
||||
allowAttachments = true,
|
||||
disableAttachments: attachDisabled = false,
|
||||
}: Props = $props();
|
||||
/* eslint-enable prefer-const */
|
||||
|
||||
const attachEnabled = $derived(attachDisabled === false);
|
||||
const attachDisabledReason = $derived(
|
||||
typeof attachDisabled === "string" ? attachDisabled : undefined,
|
||||
);
|
||||
|
||||
let selectionStart = $state(body.length);
|
||||
let selectionEnd = $state(body.length);
|
||||
let draggingOver = $state(false);
|
||||
@@ -87,7 +96,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
if (window.__TAURI_INTERNALS__) {
|
||||
if (allowAttachments) {
|
||||
if (attachEnabled) {
|
||||
dragEnterUnlistenFn = await listen("tauri://drag-enter", () => {
|
||||
draggingOver = true;
|
||||
});
|
||||
@@ -149,7 +158,7 @@
|
||||
}
|
||||
|
||||
async function handlePaste(e: ClipboardEvent) {
|
||||
if (!allowAttachments) {
|
||||
if (!attachEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -284,8 +293,8 @@
|
||||
{#if !preview}
|
||||
<div
|
||||
class="txt-overflow txt-small txt-missing"
|
||||
title={`${allowAttachments ? "Drag and drop files to add them. " : ""}Markdown is supported. Press ${utils.modifierKey()}↵ to submit.`}>
|
||||
{#if allowAttachments}Drag and drop files to add them.{/if}
|
||||
title={`${attachEnabled ? "Drag and drop files to add them. " : ""}Markdown is supported. Press ${utils.modifierKey()}↵ to submit.`}>
|
||||
{#if attachEnabled}Drag and drop files to add them.{/if}
|
||||
<Icon
|
||||
name="markdown"
|
||||
styleDisplay="inline"
|
||||
@@ -294,8 +303,12 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="buttons">
|
||||
{#if allowAttachments}
|
||||
<OutlineButton variant="ghost" onclick={selectFiles} disabled={preview}>
|
||||
{#if attachEnabled || attachDisabledReason}
|
||||
<OutlineButton
|
||||
variant="ghost"
|
||||
onclick={selectFiles}
|
||||
disabled={preview || attachDisabledReason !== undefined}
|
||||
title={attachDisabledReason}>
|
||||
<Icon name="attachment" />
|
||||
Attach
|
||||
</OutlineButton>
|
||||
|
||||
@@ -365,7 +365,7 @@
|
||||
|
||||
<div class="review-body">
|
||||
<CommentComponent
|
||||
allowAttachments={false}
|
||||
disableAttachments
|
||||
rid={repo.rid}
|
||||
disallowEmptyBody={review.verdict === undefined}
|
||||
emptyBodyTooltip="Summary is mandatory when verdict is None"
|
||||
|
||||
Reference in New Issue
Block a user