Show dedicated Notfound page for invalid routes (#2070)

This commit is contained in:
Eduard Heimbuch
2022-06-20 17:49:41 +02:00
committed by GitHub
parent 2508f32de2
commit e1196ac6a0
6 changed files with 46 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
- type: added
description: Show dedicated notfound page for invalid routes ([#2070](https://github.com/scm-manager/scm-manager/pull/2070))

View File

@@ -133,7 +133,7 @@ export class Binder {
predicate,
extension,
extensionName: extensionName ? extensionName : "",
priority,
priority: priority || 0,
} as ExtensionRegistration<E["props"], E["type"]>;
this.extensionPoints[extensionPoint].push(registration);
}

View File

@@ -260,5 +260,6 @@
},
"tag": {
"delete": "Löschen"
}
},
"pageNotFound": "Die angefragte Seite existiert nicht."
}

View File

@@ -261,5 +261,6 @@
},
"tag": {
"delete": "Delete"
}
},
"pageNotFound": "The requested page does not exist."
}

View File

@@ -0,0 +1,37 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import React, { FC } from "react";
import { Notification, Page } from "@scm-manager/ui-components";
import { useTranslation } from "react-i18next";
const NotFoundPage: FC = () => {
const [t] = useTranslation("commons");
return (
<Page>
<Notification type="danger">404: {t("pageNotFound")}</Notification>
</Page>
);
};
export default NotFoundPage;

View File

@@ -36,8 +36,10 @@ import ChangesetShortLink from "./repos/components/changesets/ChangesetShortLink
import "./tokenExpired";
import { ApiProvider } from "@scm-manager/ui-api";
import NotFoundPage from "./containers/NotFoundPage";
binder.bind<extensionPoints.ChangesetDescriptionTokens>("changeset.description.tokens", ChangesetShortLink);
binder.bind<extensionPoints.MainRoute>("main.route", NotFoundPage, { priority: -1 });
const root = document.getElementById("root");
if (!root) {