Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #101

Merged
merged 8 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lemmy-modder",
"version": "1.3.7",
"version": "1.3.8",
"description": "Lemmy Moderation App",
"author": "tgxn",
"license": "MIT",
Expand Down
18 changes: 12 additions & 6 deletions src/components/Actions/CommentButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useLemmyHttpAction } from "../../hooks/useLemmyHttp.js";

import { BaseActionButton, ActionConfirmButton, InputElement, ConfirmDialog } from "./BaseElements.jsx";
import { getSiteData } from "../../hooks/getSiteData";
import { selectShowResolved } from "../../reducers/configReducer.js";
import { selectShowResolved, selectMandatoryModComment } from "../../reducers/configReducer.js";

export const ResolveCommentReportButton = ({ report, ...props }) => {
const queryClient = useQueryClient();
Expand Down Expand Up @@ -86,6 +86,8 @@ export const ResolveCommentReportButton = ({ report, ...props }) => {
};

export const RemoveCommentButton = ({ report, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [removeReason, setRemoveReason] = React.useState("");

Expand Down Expand Up @@ -139,6 +141,7 @@ export const RemoveCommentButton = ({ report, ...props }) => {
// placeholder={`reason`}
// inputText="Reason for removal"
// isRequired={!report.comment.removed}
disabled={mandatoryModComment && removeReason == ""}
buttonMessage={actionText}
color={actionColor}
onConfirm={() => {
Expand All @@ -157,12 +160,14 @@ export const RemoveCommentButton = ({ report, ...props }) => {
};

export const PurgeCommentButton = ({ report, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [purgeReason, setPurgeReason] = React.useState("");

const queryClient = useQueryClient();

const { data, callAction, isSuccess, isLoading, error } = useLemmyHttpAction("purgePost");
const { data, callAction, isSuccess, isLoading, error } = useLemmyHttpAction("purgeComment");

React.useEffect(() => {
if (isSuccess) {
Expand All @@ -178,7 +183,7 @@ export const PurgeCommentButton = ({ report, ...props }) => {
<>
<BaseActionButton
text={"Purge"}
tooltip={`Purge Post`}
tooltip={`Purge Comment`}
color={"danger"}
onClick={() => setConfirmOpen(true)}
{...props}
Expand All @@ -187,8 +192,8 @@ export const PurgeCommentButton = ({ report, ...props }) => {
open={confirmOpen}
loading={isLoading}
error={error}
title={`Purge Post`}
message={`Are you sure you want to purge this post? Purging will delete this item, and all its children from the database. You will not be able to recover the data. Use with extreme caution.`}
title={`Purge Comment`}
message={`Are you sure you want to purge this comment? Purging will delete this item, and all its children from the database. You will not be able to recover the data. Use with extreme caution.`}
extraElements={[
<InputElement
key="purgeReason"
Expand All @@ -198,10 +203,11 @@ export const PurgeCommentButton = ({ report, ...props }) => {
/>,
]}
// disabled={purgeReason == ""}
disabled={mandatoryModComment && purgeReason == ""}
buttonMessage={"Purge"}
color={"danger"}
onConfirm={() => {
callAction({ post_id: report.post.id, reason: purgeReason });
callAction({ _id: report.comment.id, reason: purgeReason });
}}
onCancel={() => {
setConfirmOpen(false);
Expand Down
16 changes: 13 additions & 3 deletions src/components/Actions/GenButtons.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import { useDispatch, useSelector } from "react-redux";

import { useQueryClient } from "@tanstack/react-query";
import moment from "moment";

Expand All @@ -14,8 +16,12 @@ import {
ConfirmDialog,
} from "./BaseElements.jsx";

import { selectMandatoryModComment } from "../../reducers/configReducer";

// banFromCommunity
export const BanUserCommunityButton = ({ person, community, isBanned, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [banReason, setBanReason] = React.useState("");
const [removeData, setRemoveData] = React.useState(false);
Expand Down Expand Up @@ -91,7 +97,7 @@ export const BanUserCommunityButton = ({ person, community, isBanned, ...props }
/>
) : null,
]}
// disabled={banReason == ""}
disabled={mandatoryModComment && banReason == ""}
buttonMessage={actionText}
color={actionColor}
onConfirm={() => {
Expand Down Expand Up @@ -133,6 +139,8 @@ export const BanUserCommunityButton = ({ person, community, isBanned, ...props }

// band from site
export const BanUserSiteButton = ({ person, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [banReason, setBanReason] = React.useState("");
const [removeData, setRemoveData] = React.useState(false);
Expand Down Expand Up @@ -204,7 +212,7 @@ export const BanUserSiteButton = ({ person, ...props }) => {
/>
) : null,
]}
// disabled={banReason == ""}
disabled={mandatoryModComment && banReason == ""}
buttonMessage={actionText}
color={actionColor}
onConfirm={() => {
Expand Down Expand Up @@ -245,6 +253,8 @@ export const BanUserSiteButton = ({ person, ...props }) => {

// PURGE from site
export const PurgeUserSiteButton = ({ person, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [purgeReason, setPurgeReason] = React.useState("");

Expand Down Expand Up @@ -294,7 +304,7 @@ export const PurgeUserSiteButton = ({ person, ...props }) => {
placeholder={`${actionText.toLowerCase()} reason`}
/>,
]}
// disabled={purgeReason == ""}
disabled={mandatoryModComment && purgeReason == ""}
buttonMessage={actionText}
color={actionColor}
onConfirm={() => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Actions/PMButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useLemmyHttpAction } from "../../hooks/useLemmyHttp.js";

import { BaseActionButton, ActionConfirmButton, InputElement, ConfirmDialog } from "./BaseElements.jsx";
import { getSiteData } from "../../hooks/getSiteData";
import { selectShowResolved } from "../../reducers/configReducer.js";
import { selectShowResolved, selectMandatoryModComment } from "../../reducers/configReducer.js";

// allow resolving / unresolving a post report
// resolvePrivateMessageReport
Expand Down Expand Up @@ -93,7 +93,10 @@ export const ResolvePMReportButton = ({ report, ...props }) => {
};

// deletePrivateMessage
// onyl useful for owner
export const DeletePMButton = ({ report, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [removeReason, setRemoveReason] = React.useState("");

Expand Down Expand Up @@ -147,6 +150,7 @@ export const DeletePMButton = ({ report, ...props }) => {
// placeholder={`reason`}
// inputText="Reason for removal"
// isRequired={!report.post.removed}
disabled={mandatoryModComment && removeReason == ""}
buttonMessage={actionText}
color={actionColor}
onConfirm={() => {
Expand Down
9 changes: 8 additions & 1 deletion src/components/Actions/PostButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { BaseActionButton, ActionConfirmButton, InputElement, ConfirmDialog } fr
import { getSiteData } from "../../hooks/getSiteData";
import { selectShowResolved } from "../../reducers/configReducer.js";

import { selectMandatoryModComment } from "../../reducers/configReducer";

// allow resolving / unresolving a post report
export const ResolvePostReportButton = ({ report, ...props }) => {
const queryClient = useQueryClient();
Expand Down Expand Up @@ -140,6 +142,8 @@ export const DeletePostButton = ({ report, ...props }) => {

// A moderator remove for a post.
export const RemovePostButton = ({ report, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [removeReason, setRemoveReason] = React.useState("");

Expand Down Expand Up @@ -193,6 +197,7 @@ export const RemovePostButton = ({ report, ...props }) => {
// placeholder={`reason`}
// inputText="Reason for removal"
// isRequired={!report.post.removed}
disabled={mandatoryModComment && removeReason == ""}
buttonMessage={actionText}
color={actionColor}
onConfirm={() => {
Expand All @@ -208,6 +213,8 @@ export const RemovePostButton = ({ report, ...props }) => {

// completely purge a post
export const PurgePostButton = ({ report, ...props }) => {
const mandatoryModComment = useSelector(selectMandatoryModComment);

const [confirmOpen, setConfirmOpen] = React.useState(false);
const [purgeReason, setPurgeReason] = React.useState("");

Expand Down Expand Up @@ -252,7 +259,7 @@ export const PurgePostButton = ({ report, ...props }) => {
placeholder={`purge reason`}
/>,
]}
disabled={purgeReason == ""}
disabled={mandatoryModComment && purgeReason == ""}
buttonMessage={"Purge"}
color={"danger"}
onConfirm={() => {
Expand Down
13 changes: 2 additions & 11 deletions src/components/Content/PostThumb.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import React, { useState, useEffect, useRef } from "react";

import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";

import Tooltip from "@mui/joy/Tooltip";
import AspectRatio from "@mui/joy/AspectRatio";
import Typography from "@mui/joy/Typography";

import Box from "@mui/joy/Box";
import Modal from "@mui/joy/Modal";
import CircularProgress from "@mui/joy/CircularProgress";

import LaunchIcon from "@mui/icons-material/Launch";

import { SanitizedLink } from "../Display.jsx";
import { Image, Video } from "./Image.jsx";

import {
setConfigItem,
setConfigItemJson,
selectBlurNsfw,
selectShowAvatars,
selectNsfwWords,
} from "../../reducers/configReducer";
import { selectBlurNsfw, selectNsfwWords } from "../../reducers/configReducer";

function ThumbWrapper({ width = 200, tooltip, modal = null, children }) {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ export const FediverseChipLink = ({ href, size = "md", ...props }) => {
);
};

export function UserAvatar({ source, ...props }) {
export function UserAvatar({ source, size, ...props }) {
return (
<Avatar
component="span"
size="sm"
src={source}
sx={{
"--Avatar-size": size ? size : "24px",
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
Expand Down
Loading