diff --git a/package.json b/package.json index e50bb68d..2f38138a 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "husky": "^7.0.4", "import-sort-style-module": "^6.0.0", "iso-639-1": "^2.1.10", - "lemmy-js-client": "0.14.0-rc.1", + "lemmy-js-client": "0.15.0-rc.1", "lint-staged": "^12.1.2", "mini-css-extract-plugin": "^2.4.5", "node-fetch": "^2.6.1", diff --git a/src/shared/components/app/navbar.tsx b/src/shared/components/app/navbar.tsx index 2a40915d..52f9aa38 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -7,6 +7,8 @@ import { GetSiteResponse, GetUnreadCount, GetUnreadCountResponse, + GetUnreadRegistrationApplicationCount, + GetUnreadRegistrationApplicationCountResponse, PrivateMessageResponse, UserOperation, } from "lemmy-js-client"; @@ -41,6 +43,7 @@ interface NavbarState { expanded: boolean; unreadInboxCount: number; unreadReportCount: number; + unreadApplicationCount: number; searchParam: string; toggleSearch: boolean; showDropdown: boolean; @@ -52,11 +55,13 @@ export class Navbar extends Component { private userSub: Subscription; private unreadInboxCountSub: Subscription; private unreadReportCountSub: Subscription; + private unreadApplicationCountSub: Subscription; private searchTextField: RefObject; emptyState: NavbarState = { isLoggedIn: !!this.props.site_res.my_user, unreadInboxCount: 0, unreadReportCount: 0, + unreadApplicationCount: 0, expanded: false, searchParam: "", toggleSearch: false, @@ -115,6 +120,11 @@ export class Navbar extends Component { UserService.Instance.unreadReportCountSub.subscribe(res => { this.setState({ unreadReportCount: res }); }); + // Subscribe to unread application count + this.unreadApplicationCountSub = + UserService.Instance.unreadApplicationCountSub.subscribe(res => { + this.setState({ unreadApplicationCount: res }); + }); } } @@ -123,6 +133,7 @@ export class Navbar extends Component { this.userSub.unsubscribe(); this.unreadInboxCountSub.unsubscribe(); this.unreadReportCountSub.unsubscribe(); + this.unreadApplicationCountSub.unsubscribe(); } updateUrl() { @@ -215,6 +226,31 @@ export class Navbar extends Component { )} + {UserService.Instance.myUserInfo?.local_user_view.person + .admin && ( + + )} )} + {!this.props.application.registration_application.deny_reason && ( + + )} + + ); + } + + handleApprove(i: RegistrationApplication) { + let form: ApproveRegistrationApplication = { + id: i.props.application.registration_application.id, + deny_reason: "", + approve: true, + auth: authField(), + }; + WebSocketService.Instance.send( + wsClient.approveRegistrationApplication(form) + ); + } + + handleDeny(i: RegistrationApplication) { + let form: ApproveRegistrationApplication = { + id: i.props.application.registration_application.id, + approve: false, + deny_reason: i.state.denyReason, + auth: authField(), + }; + WebSocketService.Instance.send( + wsClient.approveRegistrationApplication(form) + ); + } + + handleDenyReasonChange(val: string) { + this.state.denyReason = val; + this.setState(this.state); + } +} diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 73d7dbeb..5a61d136 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -185,8 +185,6 @@ export class Login extends Component { if (msg.error) { toast(i18n.t(msg.error), "danger"); this.state = this.emptyState; - // Refetch another captcha - WebSocketService.Instance.send(wsClient.getCaptcha()); this.setState(this.state); return; } else { diff --git a/src/shared/components/home/password_change.tsx b/src/shared/components/home/password-change.tsx similarity index 100% rename from src/shared/components/home/password_change.tsx rename to src/shared/components/home/password-change.tsx diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index ebccac98..25b2bf4d 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -17,6 +17,7 @@ import { authField, isBrowser, joinLemmyUrl, + mdToHtml, setIsoData, toast, validEmail, @@ -27,6 +28,7 @@ import { } from "../../utils"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; +import { MarkdownTextArea } from "../common/markdown-textarea"; const passwordStrengthOptions: Options = [ { @@ -77,6 +79,7 @@ export class Signup extends Component { captcha_uuid: undefined, captcha_answer: undefined, honeypot: undefined, + answer: undefined, }, registerLoading: false, captcha: undefined, @@ -88,6 +91,7 @@ export class Signup extends Component { super(props, context); this.state = this.emptyState; + this.handleAnswerChange = this.handleAnswerChange.bind(this); this.parseMessage = this.parseMessage.bind(this); this.subscription = wsSubscribe(this.parseMessage); @@ -159,18 +163,24 @@ export class Signup extends Component { type="email" id="register-email" class="form-control" - placeholder={i18n.t("optional")} + placeholder={ + this.state.site_view.site.require_email_verification + ? i18n.t("required") + : i18n.t("optional") + } value={this.state.registerForm.email} autoComplete="email" onInput={linkEvent(this, this.handleRegisterEmailChange)} + required={this.state.site_view.site.require_email_verification} minLength={3} /> - {!validEmail(this.state.registerForm.email) && ( - - )} + {!this.state.site_view.site.require_email_verification && + !validEmail(this.state.registerForm.email) && ( + + )} @@ -219,6 +229,40 @@ export class Signup extends Component { + {this.state.site_view.site.require_application && ( + <> +
+
+ +
+
+
+ +
+ +
+ +
+
+ + )} + {this.state.captcha && (
- +
{ />
+ {this.state.siteForm.require_application && ( +
+ +
+ +
+
+ )}
@@ -255,6 +273,66 @@ export class SiteForm extends Component {
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+