2022-09-29 13:02:41 +03:00
|
|
|
/*
|
|
|
|
GoToSocial
|
2023-03-12 20:49:06 +03:00
|
|
|
Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
2022-09-29 13:02:41 +03:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const React = require("react");
|
|
|
|
const ReactDom = require("react-dom/client");
|
|
|
|
const { Provider } = require("react-redux");
|
|
|
|
const { PersistGate } = require("redux-persist/integration/react");
|
|
|
|
|
2023-10-05 17:06:19 +03:00
|
|
|
const { store, persistor } = require("./redux/store");
|
2023-03-29 13:18:45 +03:00
|
|
|
const { createNavigation, Menu, Item } = require("./lib/navigation");
|
|
|
|
|
2023-10-05 17:06:19 +03:00
|
|
|
const { Authorization } = require("./components/authorization");
|
2022-12-11 18:00:23 +03:00
|
|
|
const Loading = require("./components/loading");
|
2023-03-29 13:18:45 +03:00
|
|
|
const UserLogoutCard = require("./components/user-logout-card");
|
|
|
|
const { RoleContext } = require("./lib/navigation/util");
|
2022-09-29 13:02:41 +03:00
|
|
|
|
|
|
|
require("./style.css");
|
|
|
|
|
2023-03-29 13:18:45 +03:00
|
|
|
const { Sidebar, ViewRouter } = createNavigation("/settings", [
|
|
|
|
Menu("User", [
|
|
|
|
Item("Profile", { icon: "fa-user" }, require("./user/profile")),
|
|
|
|
Item("Settings", { icon: "fa-cogs" }, require("./user/settings")),
|
|
|
|
]),
|
|
|
|
Menu("Moderation", {
|
|
|
|
url: "admin",
|
|
|
|
permissions: ["admin"]
|
|
|
|
}, [
|
|
|
|
Item("Reports", { icon: "fa-flag", wildcard: true }, require("./admin/reports")),
|
2023-05-13 13:17:22 +03:00
|
|
|
Item("Accounts", { icon: "fa-users", wildcard: true }, require("./admin/accounts")),
|
2023-03-29 13:18:45 +03:00
|
|
|
Menu("Federation", { icon: "fa-hubzilla" }, [
|
|
|
|
Item("Federation", { icon: "fa-hubzilla", url: "", wildcard: true }, require("./admin/federation")),
|
|
|
|
Item("Import/Export", { icon: "fa-floppy-o", wildcard: true }, require("./admin/federation/import-export")),
|
|
|
|
])
|
|
|
|
]),
|
|
|
|
Menu("Administration", {
|
|
|
|
url: "admin",
|
|
|
|
defaultUrl: "/settings/admin/settings",
|
|
|
|
permissions: ["admin"]
|
|
|
|
}, [
|
2023-09-12 12:43:12 +03:00
|
|
|
Menu("Actions", { icon: "fa-bolt" }, [
|
|
|
|
Item("Media", { icon: "fa-photo" }, require("./admin/actions/media")),
|
|
|
|
Item("Keys", { icon: "fa-key-modern" }, require("./admin/actions/keys")),
|
|
|
|
]),
|
2023-03-29 13:18:45 +03:00
|
|
|
Menu("Custom Emoji", { icon: "fa-smile-o" }, [
|
|
|
|
Item("Local", { icon: "fa-home", wildcard: true }, require("./admin/emoji/local")),
|
|
|
|
Item("Remote", { icon: "fa-cloud" }, require("./admin/emoji/remote"))
|
|
|
|
]),
|
2023-08-19 15:33:15 +03:00
|
|
|
Menu("Settings", { icon: "fa-sliders" }, [
|
|
|
|
Item("Settings", { icon: "fa-sliders", url: "" }, require("./admin/settings")),
|
|
|
|
Item("Rules", { icon: "fa-dot-circle-o", wildcard: true }, require("./admin/settings/rules"))
|
2023-09-12 12:43:12 +03:00
|
|
|
]),
|
2023-03-29 13:18:45 +03:00
|
|
|
])
|
|
|
|
]);
|
2022-09-29 13:02:41 +03:00
|
|
|
|
2023-01-18 16:45:14 +03:00
|
|
|
function App({ account }) {
|
2023-03-29 13:18:45 +03:00
|
|
|
const permissions = [account.role.name];
|
2022-09-29 13:02:41 +03:00
|
|
|
|
2023-01-18 16:45:14 +03:00
|
|
|
return (
|
2023-03-29 13:18:45 +03:00
|
|
|
<RoleContext.Provider value={permissions}>
|
2023-01-18 16:45:14 +03:00
|
|
|
<div className="sidebar">
|
2023-03-29 13:18:45 +03:00
|
|
|
<UserLogoutCard />
|
|
|
|
<Sidebar />
|
2022-09-29 13:02:41 +03:00
|
|
|
</div>
|
2023-01-18 16:45:14 +03:00
|
|
|
<section className="with-sidebar">
|
2023-03-29 13:18:45 +03:00
|
|
|
<ViewRouter />
|
2022-09-29 13:02:41 +03:00
|
|
|
</section>
|
2023-03-29 13:18:45 +03:00
|
|
|
</RoleContext.Provider>
|
2023-01-18 16:45:14 +03:00
|
|
|
);
|
2022-09-29 13:02:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function Main() {
|
|
|
|
return (
|
|
|
|
<Provider store={store}>
|
2023-01-18 16:45:14 +03:00
|
|
|
<PersistGate loading={<section><Loading /></section>} persistor={persistor}>
|
2023-10-05 17:06:19 +03:00
|
|
|
<Authorization App={App} />
|
2022-09-29 13:02:41 +03:00
|
|
|
</PersistGate>
|
|
|
|
</Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const root = ReactDom.createRoot(document.getElementById("root"));
|
|
|
|
root.render(<React.StrictMode><Main /></React.StrictMode>);
|