mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2025-01-24 02:45:51 +00:00
feat: Clean up the Create Private Message page a bit
This commit is contained in:
parent
e5e8f29c67
commit
b231fd1e5b
4 changed files with 57 additions and 89 deletions
|
@ -35,6 +35,7 @@ export class Icon extends Component<IconProps, any> {
|
||||||
|
|
||||||
interface SpinnerProps {
|
interface SpinnerProps {
|
||||||
large?: boolean;
|
large?: boolean;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Spinner extends Component<SpinnerProps, any> {
|
export class Spinner extends Component<SpinnerProps, any> {
|
||||||
|
@ -46,7 +47,9 @@ export class Spinner extends Component<SpinnerProps, any> {
|
||||||
return (
|
return (
|
||||||
<Icon
|
<Icon
|
||||||
icon="spinner"
|
icon="spinner"
|
||||||
classes={`spin ${this.props.large && "spinner-large"}`}
|
classes={classNames("spin", this.props.className, {
|
||||||
|
"spinner-large": this.props.large,
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,19 +272,6 @@ export class MarkdownTextArea extends Component<
|
||||||
{/* A flex expander */}
|
{/* A flex expander */}
|
||||||
<div className="flex-grow-1"></div>
|
<div className="flex-grow-1"></div>
|
||||||
|
|
||||||
{this.props.buttonTitle && (
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="btn btn-sm btn-secondary ms-2"
|
|
||||||
disabled={this.isDisabled}
|
|
||||||
>
|
|
||||||
{this.state.loading ? (
|
|
||||||
<Spinner />
|
|
||||||
) : (
|
|
||||||
<span>{this.props.buttonTitle}</span>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{this.props.replyType && (
|
{this.props.replyType && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -294,8 +281,9 @@ export class MarkdownTextArea extends Component<
|
||||||
{I18NextService.i18n.t("cancel")}
|
{I18NextService.i18n.t("cancel")}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{this.state.content && (
|
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
|
disabled={!this.state.content ? true : false}
|
||||||
className={`btn btn-sm btn-secondary ms-2 ${
|
className={`btn btn-sm btn-secondary ms-2 ${
|
||||||
this.state.previewMode && "active"
|
this.state.previewMode && "active"
|
||||||
}`}
|
}`}
|
||||||
|
@ -305,6 +293,15 @@ export class MarkdownTextArea extends Component<
|
||||||
? I18NextService.i18n.t("edit")
|
? I18NextService.i18n.t("edit")
|
||||||
: I18NextService.i18n.t("preview")}
|
: I18NextService.i18n.t("preview")}
|
||||||
</button>
|
</button>
|
||||||
|
{this.props.buttonTitle && (
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-secondary ms-2"
|
||||||
|
disabled={this.isDisabled}
|
||||||
|
>
|
||||||
|
{this.state.loading && <Spinner className="me-1" />}
|
||||||
|
{this.props.buttonTitle}
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -115,7 +115,9 @@ export class CreatePrivateMessage extends Component<
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12 col-lg-6 offset-lg-3 mb-4">
|
<div className="col-12 col-lg-6 offset-lg-3 mb-4">
|
||||||
<h5>{I18NextService.i18n.t("create_private_message")}</h5>
|
<h1 className="h4">
|
||||||
|
{I18NextService.i18n.t("create_private_message")}
|
||||||
|
</h1>
|
||||||
<PrivateMessageForm
|
<PrivateMessageForm
|
||||||
onCreate={this.handlePrivateMessageCreate}
|
onCreate={this.handlePrivateMessageCreate}
|
||||||
recipient={res.person_view.person}
|
recipient={res.person_view.person}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
import { relTags } from "../../config";
|
import { relTags } from "../../config";
|
||||||
import { I18NextService } from "../../services";
|
import { I18NextService } from "../../services";
|
||||||
import { setupTippy } from "../../tippy";
|
import { setupTippy } from "../../tippy";
|
||||||
import { Icon, Spinner } from "../common/icon";
|
import { Icon } from "../common/icon";
|
||||||
import { MarkdownTextArea } from "../common/markdown-textarea";
|
import { MarkdownTextArea } from "../common/markdown-textarea";
|
||||||
import NavigationPrompt from "../common/navigation-prompt";
|
import NavigationPrompt from "../common/navigation-prompt";
|
||||||
import { PersonListing } from "../person/person-listing";
|
import { PersonListing } from "../person/person-listing";
|
||||||
|
@ -28,7 +28,6 @@ interface PrivateMessageFormState {
|
||||||
content?: string;
|
content?: string;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
previewMode: boolean;
|
previewMode: boolean;
|
||||||
showDisclaimer: boolean;
|
|
||||||
submitted: boolean;
|
submitted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ export class PrivateMessageForm extends Component<
|
||||||
state: PrivateMessageFormState = {
|
state: PrivateMessageFormState = {
|
||||||
loading: false,
|
loading: false,
|
||||||
previewMode: false,
|
previewMode: false,
|
||||||
showDisclaimer: false,
|
|
||||||
content: this.props.privateMessageView
|
content: this.props.privateMessageView
|
||||||
? this.props.privateMessageView.private_message.content
|
? this.props.privateMessageView.private_message.content
|
||||||
: undefined,
|
: undefined,
|
||||||
|
@ -71,56 +69,26 @@ export class PrivateMessageForm extends Component<
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<form
|
<form className="private-message-form">
|
||||||
className="private-message-form"
|
|
||||||
onSubmit={linkEvent(this, this.handlePrivateMessageSubmit)}
|
|
||||||
>
|
|
||||||
<NavigationPrompt
|
<NavigationPrompt
|
||||||
when={
|
when={
|
||||||
!this.state.loading && !!this.state.content && !this.state.submitted
|
!this.state.loading && !!this.state.content && !this.state.submitted
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{!this.props.privateMessageView && (
|
{!this.props.privateMessageView && (
|
||||||
<div className="mb-3 row">
|
<div className="mb-3 row align-items-baseline">
|
||||||
<label className="col-sm-2 col-form-label">
|
<label className="col-sm-2 col-form-label">
|
||||||
{capitalizeFirstLetter(I18NextService.i18n.t("to"))}
|
{capitalizeFirstLetter(I18NextService.i18n.t("to"))}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className="col-sm-10 form-control-plaintext">
|
<div className="col-sm-10">
|
||||||
<PersonListing person={this.props.recipient} />
|
<PersonListing person={this.props.recipient} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="mb-3 row">
|
<div className="alert alert-warning small">
|
||||||
<label className="col-sm-2 col-form-label">
|
<Icon icon="alert-triangle" classes="icon-inline me-1" />
|
||||||
{I18NextService.i18n.t("message")}
|
<T parent="span" i18nKey="private_message_disclaimer">
|
||||||
<button
|
|
||||||
className="btn btn-link text-warning d-inline-block"
|
|
||||||
onClick={linkEvent(this, this.handleShowDisclaimer)}
|
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
|
||||||
"private_message_disclaimer"
|
|
||||||
)}
|
|
||||||
aria-label={I18NextService.i18n.t("private_message_disclaimer")}
|
|
||||||
>
|
|
||||||
<Icon icon="alert-triangle" classes="icon-inline" />
|
|
||||||
</button>
|
|
||||||
</label>
|
|
||||||
<div className="col-sm-10">
|
|
||||||
<MarkdownTextArea
|
|
||||||
initialContent={this.state.content}
|
|
||||||
onContentChange={this.handleContentChange}
|
|
||||||
allLanguages={[]}
|
|
||||||
siteLanguages={[]}
|
|
||||||
hideNavigationWarnings
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{this.state.showDisclaimer && (
|
|
||||||
<div className="mb-3 row">
|
|
||||||
<div className="offset-sm-2 col-sm-10">
|
|
||||||
<div className="alert alert-danger" role="alert">
|
|
||||||
<T i18nKey="private_message_disclaimer">
|
|
||||||
#
|
#
|
||||||
<a
|
<a
|
||||||
className="alert-link"
|
className="alert-link"
|
||||||
|
@ -131,37 +99,39 @@ export class PrivateMessageForm extends Component<
|
||||||
</a>
|
</a>
|
||||||
</T>
|
</T>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="mb-3 row">
|
<div className="mb-3 row">
|
||||||
<div className="offset-sm-2 col-sm-10">
|
<label className="col-sm-2 col-form-label">
|
||||||
<button
|
{I18NextService.i18n.t("message")}
|
||||||
type="submit"
|
</label>
|
||||||
className="btn btn-secondary me-2"
|
<div className="col-sm-10">
|
||||||
disabled={this.state.loading}
|
<MarkdownTextArea
|
||||||
>
|
onSubmit={() => {
|
||||||
{this.state.loading ? (
|
this.handlePrivateMessageSubmit(this, event);
|
||||||
<Spinner />
|
}}
|
||||||
) : this.props.privateMessageView ? (
|
initialContent={this.state.content}
|
||||||
capitalizeFirstLetter(I18NextService.i18n.t("save"))
|
onContentChange={this.handleContentChange}
|
||||||
) : (
|
allLanguages={[]}
|
||||||
capitalizeFirstLetter(I18NextService.i18n.t("send_message"))
|
siteLanguages={[]}
|
||||||
)}
|
hideNavigationWarnings
|
||||||
</button>
|
buttonTitle={
|
||||||
|
this.props.privateMessageView
|
||||||
|
? capitalizeFirstLetter(I18NextService.i18n.t("save"))
|
||||||
|
: capitalizeFirstLetter(I18NextService.i18n.t("send_message"))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3 d-flex justify-content-end">
|
||||||
{this.props.privateMessageView && (
|
{this.props.privateMessageView && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-secondary"
|
className="btn btn-secondary w-auto"
|
||||||
onClick={linkEvent(this, this.handleCancel)}
|
onClick={linkEvent(this, this.handleCancel)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("cancel")}
|
{I18NextService.i18n.t("cancel")}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<ul className="d-inline-block float-right list-inline mb-1 text-muted font-weight-bold">
|
|
||||||
<li className="list-inline-item"></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
@ -200,8 +170,4 @@ export class PrivateMessageForm extends Component<
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
i.setState({ previewMode: !i.state.previewMode });
|
i.setState({ previewMode: !i.state.previewMode });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleShowDisclaimer(i: PrivateMessageForm) {
|
|
||||||
i.setState({ showDisclaimer: !i.state.showDisclaimer });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue