mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add board admins list modal
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
|
import Modal from 'react-modal';
|
||||||
|
import Draggable from 'react-draggable';
|
||||||
|
import { StyledModal } from '../styled/modals/ReplyModal.styled';
|
||||||
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||||
|
import { BoardForm } from '../styled/views/Board.styled'
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const AdminListModal = ({ isOpen, closeModal, roles }) => {
|
||||||
|
const {
|
||||||
|
selectedAddress,
|
||||||
|
selectedStyle,
|
||||||
|
selectedTitle,
|
||||||
|
} = useGeneralStore(state => state);
|
||||||
|
|
||||||
|
const [isMobile, setIsMobile] = useState(window.innerWidth <= 480);
|
||||||
|
const nodeRef = useRef(null);
|
||||||
|
const rolesList = roles
|
||||||
|
? Object.entries(roles).map(([address, { role }]) => ({ address, role }))
|
||||||
|
: [];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleResize = () => setIsMobile(window.innerWidth <= 480);
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
|
||||||
|
// Cleanup function
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize);
|
||||||
|
};
|
||||||
|
}, [setIsMobile]);
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledModal
|
||||||
|
isOpen={isOpen}
|
||||||
|
onRequestClose={closeModal}
|
||||||
|
contentLabel="Reply Modal"
|
||||||
|
shouldCloseOnEsc={true}
|
||||||
|
shouldCloseOnOverlayClick={isMobile}
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
overlayClassName="overlay"
|
||||||
|
style={isMobile ? ({ overlay: { backgroundColor: "rgba(0,0,0,.25)" }}) : ({ overlay: { backgroundColor: "rgba(0,0,0,0)" }})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Draggable handle=".modal-header" nodeRef={nodeRef} disabled={isMobile}>
|
||||||
|
<div className="modal-content" ref={nodeRef}
|
||||||
|
style={{
|
||||||
|
maxWidth: '300px',
|
||||||
|
maxHeight: '250px',
|
||||||
|
}}>
|
||||||
|
<div className="modal-header">
|
||||||
|
Admins for {selectedTitle ?? selectedAddress}
|
||||||
|
<button className="icon" onClick={() => closeModal()} title="close" />
|
||||||
|
</div>
|
||||||
|
<div className='list' style={{
|
||||||
|
padding: '10px',
|
||||||
|
maxHeight: '200px',
|
||||||
|
maxWidth: '300px',
|
||||||
|
overflowY: 'auto',
|
||||||
|
overflowX: 'hidden',
|
||||||
|
wordWrap: 'break-word',
|
||||||
|
wordBreak: 'break-all',
|
||||||
|
}}>
|
||||||
|
<BoardForm selectedStyle={selectedStyle} style={{all: 'unset'}}>
|
||||||
|
{rolesList.map(({ address, role }, index) => (
|
||||||
|
<p key={index}>
|
||||||
|
• <Link to={() => {}} className="quote-link">u/{address}</Link>: {role}
|
||||||
|
</p>
|
||||||
|
))}
|
||||||
|
</BoardForm>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Draggable>
|
||||||
|
</StyledModal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Modal.setAppElement('#root');
|
||||||
|
|
||||||
|
export default AdminListModal;
|
||||||
@@ -14,6 +14,7 @@ import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
|||||||
import EditModal from '../modals/EditModal';
|
import EditModal from '../modals/EditModal';
|
||||||
import EditLabel from '../EditLabel';
|
import EditLabel from '../EditLabel';
|
||||||
import ImageBanner from '../ImageBanner';
|
import ImageBanner from '../ImageBanner';
|
||||||
|
import AdminListModal from '../modals/AdminListModal';
|
||||||
import ModerationModal from '../modals/ModerationModal';
|
import ModerationModal from '../modals/ModerationModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import PendingLabel from '../PendingLabel';
|
import PendingLabel from '../PendingLabel';
|
||||||
@@ -100,6 +101,7 @@ const Board = () => {
|
|||||||
const { subscribed, subscribe, unsubscribe } = useSubscribe({subplebbitAddress: selectedAddress});
|
const { subscribed, subscribe, unsubscribe } = useSubscribe({subplebbitAddress: selectedAddress});
|
||||||
const stateString = useStateString(subplebbit);
|
const stateString = useStateString(subplebbit);
|
||||||
|
|
||||||
|
const [isAdminListOpen, setIsAdminListOpen] = useState(false);
|
||||||
const [isReplyOpen, setIsReplyOpen] = useState(false);
|
const [isReplyOpen, setIsReplyOpen] = useState(false);
|
||||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||||
const [originalCommentContent, setOriginalCommentContent] = useState(null);
|
const [originalCommentContent, setOriginalCommentContent] = useState(null);
|
||||||
@@ -610,6 +612,21 @@ const Board = () => {
|
|||||||
<title>{((selectedTitle ? selectedTitle : selectedAddress) + " - plebchan")}</title>
|
<title>{((selectedTitle ? selectedTitle : selectedAddress) + " - plebchan")}</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<Container>
|
<Container>
|
||||||
|
<AdminListModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isAdminListOpen}
|
||||||
|
closeModal={() => setIsAdminListOpen(false)}
|
||||||
|
roles={subplebbit.roles} />
|
||||||
|
<EditModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isEditModalOpen}
|
||||||
|
closeModal={() => setIsEditModalOpen(false)}
|
||||||
|
originalCommentContent={originalCommentContent} />
|
||||||
|
<ModerationModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isModerationOpen}
|
||||||
|
closeModal={() => {setIsModerationOpen(false); setDeletePost(false)}}
|
||||||
|
deletePost={deletePost} />
|
||||||
<ReplyModal
|
<ReplyModal
|
||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isReplyOpen}
|
isOpen={isReplyOpen}
|
||||||
@@ -618,16 +635,6 @@ const Board = () => {
|
|||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isSettingsOpen}
|
isOpen={isSettingsOpen}
|
||||||
closeModal={() => setIsSettingsOpen(false)} />
|
closeModal={() => setIsSettingsOpen(false)} />
|
||||||
<ModerationModal
|
|
||||||
selectedStyle={selectedStyle}
|
|
||||||
isOpen={isModerationOpen}
|
|
||||||
closeModal={() => {setIsModerationOpen(false); setDeletePost(false)}}
|
|
||||||
deletePost={deletePost} />
|
|
||||||
<EditModal
|
|
||||||
selectedStyle={selectedStyle}
|
|
||||||
isOpen={isEditModalOpen}
|
|
||||||
closeModal={() => setIsEditModalOpen(false)}
|
|
||||||
originalCommentContent={originalCommentContent} />
|
|
||||||
<NavBar selectedStyle={selectedStyle}>
|
<NavBar selectedStyle={selectedStyle}>
|
||||||
<>
|
<>
|
||||||
<span className="boardList">
|
<span className="boardList">
|
||||||
@@ -822,7 +829,10 @@ const Board = () => {
|
|||||||
<span className="name-block">
|
<span className="name-block">
|
||||||
<span className="title">Rules</span>
|
<span className="title">Rules</span>
|
||||||
|
|
||||||
<span className="name capcode">## Board Admins</span>
|
<span className="name capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
||||||
|
|
||||||
@@ -894,7 +904,10 @@ const Board = () => {
|
|||||||
<button className="post-menu-button-mobile"
|
<button className="post-menu-button-mobile"
|
||||||
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
||||||
<span className="name-block-mobile">
|
<span className="name-block-mobile">
|
||||||
<span className="name-mobile capcode">## Board Admins</span>
|
<span className="name-mobile capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="thread-icons-mobile"
|
<span className="thread-icons-mobile"
|
||||||
style={{float: "right", marginRight: "18px"}}>
|
style={{float: "right", marginRight: "18px"}}>
|
||||||
@@ -961,7 +974,10 @@ const Board = () => {
|
|||||||
<span className="name-block">
|
<span className="name-block">
|
||||||
<span className="title">Welcome to {subplebbit.title || subplebbit.address}</span>
|
<span className="title">Welcome to {subplebbit.title || subplebbit.address}</span>
|
||||||
|
|
||||||
<span className="name capcode">## Board Admins</span>
|
<span className="name capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
||||||
|
|
||||||
@@ -1031,7 +1047,10 @@ const Board = () => {
|
|||||||
<button className="post-menu-button-mobile"
|
<button className="post-menu-button-mobile"
|
||||||
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
||||||
<span className="name-block-mobile">
|
<span className="name-block-mobile">
|
||||||
<span className="name-mobile capcode">## Board Admins</span>
|
<span className="name-mobile capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="thread-icons-mobile"
|
<span className="thread-icons-mobile"
|
||||||
style={{float: "right", marginRight: "18px"}}>
|
style={{float: "right", marginRight: "18px"}}>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { Container, NavBar, Header, Break, PostMenu, PostForm } from '../styled/
|
|||||||
import { TopBar, BoardForm, Footer, ReplyFormLink} from '../styled/views/Thread.styled';
|
import { TopBar, BoardForm, Footer, ReplyFormLink} from '../styled/views/Thread.styled';
|
||||||
import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
||||||
import ImageBanner from '../ImageBanner';
|
import ImageBanner from '../ImageBanner';
|
||||||
|
import AdminListModal from '../modals/AdminListModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import SettingsModal from '../modals/SettingsModal';
|
import SettingsModal from '../modals/SettingsModal';
|
||||||
import getDate from '../../utils/getDate';
|
import getDate from '../../utils/getDate';
|
||||||
@@ -35,6 +36,7 @@ const Description = () => {
|
|||||||
const postMenuRef = useRef(null);
|
const postMenuRef = useRef(null);
|
||||||
const postMenuCatalogRef = useRef(null);
|
const postMenuCatalogRef = useRef(null);
|
||||||
|
|
||||||
|
const [isAdminListOpen, setIsAdminListOpen] = useState(false);
|
||||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
||||||
@@ -123,6 +125,11 @@ const Description = () => {
|
|||||||
</title>
|
</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<Container>
|
<Container>
|
||||||
|
<AdminListModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isAdminListOpen}
|
||||||
|
closeModal={() => setIsAdminListOpen(false)}
|
||||||
|
roles={subplebbit.roles} />
|
||||||
<SettingsModal
|
<SettingsModal
|
||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isSettingsOpen}
|
isOpen={isSettingsOpen}
|
||||||
@@ -295,7 +302,10 @@ const Description = () => {
|
|||||||
<span className="name-block">
|
<span className="name-block">
|
||||||
<span className="title">Welcome to {subplebbit.title || subplebbit.address}</span>
|
<span className="title">Welcome to {subplebbit.title || subplebbit.address}</span>
|
||||||
|
|
||||||
<span className="name capcode">## Board Admins</span>
|
<span className="name capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
||||||
|
|
||||||
@@ -362,7 +372,10 @@ const Description = () => {
|
|||||||
<button className="post-menu-button-mobile"
|
<button className="post-menu-button-mobile"
|
||||||
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
||||||
<span className="name-block-mobile">
|
<span className="name-block-mobile">
|
||||||
<span className="name-mobile capcode">## Board Admins</span>
|
<span className="name-mobile capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="thread-icons-mobile"
|
<span className="thread-icons-mobile"
|
||||||
style={{float: "right", marginRight: "18px"}}>
|
style={{float: "right", marginRight: "18px"}}>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { Container, NavBar, Header, Break, PostMenu, PostForm } from '../styled/
|
|||||||
import { TopBar, BoardForm, Footer, ReplyFormLink} from '../styled/views/Thread.styled';
|
import { TopBar, BoardForm, Footer, ReplyFormLink} from '../styled/views/Thread.styled';
|
||||||
import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
||||||
import ImageBanner from '../ImageBanner';
|
import ImageBanner from '../ImageBanner';
|
||||||
|
import AdminListModal from '../modals/AdminListModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import SettingsModal from '../modals/SettingsModal';
|
import SettingsModal from '../modals/SettingsModal';
|
||||||
import getDate from '../../utils/getDate';
|
import getDate from '../../utils/getDate';
|
||||||
@@ -34,6 +35,7 @@ const Rules = () => {
|
|||||||
const postMenuRef = useRef(null);
|
const postMenuRef = useRef(null);
|
||||||
const postMenuCatalogRef = useRef(null);
|
const postMenuCatalogRef = useRef(null);
|
||||||
|
|
||||||
|
const [isAdminListOpen, setIsAdminListOpen] = useState(false);
|
||||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
||||||
@@ -122,6 +124,11 @@ const Rules = () => {
|
|||||||
</title>
|
</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<Container>
|
<Container>
|
||||||
|
<AdminListModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isAdminListOpen}
|
||||||
|
closeModal={() => setIsAdminListOpen(false)}
|
||||||
|
roles={subplebbit.roles} />
|
||||||
<SettingsModal
|
<SettingsModal
|
||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isSettingsOpen}
|
isOpen={isSettingsOpen}
|
||||||
@@ -270,7 +277,10 @@ const Rules = () => {
|
|||||||
<span className="name-block">
|
<span className="name-block">
|
||||||
<span className="title">Rules</span>
|
<span className="title">Rules</span>
|
||||||
|
|
||||||
<span className="name capcode">## Board Admins</span>
|
<span className="name capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
||||||
|
|
||||||
@@ -342,7 +352,10 @@ const Rules = () => {
|
|||||||
<button className="post-menu-button-mobile"
|
<button className="post-menu-button-mobile"
|
||||||
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
||||||
<span className="name-block-mobile">
|
<span className="name-block-mobile">
|
||||||
<span className="name-mobile capcode">## Board Admins</span>
|
<span className="name-mobile capcode"
|
||||||
|
style={{cursor: 'pointer'}}
|
||||||
|
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||||
|
>## Board Admins</span>
|
||||||
|
|
||||||
<span className="thread-icons-mobile"
|
<span className="thread-icons-mobile"
|
||||||
style={{float: "right", marginRight: "18px"}}>
|
style={{float: "right", marginRight: "18px"}}>
|
||||||
|
|||||||
@@ -2722,21 +2722,6 @@
|
|||||||
uuid "8.3.2"
|
uuid "8.3.2"
|
||||||
zustand "4.0.0"
|
zustand "4.0.0"
|
||||||
|
|
||||||
"@plebbit/plebbit-react-hooks@https://github.com/plebbit/plebbit-react-hooks.git#efa802a1af8c75362e0d9a9afe1bc769f54e34cd":
|
|
||||||
version "0.0.1"
|
|
||||||
resolved "https://github.com/plebbit/plebbit-react-hooks.git#efa802a1af8c75362e0d9a9afe1bc769f54e34cd"
|
|
||||||
dependencies:
|
|
||||||
"@plebbit/plebbit-js" "https://github.com/plebbit/plebbit-js.git#77a05093408982086c02afea24e1d1923e1ae8a8"
|
|
||||||
"@plebbit/plebbit-logger" "https://github.com/plebbit/plebbit-logger.git"
|
|
||||||
assert "2.0.0"
|
|
||||||
ethers "5.6.9"
|
|
||||||
localforage "1.10.0"
|
|
||||||
lodash.isequal "4.5.0"
|
|
||||||
memoizee "0.4.15"
|
|
||||||
quick-lru "5.1.1"
|
|
||||||
uuid "8.3.2"
|
|
||||||
zustand "4.0.0"
|
|
||||||
|
|
||||||
"@pmmmwh/react-refresh-webpack-plugin@^0.5.3":
|
"@pmmmwh/react-refresh-webpack-plugin@^0.5.3":
|
||||||
version "0.5.10"
|
version "0.5.10"
|
||||||
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.10.tgz#2eba163b8e7dbabb4ce3609ab5e32ab63dda3ef8"
|
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.10.tgz#2eba163b8e7dbabb4ce3609ab5e32ab63dda3ef8"
|
||||||
|
|||||||
Reference in New Issue
Block a user