From 6fcef028090db47bffa478e110d16de7492736cf Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Wed, 26 Jul 2023 18:26:47 -0700 Subject: [PATCH] feat: add reporting --- src/lib/components/input/TextArea.svelte | 1 + src/lib/components/input/TextInput.svelte | 2 +- .../components/lemmy/comment/Comment.svelte | 19 ++-- .../lemmy/comment/CommentActions.svelte | 11 +++ .../lemmy/moderation/Moderation.svelte | 6 ++ .../lemmy/moderation/ReportModal.svelte | 94 +++++++++++++++++++ .../components/lemmy/moderation/moderation.ts | 26 +++++ src/lib/components/lemmy/post/Post.svelte | 28 +++--- .../components/lemmy/post/PostActions.svelte | 20 ++-- src/lib/components/markdown/Markdown.svelte | 12 +++ src/lib/components/ui/modal/Modal.svelte | 12 ++- src/lib/lemmy.ts | 1 + src/routes/+layout.svelte | 2 + src/routes/login/+page.svelte | 5 +- 14 files changed, 206 insertions(+), 33 deletions(-) create mode 100644 src/lib/components/lemmy/moderation/Moderation.svelte create mode 100644 src/lib/components/lemmy/moderation/ReportModal.svelte create mode 100644 src/lib/components/lemmy/moderation/moderation.ts diff --git a/src/lib/components/input/TextArea.svelte b/src/lib/components/input/TextArea.svelte index 98f29367..25b75e00 100644 --- a/src/lib/components/input/TextArea.svelte +++ b/src/lib/components/input/TextArea.svelte @@ -30,5 +30,6 @@ class="w-full px-3 text-sm py-2.5 bg-white dark:bg-black border border-slate-300 dark:border-zinc-700 dark:focus:border-white focus:outline-none focus:border-black transition-colors rounded-md {clazz}" + {...$$restProps} /> diff --git a/src/lib/components/input/TextInput.svelte b/src/lib/components/input/TextInput.svelte index c45e40e3..d7487cab 100644 --- a/src/lib/components/input/TextInput.svelte +++ b/src/lib/components/input/TextInput.svelte @@ -17,7 +17,7 @@ ${value.length != 0 ? 'invalid:border-red-400' : ''} w-full px-3 text-sm py-2.5 bg-white dark:bg-zinc-950 border border-slate-300 dark:border-zinc-700 dark:focus:border-white - focus:outline-none focus:border-black transition-colors rounded-md + focus:outline-none focus:border-black transition-colors rounded-md disabled:bg-slate-200 disabled:bg-zinc-800 disabled:opacity-70 ${$$props.class} ` diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index fb288f36..dcba4bc0 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -25,6 +25,7 @@ export let node: CommentNodeI export let postId: number export let op: boolean = false + export let actions: boolean = true export let open = true export let replying = false @@ -71,7 +72,7 @@ {/if}
  • -
    - (editing = true)} - /> -
    + {#if actions} +
    + (editing = true)} + /> +
    + {/if} {#if replying}
    diff --git a/src/lib/components/lemmy/comment/CommentActions.svelte b/src/lib/components/lemmy/comment/CommentActions.svelte index 4119dd73..399822be 100644 --- a/src/lib/components/lemmy/comment/CommentActions.svelte +++ b/src/lib/components/lemmy/comment/CommentActions.svelte @@ -10,6 +10,7 @@ BookmarkSlash, ChatBubbleOvalLeft, EllipsisHorizontal, + Flag, Icon, PencilSquare, Trash, @@ -21,6 +22,7 @@ import Button from '$lib/components/input/Button.svelte' import { createEventDispatcher } from 'svelte' import { isCommentMutable } from '$lib/components/lemmy/post/helpers.js' + import { report } from '$lib/components/lemmy/moderation/moderation.js' export let comment: CommentView export let replying: boolean = false @@ -114,6 +116,15 @@ Delete {/if} + {#if $authData && $user?.person.id != comment.creator.id} + report(comment)} + color={Color.dangerSecondary} + > + + Report + + {/if} {/if}
    diff --git a/src/lib/components/lemmy/moderation/Moderation.svelte b/src/lib/components/lemmy/moderation/Moderation.svelte new file mode 100644 index 00000000..84a88590 --- /dev/null +++ b/src/lib/components/lemmy/moderation/Moderation.svelte @@ -0,0 +1,6 @@ + + + diff --git a/src/lib/components/lemmy/moderation/ReportModal.svelte b/src/lib/components/lemmy/moderation/ReportModal.svelte new file mode 100644 index 00000000..c8658458 --- /dev/null +++ b/src/lib/components/lemmy/moderation/ReportModal.svelte @@ -0,0 +1,94 @@ + + + +

    Report

    +
    + {#if item} + Reporting this submission +
    + {#if isComment(item)} + + {:else if isPost(item)} + + {/if} +
    + {/if} +