diff --git a/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js b/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js index 386d93089..3dd20c8ee 100644 --- a/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js +++ b/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js @@ -32,27 +32,24 @@ const getMode = ext => { }; const SourceCodeViewer = ( - { name, content = '', lineNumbers = true, height }, + { name, content = '', lineNumbers = true }, { userSettings: { vimMode = false, darkTheme = false } } ) => - height - ? - : null; + ; SourceCodeViewer.propTypes = { name: PropTypes.string.isRequired, content: PropTypes.string, - lineNumbers: PropTypes.bool, - height: PropTypes.number + lineNumbers: PropTypes.bool }; SourceCodeViewer.contextTypes = { diff --git a/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js b/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js index dd5bc8db6..870cb6e47 100644 --- a/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js +++ b/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js @@ -16,8 +16,6 @@ import SourceCodeViewer from '../../components/helpers/SourceCodeViewer'; import styles from './sourceCode.less'; class SourceCodeViewerContainer extends Component { - state = { height: null }; - componentWillMount() { const { fileId, loadAsync } = this.props; if (fileId !== null) { @@ -31,45 +29,13 @@ class SourceCodeViewerContainer extends Component { } } - onModalEntered() { - if (this.state.height === null) { - const { headerRef, bodyRef, footerRef } = this; - const height = - window.innerHeight - - headerRef.clientHeight - - bodyRef.clientHeight - - footerRef.clientHeight; - this.setState({ height }); - } - } - - onModalEnteredWhileLoading() { - if (this.state.height === null) { - const { loadingHeaderRef, loadingBodyRef, loadingFooterRef } = this; - const height = - window.innerHeight - - loadingHeaderRef.clientHeight - - loadingBodyRef.clientHeight - - loadingFooterRef.clientHeight; - this.setState({ height }); - } else { - // console.log('already has height', this.state.height); - } - } - render() { - const { show, onHide, download, file, code } = this.props; - const { height } = this.state; + const { show, onHide, download, file, content } = this.props; return ( this.onModalEnteredWhileLoading()} - > -
(this.loadingHeaderRef = header)}> + +
{' '} @@ -80,12 +46,14 @@ class SourceCodeViewerContainer extends Component {
-
(this.loadingBodyRef = body)}> +
- +
+ +
-
(this.loadingFooterRef = footer)}> +
} - resource={[file, code]} + resource={[file, content]} > - {(file, code) => - this.onModalEntered()} - > -
(this.headerRef = header)}> + {(file, content) => + +
{file.name}
-
(this.bodyRef = body)}> +
- + {(content.malformedCharacters || content.tooLarge) && +
+ {content.malformedCharacters && +

+ +

} + {content.tooLarge && +

+ +

} +
} +
+ +
-
(this.footerRef = footer)}> +