-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalise resource loading and display. Add a bit of a hack to handle ProjectContents and WorkflowContents.
- Loading branch information
1 parent
f294e03
commit 1733091
Showing
7 changed files
with
144 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import fixIt, { options } from 'react-fix-it'; | ||
import Tutorial from './Tutorial'; | ||
import WorkflowContents from './WorkflowContents'; | ||
|
||
const resources = { | ||
tutorials: Tutorial, | ||
workflows: WorkflowContents | ||
}; | ||
|
||
const propTypes = { | ||
contents: PropTypes.object.isRequired, | ||
params: PropTypes.shape({ | ||
resource_type: PropTypes.string | ||
}) | ||
}; | ||
|
||
options.log = (test) => { | ||
console.warn(test); | ||
}; | ||
|
||
function Resource(props) { | ||
const { contents } = props; | ||
const ResourceViewer = resources[props.params.resource_type]; | ||
return (<ResourceViewer contents={contents} />); | ||
} | ||
|
||
Resource.propTypes = propTypes; | ||
export default fixIt(Resource); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import fixIt, { options } from 'react-fix-it'; | ||
|
||
const propTypes = { | ||
contents: PropTypes.object.isRequired, | ||
}; | ||
|
||
options.log = (test) => { | ||
console.warn(test); | ||
}; | ||
|
||
function Tutorial(props) { | ||
const { contents } = props; | ||
const tutorial = contents.data.length ? contents.data[0] : { steps: [] }; | ||
const steps = []; | ||
tutorial.steps && tutorial.steps.map((step, key) => { | ||
steps.push(<p key={key}><b>{key}</b> {step.content}</p>); | ||
}); | ||
return ( | ||
<div> | ||
<h2>Tutorial</h2> | ||
{steps} | ||
</div> | ||
); | ||
} | ||
|
||
Tutorial.propTypes = propTypes; | ||
export default fixIt(Tutorial); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters