From 1b8568de596be60820ff85d37d21db96e7712af8 Mon Sep 17 00:00:00 2001 From: Philipp Herz Date: Fri, 10 Nov 2023 08:36:54 +0100 Subject: [PATCH 1/3] Added search params to modlogs --- src/pages/Actions.jsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/Actions.jsx b/src/pages/Actions.jsx index 56cdc50..895cacc 100644 --- a/src/pages/Actions.jsx +++ b/src/pages/Actions.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { useSelector } from "react-redux"; import { useInView } from "react-intersection-observer"; @@ -20,9 +20,11 @@ import { parseActorId } from "../utils"; import ModLogAccordians from "../components/Activity/ModLogAccordians"; import { selectModLogType } from "../redux/reducer/configReducer"; +import { useSearchParams } from "react-router-dom"; export default function Actions() { const { baseUrl, siteData, localPerson, userRole } = getSiteData(); + const [searchParams, setSearchParams] = useSearchParams(); const locaUserParsedActor = parseActorId(localPerson.actor_id); @@ -31,6 +33,22 @@ export default function Actions() { const [limitLocalInstance, setLimitLocalInstance] = React.useState(true); const [limitCommunityId, setLimitCommunityId] = React.useState(null); const [limitModId, setLimitModId] = React.useState(null); + const [actedOnId, setActedOnID] = React.useState(null); + + useEffect(() => { + if (searchParams.get("community_id")) { + setLimitCommunityId(searchParams.get("community_id")); + } + + if (searchParams.get("mod_id")) { + setLimitModId(searchParams.get("mod_id")); + } + + if (searchParams.get("acted_on_id")) { + setActedOnID(searchParams.get("acted_on_id")); + } + }, [searchParams]); + const { ref, inView, entry } = useInView({ threshold: 0, @@ -50,6 +68,8 @@ export default function Actions() { callLemmyMethod: "getModlog", formData: { community_id: limitCommunityId ? limitCommunityId : null, + mod_person_id: limitModId ? limitModId : null, + other_person_id: actedOnId ? actedOnId : null, }, // if any of the pages have 50 results, there is another page hasNextPageFunction: (data, perPage) => { @@ -134,7 +154,6 @@ export default function Actions() { actionTime = modLogItem.mod_ban.when_; affectedActorId = modLogItem.banned_person.actor_id; break; - case "admin_purged_persons": actionTime = modLogItem.admin_purge_person.when_; // affectedActorId = modLogItem.admin_purge_person.local_community; From 7929741d9553c494c72f9c175ebb7adfca6437dc Mon Sep 17 00:00:00 2001 From: Philipp Herz Date: Fri, 10 Nov 2023 09:07:35 +0100 Subject: [PATCH 2/3] Added tooltip actions to the mod logs and fixed a react error --- src/components/Shared/ActorMeta.jsx | 14 ++++++++++++-- src/components/Tooltip.jsx | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/Shared/ActorMeta.jsx b/src/components/Shared/ActorMeta.jsx index 2005aa0..8bd4b03 100644 --- a/src/components/Shared/ActorMeta.jsx +++ b/src/components/Shared/ActorMeta.jsx @@ -28,6 +28,7 @@ import { selectShowAvatars, selectNsfwWords, } from "../../redux/reducer/configReducer"; +import { useNavigate } from "react-router-dom"; export function PersonMetaLine({ creator, by = false, sx }) { const { baseUrl, siteData, localPerson, userRole } = getSiteData(); @@ -119,12 +120,16 @@ export function PersonMetaLine({ creator, by = false, sx }) { export function CommunityMetaLine({ community, showIn = false, sx }) { const { baseUrl, siteData, localPerson, userRole } = getSiteData(); - + const navigate = useNavigate(); const actorInstanceBaseUrl = community.actor_id.split("/")[2]; const fediverseCommunityLink = community.actor_id; console.log("community", actorInstanceBaseUrl, fediverseCommunityLink); + const redirectToModlogCommunity = (community) => { + navigate(`/actions?community_id=${community.id}`); + } + let localCommunityLink = `https://${baseUrl}/c/${community.name}`; if (baseUrl != actorInstanceBaseUrl) localCommunityLink = `${localCommunityLink}@${actorInstanceBaseUrl}`; @@ -151,8 +156,13 @@ export function CommunityMetaLine({ community, showIn = false, sx }) { placement="top" variant="outlined" title={baseUrl == actorInstanceBaseUrl ? "Local Community" : "Remote Community"} + sx={{ + cursor: "pointer", + }} + onClick={() => { + redirectToModlogCommunity(community) + }} arrow - disableInteractive > diff --git a/src/components/Tooltip.jsx b/src/components/Tooltip.jsx index 62094c4..04fc800 100644 --- a/src/components/Tooltip.jsx +++ b/src/components/Tooltip.jsx @@ -29,11 +29,12 @@ import { selectShowAvatars, selectNsfwWords, } from "../redux/reducer/configReducer"; +import { useNavigate } from "react-router-dom"; export const UserTooltip = ({ user, ...props }) => { console.log("user", user); const showAvatars = useSelector(selectShowAvatars); - + const navigate = useNavigate(); // get user modlog entries const { isLoading: userModActionsLoading, @@ -44,6 +45,10 @@ export const UserTooltip = ({ user, ...props }) => { other_person_id: user.id, }); + const redirectToModlogActedOn = (user) => { + navigate(`/actions?acted_on__id=${user.id}`); + } + const fullUserString = `${user.name}@${user.actor_id.split("/")[2]}`; return ( @@ -85,10 +90,14 @@ export const UserTooltip = ({ user, ...props }) => { )} - User Mod Activity + { + redirectToModlogActedOn(user); + }}>User Mod Activity {/* List of actions taken on this user */} - + { + redirectToModlogActedOn(user); + }}> {(userModActionsLoading || userModActionsFetching) && Loading...} {userModActionsError && Error: {userModActionsError.message}} {userModActionsData && ( @@ -97,6 +106,7 @@ export const UserTooltip = ({ user, ...props }) => { (action) => userModActionsData[action].length > 0 && ( {userModActionsData[action].length}} > From b183704385fa53ca97884a786fe4351f286ad21e Mon Sep 17 00:00:00 2001 From: Domenic Horner Date: Sat, 11 Nov 2023 22:11:30 +0800 Subject: [PATCH 3/3] fix extra underscore --- src/components/Tooltip.jsx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/components/Tooltip.jsx b/src/components/Tooltip.jsx index a1472ab..d7a3720 100644 --- a/src/components/Tooltip.jsx +++ b/src/components/Tooltip.jsx @@ -45,8 +45,8 @@ export const UserTooltip = ({ user, ...props }) => { }); const redirectToModlogActedOn = (user) => { - navigate(`/actions?acted_on__id=${user.id}`); - } + navigate(`/actions?acted_on_id=${user.id}`); + }; const fullUserString = `${user.name}@${user.actor_id.split("/")[2]}`; @@ -89,14 +89,29 @@ export const UserTooltip = ({ user, ...props }) => { )} - { - redirectToModlogActedOn(user); - }}>User Mod Activity + { + redirectToModlogActedOn(user); + }} + > + User Mod Activity + {/* List of actions taken on this user */} - { - redirectToModlogActedOn(user); - }}> + { + redirectToModlogActedOn(user); + }} + > {(userModActionsLoading || userModActionsFetching) && Loading...} {userModActionsError && Error: {userModActionsError.message}} {userModActionsData && (