Add GeneralSettings component
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
2b70a49e09
commit
d6b5f92d6c
4 changed files with 63 additions and 12 deletions
|
@ -61,6 +61,7 @@ function PeopleDrawer({ roomId }) {
|
||||||
const PER_PAGE_MEMBER = 50;
|
const PER_PAGE_MEMBER = 50;
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
|
const canInvite = room?.canInvite(mx.getUserId());
|
||||||
|
|
||||||
const [itemCount, setItemCount] = useState(PER_PAGE_MEMBER);
|
const [itemCount, setItemCount] = useState(PER_PAGE_MEMBER);
|
||||||
const [membership, setMembership] = useState('join');
|
const [membership, setMembership] = useState('join');
|
||||||
|
@ -148,7 +149,7 @@ function PeopleDrawer({ roomId }) {
|
||||||
<Text className="people-drawer__member-count" variant="b3">{`${room.getJoinedMemberCount()} members`}</Text>
|
<Text className="people-drawer__member-count" variant="b3">{`${room.getJoinedMemberCount()} members`}</Text>
|
||||||
</Text>
|
</Text>
|
||||||
</TitleWrapper>
|
</TitleWrapper>
|
||||||
<IconButton onClick={() => openInviteUser(roomId)} tooltip="Invite" src={AddUserIC} />
|
<IconButton onClick={() => openInviteUser(roomId)} tooltip="Invite" src={AddUserIC} disabled={!canInvite} />
|
||||||
</Header>
|
</Header>
|
||||||
<div className="people-drawer__content-wrapper">
|
<div className="people-drawer__content-wrapper">
|
||||||
<div className="people-drawer__scrollable">
|
<div className="people-drawer__scrollable">
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
import React, { useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './RoomSettings.scss';
|
import './RoomSettings.scss';
|
||||||
|
|
||||||
|
import initMatrix from '../../../client/initMatrix';
|
||||||
import cons from '../../../client/state/cons';
|
import cons from '../../../client/state/cons';
|
||||||
import navigation from '../../../client/state/navigation';
|
import navigation from '../../../client/state/navigation';
|
||||||
|
import { openInviteUser } from '../../../client/action/navigation';
|
||||||
|
import * as roomActions from '../../../client/action/room';
|
||||||
|
|
||||||
import Text from '../../atoms/text/Text';
|
import Text from '../../atoms/text/Text';
|
||||||
import Header, { TitleWrapper } from '../../atoms/header/Header';
|
import Header, { TitleWrapper } from '../../atoms/header/Header';
|
||||||
import ScrollView from '../../atoms/scroll/ScrollView';
|
import ScrollView from '../../atoms/scroll/ScrollView';
|
||||||
import Tabs from '../../atoms/tabs/Tabs';
|
import Tabs from '../../atoms/tabs/Tabs';
|
||||||
|
import { MenuHeader, MenuItem } from '../../atoms/context-menu/ContextMenu';
|
||||||
import RoomProfile from '../../molecules/room-profile/RoomProfile';
|
import RoomProfile from '../../molecules/room-profile/RoomProfile';
|
||||||
|
import RoomNotification from '../../molecules/room-notification/RoomNotification';
|
||||||
|
|
||||||
import SettingsIC from '../../../../public/res/ic/outlined/settings.svg';
|
import SettingsIC from '../../../../public/res/ic/outlined/settings.svg';
|
||||||
import SearchIC from '../../../../public/res/ic/outlined/search.svg';
|
import SearchIC from '../../../../public/res/ic/outlined/search.svg';
|
||||||
import ShieldUserIC from '../../../../public/res/ic/outlined/shield-user.svg';
|
import ShieldUserIC from '../../../../public/res/ic/outlined/shield-user.svg';
|
||||||
import LockIC from '../../../../public/res/ic/outlined/lock.svg';
|
import LockIC from '../../../../public/res/ic/outlined/lock.svg';
|
||||||
import InfoIC from '../../../../public/res/ic/outlined/info.svg';
|
import InfoIC from '../../../../public/res/ic/outlined/info.svg';
|
||||||
|
import AddUserIC from '../../../../public/res/ic/outlined/add-user.svg';
|
||||||
|
import LeaveArrowIC from '../../../../public/res/ic/outlined/leave-arrow.svg';
|
||||||
|
|
||||||
import { useForceUpdate } from '../../hooks/useForceUpdate';
|
import { useForceUpdate } from '../../hooks/useForceUpdate';
|
||||||
|
|
||||||
|
@ -41,16 +48,53 @@ const tabItems = [{
|
||||||
disabled: false,
|
disabled: false,
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
function GeneralSettings({ roomId }) {
|
||||||
|
const mx = initMatrix.matrixClient;
|
||||||
|
const room = mx.getRoom(roomId);
|
||||||
|
const canInvite = room.canInvite(mx.getUserId());
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="room-settings__card">
|
||||||
|
<MenuHeader>Notification</MenuHeader>
|
||||||
|
<RoomNotification roomId={roomId} />
|
||||||
|
</div>
|
||||||
|
<div className="room-settings__card">
|
||||||
|
<MenuItem
|
||||||
|
disabled={!canInvite}
|
||||||
|
onClick={() => openInviteUser(roomId)}
|
||||||
|
iconSrc={AddUserIC}
|
||||||
|
>
|
||||||
|
Invite
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem variant="danger" onClick={() => roomActions.leave(roomId)} iconSrc={LeaveArrowIC}>Leave</MenuItem>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneralSettings.propTypes = {
|
||||||
|
roomId: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
function RoomSettings({ roomId }) {
|
function RoomSettings({ roomId }) {
|
||||||
const [, forceUpdate] = useForceUpdate();
|
const [, forceUpdate] = useForceUpdate();
|
||||||
|
const [selectedTab, setSelectedTab] = useState(tabItems[0]);
|
||||||
|
|
||||||
|
const handleTabChange = (tabItem) => {
|
||||||
|
setSelectedTab(tabItem);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
let mounted = true;
|
||||||
const settingsToggle = (isVisible) => {
|
const settingsToggle = (isVisible) => {
|
||||||
|
if (!mounted) return;
|
||||||
if (isVisible) forceUpdate();
|
if (isVisible) forceUpdate();
|
||||||
else setTimeout(() => forceUpdate(), 200);
|
else setTimeout(() => forceUpdate(), 200);
|
||||||
};
|
};
|
||||||
navigation.on(cons.events.navigation.ROOM_SETTINGS_TOGGLED, settingsToggle);
|
navigation.on(cons.events.navigation.ROOM_SETTINGS_TOGGLED, settingsToggle);
|
||||||
return () => {
|
return () => {
|
||||||
|
mounted = false;
|
||||||
navigation.removeListener(cons.events.navigation.ROOM_SETTINGS_TOGGLED, settingsToggle);
|
navigation.removeListener(cons.events.navigation.ROOM_SETTINGS_TOGGLED, settingsToggle);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -67,10 +111,9 @@ function RoomSettings({ roomId }) {
|
||||||
</TitleWrapper>
|
</TitleWrapper>
|
||||||
</Header>
|
</Header>
|
||||||
<RoomProfile roomId={roomId} />
|
<RoomProfile roomId={roomId} />
|
||||||
<Tabs items={tabItems} onSelect={() => false} />
|
<Tabs items={tabItems} onSelect={handleTabChange} />
|
||||||
<div className="room-settings__cards-wrapper">
|
<div className="room-settings__cards-wrapper">
|
||||||
{/* <div className="room-settings__card">
|
{selectedTab.text === tabItems[0].text && <GeneralSettings roomId={roomId} />}
|
||||||
</div> */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
.room-settings {
|
.room-settings {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
& .scrollbar {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
&__content {
|
&__content {
|
||||||
padding-bottom: calc(2 * var(--sp-extra-loose));
|
padding-bottom: calc(2 * var(--sp-extra-loose));
|
||||||
position: relative;
|
|
||||||
|
|
||||||
& .room-profile {
|
& .room-profile {
|
||||||
margin: var(--sp-extra-loose);
|
margin: var(--sp-extra-loose);
|
||||||
|
@ -15,6 +17,7 @@
|
||||||
& .tabs {
|
& .tabs {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
z-index: 999;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: var(--bg-surface-low);
|
background-color: var(--bg-surface-low);
|
||||||
box-shadow: 0 -4px 0 var(--bg-surface-low),
|
box-shadow: 0 -4px 0 var(--bg-surface-low),
|
||||||
|
@ -26,14 +29,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__cards-wrapper {
|
&__cards-wrapper {
|
||||||
padding: var(--sp-normal);
|
padding: 0 var(--sp-normal);
|
||||||
@include dir.side(padding, var(--sp-normal), var(--sp-extra-tight));
|
@include dir.side(padding, var(--sp-normal), var(--sp-extra-tight));
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card {
|
&__card {
|
||||||
|
margin: var(--sp-normal) 0;
|
||||||
background-color: var(--bg-surface);
|
background-color: var(--bg-surface);
|
||||||
border-radius: var(--bo-radius);
|
border-radius: var(--bo-radius);
|
||||||
box-shadow: var(--bs-surface-border);
|
box-shadow: var(--bs-surface-border);
|
||||||
padding: 16px;
|
overflow: hidden;
|
||||||
|
|
||||||
|
& > .context-menu__header:first-child {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,16 +7,15 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 99;
|
z-index: 999;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
|
||||||
transition: transform 200ms var(--fluid-slide-down),
|
transition: transform 200ms var(--fluid-slide-down);
|
||||||
box-shadow 200ms var(--fluid-slide-down);
|
|
||||||
|
|
||||||
&--dropped {
|
&--dropped {
|
||||||
transform: translateY(calc(100% - var(--header-height)));
|
transform: translateY(calc(100% - var(--header-height)));
|
||||||
border-radius: var(--bo-radius) var(--bo-radius) 0 0;
|
border-radius: var(--bo-radius) var(--bo-radius) 0 0;
|
||||||
box-shadow: var(--bs-popup);
|
box-shadow: 0 0 0 1px var(--bg-surface-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__content-wrapper {
|
&__content-wrapper {
|
||||||
|
|
Loading…
Reference in a new issue