diff --git a/src/sidebar/app/components/CloseIcon.js b/src/sidebar/app/components/CloseIcon.js new file mode 100644 index 000000000..0a32b07cc --- /dev/null +++ b/src/sidebar/app/components/CloseIcon.js @@ -0,0 +1,15 @@ +import React from 'react'; + +function CloseIcon(props) { + return ( + + + ); +} + +export default CloseIcon; diff --git a/src/sidebar/app/components/Editor.js b/src/sidebar/app/components/Editor.js index a5a135d2b..f55cb51c8 100644 --- a/src/sidebar/app/components/Editor.js +++ b/src/sidebar/app/components/Editor.js @@ -1,5 +1,7 @@ import React from 'react'; +import CloseIcon from './CloseIcon'; + import { getPadStats, customizeEditor, insertSelectedText } from '../utils/editor'; import INITIAL_CONFIG from '../data/editorConfig'; @@ -11,6 +13,7 @@ class Editor extends React.Component { this.state = { ignoreNextLoadEvent: false, ignoreTextSynced: false, + wasLimitReached: false, isKintoLoaded: false, content: null }; @@ -93,6 +96,12 @@ class Editor extends React.Component { }); }; + this.closeNotification = () => { + this.setState({ + wasLimitReached: false + }); + }; + this.init = (content) => { this.setState({ content @@ -128,11 +137,18 @@ class Editor extends React.Component { }); if (content.length > 15000) { console.error('Maximum notepad size reached:', content.length); // eslint-disable-line no-console - migrationBody.textContent = browser.i18n.getMessage('maximumPadSizeExceeded'); + // TODO: display 'maximumPadSizeExceeded' notification + this.setState({ + wasLimitReached: true, + }); browser.runtime.sendMessage({ action: 'metrics-limit-reached', context: getPadStats(editor) }); + } else { + this.setState({ + wasLimitReached: false, + }); } chrome.runtime.sendMessage({ @@ -165,7 +181,6 @@ class Editor extends React.Component { this.loadContent(); } - componentWillUnmount() { chrome.runtime.onMessage.removeListener(this.events); } @@ -173,13 +188,20 @@ class Editor extends React.Component { render() { return ( -
{ browser.i18n.getMessage('maximumPadSizeExceeded') }
+