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 #74

Merged
merged 5 commits into from
Oct 24, 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: 4 additions & 0 deletions src/components/Actions/PostButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ export const PurgePostButton = ({ report, ...props }) => {
const [confirmOpen, setConfirmOpen] = React.useState(false);
const [purgeReason, setPurgeReason] = React.useState("");

const { userRole } = getSiteData();

const queryClient = useQueryClient();

const { data, callAction, isSuccess, isLoading, error } = useLemmyHttpAction("purgePost");
Expand All @@ -247,6 +249,8 @@ export const PurgePostButton = ({ report, ...props }) => {
}
}, [data]);

if (userRole != "admin") return null;

return (
<>
<BaseActionButton
Expand Down
44 changes: 28 additions & 16 deletions src/components/Activity/ModLogAccordians.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,18 @@ function ModDisplayName({ moderator }) {
);
}

import ForumIcon from "@mui/icons-material/Forum";
function RemovedPostRow({ item }) {
return (
<BaseAccordian
item={item}
tint="#a83a3a21"
headerIcon={<RemoveCircleOutlineIcon />}
tint={item.mod_remove_post.removed ? "#ff3e3e21" : "#08ba3a21"}
headerIcon={<ForumIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> removed post from {item.community.actor_id}{" "}
{item.mod_remove_post.reason ? `with reason: "${item.mod_remove_post.reason}"` : ""}
<ModDisplayName moderator={item.moderator} /> re{item.mod_remove_post.removed ? "moved" : "stored"}{" "}
post in {item.community.actor_id}
{item.mod_remove_post.reason ? ` with reason: "${item.mod_remove_post.reason}"` : ""}
</>
}
>
Expand Down Expand Up @@ -220,10 +222,12 @@ function LockedPostRow({ item }) {
return (
<BaseAccordian
item={item}
tint={item.mod_lock_post.locked ? "#ff3e3e21" : "#08ba3a21"}
headerIcon={<LockIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> locked post in {item.community.actor_id}
<ModDisplayName moderator={item.moderator} /> {item.mod_lock_post.locked ? "locked" : "unlocked"}{" "}
post in {item.community.actor_id}
</>
}
>
Expand Down Expand Up @@ -260,10 +264,12 @@ function AddedToCommunityRow({ item }) {
return (
<BaseAccordian
item={item}
tint={item.mod_add_community.removed ? "#ff3e3e21" : "#08ba3a21"}
headerIcon={<SwitchAccessShortcutAddIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> added to community {item.community.actor_id}
<ModDisplayName moderator={item.moderator} />{" "}
{item.mod_add_community.removed ? "removed from" : "added to"} community {item.community.actor_id}
</>
}
>
Expand All @@ -278,9 +284,11 @@ function FeaturedPostRow({ item }) {
<BaseAccordian
item={item}
headerIcon={<SwipeUpAltIcon />}
tint={!item.mod_feature_post.featured ? "#ff3e3e21" : "#08ba3a21"}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> featured post in {item.community.actor_id}
<ModDisplayName moderator={item.moderator} />{" "}
{item.mod_feature_post.featured ? "featured" : "unfeatured"} post in {item.community.actor_id}
</>
}
>
Expand Down Expand Up @@ -314,7 +322,8 @@ function TransferredToCommunityRow({ item }) {
headerIcon={<TransferWithinAStationIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> transferred community {item.community.actor_id}
<ModDisplayName moderator={item.moderator} /> modded person "{item.modded_person.actor_id}" in
community "{item.community.actor_id}"
</>
}
>
Expand All @@ -328,10 +337,12 @@ function AddedRow({ item }) {
return (
<BaseAccordian
item={item}
tint={item.mod_add.removed ? "#ff3e3e21" : "#08ba3a21"}
headerIcon={<PersonAddAlt1Icon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> added {item.modded_person.actor_id}
<ModDisplayName moderator={item.moderator} />{" "}
{item.mod_add.removed ? "removed admin from" : "gave admin to"} "{item.modded_person.actor_id}"
</>
}
>
Expand All @@ -348,7 +359,8 @@ function AdminPurgedPersonsRow({ item }) {
headerIcon={<SecurityIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> admin purged person {item.admin_purge_person.reason}
<ModDisplayName moderator={item.moderator} /> admin purged person{" "}
{item.admin_purge_person.reason ? ` with reason: "${item.admin_purge_person.reason}"` : ""}
</>
}
>
Expand All @@ -363,8 +375,8 @@ function AdminPurgedCommunitiesRow({ item }) {
headerIcon={<SecurityIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> admin purged community {item.admin_purge_community.id}
: "{item.admin_purge_community.reason}"
<ModDisplayName moderator={item.moderator} /> admin purged community {item.admin_purge_community.id}{" "}
{item.admin_purge_community.reason ? ` with reason: "${item.admin_purge_community.reason}"` : ""}
</>
}
>
Expand All @@ -379,8 +391,8 @@ function AdminPurgedPostsRow({ item }) {
headerIcon={<SecurityIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> admin purged posts {item.actorId} "
{item.admin_purge_post.reason}"
<ModDisplayName moderator={item.moderator} /> admin purged posts {item.actorId}{" "}
{item.admin_purge_post.reason ? ` with reason: "${item.admin_purge_post.reason}"` : ""}
</>
}
>
Expand All @@ -395,8 +407,8 @@ function AdminPurgedCommentsRow({ item }) {
headerIcon={<SecurityIcon />}
headerContent={
<>
<ModDisplayName moderator={item.moderator} /> admin purged comment "
{item.admin_purge_comment.reason}"
<ModDisplayName moderator={item.moderator} /> admin purged comment{" "}
{item.admin_purge_comment.reason ? ` with reason: "${item.admin_purge_comment.reason}"` : ""}
</>
}
>
Expand Down
7 changes: 4 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export function getModLogTypeNames() {
added_to_community: "Adding Mod to Community",
transferred_to_community: "Transferring Communities",

added: "Adding Mod to Site",
added: "Site Admin Changes", // promote site admin

banned: "Mod Ban",
ModHideCommunity: "Mod Hide Community",
banned: "Site Bans", // ban user from site

// ModHideCommunity: "Mod Hide Community", // TODO doesn't seem used?

admin_purged_persons: "Admin Purge Person",
admin_purged_communities: "Admin Purge Community",
Expand Down