From bc1a58969706e3278e04ad8b0568af4fba2099dc Mon Sep 17 00:00:00 2001 From: Vysakh Premkumar <84713473+tellmeY18@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:45:46 +0530 Subject: [PATCH] migrated to Licenses Directory and transfered licenseUrl to json --- .../{ => Licenses}/LicensesPage.tsx | 0 src/Components/{ => Licenses}/SBOMViewer.tsx | 60 +------------------ src/Components/Licenses/licenseUrls.json | 51 ++++++++++++++++ src/Routers/SessionRouter.tsx | 2 +- 4 files changed, 55 insertions(+), 58 deletions(-) rename src/Components/{ => Licenses}/LicensesPage.tsx (100%) rename src/Components/{ => Licenses}/SBOMViewer.tsx (67%) create mode 100644 src/Components/Licenses/licenseUrls.json diff --git a/src/Components/LicensesPage.tsx b/src/Components/Licenses/LicensesPage.tsx similarity index 100% rename from src/Components/LicensesPage.tsx rename to src/Components/Licenses/LicensesPage.tsx diff --git a/src/Components/SBOMViewer.tsx b/src/Components/Licenses/SBOMViewer.tsx similarity index 67% rename from src/Components/SBOMViewer.tsx rename to src/Components/Licenses/SBOMViewer.tsx index cfe56c32a2d..dd2bb542811 100644 --- a/src/Components/SBOMViewer.tsx +++ b/src/Components/Licenses/SBOMViewer.tsx @@ -1,68 +1,14 @@ import React, { useState, useEffect } from "react"; -import Card from "../CAREUI/display/Card"; +import Card from "../../CAREUI/display/Card"; import dayjs from "dayjs"; import { CopyToClipboard } from "react-copy-to-clipboard"; import axios from "axios"; - -const licenseUrls: { [key: string]: string } = { - MIT: "https://opensource.org/licenses/MIT", - "GPL-3.0": "https://www.gnu.org/licenses/gpl-3.0.en.html", - "GPL-3.0-or-later": "https://www.gnu.org/licenses/gpl-3.0.en.html", - "Apache-2.0": "https://www.apache.org/licenses/LICENSE-2.0", - ISC: "https://opensource.org/licenses/ISC", - "0BSD": "https://opensource.org/licenses/0BSD", - "OFL-1.1": "https://opensource.org/licenses/OFL-1.1", - "BSD-3-Clause": "https://opensource.org/licenses/BSD-3-Clause", - "BSD-2-Clause": "https://opensource.org/licenses/BSD-2-Clause", - "LGPL-2.1": "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html", - "LGPL-3.0": "https://www.gnu.org/licenses/lgpl-3.0.en.html", - "AGPL-3.0": "https://www.gnu.org/licenses/agpl-3.0.en.html", - "MPL-2.0": "https://www.mozilla.org/en-US/MPL/2.0/", - "EPL-2.0": "https://www.eclipse.org/legal/epl-2.0/", - "CC-BY-4.0": "https://creativecommons.org/licenses/by/4.0/", - Unlicense: "https://unlicense.org/", - "BlueOak-1.0.0": "https://blueoakcouncil.org/license/1.0.0", - "GPL-2.0": "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html", - "GPL-2.0-or-later": - "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html", - "LGPL-2.0": "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html", - "LGPL-2.0-or-later": - "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html", - "AGPL-1.0": "https://www.gnu.org/licenses/agpl-1.0.html", - "AGPL-1.0-or-later": "https://www.gnu.org/licenses/agpl-1.0.html", - "AGPL-2.0": "https://www.gnu.org/licenses/agpl-2.0.html", - "AGPL-2.0-or-later": "https://www.gnu.org/licenses/agpl-2.0.html", - "AGPL-3.0-or-later": "https://www.gnu.org/licenses/agpl-3.0.en.html", - "MPL-1.1": "https://www.mozilla.org/MPL/MPL-1.1.html", - "MPL-1.0": "https://www.mozilla.org/MPL/MPL-1.0.html", - "EPL-1.0": "https://www.eclipse.org/legal/epl-v10.html", - "CC-BY-SA-4.0": "https://creativecommons.org/licenses/by-sa/4.0/", - "CC-BY-NC-4.0": "https://creativecommons.org/licenses/by-nc/4.0/", - "CC-BY-ND-4.0": "https://creativecommons.org/licenses/by-nd/4.0/", - "CC-BY-NC-SA-4.0": "https://creativecommons.org/licenses/by-nc-sa/4.0/", - "CC-BY-NC-ND-4.0": "https://creativecommons.org/licenses/by-nc-nd/4.0/", - "CC0-1.0": "https://creativecommons.org/publicdomain/zero/1.0/", - "Artistic-2.0": "https://opensource.org/licenses/Artistic-2.0", - "EUPL-1.2": "https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12", - "EUPL-1.1": "https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-11", - "EUPL-1.0": "https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-10", - Zlib: "https://opensource.org/licenses/Zlib", - "BSL-1.0": "https://opensource.org/licenses/BSL-1.0", - "Apache-1.1": "https://opensource.org/licenses/Apache-1.1", - "Apache-1.0": "https://opensource.org/licenses/Apache-1.0", - "AFL-3.0": "https://opensource.org/licenses/AFL-3.0", - "AFL-2.1": "https://opensource.org/licenses/AFL-2.1", - "AFL-2.0": "https://opensource.org/licenses/AFL-2.0", - "AFL-1.2": "https://opensource.org/licenses/AFL-1.2", - "AFL-1.1": "https://opensource.org/licenses/AFL-1.1", - "AFL-1.0": "https://opensource.org/licenses/AFL-1.0", -}; +import licenseUrls from "./licenseUrls.json"; const getLicenseUrl = (licenseId: string | undefined): string | null => { if (!licenseId) return null; - return licenseUrls[licenseId] || null; + return licenseUrls[licenseId as keyof typeof licenseUrls] || null; }; - interface CycloneDXExternalRef { url?: string; type?: string; diff --git a/src/Components/Licenses/licenseUrls.json b/src/Components/Licenses/licenseUrls.json new file mode 100644 index 00000000000..88713d0865f --- /dev/null +++ b/src/Components/Licenses/licenseUrls.json @@ -0,0 +1,51 @@ + { + "MIT": "https://opensource.org/licenses/MIT", + "GPL-3.0": "https://www.gnu.org/licenses/gpl-3.0.en.html", + "GPL-3.0-or-later": "https://www.gnu.org/licenses/gpl-3.0.en.html", + "Apache-2.0": "https://www.apache.org/licenses/LICENSE-2.0", + "ISC": "https://opensource.org/licenses/ISC", + "0BSD": "https://opensource.org/licenses/0BSD", + "OFL-1.1": "https://opensource.org/licenses/OFL-1.1", + "BSD-3-Clause": "https://opensource.org/licenses/BSD-3-Clause", + "BSD-2-Clause": "https://opensource.org/licenses/BSD-2-Clause", + "LGPL-2.1": "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html", + "LGPL-3.0": "https://www.gnu.org/licenses/lgpl-3.0.en.html", + "AGPL-3.0": "https://www.gnu.org/licenses/agpl-3.0.en.html", + "MPL-2.0": "https://www.mozilla.org/en-US/MPL/2.0/", + "EPL-2.0": "https://www.eclipse.org/legal/epl-2.0/", + "CC-BY-4.0": "https://creativecommons.org/licenses/by/4.0/", + "Unlicense": "https://unlicense.org/", + "BlueOak-1.0.0": "https://blueoakcouncil.org/license/1.0.0", + "GPL-2.0": "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html", + "GPL-2.0-or-later": "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html", + "LGPL-2.0": "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html", + "LGPL-2.0-or-later": "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html", + "AGPL-1.0": "https://www.gnu.org/licenses/agpl-1.0.html", + "AGPL-1.0-or-later": "https://www.gnu.org/licenses/agpl-1.0.html", + "AGPL-2.0": "https://www.gnu.org/licenses/agpl-2.0.html", + "AGPL-2.0-or-later": "https://www.gnu.org/licenses/agpl-2.0.html", + "AGPL-3.0-or-later": "https://www.gnu.org/licenses/agpl-3.0.en.html", + "MPL-1.1": "https://www.mozilla.org/MPL/MPL-1.1.html", + "MPL-1.0": "https://www.mozilla.org/MPL/MPL-1.0.html", + "EPL-1.0": "https://www.eclipse.org/legal/epl-v10.html", + "CC-BY-SA-4.0": "https://creativecommons.org/licenses/by-sa/4.0/", + "CC-BY-NC-4.0": "https://creativecommons.org/licenses/by-nc/4.0/", + "CC-BY-ND-4.0": "https://creativecommons.org/licenses/by-nd/4.0/", + "CC-BY-NC-SA-4.0": "https://creativecommons.org/licenses/by-nc-sa/4.0/", + "CC-BY-NC-ND-4.0": "https://creativecommons.org/licenses/by-nc-nd/4.0/", + "CC0-1.0": "https://creativecommons.org/publicdomain/zero/1.0/", + "Artistic-2.0": "https://opensource.org/licenses/Artistic-2.0", + "EUPL-1.2": "https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12", + "EUPL-1.1": "https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-11", + "EUPL-1.0": "https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-10", + "Zlib": "https://opensource.org/licenses/Zlib", + "BSL-1.0": "https://opensource.org/licenses/BSL-1.0", + "Apache-1.1": "https://opensource.org/licenses/Apache-1.1", + "Apache-1.0": "https://opensource.org/licenses/Apache-1.0", + "AFL-3.0": "https://opensource.org/licenses/AFL-3.0", + "AFL-2.1": "https://opensource.org/licenses/AFL-2.1", + "AFL-2.0": "https://opensource.org/licenses/AFL-2.0", + "AFL-1.2": "https://opensource.org/licenses/AFL-1.2", + "AFL-1.1": "https://opensource.org/licenses/AFL-1.1", + "AFL-1.0": "https://opensource.org/licenses/AFL-1.0" + } diff --git a/src/Routers/SessionRouter.tsx b/src/Routers/SessionRouter.tsx index 7449d4d771a..faefbf0d4c7 100644 --- a/src/Routers/SessionRouter.tsx +++ b/src/Routers/SessionRouter.tsx @@ -2,7 +2,7 @@ import { Login, ResetPassword } from "../Components/Auth"; import { useRoutes } from "raviger"; import SessionExpired from "../Components/ErrorPages/SessionExpired"; import InvalidReset from "../Components/ErrorPages/InvalidReset"; -import LicensesPage from "../Components/LicensesPage"; +import LicensesPage from "../Components/Licenses/LicensesPage"; const routes = { "/": () => ,