mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-23 12:51:13 +00:00
Make modal
This commit is contained in:
parent
335e8b38c9
commit
b7d71e0e1b
2 changed files with 103 additions and 39 deletions
|
@ -6,6 +6,7 @@ import { HistoryService, UserService } from "../shared/services";
|
||||||
|
|
||||||
import "bootstrap/js/dist/collapse";
|
import "bootstrap/js/dist/collapse";
|
||||||
import "bootstrap/js/dist/dropdown";
|
import "bootstrap/js/dist/dropdown";
|
||||||
|
import "bootstrap/js/dist/modal";
|
||||||
|
|
||||||
async function startClient() {
|
async function startClient() {
|
||||||
initializeSite(window.isoData.site_res);
|
initializeSite(window.isoData.site_res);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
import { myAuthRequired } from "@utils/app";
|
||||||
import { getUnixTime, hostname } from "@utils/helpers";
|
import { getUnixTime, hostname } from "@utils/helpers";
|
||||||
import { amAdmin, amMod, amTopMod } from "@utils/roles";
|
import { amAdmin, amMod, amTopMod } from "@utils/roles";
|
||||||
|
import { NoOptionI18nKeys } from "i18next";
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
import { Link } from "inferno-router";
|
import { Link } from "inferno-router";
|
||||||
|
@ -131,7 +132,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
{this.communityTitle()}
|
{this.communityTitle()}
|
||||||
{this.props.editable && this.adminButtons()}
|
{this.props.editable && this.adminButtons()}
|
||||||
{myUSerInfo && this.subscribe()}
|
{this.subscribeButton}
|
||||||
{this.canPost && this.createPost()}
|
{this.canPost && this.createPost()}
|
||||||
{myUSerInfo && this.blockCommunity()}
|
{myUSerInfo && this.blockCommunity()}
|
||||||
{!myUSerInfo && (
|
{!myUSerInfo && (
|
||||||
|
@ -160,6 +161,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
{this.remoteFetchModal}
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -230,57 +232,118 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe() {
|
get subscribeButton() {
|
||||||
const community_view = this.props.community_view;
|
const community_view = this.props.community_view;
|
||||||
|
|
||||||
if (community_view.subscribed === "NotSubscribed") {
|
let i18key: NoOptionI18nKeys;
|
||||||
|
|
||||||
|
switch (community_view.subscribed) {
|
||||||
|
case "NotSubscribed": {
|
||||||
|
i18key = "subscribe";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Subscribed": {
|
||||||
|
i18key = "joined";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Pending": {
|
||||||
|
i18key = "subscribe_pending";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UserService.Instance.myUserInfo) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
type="button"
|
||||||
className="btn btn-secondary d-block mb-2 w-100"
|
className="btn btn-secondary d-block mb-2 w-100"
|
||||||
onClick={linkEvent(this, this.handleFollowCommunity)}
|
data-bs-toggle="modal"
|
||||||
|
data-bs-target="#remoteFetchModal"
|
||||||
>
|
>
|
||||||
{this.state.followCommunityLoading ? (
|
{I18NextService.i18n.t("subscribe")}
|
||||||
<Spinner />
|
|
||||||
) : (
|
|
||||||
I18NextService.i18n.t("subscribe")
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (community_view.subscribed === "Subscribed") {
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-secondary d-block mb-2 w-100"
|
type="button"
|
||||||
onClick={linkEvent(this, this.handleUnfollowCommunity)}
|
className={`btn btn-${
|
||||||
|
community_view.subscribed === "Pending" ? "warning" : "secondary"
|
||||||
|
} d-block mb-2 w-100`}
|
||||||
|
onClick={linkEvent(
|
||||||
|
this,
|
||||||
|
community_view.subscribed === "NotSubscribed"
|
||||||
|
? this.handleFollowCommunity
|
||||||
|
: this.handleUnfollowCommunity
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{this.state.followCommunityLoading ? (
|
{this.state.followCommunityLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
{community_view.subscribed === "Subscribed" && (
|
||||||
<Icon icon="check" classes="icon-inline me-1" />
|
<Icon icon="check" classes="icon-inline me-1" />
|
||||||
{I18NextService.i18n.t("joined")}
|
)}
|
||||||
|
{I18NextService.i18n.t(i18key)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (community_view.subscribed === "Pending") {
|
get remoteFetchModal() {
|
||||||
return (
|
return (
|
||||||
<button
|
<div
|
||||||
className="btn btn-warning d-block mb-2 w-100"
|
className="modal fade"
|
||||||
onClick={linkEvent(this, this.handleUnfollowCommunity)}
|
id="remoteFetchModal"
|
||||||
|
tabIndex={-1}
|
||||||
|
aria-hidden={true}
|
||||||
|
aria-labelledby="#remoteFetchModalTitle"
|
||||||
>
|
>
|
||||||
{this.state.followCommunityLoading ? (
|
<div className="modal-dialog">
|
||||||
<Spinner />
|
<div className="modal-content">
|
||||||
) : (
|
<header className="modal-header">
|
||||||
I18NextService.i18n.t("subscribe_pending")
|
<h1 className="modal-title" id="remoteFetchModalTitle">
|
||||||
)}
|
Subscribe from Remote Instance
|
||||||
|
</h1>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"
|
||||||
|
/>
|
||||||
|
</header>
|
||||||
|
</div>
|
||||||
|
<form className="modal-body">
|
||||||
|
<label className="form-label" htmlFor="remoteFetchInstance">
|
||||||
|
Enter the instance you would like to follow this community from
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="remoteFetchInstance"
|
||||||
|
className="form-control"
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
<footer className="modal-footer">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-secondary"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
>
|
||||||
|
Close
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" className="btn btn-primary">
|
||||||
|
Save changes
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
blockCommunity() {
|
blockCommunity() {
|
||||||
const { subscribed, blocked } = this.props.community_view;
|
const { subscribed, blocked } = this.props.community_view;
|
||||||
|
|
Loading…
Reference in a new issue