index.js (3210B)
1 /* 2 GoToSocial 3 Copyright (C) GoToSocial Authors admin@gotosocial.org 4 SPDX-License-Identifier: AGPL-3.0-or-later 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU Affero General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 "use strict"; 21 22 const React = require("react"); 23 const ReactDom = require("react-dom/client"); 24 const { Provider } = require("react-redux"); 25 const { PersistGate } = require("redux-persist/integration/react"); 26 27 const { store, persistor } = require("./redux"); 28 const { createNavigation, Menu, Item } = require("./lib/navigation"); 29 30 const AuthorizationGate = require("./components/authorization"); 31 const Loading = require("./components/loading"); 32 const UserLogoutCard = require("./components/user-logout-card"); 33 const { RoleContext } = require("./lib/navigation/util"); 34 35 require("./style.css"); 36 37 const { Sidebar, ViewRouter } = createNavigation("/settings", [ 38 Menu("User", [ 39 Item("Profile", { icon: "fa-user" }, require("./user/profile")), 40 Item("Settings", { icon: "fa-cogs" }, require("./user/settings")), 41 ]), 42 Menu("Moderation", { 43 url: "admin", 44 permissions: ["admin"] 45 }, [ 46 Item("Reports", { icon: "fa-flag", wildcard: true }, require("./admin/reports")), 47 Item("Accounts", { icon: "fa-users", wildcard: true }, require("./admin/accounts")), 48 Menu("Federation", { icon: "fa-hubzilla" }, [ 49 Item("Federation", { icon: "fa-hubzilla", url: "", wildcard: true }, require("./admin/federation")), 50 Item("Import/Export", { icon: "fa-floppy-o", wildcard: true }, require("./admin/federation/import-export")), 51 ]) 52 ]), 53 Menu("Administration", { 54 url: "admin", 55 defaultUrl: "/settings/admin/settings", 56 permissions: ["admin"] 57 }, [ 58 Item("Actions", { icon: "fa-bolt" }, require("./admin/actions")), 59 Menu("Custom Emoji", { icon: "fa-smile-o" }, [ 60 Item("Local", { icon: "fa-home", wildcard: true }, require("./admin/emoji/local")), 61 Item("Remote", { icon: "fa-cloud" }, require("./admin/emoji/remote")) 62 ]), 63 Item("Settings", { icon: "fa-sliders" }, require("./admin/settings")) 64 ]) 65 ]); 66 67 function App({ account }) { 68 const permissions = [account.role.name]; 69 70 return ( 71 <RoleContext.Provider value={permissions}> 72 <div className="sidebar"> 73 <UserLogoutCard /> 74 <Sidebar /> 75 </div> 76 <section className="with-sidebar"> 77 <ViewRouter /> 78 </section> 79 </RoleContext.Provider> 80 ); 81 } 82 83 function Main() { 84 return ( 85 <Provider store={store}> 86 <PersistGate loading={<section><Loading /></section>} persistor={persistor}> 87 <AuthorizationGate App={App} /> 88 </PersistGate> 89 </Provider> 90 ); 91 } 92 93 const root = ReactDom.createRoot(document.getElementById("root")); 94 root.render(<React.StrictMode><Main /></React.StrictMode>);