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

Move to context based pattern #147

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions src/components/FeaturedDatasets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from "react";
import PropTypes from "prop-types";
import excerpts from 'excerpts';
import { Link } from 'react-router-dom';
import { Text } from "@civicactions/data-catalog-components";
// import { Text } from "@civicactions/data-catalog-components";
import config from "../../assets/config";
import './featureddatasets.scss';

const FeaturedDatasets = ({ datasets }) => {
return (
<div className={`dc-featured-datasets ${config.container}`}>
<h2 className="dc-featured-title">Featured Datasets</h2>
<ol>
{/* <ol>
{datasets.map((item) => (
<li>
<Link to={`dataset/${item.identifier}`} key={item.identifier}>
Expand All @@ -21,7 +21,7 @@ const FeaturedDatasets = ({ datasets }) => {
</Text>
</li>
))}
</ol>
</ol> */}
</div>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/Layout/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import Helmet from "react-helmet";
import { Link } from 'react-router-dom';
import { Header, NavBar, Footer } from "@civicactions/data-catalog-components";
// import { Header, NavBar, Footer } from "@civicactions/data-catalog-components";
import config from "../../assets/config.json";
import links from "../../assets/menu.json";

Expand All @@ -21,19 +21,19 @@ const Layout = ({
"lang": "en"
}}
/>
<Header site={config.site} slogan={config.slogan} customClasses={config.container} />
{/* <Header site={config.site} slogan={config.slogan} customClasses={config.container} />
<NavBar
navItems={links.main.map(item => (
<Link to={item.url}>
{item.label}
</Link>
))}
customClasses={config.container}
/>
/> */}
<main>
{children}
</main>
<Footer links={links} customClasses={config.container} />
{/* <Footer links={links} customClasses={config.container} /> */}
</div>
);
};
Expand Down
22 changes: 11 additions & 11 deletions src/components/Resource/index.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from "react";
import {
Resource,
FileDownload,
} from "@civicactions/data-catalog-components";
// import {
// Resource,
// FileDownload,
// } from "@civicactions/data-catalog-components";

const ResourceTemplate = ({ resource }) => {
const type = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('mediaType') ? resource.data.mediaType.split("/") : '';
const backup = type ? type[1] : 'data';
const format = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('format') ? resource.data.format : backup;
// const type = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('mediaType') ? resource.data.mediaType.split("/") : '';
// const backup = type ? type[1] : 'data';
// const format = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('format') ? resource.data.format : backup;

const downloadURL = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('downloadURL') ? resource.data.downloadURL : '';
const accessURL = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('accessURL') ? resource.data.accessURL : downloadURL;
// const downloadURL = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('downloadURL') ? resource.data.downloadURL : '';
// const accessURL = resource.hasOwnProperty('data') && resource.data.hasOwnProperty('accessURL') ? resource.data.accessURL : downloadURL;
const rootURL = `${import.meta.env.VITE_REACT_APP_ROOT_URL}`;

return (
<div id={`resource_${resource.identifier}`}>
{format.toLowerCase() === 'csv'
{/* {format.toLowerCase() === 'csv'
? (
<Resource
apiURL={rootURL}
Expand All @@ -35,7 +35,7 @@ const ResourceTemplate = ({ resource }) => {
downloadURL={resource.data.downloadURL}
/>
)
}
} */}
</div>
);
};
Expand Down
6 changes: 3 additions & 3 deletions src/templates/about/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Announcement } from "@civicactions/data-catalog-components";
// import { Announcement } from "@civicactions/data-catalog-components";
import Layout from '../../components/Layout';
import config from "../../assets/config";
import { version, dependencies } from '../../../package.json';
Expand All @@ -17,9 +17,9 @@ const About = () => (
</p>
</div>
<div className="col-md-3 col-sm-12">
<Announcement variation="info" heading="Note">
{/* <Announcement variation="info" heading="Note">
<p>Update this about page before publishing.</p>
</Announcement>
</Announcement> */}
</div>
</div>
<h2>App version:</h2>
Expand Down
6 changes: 3 additions & 3 deletions src/templates/api/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import config from "../../assets/config";
import Layout from "../../components/Layout";
import { ApiDocs } from "@civicactions/data-catalog-components";
// import { ApiDocs } from "@civicactions/data-catalog-components";

const ApiDocsFull = ({ path }) => (
<Layout title="API Documentation">
<div className={`dc-page ${config.container}`}>
<div className="page-content">
{typeof window !== `undefined` && (
{/* {typeof window !== `undefined` && (
<ApiDocs endpoint={import.meta.env.VITE_REACT_APP_ROOT_URL} />
)}
)} */}
</div>
</div>
</Layout>
Expand Down
32 changes: 16 additions & 16 deletions src/templates/dataset/api.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { Link, useParams } from "react-router-dom";
import { Spinner } from "reactstrap";
import {
ApiDocs,
Organization
} from "@civicactions/data-catalog-components";
// import {
// ApiDocs,
// Organization
// } from "@civicactions/data-catalog-components";
import config from "../../assets/config";
import orgs from "../../assets/publishers";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
Expand All @@ -23,20 +23,20 @@ const ApiDocsSpecific = () => {
});
const item = data ? data : {};

const orgName = "publisher" in item && item.publisher.data ? item.publisher.data.name : "";
const orgDetails = orgs.filter(org => orgName === org.name);
const orgImage = orgDetails.length && orgDetails[0].imageUrl ? orgDetails[0].imageUrl : "";
const orgDesc = orgDetails.length && orgDetails[0].description ? orgDetails[0].description : "";
let renderOrg;
if(orgDetails.length > 0 && orgDetails[0].imageUrl) {
renderOrg = <Organization name={orgName} imageUrl={orgImage} description={orgDesc}/>;
} else {
renderOrg = <Organization name={orgName} description={orgDesc}/>;
}
// const orgName = "publisher" in item && item.publisher.data ? item.publisher.data.name : "";
// const orgDetails = orgs.filter(org => orgName === org.name);
// const orgImage = orgDetails.length && orgDetails[0].imageUrl ? orgDetails[0].imageUrl : "";
// const orgDesc = orgDetails.length && orgDetails[0].description ? orgDetails[0].description : "";
// let renderOrg;
// if(orgDetails.length > 0 && orgDetails[0].imageUrl) {
// renderOrg = <Organization name={orgName} imageUrl={orgImage} description={orgDesc}/>;
// } else {
// renderOrg = <Organization name={orgName} description={orgDesc}/>;
// }

return (
<Layout title="Dataset API">
<div className={`dc-dataset-page ${config.container}`}>
{/* <div className={`dc-dataset-page ${config.container}`}>
{loading ? (
<Spinner color="primary" />
) : (
Expand Down Expand Up @@ -74,7 +74,7 @@ const ApiDocsSpecific = () => {
</div>
)}

</div>
</div> */}
</Layout>
);
}
Expand Down
Loading