Skip to content

Commit

Permalink
improve licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Feb 10, 2024
1 parent 055ec8c commit d1fc711
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
8 changes: 3 additions & 5 deletions Website/src/activitys/LicensesActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DepCard = (props: { dep: (typeof li)[0] }) => {
};

const handleOpenLicense = () => {
fetch(`https://spdx.org/licenses/${dep.license}.json`)
fetch(`https://raw.githubusercontent.com/spdx/license-list-data/main/website/${dep.license}.json`)
.then((res) => {
if (res.status === 200) {
return res.json();
Expand All @@ -48,9 +48,7 @@ const DepCard = (props: { dep: (typeof li)[0] }) => {
},
});
})
.catch((err) => {
os.toast(err, Toast.LENGTH_SHORT);
});
.catch((err) => {});
};

return (
Expand Down Expand Up @@ -107,7 +105,7 @@ const LicensesActivity = () => {

return (
<Page renderToolbar={renderToolbar}>
<Page.RelativeContent zeroMargin>
<Page.RelativeContent>
<FlatList
list={li}
renderItem={(dep) => <DepCard dep={dep} />}
Expand Down
27 changes: 25 additions & 2 deletions Website/src/activitys/ModuleViewActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import DownloadIcon from "@mui/icons-material/Download";
import Tooltip from "@mui/material/Tooltip";
import { view } from "@Native/View";
import AntiFeatureListItem from "@Components/AntiFeatureListItem";
import FetchTextActivity from "./FetchTextActivity";

function a11yProps(index: number) {
return {
Expand Down Expand Up @@ -583,12 +584,34 @@ const ModuleViewActivity = () => {
)}

{track.license && (
<ListItem>
<ListItemButton
onClick={() => {
fetch(`https://raw.githubusercontent.com/spdx/license-list-data/main/website/${track.license}.json`)
.then((res) => {
if (res.status === 200) {
return res.json();
} else {
throw new Error("Fetching license failed");
}
})
.then((json: LicenseSPX) => {
context.pushPage({
component: FetchTextActivity,
key: "license_" + track.license,
extra: {
raw_data: json.licenseText,
modulename: json.name,
},
});
})
.catch((err) => {});
}}
>
<ListItemIcon>
<FormatAlignLeftIcon />
</ListItemIcon>
<StyledListItemText primary={strings("license")} secondary={track.license} />
</ListItem>
</ListItemButton>
)}

{track.support && (
Expand Down

0 comments on commit d1fc711

Please sign in to comment.