Skip to content

TagSpaces is an offline, open source, document manager with tagging support

optimizing the license dialog

Ilian Sapundshievde651306592b
diff --git a/app/components/dialogs/LicenseDialog.js b/app/components/dialogs/LicenseDialog.js
index 7b6c77777..c78f56783 100644
--- a/app/components/dialogs/LicenseDialog.js
+++ b/app/components/dialogs/LicenseDialog.js
@@ -23,9 +23,10 @@ import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import withMobileDialog from '@material-ui/core/withMobileDialog';
-import GenericDialog, { onEnterKeyHandler } from './GenericDialog';
+import GenericDialog from './GenericDialog';
import i18n from '../../services/i18n';
import { Pro } from '../../pro';
+import AppConfig from '../../config';
import LicenseContent from '../../LICENSE.txt';
type Props = {
@@ -34,72 +35,76 @@ type Props = {
onClose: () => void
};
-function printElem(elem) {
- const printWin = window.open('', 'PRINT', 'height=400,width=600');
- printWin.document.write('<html><head><title>License Agreement</title>');
- printWin.document.write('</head><body >');
- printWin.document.write(document.getElementById(elem).innerHTML);
- printWin.document.write('</body></html>');
- printWin.document.close(); // necessary for IE >= 10
- printWin.focus(); // necessary for IE >= 10*/
- printWin.print();
- printWin.close();
- return true;
-}
+// function printElem(elem) {
+// const printWin = window.open('', 'PRINT', 'height=400,width=600');
+// printWin.document.write('<html><head><title>License Agreement</title>');
+// printWin.document.write('</head><body >');
+// printWin.document.write(elem.innerHTML);
+// printWin.document.write('</body></html>');
+// printWin.document.close(); // necessary for IE >= 10
+// printWin.focus(); // necessary for IE >= 10*/
+// printWin.print();
+// printWin.close();
+// return true;
+// }
-class LicenseDialog extends React.Component<Props> {
- licenseElement;
+const LicenseDialog = (props: Props) => {
+ // let licenseElement;
+ // function printLicense() {
+ // // printElem(licenseElement);
+ // window.print();
+ // }
- printLicense = () => {
- printElem(this.licenseElement);
- };
-
- renderTitle = () => <DialogTitle>{i18n.t('core:license')}</DialogTitle>;
-
- renderContent = () => (
- <DialogContent style={{ overflowY: 'visible', overflowX: 'auto' }}>
- <pre
- inputRef={ref => {
- this.licenseElement = ref;
- }}
- style={{ whiteSpace: 'pre-wrap' }}
- >
- {Pro ? Pro.EULAContent : LicenseContent}
- </pre>
- </DialogContent>
- );
+ function renderTitle() {
+ return <DialogTitle>{i18n.t('core:license')}</DialogTitle>;
+ }
- renderActions = () => (
- <DialogActions>
- {/* <Button
- onClick={this.printLicense}
- color="primary"
- >
- {i18n.t('core:print')}
- </Button> */}
- <Button
- data-tid="confirmLicenseDialog"
- onClick={this.props.onClose}
- color="primary"
+ function renderContent() {
+ return (
+ <DialogContent
+ // inputRef={ref => {
+ // licenseElement = ref;
+ // }}
+ style={{ overflow: AppConfig.isFirefox ? 'auto' : 'overlay' }}
>
- {i18n.t('core:ok')}
- </Button>
- </DialogActions>
- );
+ <pre style={{ whiteSpace: 'pre-wrap' }} >
+ {Pro ? Pro.EULAContent : LicenseContent}
+ </pre>
+ </DialogContent>
+ );
+ }
- render() {
- const { fullScreen, open, onClose } = this.props;
+ function renderActions() {
return (
- <GenericDialog
- open={open}
- onClose={onClose}
- fullScreen={fullScreen}
- renderTitle={this.renderTitle}
- renderContent={this.renderContent}
- renderActions={this.renderActions}
- />
+ <DialogActions>
+ {/* <Button
+ onClick={printLicense}
+ color="primary"
+ >
+ {i18n.t('core:print')}
+ </Button> */}
+ <Button
+ data-tid="confirmLicenseDialog"
+ onClick={props.onClose}
+ color="primary"
+ >
+ {i18n.t('core:ok')}
+ </Button>
+ </DialogActions>
);
}
-}
+
+ const { fullScreen, open, onClose } = props;
+ return (
+ <GenericDialog
+ open={open}
+ onClose={onClose}
+ fullScreen={fullScreen}
+ renderTitle={renderTitle}
+ renderContent={renderContent}
+ renderActions={renderActions}
+ />
+ );
+};
export default withMobileDialog()(LicenseDialog);