mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-30 00:01:15 +00:00
Merge branch 'modlog-filters-dess'
This commit is contained in:
commit
53e973c140
7 changed files with 305 additions and 72 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 9ba11fa31001baac6bacb4eea651942cc48d41a9
|
Subproject commit 7ac48ae98271b3b573e28c90b87f9704492e0b62
|
|
@ -77,7 +77,7 @@
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
"import-sort-style-module": "^6.0.0",
|
"import-sort-style-module": "^6.0.0",
|
||||||
"lemmy-js-client": "0.17.0-rc.41",
|
"lemmy-js-client": "0.17.0-rc.43",
|
||||||
"lint-staged": "^13.0.3",
|
"lint-staged": "^13.0.3",
|
||||||
"mini-css-extract-plugin": "^2.6.1",
|
"mini-css-extract-plugin": "^2.6.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
|
|
@ -375,6 +375,10 @@ br.big {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modlog-choices-font-size {
|
||||||
|
font-size: .9375rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
.preview-lines {
|
.preview-lines {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|
|
@ -54,6 +54,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
description: None,
|
description: None,
|
||||||
community_creation_admin_only: None,
|
community_creation_admin_only: None,
|
||||||
auth: undefined,
|
auth: undefined,
|
||||||
|
hide_modlog_mod_names: Some(true),
|
||||||
}),
|
}),
|
||||||
loading: false,
|
loading: false,
|
||||||
themeList: None,
|
themeList: None,
|
||||||
|
@ -98,6 +99,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
default_theme: Some(site.default_theme),
|
default_theme: Some(site.default_theme),
|
||||||
default_post_listing_type: Some(site.default_post_listing_type),
|
default_post_listing_type: Some(site.default_post_listing_type),
|
||||||
legal_information: site.legal_information,
|
legal_information: site.legal_information,
|
||||||
|
hide_modlog_mod_names: site.hide_modlog_mod_names,
|
||||||
auth: undefined,
|
auth: undefined,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -437,6 +439,27 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
id="create-site-hide-modlog-mod-names"
|
||||||
|
type="checkbox"
|
||||||
|
checked={toUndefined(
|
||||||
|
this.state.siteForm.hide_modlog_mod_names
|
||||||
|
)}
|
||||||
|
onChange={linkEvent(this, this.handleSiteHideModlogModNames)}
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
class="form-check-label"
|
||||||
|
htmlFor="create-site-hide-modlog-mod-names"
|
||||||
|
>
|
||||||
|
{i18n.t("hide_modlog_mod_names")}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<button
|
<button
|
||||||
|
@ -495,6 +518,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
default_theme: sForm.default_theme,
|
default_theme: sForm.default_theme,
|
||||||
default_post_listing_type: sForm.default_post_listing_type,
|
default_post_listing_type: sForm.default_post_listing_type,
|
||||||
auth: auth().unwrap(),
|
auth: auth().unwrap(),
|
||||||
|
hide_modlog_mod_names: sForm.hide_modlog_mod_names,
|
||||||
});
|
});
|
||||||
WebSocketService.Instance.send(wsClient.createSite(form));
|
WebSocketService.Instance.send(wsClient.createSite(form));
|
||||||
}
|
}
|
||||||
|
@ -561,6 +585,11 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSiteHideModlogModNames(i: SiteForm, event: any) {
|
||||||
|
i.state.siteForm.hide_modlog_mod_names = Some(event.target.checked);
|
||||||
|
i.setState(i.state);
|
||||||
|
}
|
||||||
|
|
||||||
handleSiteDefaultTheme(i: SiteForm, event: any) {
|
handleSiteDefaultTheme(i: SiteForm, event: any) {
|
||||||
i.state.siteForm.default_theme = Some(event.target.value);
|
i.state.siteForm.default_theme = Some(event.target.value);
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { None, Option, Some } from "@sniptt/monads";
|
import { None, Option, Some } from "@sniptt/monads";
|
||||||
import { Component } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import { Link } from "inferno-router";
|
import { Link } from "inferno-router";
|
||||||
import {
|
import {
|
||||||
AdminPurgeCommentView,
|
AdminPurgeCommentView,
|
||||||
|
@ -17,12 +17,14 @@ import {
|
||||||
ModBanFromCommunityView,
|
ModBanFromCommunityView,
|
||||||
ModBanView,
|
ModBanView,
|
||||||
ModLockPostView,
|
ModLockPostView,
|
||||||
|
ModlogActionType,
|
||||||
ModRemoveCommentView,
|
ModRemoveCommentView,
|
||||||
ModRemoveCommunityView,
|
ModRemoveCommunityView,
|
||||||
ModRemovePostView,
|
ModRemovePostView,
|
||||||
ModStickyPostView,
|
ModStickyPostView,
|
||||||
ModTransferCommunityView,
|
ModTransferCommunityView,
|
||||||
PersonSafe,
|
PersonSafe,
|
||||||
|
toUndefined,
|
||||||
UserOperation,
|
UserOperation,
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
wsUserOp,
|
wsUserOp,
|
||||||
|
@ -36,7 +38,10 @@ import {
|
||||||
amAdmin,
|
amAdmin,
|
||||||
amMod,
|
amMod,
|
||||||
auth,
|
auth,
|
||||||
|
choicesModLogConfig,
|
||||||
|
debounce,
|
||||||
fetchLimit,
|
fetchLimit,
|
||||||
|
fetchUsers,
|
||||||
isBrowser,
|
isBrowser,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
toast,
|
toast,
|
||||||
|
@ -49,28 +54,10 @@ import { MomentTime } from "./common/moment-time";
|
||||||
import { Paginator } from "./common/paginator";
|
import { Paginator } from "./common/paginator";
|
||||||
import { CommunityLink } from "./community/community-link";
|
import { CommunityLink } from "./community/community-link";
|
||||||
import { PersonListing } from "./person/person-listing";
|
import { PersonListing } from "./person/person-listing";
|
||||||
|
|
||||||
enum ModlogEnum {
|
|
||||||
ModRemovePost,
|
|
||||||
ModLockPost,
|
|
||||||
ModStickyPost,
|
|
||||||
ModRemoveComment,
|
|
||||||
ModRemoveCommunity,
|
|
||||||
ModBanFromCommunity,
|
|
||||||
ModAddCommunity,
|
|
||||||
ModTransferCommunity,
|
|
||||||
ModAdd,
|
|
||||||
ModBan,
|
|
||||||
AdminPurgePerson,
|
|
||||||
AdminPurgeCommunity,
|
|
||||||
AdminPurgePost,
|
|
||||||
AdminPurgeComment,
|
|
||||||
}
|
|
||||||
|
|
||||||
type ModlogType = {
|
type ModlogType = {
|
||||||
id: number;
|
id: number;
|
||||||
type_: ModlogEnum;
|
type_: ModlogActionType;
|
||||||
moderator: PersonSafe;
|
moderator: Option<PersonSafe>;
|
||||||
view:
|
view:
|
||||||
| ModRemovePostView
|
| ModRemovePostView
|
||||||
| ModLockPostView
|
| ModLockPostView
|
||||||
|
@ -88,14 +75,22 @@ type ModlogType = {
|
||||||
| AdminPurgeCommentView;
|
| AdminPurgeCommentView;
|
||||||
when_: string;
|
when_: string;
|
||||||
};
|
};
|
||||||
|
var Choices: any;
|
||||||
|
if (isBrowser()) {
|
||||||
|
Choices = require("choices.js");
|
||||||
|
}
|
||||||
|
|
||||||
interface ModlogState {
|
interface ModlogState {
|
||||||
res: Option<GetModlogResponse>;
|
res: Option<GetModlogResponse>;
|
||||||
communityId: Option<number>;
|
communityId: Option<number>;
|
||||||
communityMods: Option<CommunityModeratorView[]>;
|
communityMods: Option<CommunityModeratorView[]>;
|
||||||
|
communityName: Option<string>;
|
||||||
page: number;
|
page: number;
|
||||||
siteRes: GetSiteResponse;
|
siteRes: GetSiteResponse;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
filter_action: ModlogActionType;
|
||||||
|
filter_user: Option<number>;
|
||||||
|
filter_mod: Option<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Modlog extends Component<any, ModlogState> {
|
export class Modlog extends Component<any, ModlogState> {
|
||||||
|
@ -105,18 +100,22 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
GetCommunityResponse
|
GetCommunityResponse
|
||||||
);
|
);
|
||||||
private subscription: Subscription;
|
private subscription: Subscription;
|
||||||
|
private userChoices: any;
|
||||||
|
private modChoices: any;
|
||||||
private emptyState: ModlogState = {
|
private emptyState: ModlogState = {
|
||||||
res: None,
|
res: None,
|
||||||
communityId: None,
|
communityId: None,
|
||||||
communityMods: None,
|
communityMods: None,
|
||||||
|
communityName: None,
|
||||||
page: 1,
|
page: 1,
|
||||||
loading: true,
|
loading: true,
|
||||||
siteRes: this.isoData.site_res,
|
siteRes: this.isoData.site_res,
|
||||||
|
filter_action: ModlogActionType.All,
|
||||||
|
filter_user: None,
|
||||||
|
filter_mod: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: any, context: any) {
|
constructor(props: any, context: any) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
|
||||||
this.state = this.emptyState;
|
this.state = this.emptyState;
|
||||||
this.handlePageChange = this.handlePageChange.bind(this);
|
this.handlePageChange = this.handlePageChange.bind(this);
|
||||||
|
|
||||||
|
@ -145,6 +144,11 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.setupUserFilter();
|
||||||
|
this.setupModFilter();
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (isBrowser()) {
|
if (isBrowser()) {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
@ -154,7 +158,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
buildCombined(res: GetModlogResponse): ModlogType[] {
|
buildCombined(res: GetModlogResponse): ModlogType[] {
|
||||||
let removed_posts: ModlogType[] = res.removed_posts.map(r => ({
|
let removed_posts: ModlogType[] = res.removed_posts.map(r => ({
|
||||||
id: r.mod_remove_post.id,
|
id: r.mod_remove_post.id,
|
||||||
type_: ModlogEnum.ModRemovePost,
|
type_: ModlogActionType.ModRemovePost,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_remove_post.when_,
|
when_: r.mod_remove_post.when_,
|
||||||
|
@ -162,7 +166,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let locked_posts: ModlogType[] = res.locked_posts.map(r => ({
|
let locked_posts: ModlogType[] = res.locked_posts.map(r => ({
|
||||||
id: r.mod_lock_post.id,
|
id: r.mod_lock_post.id,
|
||||||
type_: ModlogEnum.ModLockPost,
|
type_: ModlogActionType.ModLockPost,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_lock_post.when_,
|
when_: r.mod_lock_post.when_,
|
||||||
|
@ -170,7 +174,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let stickied_posts: ModlogType[] = res.stickied_posts.map(r => ({
|
let stickied_posts: ModlogType[] = res.stickied_posts.map(r => ({
|
||||||
id: r.mod_sticky_post.id,
|
id: r.mod_sticky_post.id,
|
||||||
type_: ModlogEnum.ModStickyPost,
|
type_: ModlogActionType.ModStickyPost,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_sticky_post.when_,
|
when_: r.mod_sticky_post.when_,
|
||||||
|
@ -178,7 +182,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let removed_comments: ModlogType[] = res.removed_comments.map(r => ({
|
let removed_comments: ModlogType[] = res.removed_comments.map(r => ({
|
||||||
id: r.mod_remove_comment.id,
|
id: r.mod_remove_comment.id,
|
||||||
type_: ModlogEnum.ModRemoveComment,
|
type_: ModlogActionType.ModRemoveComment,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_remove_comment.when_,
|
when_: r.mod_remove_comment.when_,
|
||||||
|
@ -186,7 +190,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let removed_communities: ModlogType[] = res.removed_communities.map(r => ({
|
let removed_communities: ModlogType[] = res.removed_communities.map(r => ({
|
||||||
id: r.mod_remove_community.id,
|
id: r.mod_remove_community.id,
|
||||||
type_: ModlogEnum.ModRemoveCommunity,
|
type_: ModlogActionType.ModRemoveCommunity,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_remove_community.when_,
|
when_: r.mod_remove_community.when_,
|
||||||
|
@ -195,7 +199,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
let banned_from_community: ModlogType[] = res.banned_from_community.map(
|
let banned_from_community: ModlogType[] = res.banned_from_community.map(
|
||||||
r => ({
|
r => ({
|
||||||
id: r.mod_ban_from_community.id,
|
id: r.mod_ban_from_community.id,
|
||||||
type_: ModlogEnum.ModBanFromCommunity,
|
type_: ModlogActionType.ModBanFromCommunity,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_ban_from_community.when_,
|
when_: r.mod_ban_from_community.when_,
|
||||||
|
@ -204,7 +208,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let added_to_community: ModlogType[] = res.added_to_community.map(r => ({
|
let added_to_community: ModlogType[] = res.added_to_community.map(r => ({
|
||||||
id: r.mod_add_community.id,
|
id: r.mod_add_community.id,
|
||||||
type_: ModlogEnum.ModAddCommunity,
|
type_: ModlogActionType.ModAddCommunity,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_add_community.when_,
|
when_: r.mod_add_community.when_,
|
||||||
|
@ -213,7 +217,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
let transferred_to_community: ModlogType[] =
|
let transferred_to_community: ModlogType[] =
|
||||||
res.transferred_to_community.map(r => ({
|
res.transferred_to_community.map(r => ({
|
||||||
id: r.mod_transfer_community.id,
|
id: r.mod_transfer_community.id,
|
||||||
type_: ModlogEnum.ModTransferCommunity,
|
type_: ModlogActionType.ModTransferCommunity,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_transfer_community.when_,
|
when_: r.mod_transfer_community.when_,
|
||||||
|
@ -221,7 +225,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let added: ModlogType[] = res.added.map(r => ({
|
let added: ModlogType[] = res.added.map(r => ({
|
||||||
id: r.mod_add.id,
|
id: r.mod_add.id,
|
||||||
type_: ModlogEnum.ModAdd,
|
type_: ModlogActionType.ModAdd,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_add.when_,
|
when_: r.mod_add.when_,
|
||||||
|
@ -229,7 +233,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let banned: ModlogType[] = res.banned.map(r => ({
|
let banned: ModlogType[] = res.banned.map(r => ({
|
||||||
id: r.mod_ban.id,
|
id: r.mod_ban.id,
|
||||||
type_: ModlogEnum.ModBan,
|
type_: ModlogActionType.ModBan,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.moderator,
|
moderator: r.moderator,
|
||||||
when_: r.mod_ban.when_,
|
when_: r.mod_ban.when_,
|
||||||
|
@ -237,7 +241,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let purged_persons: ModlogType[] = res.admin_purged_persons.map(r => ({
|
let purged_persons: ModlogType[] = res.admin_purged_persons.map(r => ({
|
||||||
id: r.admin_purge_person.id,
|
id: r.admin_purge_person.id,
|
||||||
type_: ModlogEnum.AdminPurgePerson,
|
type_: ModlogActionType.AdminPurgePerson,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.admin,
|
moderator: r.admin,
|
||||||
when_: r.admin_purge_person.when_,
|
when_: r.admin_purge_person.when_,
|
||||||
|
@ -246,7 +250,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
let purged_communities: ModlogType[] = res.admin_purged_communities.map(
|
let purged_communities: ModlogType[] = res.admin_purged_communities.map(
|
||||||
r => ({
|
r => ({
|
||||||
id: r.admin_purge_community.id,
|
id: r.admin_purge_community.id,
|
||||||
type_: ModlogEnum.AdminPurgeCommunity,
|
type_: ModlogActionType.AdminPurgeCommunity,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.admin,
|
moderator: r.admin,
|
||||||
when_: r.admin_purge_community.when_,
|
when_: r.admin_purge_community.when_,
|
||||||
|
@ -255,7 +259,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let purged_posts: ModlogType[] = res.admin_purged_posts.map(r => ({
|
let purged_posts: ModlogType[] = res.admin_purged_posts.map(r => ({
|
||||||
id: r.admin_purge_post.id,
|
id: r.admin_purge_post.id,
|
||||||
type_: ModlogEnum.AdminPurgePost,
|
type_: ModlogActionType.AdminPurgePost,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.admin,
|
moderator: r.admin,
|
||||||
when_: r.admin_purge_post.when_,
|
when_: r.admin_purge_post.when_,
|
||||||
|
@ -263,7 +267,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
let purged_comments: ModlogType[] = res.admin_purged_comments.map(r => ({
|
let purged_comments: ModlogType[] = res.admin_purged_comments.map(r => ({
|
||||||
id: r.admin_purge_comment.id,
|
id: r.admin_purge_comment.id,
|
||||||
type_: ModlogEnum.AdminPurgeComment,
|
type_: ModlogActionType.AdminPurgeComment,
|
||||||
view: r,
|
view: r,
|
||||||
moderator: r.admin,
|
moderator: r.admin,
|
||||||
when_: r.admin_purge_comment.when_,
|
when_: r.admin_purge_comment.when_,
|
||||||
|
@ -294,7 +298,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
renderModlogType(i: ModlogType) {
|
renderModlogType(i: ModlogType) {
|
||||||
switch (i.type_) {
|
switch (i.type_) {
|
||||||
case ModlogEnum.ModRemovePost: {
|
case ModlogActionType.ModRemovePost: {
|
||||||
let mrpv = i.view as ModRemovePostView;
|
let mrpv = i.view as ModRemovePostView;
|
||||||
return [
|
return [
|
||||||
mrpv.mod_remove_post.removed.unwrapOr(false)
|
mrpv.mod_remove_post.removed.unwrapOr(false)
|
||||||
|
@ -309,7 +313,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModLockPost: {
|
case ModlogActionType.ModLockPost: {
|
||||||
let mlpv = i.view as ModLockPostView;
|
let mlpv = i.view as ModLockPostView;
|
||||||
return [
|
return [
|
||||||
mlpv.mod_lock_post.locked.unwrapOr(false) ? "Locked " : "Unlocked ",
|
mlpv.mod_lock_post.locked.unwrapOr(false) ? "Locked " : "Unlocked ",
|
||||||
|
@ -318,7 +322,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</span>,
|
</span>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModStickyPost: {
|
case ModlogActionType.ModStickyPost: {
|
||||||
let mspv = i.view as ModStickyPostView;
|
let mspv = i.view as ModStickyPostView;
|
||||||
return [
|
return [
|
||||||
mspv.mod_sticky_post.stickied.unwrapOr(false)
|
mspv.mod_sticky_post.stickied.unwrapOr(false)
|
||||||
|
@ -329,7 +333,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</span>,
|
</span>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModRemoveComment: {
|
case ModlogActionType.ModRemoveComment: {
|
||||||
let mrc = i.view as ModRemoveCommentView;
|
let mrc = i.view as ModRemoveCommentView;
|
||||||
return [
|
return [
|
||||||
mrc.mod_remove_comment.removed.unwrapOr(false)
|
mrc.mod_remove_comment.removed.unwrapOr(false)
|
||||||
|
@ -351,7 +355,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModRemoveCommunity: {
|
case ModlogActionType.ModRemoveCommunity: {
|
||||||
let mrco = i.view as ModRemoveCommunityView;
|
let mrco = i.view as ModRemoveCommunityView;
|
||||||
return [
|
return [
|
||||||
mrco.mod_remove_community.removed.unwrapOr(false)
|
mrco.mod_remove_community.removed.unwrapOr(false)
|
||||||
|
@ -372,7 +376,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModBanFromCommunity: {
|
case ModlogActionType.ModBanFromCommunity: {
|
||||||
let mbfc = i.view as ModBanFromCommunityView;
|
let mbfc = i.view as ModBanFromCommunityView;
|
||||||
return [
|
return [
|
||||||
<span>
|
<span>
|
||||||
|
@ -399,7 +403,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModAddCommunity: {
|
case ModlogActionType.ModAddCommunity: {
|
||||||
let mac = i.view as ModAddCommunityView;
|
let mac = i.view as ModAddCommunityView;
|
||||||
return [
|
return [
|
||||||
<span>
|
<span>
|
||||||
|
@ -416,7 +420,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</span>,
|
</span>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModTransferCommunity: {
|
case ModlogActionType.ModTransferCommunity: {
|
||||||
let mtc = i.view as ModTransferCommunityView;
|
let mtc = i.view as ModTransferCommunityView;
|
||||||
return [
|
return [
|
||||||
<span>
|
<span>
|
||||||
|
@ -433,7 +437,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</span>,
|
</span>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModBan: {
|
case ModlogActionType.ModBan: {
|
||||||
let mb = i.view as ModBanView;
|
let mb = i.view as ModBanView;
|
||||||
return [
|
return [
|
||||||
<span>
|
<span>
|
||||||
|
@ -454,7 +458,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.ModAdd: {
|
case ModlogActionType.ModAdd: {
|
||||||
let ma = i.view as ModAddView;
|
let ma = i.view as ModAddView;
|
||||||
return [
|
return [
|
||||||
<span>
|
<span>
|
||||||
|
@ -466,7 +470,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
<span> as an admin </span>,
|
<span> as an admin </span>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.AdminPurgePerson: {
|
case ModlogActionType.AdminPurgePerson: {
|
||||||
let ap = i.view as AdminPurgePersonView;
|
let ap = i.view as AdminPurgePersonView;
|
||||||
return [
|
return [
|
||||||
<span>Purged a Person</span>,
|
<span>Purged a Person</span>,
|
||||||
|
@ -476,7 +480,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.AdminPurgeCommunity: {
|
case ModlogActionType.AdminPurgeCommunity: {
|
||||||
let ap = i.view as AdminPurgeCommunityView;
|
let ap = i.view as AdminPurgeCommunityView;
|
||||||
return [
|
return [
|
||||||
<span>Purged a Community</span>,
|
<span>Purged a Community</span>,
|
||||||
|
@ -486,7 +490,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.AdminPurgePost: {
|
case ModlogActionType.AdminPurgePost: {
|
||||||
let ap = i.view as AdminPurgePostView;
|
let ap = i.view as AdminPurgePostView;
|
||||||
return [
|
return [
|
||||||
<span>Purged a Post from from </span>,
|
<span>Purged a Post from from </span>,
|
||||||
|
@ -497,7 +501,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case ModlogEnum.AdminPurgeComment: {
|
case ModlogActionType.AdminPurgeComment: {
|
||||||
let ap = i.view as AdminPurgeCommentView;
|
let ap = i.view as AdminPurgeCommentView;
|
||||||
return [
|
return [
|
||||||
<span>
|
<span>
|
||||||
|
@ -527,7 +531,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{this.amAdminOrMod ? (
|
{this.amAdminOrMod ? (
|
||||||
<PersonListing person={i.moderator} />
|
<PersonListing person={i.moderator.unwrap()} />
|
||||||
) : (
|
) : (
|
||||||
<div>{this.modOrAdminText(i.moderator)}</div>
|
<div>{this.modOrAdminText(i.moderator)}</div>
|
||||||
)}
|
)}
|
||||||
|
@ -546,14 +550,14 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
modOrAdminText(person: PersonSafe): string {
|
modOrAdminText(person: Option<PersonSafe>): string {
|
||||||
if (
|
return person.match({
|
||||||
this.isoData.site_res.admins.map(a => a.person.id).includes(person.id)
|
some: res =>
|
||||||
) {
|
this.isoData.site_res.admins.map(a => a.person.id).includes(res.id)
|
||||||
return i18n.t("admin");
|
? i18n.t("admin")
|
||||||
} else {
|
: i18n.t("mod"),
|
||||||
return i18n.t("mod");
|
none: i18n.t("mod"),
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get documentTitle(): string {
|
get documentTitle(): string {
|
||||||
|
@ -565,7 +569,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class="container">
|
<div className="container">
|
||||||
<HtmlTags
|
<HtmlTags
|
||||||
title={this.documentTitle}
|
title={this.documentTitle}
|
||||||
path={this.context.router.route.match.url}
|
path={this.context.router.route.match.url}
|
||||||
|
@ -578,9 +582,81 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</h5>
|
</h5>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<div class="table-responsive">
|
<h5>
|
||||||
<table id="modlog_table" class="table table-sm table-hover">
|
{this.state.communityName.match({
|
||||||
<thead class="pointer">
|
some: name => (
|
||||||
|
<Link className="text-body" to={`/c/${name}`}>
|
||||||
|
/c/{name}{" "}
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
none: <></>,
|
||||||
|
})}
|
||||||
|
<span>{i18n.t("modlog")}</span>
|
||||||
|
</h5>
|
||||||
|
<form className="form-inline mr-2">
|
||||||
|
<select
|
||||||
|
value={this.state.filter_action}
|
||||||
|
onChange={linkEvent(this, this.handleFilterActionChange)}
|
||||||
|
className="custom-select col-4 mb-2"
|
||||||
|
aria-label="action"
|
||||||
|
>
|
||||||
|
<option disabled aria-hidden="true">
|
||||||
|
{i18n.t("filter_by_action")}
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.All}>{i18n.t("all")}</option>
|
||||||
|
<option value={ModlogActionType.ModRemovePost}>
|
||||||
|
Removing Posts
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModLockPost}>
|
||||||
|
Locking Posts
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModStickyPost}>
|
||||||
|
Stickying Posts
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModRemoveComment}>
|
||||||
|
Removing Comments
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModRemoveCommunity}>
|
||||||
|
Removing Communities
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModBanFromCommunity}>
|
||||||
|
Banning From Communities
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModAddCommunity}>
|
||||||
|
Adding Mod to Community
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModTransferCommunity}>
|
||||||
|
Transfering Communities
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModAdd}>
|
||||||
|
Adding Mod to Site
|
||||||
|
</option>
|
||||||
|
<option value={ModlogActionType.ModBan}>
|
||||||
|
Banning From Site
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
{this.state.siteRes.site_view.match({
|
||||||
|
some: site_view =>
|
||||||
|
!site_view.site.hide_modlog_mod_names.unwrapOr(false) && (
|
||||||
|
<select
|
||||||
|
id="filter-mod"
|
||||||
|
value={toUndefined(this.state.filter_mod)}
|
||||||
|
>
|
||||||
|
<option>{i18n.t("filter_by_mod")}</option>
|
||||||
|
</select>
|
||||||
|
),
|
||||||
|
none: <></>,
|
||||||
|
})}
|
||||||
|
<select
|
||||||
|
id="filter-user"
|
||||||
|
value={toUndefined(this.state.filter_user)}
|
||||||
|
>
|
||||||
|
<option>{i18n.t("filter_by_user")}</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
<div className="table-responsive">
|
||||||
|
<table id="modlog_table" className="table table-sm table-hover">
|
||||||
|
<thead className="pointer">
|
||||||
<tr>
|
<tr>
|
||||||
<th> {i18n.t("time")}</th>
|
<th> {i18n.t("time")}</th>
|
||||||
<th>{i18n.t("mod")}</th>
|
<th>{i18n.t("mod")}</th>
|
||||||
|
@ -600,6 +676,11 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleFilterActionChange(i: Modlog, event: any) {
|
||||||
|
i.setState({ filter_action: event.target.value });
|
||||||
|
i.refetch();
|
||||||
|
}
|
||||||
|
|
||||||
handlePageChange(val: number) {
|
handlePageChange(val: number) {
|
||||||
this.setState({ page: val });
|
this.setState({ page: val });
|
||||||
this.refetch();
|
this.refetch();
|
||||||
|
@ -608,10 +689,12 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
refetch() {
|
refetch() {
|
||||||
let modlogForm = new GetModlog({
|
let modlogForm = new GetModlog({
|
||||||
community_id: this.state.communityId,
|
community_id: this.state.communityId,
|
||||||
mod_person_id: None,
|
|
||||||
page: Some(this.state.page),
|
page: Some(this.state.page),
|
||||||
limit: Some(fetchLimit),
|
limit: Some(fetchLimit),
|
||||||
auth: auth(false).ok(),
|
auth: auth(false).ok(),
|
||||||
|
type_: this.state.filter_action,
|
||||||
|
other_person_id: this.state.filter_user,
|
||||||
|
mod_person_id: this.state.filter_mod,
|
||||||
});
|
});
|
||||||
WebSocketService.Instance.send(wsClient.getModlog(modlogForm));
|
WebSocketService.Instance.send(wsClient.getModlog(modlogForm));
|
||||||
|
|
||||||
|
@ -628,6 +711,86 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupUserFilter() {
|
||||||
|
if (isBrowser()) {
|
||||||
|
let selectId: any = document.getElementById("filter-user");
|
||||||
|
if (selectId) {
|
||||||
|
this.userChoices = new Choices(selectId, choicesModLogConfig);
|
||||||
|
this.userChoices.passedElement.element.addEventListener(
|
||||||
|
"choice",
|
||||||
|
(e: any) => {
|
||||||
|
this.state.filter_user = Some(Number(e.detail.choice.value));
|
||||||
|
this.setState(this.state);
|
||||||
|
this.refetch();
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
this.userChoices.passedElement.element.addEventListener(
|
||||||
|
"search",
|
||||||
|
debounce(async (e: any) => {
|
||||||
|
try {
|
||||||
|
let users = (await fetchUsers(e.detail.value)).users;
|
||||||
|
this.userChoices.setChoices(
|
||||||
|
users.map(u => {
|
||||||
|
return {
|
||||||
|
value: u.person.id.toString(),
|
||||||
|
label: u.person.name,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
"value",
|
||||||
|
"label",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setupModFilter() {
|
||||||
|
if (isBrowser()) {
|
||||||
|
let selectId: any = document.getElementById("filter-mod");
|
||||||
|
if (selectId) {
|
||||||
|
this.modChoices = new Choices(selectId, choicesModLogConfig);
|
||||||
|
this.modChoices.passedElement.element.addEventListener(
|
||||||
|
"choice",
|
||||||
|
(e: any) => {
|
||||||
|
this.state.filter_mod = Some(Number(e.detail.choice.value));
|
||||||
|
this.setState(this.state);
|
||||||
|
this.refetch();
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
this.modChoices.passedElement.element.addEventListener(
|
||||||
|
"search",
|
||||||
|
debounce(async (e: any) => {
|
||||||
|
try {
|
||||||
|
let mods = (await fetchUsers(e.detail.value)).users;
|
||||||
|
this.modChoices.setChoices(
|
||||||
|
mods.map(u => {
|
||||||
|
return {
|
||||||
|
value: u.person.id.toString(),
|
||||||
|
label: u.person.name,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
"value",
|
||||||
|
"label",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
|
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
|
||||||
let pathSplit = req.path.split("/");
|
let pathSplit = req.path.split("/");
|
||||||
let communityId = Some(pathSplit[3]).map(Number);
|
let communityId = Some(pathSplit[3]).map(Number);
|
||||||
|
@ -639,6 +802,8 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
community_id: communityId,
|
community_id: communityId,
|
||||||
mod_person_id: None,
|
mod_person_id: None,
|
||||||
auth: req.auth,
|
auth: req.auth,
|
||||||
|
type_: ModlogActionType.All,
|
||||||
|
other_person_id: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
promises.push(req.client.getModlog(modlogForm));
|
promises.push(req.client.getModlog(modlogForm));
|
||||||
|
@ -671,6 +836,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
} else if (op == UserOperation.GetCommunity) {
|
} else if (op == UserOperation.GetCommunity) {
|
||||||
let data = wsJsonToRes<GetCommunityResponse>(msg, GetCommunityResponse);
|
let data = wsJsonToRes<GetCommunityResponse>(msg, GetCommunityResponse);
|
||||||
this.state.communityMods = Some(data.moderators);
|
this.state.communityMods = Some(data.moderators);
|
||||||
|
this.state.communityName = Some(data.community_view.community.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1271,7 +1271,7 @@ export function showLocal(isoData: IsoData): boolean {
|
||||||
.unwrapOr(false);
|
.unwrapOr(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChoicesValue {
|
export interface ChoicesValue {
|
||||||
value: string;
|
value: string;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
@ -1359,6 +1359,40 @@ export const choicesConfig = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const choicesModLogConfig = {
|
||||||
|
shouldSort: false,
|
||||||
|
searchResultLimit: fetchLimit,
|
||||||
|
classNames: {
|
||||||
|
containerOuter: "choices mb-2 custom-select col-4 px-0",
|
||||||
|
containerInner:
|
||||||
|
"choices__inner bg-secondary border-0 py-0 modlog-choices-font-size",
|
||||||
|
input: "form-control",
|
||||||
|
inputCloned: "choices__input--cloned w-100",
|
||||||
|
list: "choices__list",
|
||||||
|
listItems: "choices__list--multiple",
|
||||||
|
listSingle: "choices__list--single py-0",
|
||||||
|
listDropdown: "choices__list--dropdown",
|
||||||
|
item: "choices__item bg-secondary",
|
||||||
|
itemSelectable: "choices__item--selectable",
|
||||||
|
itemDisabled: "choices__item--disabled",
|
||||||
|
itemChoice: "choices__item--choice",
|
||||||
|
placeholder: "choices__placeholder",
|
||||||
|
group: "choices__group",
|
||||||
|
groupHeading: "choices__heading",
|
||||||
|
button: "choices__button",
|
||||||
|
activeState: "is-active",
|
||||||
|
focusState: "is-focused",
|
||||||
|
openState: "is-open",
|
||||||
|
disabledState: "is-disabled",
|
||||||
|
highlightedState: "text-info",
|
||||||
|
selectedState: "text-info",
|
||||||
|
flippedState: "is-flipped",
|
||||||
|
loadingState: "is-loading",
|
||||||
|
noResults: "has-no-results",
|
||||||
|
noChoices: "has-no-choices",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export function communitySelectName(cv: CommunityView): string {
|
export function communitySelectName(cv: CommunityView): string {
|
||||||
return cv.community.local
|
return cv.community.local
|
||||||
? cv.community.title
|
? cv.community.title
|
||||||
|
|
|
@ -5056,10 +5056,10 @@ lcid@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
invert-kv "^1.0.0"
|
invert-kv "^1.0.0"
|
||||||
|
|
||||||
lemmy-js-client@0.17.0-rc.41:
|
lemmy-js-client@0.17.0-rc.43:
|
||||||
version "0.17.0-rc.41"
|
version "0.17.0-rc.43"
|
||||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.41.tgz#a72bd41b76af834d97914d3790810efa610a6e89"
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.43.tgz#30e985365a93d72184646fdfe359f39ccc2e2091"
|
||||||
integrity sha512-VJ0qMXaEuOvmUxWR/jWnnoWknpNSXxbz/J29ADTn9arJEbOfTQB60ILeg8wICSRI23jzU9/0lqAZ+rjgXN0p4w==
|
integrity sha512-/+TOTZazoi74zwc8H2AJMd/Znrdnqfi0+TrfnmqvQ3fzrOl741ojEURxAHw3NsgW9b8HkubXZFLsi1RVR99UqA==
|
||||||
|
|
||||||
levn@^0.4.1:
|
levn@^0.4.1:
|
||||||
version "0.4.1"
|
version "0.4.1"
|
||||||
|
|
Loading…
Reference in a new issue