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

Add moderator view button #1993

Merged
merged 7 commits into from
Sep 6, 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
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@
"translations:update": "git submodule update --remote --recursive"
},
"lint-staged": {
"*.{ts,tsx,js}": ["prettier --write", "eslint --fix"],
"*.{css, scss}": ["prettier --write"],
"package.json": ["sortpack"]
"*.{ts,tsx,js}": [
"prettier --write",
"eslint --fix"
],
"*.{css, scss}": [
"prettier --write"
],
"package.json": [
"sortpack"
]
},
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.21.5",
Expand Down Expand Up @@ -61,7 +68,7 @@
"inferno-router": "^8.2.2",
"inferno-server": "^8.2.2",
"jwt-decode": "^3.1.2",
"lemmy-js-client": "0.19.0-rc.1",
"lemmy-js-client": "^0.19.0-rc.7",
"lodash.isequal": "^4.5.0",
"markdown-it": "^13.0.1",
"markdown-it-container": "^3.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/server/utils/generate-manifest-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export default async function ({
description: "Create a post.",
},
].concat(
my_user?.local_user_view.person.admin || !community_creation_admin_only
my_user?.local_user_view.local_user.admin ||
!community_creation_admin_only
? [
{
name: "Create Community",
Expand Down
5 changes: 1 addition & 4 deletions src/shared/components/comment/comment-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ export class CommentForm extends Component<CommentFormProps, any> {
: capitalizeFirstLetter(I18NextService.i18n.t("reply"));
}

handleCommentSubmit(content: string, form_id: string, language_id?: number) {
handleCommentSubmit(content: string, language_id?: number) {
const { node, onUpsertComment, edit } = this.props;
if (typeof node === "number") {
const post_id = node;
onUpsertComment({
content,
post_id,
language_id,
form_id,
auth: myAuthRequired(),
});
} else {
Expand All @@ -101,7 +100,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
onUpsertComment({
content,
comment_id,
form_id,
language_id,
auth: myAuthRequired(),
});
Expand All @@ -112,7 +110,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
content,
parent_id,
post_id,
form_id,
language_id,
auth: myAuthRequired(),
});
Expand Down
21 changes: 21 additions & 0 deletions src/shared/components/common/listing-type-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ export class ListingTypeSelect extends Component<
>
{I18NextService.i18n.t("all")}
</label>
{(UserService.Instance.myUserInfo?.moderates.length ?? 0) > 0 && (
<>
<input
id={`${this.id}-moderator-view`}
type="radio"
className="btn-check"
value={"ModeratorView"}
checked={this.state.type_ === "ModeratorView"}
onChange={linkEvent(this, this.handleTypeChange)}
/>
<label
htmlFor={`${this.id}-moderator-view`}
title={I18NextService.i18n.t("moderator_view_description")}
className={classNames("pointer btn btn-outline-secondary", {
active: this.state.type_ === "ModeratorView",
})}
>
{I18NextService.i18n.t("moderator_view")}
</label>
</>
)}
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/common/markdown-textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface MarkdownTextAreaProps {
hideNavigationWarnings?: boolean;
onContentChange?(val: string): void;
onReplyCancel?(): void;
onSubmit?(content: string, formId: string, languageId?: number): void;
onSubmit?(content: string, languageId?: number): void;
allLanguages: Language[]; // TODO should probably be nullable
siteLanguages: number[]; // TODO same
}
Expand Down Expand Up @@ -534,7 +534,7 @@ export class MarkdownTextArea extends Component<
event.preventDefault();
if (i.state.content) {
i.setState({ loading: true, submitted: true });
i.props.onSubmit?.(i.state.content, i.formId, i.state.languageId);
i.props.onSubmit?.(i.state.content, i.state.languageId);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/person/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class Profile extends Component<
classNames="ms-1"
isBanned={isBanned(pv.person)}
isDeleted={pv.person.deleted}
isAdmin={pv.person.admin}
isAdmin={isAdmin(pv.person.id, admins)}
isBot={pv.person.bot_account}
/>
</li>
Expand Down
2 changes: 2 additions & 0 deletions src/shared/components/person/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,8 @@ export class Settings extends Component<any, SettingsState> {
const deleteAccountRes = await HttpService.client.deleteAccount({
password,
auth: myAuthRequired(),
// TODO: promt user weather he wants the content to be deleted
delete_content: false,
});
if (deleteAccountRes.state === "success") {
UserService.Instance.logout();
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils/roles/am-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { UserService } from "../../services";
export default function amAdmin(
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
return myUserInfo?.local_user_view.person.admin ?? false;
return myUserInfo?.local_user_view.local_user.admin ?? false;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6035,10 +6035,10 @@ leac@^0.6.0:
resolved "https://registry.yarnpkg.com/leac/-/leac-0.6.0.tgz#dcf136e382e666bd2475f44a1096061b70dc0912"
integrity sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==

lemmy-js-client@0.19.0-rc.1:
version "0.19.0-rc.1"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-rc.1.tgz#e6bf9abdd82ea7bb7035a120925498f6dd8851c9"
integrity sha512-d0rDCvGV8lh8JkRjeEZdWjuE2OAvrDSei+4LUUSrcJVVMqG9PdjPRstKJ3JG4kT1aH3Nsp5AQynMyh9iQrfgTg==
lemmy-js-client@^0.19.0-rc.7:
version "0.19.0-rc.7"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-rc.7.tgz#822dd85c44c2df03eafb71c6e046dbeeb6ed854d"
integrity sha512-dqnyepju5sCRu+zwwm8GeQtXJpRnz/mARo//fZBPz1EgNA70crWheamBoJ9GSm19znsZzu0853t8GxVhNT9iIw==
dependencies:
cross-fetch "^3.1.5"
form-data "^4.0.0"
Expand Down