diff --git a/app/components/DatasetComponent.tsx b/app/components/DatasetComponent.tsx index 01901870..33e2c62d 100644 --- a/app/components/DatasetComponent.tsx +++ b/app/components/DatasetComponent.tsx @@ -7,6 +7,7 @@ import BodyContainer from '../containers/BodyContainer' import StructureContainer from '../containers/StructureContainer' import ParseError from './ParseError' import ReadmeContainer from '../containers/ReadmeContainer' +import ReadmeHistoryContainer from '../containers/ReadmeHistoryContainer' import { CSSTransition } from 'react-transition-group' import SpinnerWithIcon from './chrome/SpinnerWithIcon' @@ -65,7 +66,9 @@ const DatasetComponent: React.FunctionComponent = (props: appear={true} >
- + {history + ? + : }
= (props) => { + const { peername, name, path } = props + const divElem = React.useRef(null) + React.useEffect(() => { + fetch(`http://localhost:2503/render/${peername}/${name}/at/${path}`) + .then(async (res) => res.text()) + .then((render) => { + if (divElem && divElem.current) { + divElem.current.innerHTML = render + } + }) + }, [peername, name, path]) + return ( +
loading... +
+ ) +} + +export default ReadmeHistory diff --git a/app/containers/ReadmeContainer.tsx b/app/containers/ReadmeContainer.tsx index 3c0a14ab..45ed7943 100644 --- a/app/containers/ReadmeContainer.tsx +++ b/app/containers/ReadmeContainer.tsx @@ -20,7 +20,7 @@ const mapStateToProps = (state: Store) => { } } -const mergeProps = (props: any, actions: any): ReadmeProps => { +const mergeProps = (props: any, actions: any): ReadmeProps => { //eslint-disable-line return { ...props, ...actions } } diff --git a/app/containers/ReadmeHistoryContainer.tsx b/app/containers/ReadmeHistoryContainer.tsx new file mode 100644 index 00000000..1938692f --- /dev/null +++ b/app/containers/ReadmeHistoryContainer.tsx @@ -0,0 +1,18 @@ +import { connect } from 'react-redux' +import ReadmeHistory from '../components/ReadmeHistory' +import Store from '../models/store' + +const mapStateToProps = (state: Store) => { + const { selections } = state + + const { peername, name, commit } = selections + + // get data for the currently selected component + return { + peername, + path: commit, + name + } +} + +export default connect(mapStateToProps)(ReadmeHistory) diff --git a/app/reducers/commitDetail.ts b/app/reducers/commitDetail.ts index 871d31d8..4fede233 100644 --- a/app/reducers/commitDetail.ts +++ b/app/reducers/commitDetail.ts @@ -15,9 +15,6 @@ const initialState: CommitDetails = { status: {}, isLoading: true, components: { - readme: { - value: '' - }, body: { value: [], pageInfo: initialPageInfo @@ -54,9 +51,6 @@ const commitDetailsReducer: Reducer = (state = initialState, action: AnyAction): published, isLoading: false, components: { - readme: { - value: dataset && dataset.readme ? atob(dataset.readme.scriptBytes) : '' - }, body: initialState.components.body, meta: { value: dataset.meta