mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-23 21:01:14 +00:00
Bring back remote fetch modal
This commit is contained in:
parent
235843f96f
commit
fa37321dbd
4 changed files with 90 additions and 13 deletions
|
@ -6,6 +6,7 @@ import { 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,22 +1,24 @@
|
||||||
|
import classNames from "classnames";
|
||||||
import { NoOptionI18nKeys } from "i18next";
|
import { NoOptionI18nKeys } from "i18next";
|
||||||
import { MouseEventHandler } from "inferno";
|
import { Component, MouseEventHandler } from "inferno";
|
||||||
import { SubscribedType } from "lemmy-js-client";
|
import { CommunityView } from "lemmy-js-client";
|
||||||
import { I18NextService, UserService } from "../../services";
|
import { I18NextService, UserService } from "../../services";
|
||||||
import { Icon, Spinner } from "./icon";
|
import { Icon, Spinner } from "./icon";
|
||||||
|
|
||||||
interface SubscribeButtonProps {
|
interface SubscribeButtonProps {
|
||||||
subscribed: SubscribedType;
|
communityView: CommunityView;
|
||||||
onFollow: MouseEventHandler;
|
onFollow: MouseEventHandler;
|
||||||
onUnFollow: MouseEventHandler;
|
onUnFollow: MouseEventHandler;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SubscribeButton({
|
export function SubscribeButton({
|
||||||
subscribed,
|
communityView,
|
||||||
onFollow,
|
onFollow,
|
||||||
onUnFollow,
|
onUnFollow,
|
||||||
loading,
|
loading,
|
||||||
}: SubscribeButtonProps) {
|
}: SubscribeButtonProps) {
|
||||||
|
const { subscribed } = communityView;
|
||||||
let i18key: NoOptionI18nKeys;
|
let i18key: NoOptionI18nKeys;
|
||||||
|
|
||||||
switch (subscribed) {
|
switch (subscribed) {
|
||||||
|
@ -37,20 +39,31 @@ export function SubscribeButton({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const buttonClass = "btn d-block mb-2 w-100";
|
||||||
|
|
||||||
if (!UserService.Instance.myUserInfo) {
|
if (!UserService.Instance.myUserInfo) {
|
||||||
return (
|
return (
|
||||||
<button type="button" className="btn btn-secondary d-block mb-2 w-100">
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={classNames(buttonClass, "btn-secondary")}
|
||||||
|
data-bs-toggle="modal"
|
||||||
|
data-bs-target="#remoteFetchModal"
|
||||||
|
>
|
||||||
{I18NextService.i18n.t("subscribe")}
|
{I18NextService.i18n.t("subscribe")}
|
||||||
</button>
|
</button>
|
||||||
|
<RemoteFetchModal />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn btn-${
|
className={classNames(
|
||||||
subscribed === "Pending" ? "warning" : "secondary"
|
buttonClass,
|
||||||
} d-block mb-2 w-100`}
|
`btn-${subscribed === "Pending" ? "warning" : "secondary"}`
|
||||||
|
)}
|
||||||
onClick={subscribed === "NotSubscribed" ? onFollow : onUnFollow}
|
onClick={subscribed === "NotSubscribed" ? onFollow : onUnFollow}
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
@ -66,3 +79,67 @@ export function SubscribeButton({
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RemoteFetchModal extends Component {
|
||||||
|
constructor(props, context) {
|
||||||
|
super(props, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="modal fade"
|
||||||
|
id="remoteFetchModal"
|
||||||
|
tabIndex={-1}
|
||||||
|
aria-hidden
|
||||||
|
aria-labelledby="#remoteFetchModalTitle"
|
||||||
|
>
|
||||||
|
<div className="modal-dialog modal-fullscreen-sm-down">
|
||||||
|
<div className="modal-content">
|
||||||
|
<header className="modal-header">
|
||||||
|
<h3 className="modal-title" id="remoteFetchModalTitle">
|
||||||
|
Subscribe from Remote Instance
|
||||||
|
</h3>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"
|
||||||
|
/>
|
||||||
|
</header>
|
||||||
|
<form
|
||||||
|
id="remote-fetch-form"
|
||||||
|
className="modal-body d-flex flex-column justify-content-center"
|
||||||
|
>
|
||||||
|
<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"
|
||||||
|
name="instance"
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
<footer className="modal-footer">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-secondary"
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-primary"
|
||||||
|
form="remote-fetch-form"
|
||||||
|
>
|
||||||
|
Save changes
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -126,7 +126,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
const myUSerInfo = UserService.Instance.myUserInfo;
|
const myUSerInfo = UserService.Instance.myUserInfo;
|
||||||
const {
|
const {
|
||||||
community: { name, actor_id },
|
community: { name, actor_id },
|
||||||
subscribed,
|
|
||||||
} = this.props.community_view;
|
} = this.props.community_view;
|
||||||
return (
|
return (
|
||||||
<aside className="mb-3">
|
<aside className="mb-3">
|
||||||
|
@ -136,7 +135,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
{this.communityTitle()}
|
{this.communityTitle()}
|
||||||
{this.props.editable && this.adminButtons()}
|
{this.props.editable && this.adminButtons()}
|
||||||
<SubscribeButton
|
<SubscribeButton
|
||||||
subscribed={subscribed}
|
communityView={this.props.community_view}
|
||||||
onFollow={linkEvent(this, this.handleFollowCommunity)}
|
onFollow={linkEvent(this, this.handleFollowCommunity)}
|
||||||
onUnFollow={linkEvent(this, this.handleUnfollowCommunity)}
|
onUnFollow={linkEvent(this, this.handleUnfollowCommunity)}
|
||||||
loading={this.state.followCommunityLoading}
|
loading={this.state.followCommunityLoading}
|
||||||
|
|
|
@ -193,7 +193,7 @@ export class RemoteFetch extends Component<any, RemoteFetchState> {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<SubscribeButton
|
<SubscribeButton
|
||||||
subscribed={_test_com_view.subscribed}
|
communityView={_test_com_view}
|
||||||
onFollow={linkEvent(this, handleFollow)}
|
onFollow={linkEvent(this, handleFollow)}
|
||||||
onUnFollow={linkEvent(this, handleUnfollow)}
|
onUnFollow={linkEvent(this, handleUnfollow)}
|
||||||
loading={this.state.followCommunityLoading}
|
loading={this.state.followCommunityLoading}
|
||||||
|
|
Loading…
Reference in a new issue