2024-04-24 10:12:47 +00:00
|
|
|
/*
|
|
|
|
GoToSocial
|
|
|
|
Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2024-04-25 16:24:24 +00:00
|
|
|
import { BaseUrlContext, useBaseUrl, useHasPermission } from "../../lib/navigation/util";
|
2024-04-24 10:12:47 +00:00
|
|
|
import { Redirect, Route, Router, Switch } from "wouter";
|
2024-06-18 16:18:00 +00:00
|
|
|
import ReportsSearch from "./reports/search";
|
2024-04-25 16:24:24 +00:00
|
|
|
import ReportDetail from "./reports/detail";
|
|
|
|
import { ErrorBoundary } from "../../lib/navigation/error";
|
|
|
|
import ImportExport from "./domain-permissions/import-export";
|
2024-04-24 10:12:47 +00:00
|
|
|
import DomainPermissionsOverview from "./domain-permissions/overview";
|
|
|
|
import DomainPermDetail from "./domain-permissions/detail";
|
2024-05-01 13:11:22 +00:00
|
|
|
import AccountsSearch from "./accounts";
|
2024-04-25 16:24:24 +00:00
|
|
|
import AccountsPending from "./accounts/pending";
|
|
|
|
import AccountDetail from "./accounts/detail";
|
2024-11-21 13:09:58 +00:00
|
|
|
import DomainPermissionDraftsSearch from "./domain-permissions/drafts";
|
|
|
|
import DomainPermissionDraftNew from "./domain-permissions/drafts/new";
|
|
|
|
import DomainPermissionDraftDetail from "./domain-permissions/drafts/detail";
|
|
|
|
import DomainPermissionExcludeDetail from "./domain-permissions/excludes/detail";
|
|
|
|
import DomainPermissionExcludesSearch from "./domain-permissions/excludes";
|
|
|
|
import DomainPermissionExcludeNew from "./domain-permissions/excludes/new";
|
2024-04-24 10:12:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
EXPORTED COMPONENTS
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2024-04-25 16:24:24 +00:00
|
|
|
* - /settings/moderation/reports/overview
|
|
|
|
* - /settings/moderation/reports/:reportId
|
2024-05-01 13:11:22 +00:00
|
|
|
* - /settings/moderation/accounts/search
|
2024-04-25 16:24:24 +00:00
|
|
|
* - /settings/moderation/accounts/pending
|
|
|
|
* - /settings/moderation/accounts/:accountID
|
|
|
|
* - /settings/moderation/domain-permissions/:permType
|
|
|
|
* - /settings/moderation/domain-permissions/:permType/:domain
|
|
|
|
* - /settings/moderation/domain-permissions/import-export
|
|
|
|
* - /settings/moderation/domain-permissions/process
|
2024-04-24 10:12:47 +00:00
|
|
|
*/
|
2024-04-25 16:24:24 +00:00
|
|
|
export default function ModerationRouter() {
|
2024-04-24 10:12:47 +00:00
|
|
|
const parentUrl = useBaseUrl();
|
|
|
|
const thisBase = "/moderation";
|
|
|
|
const absBase = parentUrl + thisBase;
|
2024-04-25 16:24:24 +00:00
|
|
|
|
|
|
|
const permissions = ["moderator"];
|
|
|
|
const moderator = useHasPermission(permissions);
|
|
|
|
if (!moderator) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-04-24 10:12:47 +00:00
|
|
|
return (
|
|
|
|
<BaseUrlContext.Provider value={absBase}>
|
|
|
|
<Router base={thisBase}>
|
|
|
|
<ModerationReportsRouter />
|
|
|
|
<ModerationAccountsRouter />
|
|
|
|
<ModerationDomainPermsRouter />
|
|
|
|
</Router>
|
|
|
|
</BaseUrlContext.Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
INTERNAL COMPONENTS
|
|
|
|
*/
|
|
|
|
|
2024-04-25 16:24:24 +00:00
|
|
|
/**
|
|
|
|
* - /settings/moderation/reports/overview
|
|
|
|
* - /settings/moderation/reports/:reportId
|
|
|
|
*/
|
2024-04-24 10:12:47 +00:00
|
|
|
function ModerationReportsRouter() {
|
|
|
|
const parentUrl = useBaseUrl();
|
|
|
|
const thisBase = "/reports";
|
|
|
|
const absBase = parentUrl + thisBase;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BaseUrlContext.Provider value={absBase}>
|
|
|
|
<Router base={thisBase}>
|
2024-04-25 16:24:24 +00:00
|
|
|
<ErrorBoundary>
|
|
|
|
<Switch>
|
2024-06-18 16:18:00 +00:00
|
|
|
<Route path="/search" component={ReportsSearch}/>
|
2024-04-25 16:24:24 +00:00
|
|
|
<Route path={"/:reportId"} component={ReportDetail} />
|
2024-06-18 16:18:00 +00:00
|
|
|
<Route><Redirect to="/search"/></Route>
|
2024-04-25 16:24:24 +00:00
|
|
|
</Switch>
|
|
|
|
</ErrorBoundary>
|
2024-04-24 10:12:47 +00:00
|
|
|
</Router>
|
|
|
|
</BaseUrlContext.Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-04-25 16:24:24 +00:00
|
|
|
/**
|
2024-05-01 13:11:22 +00:00
|
|
|
* - /settings/moderation/accounts/search
|
2024-04-25 16:24:24 +00:00
|
|
|
* - /settings/moderation/accounts/pending
|
|
|
|
* - /settings/moderation/accounts/:accountID
|
|
|
|
*/
|
2024-04-24 10:12:47 +00:00
|
|
|
function ModerationAccountsRouter() {
|
|
|
|
const parentUrl = useBaseUrl();
|
|
|
|
const thisBase = "/accounts";
|
|
|
|
const absBase = parentUrl + thisBase;
|
2024-04-25 16:24:24 +00:00
|
|
|
|
2024-04-24 10:12:47 +00:00
|
|
|
return (
|
|
|
|
<BaseUrlContext.Provider value={absBase}>
|
|
|
|
<Router base={thisBase}>
|
2024-04-25 16:24:24 +00:00
|
|
|
<ErrorBoundary>
|
|
|
|
<Switch>
|
2024-05-01 13:11:22 +00:00
|
|
|
<Route path="/search" component={AccountsSearch}/>
|
2024-04-25 16:24:24 +00:00
|
|
|
<Route path="/pending" component={AccountsPending}/>
|
|
|
|
<Route path="/:accountID" component={AccountDetail}/>
|
2024-05-01 13:11:22 +00:00
|
|
|
<Route><Redirect to="/search"/></Route>
|
2024-04-25 16:24:24 +00:00
|
|
|
</Switch>
|
|
|
|
</ErrorBoundary>
|
2024-04-24 10:12:47 +00:00
|
|
|
</Router>
|
|
|
|
</BaseUrlContext.Provider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-04-25 16:24:24 +00:00
|
|
|
/**
|
|
|
|
* - /settings/moderation/domain-permissions/:permType
|
|
|
|
* - /settings/moderation/domain-permissions/:permType/:domain
|
|
|
|
* - /settings/moderation/domain-permissions/import-export
|
|
|
|
* - /settings/moderation/domain-permissions/process
|
|
|
|
*/
|
2024-04-24 10:12:47 +00:00
|
|
|
function ModerationDomainPermsRouter() {
|
|
|
|
const parentUrl = useBaseUrl();
|
|
|
|
const thisBase = "/domain-permissions";
|
|
|
|
const absBase = parentUrl + thisBase;
|
2024-04-25 16:24:24 +00:00
|
|
|
|
2024-04-24 10:12:47 +00:00
|
|
|
return (
|
|
|
|
<BaseUrlContext.Provider value={absBase}>
|
|
|
|
<Router base={thisBase}>
|
2024-04-25 16:24:24 +00:00
|
|
|
<ErrorBoundary>
|
|
|
|
<Switch>
|
|
|
|
<Route path="/import-export" component={ImportExport} />
|
|
|
|
<Route path="/process" component={ImportExport} />
|
2024-11-21 13:09:58 +00:00
|
|
|
<Route path="/drafts/search" component={DomainPermissionDraftsSearch} />
|
|
|
|
<Route path="/drafts/new" component={DomainPermissionDraftNew} />
|
|
|
|
<Route path="/drafts/:permDraftId" component={DomainPermissionDraftDetail} />
|
|
|
|
<Route path="/excludes/search" component={DomainPermissionExcludesSearch} />
|
|
|
|
<Route path="/excludes/new" component={DomainPermissionExcludeNew} />
|
|
|
|
<Route path="/excludes/:excludeId" component={DomainPermissionExcludeDetail} />
|
2024-04-25 16:24:24 +00:00
|
|
|
<Route path="/:permType" component={DomainPermissionsOverview} />
|
|
|
|
<Route path="/:permType/:domain" component={DomainPermDetail} />
|
|
|
|
<Route><Redirect to="/blocks"/></Route>
|
|
|
|
</Switch>
|
|
|
|
</ErrorBoundary>
|
2024-04-24 10:12:47 +00:00
|
|
|
</Router>
|
|
|
|
</BaseUrlContext.Provider>
|
|
|
|
);
|
|
|
|
}
|