Skip to content
Snippets Groups Projects
Unverified Commit d215c3da authored by Chris Beer's avatar Chris Beer Committed by GitHub
Browse files

Wrap the export json in an accordion; fixes #3440 (#3443)

parent 19d82cf0
Branches
Tags
No related merge requests found
...@@ -3,13 +3,17 @@ import Button from '@material-ui/core/Button'; ...@@ -3,13 +3,17 @@ import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog'; import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions'; import DialogActions from '@material-ui/core/DialogActions';
import DialogTitle from '@material-ui/core/DialogTitle'; import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import Snackbar from '@material-ui/core/Snackbar'; import Snackbar from '@material-ui/core/Snackbar';
import IconButton from '@material-ui/core/IconButton'; import IconButton from '@material-ui/core/IconButton';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import CloseIcon from '@material-ui/icons/Close'; import CloseIcon from '@material-ui/icons/Close';
import Accordion from '@material-ui/core/Accordion';
import AccordionSummary from '@material-ui/core/AccordionSummary';
import AccordionDetails from '@material-ui/core/AccordionDetails';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { CopyToClipboard } from 'react-copy-to-clipboard'; import { CopyToClipboard } from 'react-copy-to-clipboard';
import ScrollIndicatedDialogContent from '../containers/ScrollIndicatedDialogContent';
/** /**
*/ */
...@@ -50,7 +54,7 @@ export class WorkspaceExport extends Component { ...@@ -50,7 +54,7 @@ export class WorkspaceExport extends Component {
*/ */
render() { render() {
const { const {
children, container, open, t, children, classes, container, open, t,
} = this.props; } = this.props;
const { copied } = this.state; const { copied } = this.state;
...@@ -87,12 +91,24 @@ export class WorkspaceExport extends Component { ...@@ -87,12 +91,24 @@ export class WorkspaceExport extends Component {
<DialogTitle id="form-dialog-title" disableTypography> <DialogTitle id="form-dialog-title" disableTypography>
<Typography variant="h2">{t('downloadExport')}</Typography> <Typography variant="h2">{t('downloadExport')}</Typography>
</DialogTitle> </DialogTitle>
<ScrollIndicatedDialogContent>
<DialogContent>
<Accordion elevation={0}>
<AccordionSummary
classes={{ root: classes.accordionTitle }}
expandIcon={<ExpandMoreIcon />}
>
<Typography variant="h4">{t('viewWorkspaceConfiguration')}</Typography>
</AccordionSummary>
<AccordionDetails>
{children} {children}
<pre> <pre>
{this.exportedState()} {this.exportedState()}
</pre> </pre>
</ScrollIndicatedDialogContent> </AccordionDetails>
</Accordion>
</DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.handleClose}>{t('cancel')}</Button> <Button onClick={this.handleClose}>{t('cancel')}</Button>
<CopyToClipboard <CopyToClipboard
...@@ -109,6 +125,7 @@ export class WorkspaceExport extends Component { ...@@ -109,6 +125,7 @@ export class WorkspaceExport extends Component {
WorkspaceExport.propTypes = { WorkspaceExport.propTypes = {
children: PropTypes.node, children: PropTypes.node,
classes: PropTypes.objectOf(PropTypes.string),
container: PropTypes.object, // eslint-disable-line react/forbid-prop-types container: PropTypes.object, // eslint-disable-line react/forbid-prop-types
exportableState: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types exportableState: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
handleClose: PropTypes.func.isRequired, handleClose: PropTypes.func.isRequired,
...@@ -118,6 +135,7 @@ WorkspaceExport.propTypes = { ...@@ -118,6 +135,7 @@ WorkspaceExport.propTypes = {
WorkspaceExport.defaultProps = { WorkspaceExport.defaultProps = {
children: null, children: null,
classes: {},
container: null, container: null,
open: false, open: false,
t: key => key, t: key => key,
... ...
......
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import { WorkspaceExport } from '../components/WorkspaceExport'; import { WorkspaceExport } from '../components/WorkspaceExport';
...@@ -16,8 +17,18 @@ const mapStateToProps = state => ({ ...@@ -16,8 +17,18 @@ const mapStateToProps = state => ({
exportableState: getExportableState(state), exportableState: getExportableState(state),
}); });
/**
* Styles for the withStyles HOC
*/
const styles = theme => ({
accordionTitle: {
padding: 0,
},
});
const enhance = compose( const enhance = compose(
withTranslation(), withTranslation(),
withStyles(styles),
connect(mapStateToProps, {}), connect(mapStateToProps, {}),
withPlugins('WorkspaceExport'), withPlugins('WorkspaceExport'),
); );
... ...
......
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
"tryAgain": "Try again", "tryAgain": "Try again",
"untitled": "[Untitled]", "untitled": "[Untitled]",
"view": "View", "view": "View",
"viewWorkspaceConfiguration": "View workspace configuration",
"welcome": "Welcome to Mirador", "welcome": "Welcome to Mirador",
"window": "Window: {{label}}", "window": "Window: {{label}}",
"windowMenu": "Window views & thumbnail display", "windowMenu": "Window views & thumbnail display",
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment