Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 change license implementation #104

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/components/common/store/OGCCollectionDefinitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class OGCCollection {
getTemporal = (): ITemporal[] | undefined => this.propValue?.temporal;
getCitation = (): ICitation | undefined => this.propValue?.citation;
getStatement = (): string | undefined => this.propValue?.statement;
getLicense = (): ILicense | undefined => this.propValue?.license;
getLicense = (): string | undefined => this.propValue?.license;
getCreation = (): string | undefined => this.propValue?.creation;
getRevision = (): string | undefined => this.propValue?.revision;
}
Expand All @@ -78,7 +78,7 @@ export class SummariesProperties {
readonly temporal?: ITemporal[];
readonly citation?: ICitation;
readonly statement?: string;
readonly license?: ILicense;
readonly license?: string;
readonly creation?: string;
readonly revision?: string;
}
Expand Down Expand Up @@ -128,7 +128,6 @@ export class Spatial {
}

// interfaces:

export interface OGCCollections {
collections: Array<OGCCollection>;
links: Array<ILink>;
Expand Down Expand Up @@ -169,12 +168,6 @@ export interface ICitation {
useLimitations?: string[];
}

export interface ILicense {
title: string;
url: string;
licenseGraphic: string;
}

export interface IContact {
name: string;
organization: string;
Expand All @@ -198,3 +191,14 @@ export interface ITheme {
title: string;
concepts: IConcept[];
}

// Enums
export enum RelationType {
SELF = "self",
LICENSE = "license",
}

export enum MediaType {
TEXT_HTML = "text/html",
IMAGE_PNG = "image/png",
}
19 changes: 12 additions & 7 deletions src/pages/detail-page/subpages/components/LicenseBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { Grid, Link } from "@mui/material";
import { margin } from "../../../../styles/constants";
import { ILicense } from "../../../../components/common/store/OGCCollectionDefinitions";
import React from "react";
import BlockList from "./BlockList";

interface LicenseBlockProps {
license: ILicense;
license: string;
url: string;
graphic: string;
}

const LicenseBlock: React.FC<LicenseBlockProps> = ({ license }) => {
const LicenseBlock: React.FC<LicenseBlockProps> = ({
license,
url,
graphic,
}) => {
const licenseComponent = () => {
return (
<Grid
Expand All @@ -27,22 +32,22 @@ const LicenseBlock: React.FC<LicenseBlockProps> = ({ license }) => {
<Grid item md={1} />
<Grid container item md={11}>
<Grid item md={12}>
{license.title}
{license}
</Grid>
<Grid item md={12}>
<Link
href={license.url}
href={url}
target="_blank"
rel="noreferrer"
sx={{
color: "#468CB6",
}}
>
{license.url}
{url}
</Link>
</Grid>
<Grid item md={12}>
<img src={license.licenseGraphic} alt="license graphic" />
<img src={graphic} alt="license graphic" />
</Grid>
</Grid>
</Grid>
Expand Down
35 changes: 33 additions & 2 deletions src/pages/detail-page/subpages/tab-panels/CitationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import NavigatablePanel from "../components/NavigatablePanel";
import PlainTextBlock from "../components/PlainTextBlock";
import PlainCollapseBlock from "../components/PlainCollapseBlock";
import LicenseBlock from "../components/LicenseBlock";
import {
MediaType,
RelationType,
} from "../../../../components/common/store/OGCCollectionDefinitions";

const CitationPanel = () => {
const context = useDetailPageContext();
Expand All @@ -14,6 +18,22 @@ const CitationPanel = () => {
[context.collection]
);

const licenseUrl = useMemo(() => {
return context.collection?.links?.find((link) => {
return (
link.rel === RelationType.LICENSE && link.type === MediaType.TEXT_HTML
);
})?.href;
}, [context.collection?.links]);

const licenseGraphic = useMemo(() => {
return context.collection?.links?.find((link) => {
return (
link.rel === RelationType.LICENSE && link.type === MediaType.IMAGE_PNG
);
})?.href;
}, [context.collection?.links]);

const citationContacts = useMemo(
() =>
context.collection
Expand Down Expand Up @@ -78,7 +98,11 @@ const CitationPanel = () => {
{
title: "License",
component: license ? (
<LicenseBlock license={license} />
<LicenseBlock
license={license}
url={licenseUrl ? licenseUrl : ""}
graphic={licenseGraphic ? licenseGraphic : ""}
/>
) : (
<div>no license</div>
),
Expand All @@ -99,7 +123,14 @@ const CitationPanel = () => {
),
},
],
[citationContacts, constraints, license, suggestedCitation]
[
citationContacts,
constraints,
license,
licenseGraphic,
licenseUrl,
suggestedCitation,
]
);

return <NavigatablePanel childrenList={blocks} isLoading={isLoading} />;
Expand Down
Loading