2022-09-29 10:02:41 +00:00
|
|
|
/*
|
|
|
|
GoToSocial
|
2023-01-05 11:43:00 +00:00
|
|
|
Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org
|
2022-09-29 10:02:41 +00: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const React = require("react");
|
|
|
|
const ReactDom = require("react-dom/client");
|
|
|
|
const { Provider } = require("react-redux");
|
|
|
|
const { PersistGate } = require("redux-persist/integration/react");
|
2023-01-18 13:45:14 +00:00
|
|
|
const { Switch, Route, Redirect } = require("wouter");
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
const query = require("./lib/query");
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
const { store, persistor } = require("./redux");
|
|
|
|
const AuthorizationGate = require("./components/authorization");
|
2022-12-11 15:00:23 +00:00
|
|
|
const Loading = require("./components/loading");
|
2022-09-29 10:02:41 +00:00
|
|
|
|
|
|
|
require("./style.css");
|
|
|
|
|
|
|
|
// TODO: nested categories?
|
|
|
|
const nav = {
|
|
|
|
"User": {
|
|
|
|
"Profile": require("./user/profile.js"),
|
|
|
|
"Settings": require("./user/settings.js"),
|
|
|
|
},
|
|
|
|
"Admin": {
|
|
|
|
adminOnly: true,
|
|
|
|
"Instance Settings": require("./admin/settings.js"),
|
|
|
|
"Actions": require("./admin/actions"),
|
2023-01-18 13:45:14 +00:00
|
|
|
"Federation": require("./admin/federation"),
|
2023-02-06 08:33:47 +00:00
|
|
|
"Reports": require("./admin/reports")
|
2022-12-11 15:00:23 +00:00
|
|
|
},
|
|
|
|
"Custom Emoji": {
|
|
|
|
adminOnly: true,
|
|
|
|
"Local": require("./admin/emoji/local"),
|
|
|
|
"Remote": require("./admin/emoji/remote"),
|
2022-09-29 10:02:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const { sidebar, panelRouter } = require("./lib/get-views")(nav);
|
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
function App({ account }) {
|
2023-02-20 16:00:44 +00:00
|
|
|
const isAdmin = account.role.name == "admin";
|
2023-01-18 13:45:14 +00:00
|
|
|
const [logoutQuery] = query.useLogoutMutation();
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="sidebar">
|
|
|
|
{sidebar.all}
|
|
|
|
{isAdmin && sidebar.admin}
|
|
|
|
<button className="logout" onClick={logoutQuery}>
|
|
|
|
Log out
|
|
|
|
</button>
|
2022-09-29 10:02:41 +00:00
|
|
|
</div>
|
2023-01-18 13:45:14 +00:00
|
|
|
<section className="with-sidebar">
|
|
|
|
<Switch>
|
|
|
|
{panelRouter.all}
|
|
|
|
{isAdmin && panelRouter.admin}
|
|
|
|
<Route>
|
|
|
|
<Redirect to="/settings/user" />
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
2022-09-29 10:02:41 +00:00
|
|
|
</section>
|
2023-01-18 13:45:14 +00:00
|
|
|
</>
|
|
|
|
);
|
2022-09-29 10:02:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function Main() {
|
|
|
|
return (
|
|
|
|
<Provider store={store}>
|
2023-01-18 13:45:14 +00:00
|
|
|
<PersistGate loading={<section><Loading /></section>} persistor={persistor}>
|
|
|
|
<AuthorizationGate App={App} />
|
2022-09-29 10:02:41 +00:00
|
|
|
</PersistGate>
|
|
|
|
</Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const root = ReactDom.createRoot(document.getElementById("root"));
|
|
|
|
root.render(<React.StrictMode><Main /></React.StrictMode>);
|