]> Untitled Git - lemmy-ui.git/commitdiff
fix: Fix some more private message form stuff
authorJay Sitter <jay@jaysitter.com>
Sat, 24 Jun 2023 03:38:39 +0000 (23:38 -0400)
committerJay Sitter <jay@jaysitter.com>
Sat, 24 Jun 2023 03:38:39 +0000 (23:38 -0400)
src/shared/components/common/markdown-textarea.tsx
src/shared/components/private_message/private-message-form.tsx
src/shared/components/private_message/private-message.tsx

index 73946ea8e8a43cdcc3c7ab6ac4719c0f3814ad5c..97a26a742b195323f5351ee7bbe3ebac0996203f 100644 (file)
@@ -23,15 +23,27 @@ import NavigationPrompt from "./navigation-prompt";
 import ProgressBar from "./progress-bar";
 
 interface MarkdownTextAreaProps {
+  /**
+   * Initial content inside the textarea
+   */
   initialContent?: string;
+  /**
+   * Numerical ID of the language to select in dropdown
+   */
   initialLanguageId?: number;
   placeholder?: string;
   buttonTitle?: string;
   maxLength?: number;
+  /**
+   * Whether this form is for a reply to a Private Message
+   */
   replyType?: boolean;
   focus?: boolean;
   disabled?: boolean;
   finished?: boolean;
+  /**
+   * Whether to show the language selector
+   */
   showLanguage?: boolean;
   hideNavigationWarnings?: boolean;
   onContentChange?(val: string): void;
index 12fd9bd23a9206bfb98ad5607dd6a026dc510af2..147269a58415424806586eac5799b512c59344a5 100644 (file)
@@ -1,6 +1,6 @@
 import { myAuthRequired } from "@utils/app";
 import { capitalizeFirstLetter } from "@utils/helpers";
-import { Component, InfernoNode, linkEvent } from "inferno";
+import { Component, InfernoNode } from "inferno";
 import { T } from "inferno-i18next-dess";
 import {
   CreatePrivateMessage,
@@ -19,6 +19,7 @@ import { PersonListing } from "../person/person-listing";
 interface PrivateMessageFormProps {
   recipient: Person;
   privateMessageView?: PrivateMessageView; // If a pm is given, that means this is an edit
+  replyType?: boolean;
   onCancel?(): any;
   onCreate?(form: CreatePrivateMessage): void;
   onEdit?(form: EditPrivateMessage): void;
@@ -113,6 +114,8 @@ export class PrivateMessageForm extends Component<
               allLanguages={[]}
               siteLanguages={[]}
               hideNavigationWarnings
+              onReplyCancel={() => handleCancel()}
+              replyType={this.props.replyType}
               buttonTitle={
                 this.props.privateMessageView
                   ? capitalizeFirstLetter(I18NextService.i18n.t("save"))
@@ -121,18 +124,6 @@ export class PrivateMessageForm extends Component<
             />
           </div>
         </div>
-
-        <div className="mb-3 d-flex justify-content-end">
-          {this.props.privateMessageView && (
-            <button
-              type="button"
-              className="btn btn-secondary w-auto"
-              onClick={linkEvent(this, this.handleCancel)}
-            >
-              {I18NextService.i18n.t("cancel")}
-            </button>
-          )}
-        </div>
       </form>
     );
   }
index af8d64e5110ff64d0f65de8f7f0c57c288380de5..110a908f32e467b24804ca25b2fa7f40a0ddc7cf 100644 (file)
@@ -145,6 +145,7 @@ export class PrivateMessage extends Component<
                   <>
                     <li className="list-inline-item">
                       <button
+                        type="button"
                         className="btn btn-link btn-animate text-muted"
                         onClick={linkEvent(this, this.handleMarkRead)}
                         data-tippy-content={
@@ -174,6 +175,7 @@ export class PrivateMessage extends Component<
                     <li className="list-inline-item">{this.reportButton}</li>
                     <li className="list-inline-item">
                       <button
+                        type="button"
                         className="btn btn-link btn-animate text-muted"
                         onClick={linkEvent(this, this.handleReplyClick)}
                         data-tippy-content={I18NextService.i18n.t("reply")}
@@ -188,6 +190,7 @@ export class PrivateMessage extends Component<
                   <>
                     <li className="list-inline-item">
                       <button
+                        type="button"
                         className="btn btn-link btn-animate text-muted"
                         onClick={linkEvent(this, this.handleEditClick)}
                         data-tippy-content={I18NextService.i18n.t("edit")}
@@ -198,6 +201,7 @@ export class PrivateMessage extends Component<
                     </li>
                     <li className="list-inline-item">
                       <button
+                        type="button"
                         className="btn btn-link btn-animate text-muted"
                         onClick={linkEvent(this, this.handleDeleteClick)}
                         data-tippy-content={
@@ -228,6 +232,7 @@ export class PrivateMessage extends Component<
                 )}
                 <li className="list-inline-item">
                   <button
+                    type="button"
                     className="btn btn-link btn-animate text-muted"
                     onClick={linkEvent(this, this.handleViewSource)}
                     data-tippy-content={I18NextService.i18n.t("view_source")}
@@ -276,10 +281,17 @@ export class PrivateMessage extends Component<
           </form>
         )}
         {this.state.showReply && (
-          <PrivateMessageForm
-            recipient={otherPerson}
-            onCreate={this.props.onCreate}
-          />
+          <div className="row">
+            <div className="col-sm-6">
+              <PrivateMessageForm
+                privateMessageView={message_view}
+                replyType={true}
+                recipient={otherPerson}
+                onCreate={this.props.onCreate}
+                onCancel={this.handleReplyCancel}
+              />
+            </div>
+          </div>
         )}
         {/* A collapsed clearfix */}
         {this.state.collapsed && <div className="row col-12"></div>}
@@ -290,6 +302,7 @@ export class PrivateMessage extends Component<
   get reportButton() {
     return (
       <button
+        type="button"
         className="btn btn-link btn-animate text-muted py-0"
         onClick={linkEvent(this, this.handleShowReportDialog)}
         data-tippy-content={I18NextService.i18n.t("show_report_dialog")}