Commit dd359a1c authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '39-markdown' into 'main'

Markdown for Subset, Dataset title

Closes #39

See merge request !37
parents b982659e c0112a86
......@@ -12,6 +12,7 @@ import {AccessionService, DatasetService} from '@genesys-pgr/client/service';
import {Property} from 'ui/common/Property';
import Loading from 'ui/common/Loading';
import PageTitle from 'ui/common/PageTitle';
import Markdown from 'ui/common/Markdown';
interface DatasetDetailsPageProps {
match: any;
......@@ -65,10 +66,10 @@ const DatasetDetailsPage = ({match}: DatasetDetailsPageProps) => {
<>
<PageTitle title={t('pagetitle.dataset', {datasetTitle: dataset.title})}/>
<div className="d-flex justify-content-between align-items-center">
<h1>{dataset.title}</h1>
<h1><Markdown basic source={dataset.title}/></h1>
</div>
{dataset.description && <p>{dataset.description}</p> }
{dataset.description && <Markdown source={dataset.description} /> }
{dataset.owner &&
<Property
......@@ -171,7 +172,7 @@ const DatasetDetailsPage = ({match}: DatasetDetailsPageProps) => {
/>
}
{ dataset.repositoryFiles &&
{ dataset.repositoryFiles &&
<>
<h2 className="mt-4">{t('dataset.details.repositoryFiles')}</h2>
{dataset.repositoryFiles.map((repoFile) =>
......@@ -209,4 +210,4 @@ const DatasetDetailsPage = ({match}: DatasetDetailsPageProps) => {
);
};
export default DatasetDetailsPage;
\ No newline at end of file
export default DatasetDetailsPage;
......@@ -17,7 +17,6 @@ export function DatasetFilters({filter, applyFilter}: DatasetFiltersProps) {
const handleSubmit = (e) => {
e.preventDefault();
console.log('------------')
applyFilter({
_text: text,
});
......
......@@ -18,6 +18,7 @@ import {DatasetFilters} from "dataset/DatasetFilters";
// util
import {parseLocationSearch} from "utilities/filterUtil";
import {useSelector} from "react-redux";
import Markdown from 'ui/common/Markdown';
interface IDatasetListPageProps {
location: any;
......@@ -88,10 +89,10 @@ const DatasetListPage = ({location}: IDatasetListPageProps) => {
<tbody>
{datasets.content.map((d) => (
<tr key={d.id}>
<td><Link to={`/datasets/${d.uuid}`}>{d.title}</Link></td>
<td><Link to={`/datasets/${d.uuid}`}><Markdown basic source={d.title}/></Link></td>
<td>{d.crops && d.crops.length > 0 && <p>{d.crops.join(', ')}</p>}</td>
<td>{d.accessionCount}</td>
<td>{d.description}</td>
<td><Markdown firstParagraph source={d.description} /></td>
</tr>
))}
</tbody>
......
......@@ -262,7 +262,8 @@
"role": {
"COLLECTOR": "Data collector",
"CURATOR": "Curator",
"MANAGER": "Manager"
"MANAGER": "Manager",
"DIGITIZER": "Data entry"
}
},
"subset": {
......
......@@ -14,6 +14,7 @@ import {AccessionService, SubsetService} from '@genesys-pgr/client/service';
import {Property} from 'ui/common/Property';
import Loading from 'ui/common/Loading';
import PageTitle from 'ui/common/PageTitle';
import Markdown from 'ui/common/Markdown';
interface SubsetDetailsPageProps {
match: any;
......@@ -65,9 +66,9 @@ const SubsetDetailsPage = ({match}: SubsetDetailsPageProps) => {
return (
<>
<PageTitle title={t('pagetitle.subset', {subsetTitle: subset.title})}/>
<h1>{subset.title}</h1>
<h1><Markdown basic source={subset.title}/></h1>
{subset.description && <p>{subset.description}</p> }
{subset.description && <Markdown source={subset.description} /> }
{subset.institute &&
<Property
......@@ -134,4 +135,4 @@ const SubsetDetailsPage = ({match}: SubsetDetailsPageProps) => {
);
};
export default SubsetDetailsPage;
\ No newline at end of file
export default SubsetDetailsPage;
......@@ -15,6 +15,7 @@ import {SubsetService} from "@genesys-pgr/client/service";
import PageTitle from "ui/common/PageTitle";
import Pagination from "ui/common/Pagination";
import {SubsetFilters} from "subset/SubsetFilters";
import Markdown from 'ui/common/Markdown';
// util
import {parseLocationSearch} from "utilities/filterUtil";
import {useSelector} from "react-redux";
......@@ -92,11 +93,11 @@ const SubsetListPage = ({location}: ISubsetListPageProps) => {
<tbody>
{subsets.content.map((s) => (
<tr key={s.id}>
<td><Link to={`/subsets/${s.uuid}`}>{s.title}</Link></td>
<td><Link to={`/subsets/${s.uuid}`}><Markdown basic source={ s.title }/></Link></td>
<td>{s?.crops.join(', ')}</td>
<td>{s.accessionCount}</td>
{/* <td><a href={`${publicWebsiteUrl}/wiews/${s.wiewsCode}`}>{s.wiewsCode}</a></td> */}
<td>{s?.description}</td>
<td><Markdown firstParagraph source={ s?.description } /></td>
</tr>
))}
</tbody>
......
import * as React from 'react';
import MarkdownComponent from 'react-markdown';
interface IMarkdownTextProps extends React.HTMLProps<HTMLElement> {
source: string;
basic?: boolean;
firstParagraph?: boolean;
}
const Markdown = ({ source, className, basic, firstParagraph }: IMarkdownTextProps) => {
if (source) {
const eol = source.indexOf('\n\n');
const text = firstParagraph && eol > 0 ? source.substring(0, eol) : source;
if (basic) {
// the 'markdown-basic' className is used to render the div as inline
return (
<span className={ `markdown-basic ${className ? className : ''}` }>
<MarkdownComponent skipHtml unwrapDisallowed allowedElements={ [ 'text', 'strong', 'emphasis', 'em' ] }>{ text }</MarkdownComponent>
</span>
);
} else {
return (
<MarkdownComponent skipHtml className={ `markdown ${className ? className : ''}` }>{ text }</MarkdownComponent>
);
}
} else {
return null;
}
}
export default Markdown
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment