mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
more react changes, incomplete
This commit is contained in:
49
src/app/components/ModalExport.jsx
Normal file
49
src/app/components/ModalExport.jsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import TranslatedComponent from './TranslatedComponent';
|
||||
import InterfaceEvents from '../utils/InterfaceEvents';
|
||||
|
||||
export default class DeleteAllModal extends TranslatedComponent {
|
||||
|
||||
static propTypes = {
|
||||
title: React.propTypes.string,
|
||||
promise: : React.propTypes.func,
|
||||
data: React.propTypes.oneOfType[React.propTypes.string, React.propTypes.object]
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
let exportJson;
|
||||
|
||||
if (props.promise) {
|
||||
exportJson = 'Generating...';
|
||||
} else if(typeof props.data == 'string') {
|
||||
exportJson = props.data;
|
||||
} else {
|
||||
exportJson = JSON.stringify(this.props.data);
|
||||
}
|
||||
|
||||
this.state = { exportJson };
|
||||
}
|
||||
|
||||
componentWillMount(){
|
||||
// When promise is done update exportJson accordingly
|
||||
}
|
||||
|
||||
render() {
|
||||
let translate = this.context.language.translate;
|
||||
let description;
|
||||
|
||||
if (this.props.description) {
|
||||
description = <div>{translate(this.props.description)}</div>
|
||||
}
|
||||
|
||||
return <div className='modal' onClick={ (e) => e.stopPropagation() }>
|
||||
<h2>{translate(this.props.title || 'Export')}</h2>
|
||||
{description}
|
||||
<div>
|
||||
<textarea className='cb json' onFocus={ (e) => e.target.select() }>{this.state.exportJson}</textarea>
|
||||
</div>
|
||||
<button className={'r dismiss cap'} onClick={InterfaceEvents.hideModal}>{translate('close')}</button>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user