remove unneeded wrapper components

This commit is contained in:
f0x 2022-09-13 18:35:27 +02:00
parent 0a4b1f79de
commit b01267de17
4 changed files with 14 additions and 80 deletions

View file

@ -1,31 +0,0 @@
/*
GoToSocial
Copyright (C) 2021-2022 GoToSocial Authors admin@gotosocial.org
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 Promise = require("bluebird");
const React = require("react");
const { Route, Switch } = require("wouter");
module.exports = function AdminPanel({oauth, routes}) {
return (
<Switch>
{routes}
</Switch>
);
};

View file

@ -36,20 +36,14 @@ require("./style.css");
// TODO: nested categories?
const nav = {
"User": {
Component: require("./user"),
entries: {
"Profile": require("./user/profile.js"),
"Settings": require("./user/settings.js"),
}
},
"Admin": {
Component: require("./admin"),
entries: {
"Instance Settings": require("./admin/settings.js"),
"Federation": require("./admin/federation.js"),
"Customization": require("./admin/customization.js")
}
}
};
// Generate component tree from `nav` object once, as it won't change

View file

@ -19,7 +19,7 @@
"use strict";
const React = require("react");
const { Link, Route, Redirect } = require("wouter");
const { Link, Route, Switch, Redirect } = require("wouter");
const { ErrorBoundary } = require("react-error-boundary");
const ErrorFallback = require("../components/error");
@ -33,7 +33,7 @@ module.exports = function generateViews(struct) {
const sidebar = [];
const panelRouter = [];
Object.entries(struct).forEach(([name, {Component, entries}]) => {
Object.entries(struct).forEach(([name, entries]) => {
let base = `/settings/${urlSafe(name)}`;
let links = [];
@ -50,9 +50,9 @@ module.exports = function generateViews(struct) {
routes.push((
<Route path={url} key={url}>
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={() => {}}>
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={() => { }}>
{/* FIXME: implement onReset */}
<ViewComponent/>
<ViewComponent />
</ErrorBoundary>
</Route>
));
@ -64,14 +64,16 @@ module.exports = function generateViews(struct) {
panelRouter.push(
<Route key={base} path={base}>
<Redirect to={firstRoute}/>
<Redirect to={firstRoute} />
</Route>
);
let childrenPath = `${base}/:section`;
panelRouter.push(
<Route key={childrenPath} path={childrenPath}>
<Component routes={routes}/>
<Switch>
{routes}
</Switch>
</Route>
);
@ -89,5 +91,5 @@ module.exports = function generateViews(struct) {
);
});
return {sidebar, panelRouter};
return { sidebar, panelRouter };
};

View file

@ -1,31 +0,0 @@
/*
GoToSocial
Copyright (C) 2021-2022 GoToSocial Authors admin@gotosocial.org
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 Promise = require("bluebird");
const React = require("react");
const { Switch } = require("wouter");
module.exports = function UserPanel({routes}) {
return (
<Switch>
{routes}
</Switch>
);
};