Commit ebbfe718 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added json button to metainfo in ArchiveView.

parent c43eb809
......@@ -74,7 +74,8 @@ class ApiDialogButtonUnstyled extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
data: PropTypes.any.isRequired,
title: PropTypes.string
title: PropTypes.string,
component: PropTypes.func
}
static styles = theme => ({
......@@ -85,15 +86,25 @@ class ApiDialogButtonUnstyled extends React.Component {
showDialog: false
}
constructor(props) {
super(props)
this.handleShowDialog = this.handleShowDialog.bind(this)
}
handleShowDialog() {
this.setState({showDialog: !this.state.showDialog})
}
render() {
const { classes, ...dialogProps } = this.props
const { classes, component, ...dialogProps } = this.props
const { showDialog } = this.state
return (
<div className={classes.root}>
<IconButton onClick={() => this.setState({showDialog: true})}>
{component ? component({onClick: this.handleShowDialog}) : <IconButton onClick={this.handleShowDialog}>
<CodeIcon />
</IconButton>
}
<ApiDialog
{...dialogProps} open={showDialog}
onClose={() => this.setState({showDialog: false})}
......
......@@ -9,6 +9,7 @@ import { withApi } from '../api'
import DownloadIcon from '@material-ui/icons/CloudDownload'
import Download from './Download'
import { ValueAttributes, MetaAttribute } from '../metaInfoBrowser/ValueCard'
import ApiDialogButton from '../ApiDialogButton'
class ArchiveEntryView extends React.Component {
static propTypes = {
......@@ -122,11 +123,19 @@ class ArchiveEntryView extends React.Component {
<CardActions className={classes.metaInfoActions}>
{ (showMetaInfo && metaInfo && metaInfoData)
? <Button color="primary" component={props => <Link to={`/metainfo/${metaInfoData.name}`} {...props} />}>
Goto Metainfo
Goto Metainfo Browser
</Button>
: <Button color="primary" disabled>
Goto Metainfo
Goto Metainfo Browser
</Button>}
<ApiDialogButton
component={props => (
<Button color="primary" disabled={!(showMetaInfo && metaInfo && metaInfoData)} {...props}>
Metainfo JSON
</Button>
)}
data={metaInfoData ? metaInfoData.miJson : {}} title="Metainfo JSON"
/>
</CardActions>
</Card>
<Card className={classes.data}>
......
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