From 030d743af9b0aac22609054d88377d00a03c9a0c Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 2 Jul 2021 22:08:03 +0100 Subject: [PATCH] Fix i18n for server settings. Start work on roles. Add temporary age gate. --- .../navigation/BottomNavigation.tsx | 18 ++- src/pages/channels/Channel.tsx | 18 ++- src/pages/settings/GenericSettings.tsx | 9 +- src/pages/settings/ServerSettings.tsx | 11 +- src/pages/settings/server/Panes.module.scss | 25 +++-- src/pages/settings/server/Roles.tsx | 106 +++++++++--------- 6 files changed, 111 insertions(+), 76 deletions(-) diff --git a/src/components/navigation/BottomNavigation.tsx b/src/components/navigation/BottomNavigation.tsx index 00bd0ab8..f8f0477f 100644 --- a/src/components/navigation/BottomNavigation.tsx +++ b/src/components/navigation/BottomNavigation.tsx @@ -5,6 +5,8 @@ import { useSelf } from "../../context/revoltjs/hooks"; import { useHistory, useLocation } from "react-router"; import ConditionalLink from "../../lib/ConditionalLink"; import { Message, Group } from "@styled-icons/boxicons-solid"; +import { LastOpened } from "../../redux/reducers/last_opened"; +import { connectState } from "../../redux/connector"; const NavigationBase = styled.div` z-index: 100; @@ -26,15 +28,23 @@ const Button = styled.a<{ active: boolean }>` ` } `; -export default function BottomNavigation() { +interface Props { + lastOpened: LastOpened +} + +export function BottomNavigation({ lastOpened }: Props) { const user = useSelf(); const history = useHistory(); const path = useLocation().pathname; + const channel_id = lastOpened['home']; + const friendsActive = path.startsWith("/friends"); const settingsActive = path.startsWith("/settings"); const homeActive = !(friendsActive || settingsActive); + // console.info(channel_id); + return ( + + ) + } + } + let id = channel._id; return <> setMembers(!showMembers)} /> diff --git a/src/pages/settings/GenericSettings.tsx b/src/pages/settings/GenericSettings.tsx index a3700603..6b20e0c3 100644 --- a/src/pages/settings/GenericSettings.tsx +++ b/src/pages/settings/GenericSettings.tsx @@ -13,11 +13,12 @@ import ButtonItem from "../../components/navigation/items/ButtonItem"; interface Props { pages: { - category?: Children, - divider?: boolean, - id: string, + category?: Children + divider?: boolean + id: string icon: Children title: Children + hideTitle?: boolean }[] custom?: Children children: Children @@ -96,7 +97,7 @@ export function GenericSettings({ pages, switchPage, category, custom, children, )} {(!isTouchscreenDevice || typeof page === "string") && (
- {!isTouchscreenDevice && ( + {!isTouchscreenDevice && !(pages.find(x => x.id === page && x.hideTitle)) && (

, //TOFIX: Just add the server.name as a string, otherwise it makes a duplicate category id: 'overview', icon: , - title: + title: }, { id: 'members', icon: , - title: "Members" + title: }, { id: 'invites', icon: , - title: "Invites" + title: }, { id: 'bans', icon: , - title: "Bans" + title: }, { id: 'roles', icon: , - title: "Roles" + title: , + hideTitle: true } ]} children={[ diff --git a/src/pages/settings/server/Panes.module.scss b/src/pages/settings/server/Panes.module.scss index b34d3b78..fe16fd40 100644 --- a/src/pages/settings/server/Panes.module.scss +++ b/src/pages/settings/server/Panes.module.scss @@ -78,16 +78,21 @@ } .roles { - .overview { - height: 85vh; //TOFIX change later - display: flex; - - .list { - overflow-y: scroll; - } + gap: 12px; + height: 100%; + display: flex; - .permissions { - overflow-y: scroll; - } + .list { + width: 160px; + overflow-y: scroll; + } + + .permissions { + flex-grow: 1; + overflow-y: scroll; + } + + h2 { + margin: 8px 0; } } \ No newline at end of file diff --git a/src/pages/settings/server/Roles.tsx b/src/pages/settings/server/Roles.tsx index 2db9baff..a4118092 100644 --- a/src/pages/settings/server/Roles.tsx +++ b/src/pages/settings/server/Roles.tsx @@ -1,4 +1,4 @@ -import Tip from "../../../components/ui/Tip"; +import { Text } from "preact-i18n"; import styles from './Panes.module.scss'; import Button from "../../../components/ui/Button"; import { Servers } from "revolt.js/dist/api/objects"; @@ -7,7 +7,7 @@ import Checkbox from "../../../components/ui/Checkbox"; import { useContext, useEffect, useState } from "preact/hooks"; import { AppContext } from "../../../context/revoltjs/RevoltClient"; import { ChannelPermission, ServerPermission } from "revolt.js/dist/api/permissions"; -import { Styleshare } from "@styled-icons/simple-icons"; +import Tip from "../../../components/ui/Tip"; interface Props { server: Servers.Server; @@ -46,61 +46,57 @@ export function Roles({ server }: Props) { return (
This section is under construction. -
-
-

select role

- { selected } - { keys - .map(id => { - let role: Servers.Role = id === 'default' ? defaultRole : roles[id]; +
+

+ { keys + .map(id => { + let role: Servers.Role = id === 'default' ? defaultRole : roles[id]; - return ( - selected && setSelected(id)}> - { role.name } - - ) - }) - } -
- setName(e.currentTarget.value)} /> - -
-
-

serverm permmissions

- { Object.keys(ServerPermission) - .map(perm => { - let value = ServerPermission[perm as keyof typeof ServerPermission]; - - return ( - 0} onChange={c => setPerm([ c ? (p[0] | value) : (p[0] ^ value), p[1] ])}> - { perm } - - ) - }) - } -

channel permmissions

- { Object.keys(ChannelPermission) - .map(perm => { - let value = ChannelPermission[perm as keyof typeof ChannelPermission]; - - return ( - >> 0) & value) > 0} onChange={c => setPerm([ p[0], c ? (p[1] | value) : (p[1] ^ value) ])}> - { perm } - - ) - }) - } - -
+ return ( + selected && setSelected(id)}> + { role.name } + + ) + }) + } +
+ setName(e.currentTarget.value)} /> + +
+
+

{ selectedRole.name }

+ { Object.keys(ServerPermission) + .map(perm => { + let value = ServerPermission[perm as keyof typeof ServerPermission]; + + return ( + 0} onChange={c => setPerm([ c ? (p[0] | value) : (p[0] ^ value), p[1] ])}> + { perm } + + ) + }) + } +

channel permmissions

+ { Object.keys(ChannelPermission) + .map(perm => { + let value = ChannelPermission[perm as keyof typeof ChannelPermission]; + + return ( + >> 0) & value) > 0} onChange={c => setPerm([ p[0], c ? (p[1] | value) : (p[1] ^ value) ])}> + { perm } + + ) + }) + } +
-
); }