]> git.localhorst.tv Git - alttp.git/commitdiff
all the...small things
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 1 Oct 2023 11:52:46 +0000 (13:52 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 1 Oct 2023 11:52:46 +0000 (13:52 +0200)
resources/js/app/Routes.js
resources/js/components/twitch-bot/Controls.js [new file with mode: 0644]
resources/js/helpers/permissions.js
resources/js/i18n/de.js
resources/js/i18n/en.js
resources/js/pages/DiscordBot.js
resources/js/pages/TwitchBot.js [new file with mode: 0644]

index ca543ee7088b0de66fb6c85c89e39d0d34e05c4d..d9f276728d5d8a04534ac9e8ebc9fd68c8bf4d30 100644 (file)
@@ -13,6 +13,7 @@ import Schedule from '../pages/Schedule';
 import Technique from '../pages/Technique';
 import Techniques from '../pages/Techniques';
 import Tournament from '../pages/Tournament';
+import TwitchBot from '../pages/TwitchBot';
 import User from '../pages/User';
 
 const AppRoutes = ({ doLogout }) => <Routes>
@@ -72,6 +73,10 @@ const AppRoutes = ({ doLogout }) => <Routes>
                        element={<Technique basepath="tech" type="tech" />}
                />
                <Route path="tournaments/:id" element={<Tournament />} />
+               <Route
+                       path="twitch-bot"
+                       element={<TwitchBot />}
+               />
                <Route path="users/:id" element={<User />} />
                <Route path="/" element={<Front />} />
                <Route path="*" element={<Navigate to="/" />} />
diff --git a/resources/js/components/twitch-bot/Controls.js b/resources/js/components/twitch-bot/Controls.js
new file mode 100644 (file)
index 0000000..158fb7c
--- /dev/null
@@ -0,0 +1,7 @@
+import React from 'react';
+
+const Controls = () => {
+       return <div />;
+};
+
+export default Controls;
index 1bdb2622b6a44bb9115521ba9d8a14f1c5503561..706e676ab692d5b44ec606e66ad8fc01c13a372f 100644 (file)
@@ -155,6 +155,10 @@ export const maySeeResults = (user, tournament, round) =>
        isTournamentMonitor(user, tournament) ||
        Round.isComplete(tournament, round);
 
+// Twitch
+
+export const mayManageTwitchBot = user => isAdmin(user) || hasGlobalRole(user, 'twitch');
+
 // Users
 
 export const mayEditNickname = (user, subject) =>
index 35328134e8bc6deb857b8558ebd0620fe3abf36a..9b6891b02941662d00d2326df62ea62c5ae7498a 100644 (file)
@@ -474,6 +474,11 @@ export default {
                        unlockError: 'Fehler beim Entsperren',
                        unlockSuccess: 'Turnier entsperrt',
                },
+               twitchBot: {
+                       controls: 'Controls',
+                       heading: 'Twitch Bot',
+                       noManagePermission: 'Du verfügst nicht über die notwendigen Berechtigungen, um den Twitch Bot zu administrieren.',
+               },
                users: {
                        discordTag: 'Discord Tag',
                        editNickname: 'Name bearbeiten',
index 3de3e0de8d7d5592b48fd2ab0a2c516e8b06f311..58d406ca14441aaf55f64261fcb4dd643cb94a13 100644 (file)
@@ -474,6 +474,11 @@ export default {
                        unlockError: 'Error unlocking tournaments',
                        unlockSuccess: 'Tournament unlocked',
                },
+               twitchBot: {
+                       controls: 'Controls',
+                       heading: 'Twitch Bot',
+                       noManagePermission: 'You lack the required privileges to manage the twitch bot.',
+               },
                users: {
                        discordTag: 'Discord tag',
                        editNickname: 'Edit name',
index 6796a9445e4b67e88837b43546cd25ec55588658..1bea822ce2503450e2956da7ef5e9d525d13d46f 100644 (file)
@@ -1,5 +1,6 @@
 import React from 'react';
 import { Button, Container } from 'react-bootstrap';
+import { Helmet } from 'react-helmet';
 import { useTranslation } from 'react-i18next';
 
 import Icon from '../components/common/Icon';
@@ -13,6 +14,9 @@ const DiscordBot = () => {
 
        return <Container>
                <h1>{t('discordBot.heading')}</h1>
+               <Helmet>
+                       <title>{t('discordBot.heading')}</title>
+               </Helmet>
                <p>
                        <span className="button-bar">
                                <Button
diff --git a/resources/js/pages/TwitchBot.js b/resources/js/pages/TwitchBot.js
new file mode 100644 (file)
index 0000000..1bbec76
--- /dev/null
@@ -0,0 +1,30 @@
+import React from 'react';
+import { Alert, Container } from 'react-bootstrap';
+import { Helmet } from 'react-helmet';
+import { useTranslation } from 'react-i18next';
+
+import Controls from '../components/twitch-bot/Controls';
+import { mayManageTwitchBot } from '../helpers/permissions';
+import { useUser } from '../helpers/UserContext';
+
+const TwitchBot = () => {
+       const { t } = useTranslation();
+       const user = useUser();
+
+       return <Container>
+               <h1>{t('twitchBot.heading')}</h1>
+               <Helmet>
+                       <title>{t('twitchBot.heading')}</title>
+               </Helmet>
+               {mayManageTwitchBot(user) ? <>
+                       <h2>{t('twitchBot.controls')}</h2>
+                       <Controls />
+               </> :
+                       <Alert variant="info">
+                               {t('twitchBot.noManagePermission')}
+                       </Alert>
+               }
+       </Container>;
+};
+
+export default TwitchBot;