diff --git a/client/modules/IDE/components/Preferences/Preferences.unit.test.jsx b/client/modules/IDE/components/Preferences/Preferences.unit.test.jsx index fe414ffb58..7f13eb4bad 100644 --- a/client/modules/IDE/components/Preferences/Preferences.unit.test.jsx +++ b/client/modules/IDE/components/Preferences/Preferences.unit.test.jsx @@ -1,63 +1,23 @@ import React from 'react'; -import { act } from 'react-dom/test-utils'; -import { fireEvent, render, screen } from '../../../../test-utils'; +import { act, fireEvent, reduxRender, screen } from '../../../../test-utils'; import Preferences from './index'; - -/* props to pass in: - * - this.props.fontSize : number - * - this.props.autosave : bool - * - this.props.autocloseBracketsQuotes : bool - * - this.props.autocompleteHinter : bool - * - this.props.linewrap : bool - * - this.props.lineNumbers : bool - * - this.props.theme : string - * - this.props.lintWarning : bool - * - this.props.textOutput : bool - * - this.props.gridOutput : bool - * - this.props.soundOutput : bool - * - t from internationalization - * - * - this.props.setFontSize(fontsize : number) - * - this.props.setAutosave(value : bool) - * - this.props.setAutocloseBracketsQuotes(value: bool) - * - this.props.setLinewrap(value : bool) - * - this.props.setLineNumbers(value : bool) - * - this.props.setTheme(color : string) -> can be {"light", "dark", "contrast"} - * - this.props.setLintWarning(value : bool) - * - this.props.setTextOutput(value : bool) - * - this.props.setGridOutput(value : bool) - * - this.props.setSoundOutput(value : bool) - * - - */ +import * as PreferencesActions from '../../actions/preferences'; describe('', () => { - let props = { - t: jest.fn(), - fontSize: 12, - autosave: false, - autocloseBracketsQuotes: false, - autocompleteHinter: false, - linewrap: false, - lineNumbers: false, - theme: 'contrast', - lintWarning: false, - textOutput: false, - gridOutput: false, - soundOutput: false, - setFontSize: jest.fn(), - setAutosave: jest.fn(), - setAutocloseBracketsQuotes: jest.fn(), - setAutocompleteHinter: jest.fn(), - setLinewrap: jest.fn(), - setLineNumbers: jest.fn(), - setTheme: jest.fn(), - setLintWarning: jest.fn(), - setTextOutput: jest.fn(), - setGridOutput: jest.fn(), - setSoundOutput: jest.fn() - }; - - const subject = () => render(); + // For backwards compatibility, spy on each action creator to see when it was dispatched. + const props = Object.fromEntries( + Object.keys(PreferencesActions).map((name) => { + const spied = jest.spyOn(PreferencesActions, name); + return [name, spied]; + }) + ); + + const subject = (initialPreferences = {}) => + reduxRender(, { + initialState: { + preferences: initialPreferences + } + }); afterEach(() => { jest.clearAllMocks(); @@ -66,9 +26,7 @@ describe('', () => { describe('font tests', () => { it('font size increase button says increase', () => { // render the component - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the button for increasing text size const fontPlusButton = screen.getByRole('button', { @@ -81,9 +39,7 @@ describe('', () => { it('increase font size by 2 when clicking plus button', () => { // render the component with font size set to 12 - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the button for increasing text size const fontPlusButton = screen.getByRole('button', { @@ -102,9 +58,7 @@ describe('', () => { it('font size decrease button says decrease', () => { // render the component with font size set to 12 - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the button for decreasing font size const fontPlusButton = screen.getByRole('button', { @@ -117,9 +71,7 @@ describe('', () => { it('decrease font size by 2 when clicking minus button', () => { // render the component with font size set to 12 - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the button for decreasing text size const fontMinusButton = screen.getByRole('button', { @@ -138,9 +90,7 @@ describe('', () => { it('font text field changes on manual text input', () => { // render the component with font size set to 12 - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the text field const input = screen.getByRole('textbox', { name: /font size/i }); @@ -166,9 +116,7 @@ describe('', () => { it('font size CAN NOT go over 36', () => { // render the component - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the text field const input = screen.getByRole('textbox', { name: /font size/i }); @@ -193,9 +141,7 @@ describe('', () => { it('font size CAN NOT go under 8', () => { // render the component - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the text field const input = screen.getByRole('textbox', { name: /font size/i }); @@ -222,9 +168,7 @@ describe('', () => { // h and then i, but it tests the same idea it('font size input field does NOT take non-integers', () => { // render the component - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the text field const input = screen.getByRole('textbox', { name: /font size/i }); @@ -252,9 +196,7 @@ describe('', () => { it('font size input field does NOT take "-"', () => { // render the component - act(() => { - subject(); - }); + subject({ fontSize: 12 }); // get ahold of the text field const input = screen.getByRole('textbox', { name: /font size/i }); @@ -311,14 +253,8 @@ describe('', () => { describe('testing theme switching', () => { describe('dark mode', () => { - beforeAll(() => { - props.theme = 'dark'; - }); - it('switch to light', () => { - act(() => { - subject(); - }); + subject({ theme: 'dark' }); const themeRadioCurrent = screen.getByRole('radio', { name: /dark theme on/i @@ -338,14 +274,8 @@ describe('', () => { }); describe('light mode', () => { - beforeAll(() => { - props.theme = 'light'; - }); - it('switch to dark', () => { - act(() => { - subject(); - }); + subject({ theme: 'light' }); const themeRadioCurrent = screen.getByRole('radio', { name: /light theme on/i @@ -364,9 +294,8 @@ describe('', () => { }); it('switch to contrast', () => { - act(() => { - subject(); - }); + subject({ theme: 'light' }); + const themeRadioCurrent = screen.getByRole('radio', { name: /light theme on/i }); @@ -387,9 +316,7 @@ describe('', () => { describe('testing toggle UI elements on starting tab', () => { it('autosave toggle, starting at false', () => { - act(() => { - subject(); - }); + subject({ autosave: false }); // get ahold of the radio buttons for toggling autosave const autosaveRadioFalse = screen.getByRole('radio', { @@ -409,9 +336,7 @@ describe('', () => { it('autocloseBracketsQuotes toggle, starting at false', () => { // render the component with autocloseBracketsQuotes prop set to false - act(() => { - subject(); - }); + subject({ autocloseBracketsQuotes: false }); // get ahold of the radio buttons for toggling autocloseBracketsQuotes const autocloseRadioFalse = screen.getByRole('radio', { @@ -431,9 +356,7 @@ describe('', () => { it('autocompleteHinter toggle, starting at false', () => { // render the component with autocompleteHinter prop set to false - act(() => { - subject(); - }); + subject({ autocompleteHinter: false }); // get ahold of the radio buttons for toggling autocompleteHinter const autocompleteRadioFalse = screen.getByRole('radio', { @@ -452,15 +375,9 @@ describe('', () => { }); describe('start autosave value at true', () => { - beforeAll(() => { - props.autosave = true; - }); - it('autosave toggle, starting at true', () => { // render the component with autosave prop set to true - act(() => { - subject(); - }); + subject({ autosave: true }); // get ahold of the radio buttons for toggling autosave const autosaveRadioFalse = screen.getByRole('radio', { @@ -480,14 +397,8 @@ describe('', () => { }); describe('start autoclose brackets value at true', () => { - beforeAll(() => { - props.autocloseBracketsQuotes = true; - }); - it('autocloseBracketsQuotes toggle, starting at true', () => { - act(() => { - subject(); - }); + subject({ autocloseBracketsQuotes: true }); // get ahold of the radio buttons for toggling autocloseBracketsQuotes const autocloseRadioFalse = screen.getByRole('radio', { @@ -507,15 +418,9 @@ describe('', () => { }); describe('start autocomplete hinter value at true', () => { - beforeAll(() => { - props.autocompleteHinter = true; - }); - it('autocompleteHinter toggle, starting at true', () => { // render the component with autocompleteHinter prop set to true - act(() => { - subject(); - }); + subject({ autocompleteHinter: true }); // get ahold of the radio buttons for toggling autocompleteHinter const autocompleteRadioFalse = screen.getByRole('radio', { @@ -535,15 +440,9 @@ describe('', () => { }); describe('start linewrap at false', () => { - beforeAll(() => { - props.linewrap = false; - }); - it('linewrap toggle, starting at false', () => { // render the component with linewrap prop set to false - act(() => { - subject(); - }); + subject({ linewrap: false }); // get ahold of the radio buttons for toggling linewrap const linewrapRadioFalse = screen.getByRole('radio', { @@ -563,15 +462,9 @@ describe('', () => { }); describe('start linewrap at true', () => { - beforeAll(() => { - props.linewrap = true; - }); - it('linewrap toggle, starting at true', () => { // render the component with linewrap prop set to false - act(() => { - subject(); - }); + subject({ linewrap: true }); // get ahold of the radio buttons for toggling linewrap const linewrapRadioFalse = screen.getByRole('radio', { @@ -594,9 +487,7 @@ describe('', () => { describe('can toggle between general settings and accessibility tabs successfully', () => { it('can toggle sucessfully', () => { // render the component with lineNumbers prop set to false - act(() => { - subject(); - }); + subject({ lineNumbers: false }); // switch to accessibility act(() => { @@ -626,15 +517,9 @@ describe('', () => { describe('testing toggle UI elements on accessibility tab', () => { describe('starting linenumbers at false', () => { - beforeAll(() => { - props.lineNumbers = false; - }); - it('lineNumbers toggle, starting at false', () => { // render the component with lineNumbers prop set to false - act(() => { - subject(); - }); + subject({ lineNumbers: false }); // switch tabs act(() => { @@ -661,15 +546,9 @@ describe('', () => { }); describe('starting linenumbers at true', () => { - beforeAll(() => { - props.lineNumbers = true; - }); - it('lineNumbers toggle, starting at true', () => { // render the component with lineNumbers prop set to false - act(() => { - subject(); - }); + subject({ lineNumbers: true }); // switch tabs act(() => { @@ -696,15 +575,9 @@ describe('', () => { }); describe('starting lintWarning at false', () => { - beforeAll(() => { - props.lintWarning = false; - }); - it('lintWarning toggle, starting at false', () => { // render the component with lintWarning prop set to false - act(() => { - subject(); - }); + subject({ lintWarning: false }); // switch tabs act(() => { @@ -731,15 +604,9 @@ describe('', () => { }); describe('starting lintWarning at true', () => { - beforeAll(() => { - props.lintWarning = true; - }); - it('lintWarning toggle, starting at true', () => { // render the component with lintWarning prop set to false - act(() => { - subject(); - }); + subject({ lintWarning: true }); // switch tabs act(() => { @@ -766,15 +633,10 @@ describe('', () => { }); const testCheckbox = (arialabel, startState, setter) => { - props = { - ...props, + subject({ textOutput: startState && arialabel === 'text output on', soundOutput: startState && arialabel === 'sound output on', gridOutput: startState && arialabel === 'table output on' - }; - - act(() => { - subject(); }); // switch tabs @@ -817,17 +679,10 @@ describe('', () => { }); describe('multiple checkboxes can be selected', () => { - beforeAll(() => { - props = { - ...props, + it('multiple checkboxes can be selected', () => { + subject({ textOutput: true, gridOutput: true - }; - }); - - it('multiple checkboxes can be selected', () => { - act(() => { - subject(); }); // switch tabs @@ -850,16 +705,10 @@ describe('', () => { }); describe('none of the checkboxes can be selected', () => { - beforeAll(() => { - props = { - ...props, + it('none of the checkboxes can be selected', () => { + subject({ textOutput: false, gridOutput: false - }; - }); - it('none of the checkboxes can be selected', () => { - act(() => { - subject(); }); // switch tabs diff --git a/client/modules/IDE/components/Preferences/index.jsx b/client/modules/IDE/components/Preferences/index.jsx index 87d0a28b9d..fa5859400e 100644 --- a/client/modules/IDE/components/Preferences/index.jsx +++ b/client/modules/IDE/components/Preferences/index.jsx @@ -1,46 +1,61 @@ -import PropTypes from 'prop-types'; -import React from 'react'; +import React, { useRef, useState } from 'react'; import { Helmet } from 'react-helmet'; +import { useDispatch, useSelector } from 'react-redux'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; -import { withTranslation } from 'react-i18next'; -// import { bindActionCreators } from 'redux'; -// import { connect } from 'react-redux'; -// import * as PreferencesActions from '../actions/preferences'; - +import { useTranslation } from 'react-i18next'; import PlusIcon from '../../../../images/plus.svg'; import MinusIcon from '../../../../images/minus.svg'; import beepUrl from '../../../../sounds/audioAlert.mp3'; +import { + setTheme, + setAutosave, + setTextOutput, + setGridOutput, + setFontSize, + setLineNumbers, + setLintWarning, + setAutocloseBracketsQuotes, + setAutocompleteHinter, + setLinewrap +} from '../../actions/preferences'; -class Preferences extends React.Component { - constructor(props) { - super(props); - this.handleUpdateAutosave = this.handleUpdateAutosave.bind(this); - this.handleUpdateLinewrap = this.handleUpdateLinewrap.bind(this); - this.handleLintWarning = this.handleLintWarning.bind(this); - this.handleLineNumbers = this.handleLineNumbers.bind(this); - this.onFontInputChange = this.onFontInputChange.bind(this); - this.onFontInputSubmit = this.onFontInputSubmit.bind(this); - this.increaseFontSize = this.increaseFontSize.bind(this); - this.decreaseFontSize = this.decreaseFontSize.bind(this); - this.setFontSize = this.setFontSize.bind(this); +export default function Preferences() { + const { t } = useTranslation(); - this.state = { - fontSize: props.fontSize - }; - } + const dispatch = useDispatch(); + + const { + fontSize, + autosave, + linewrap, + lineNumbers, + lintWarning, + textOutput, + gridOutput, + theme, + autocloseBracketsQuotes, + autocompleteHinter + } = useSelector((state) => state.preferences); - onFontInputChange(event) { + const [state, setState] = useState({ fontSize }); + + function onFontInputChange(event) { const INTEGER_REGEX = /^[0-9\b]+$/; if (event.target.value === '' || INTEGER_REGEX.test(event.target.value)) { - this.setState({ + setState({ fontSize: event.target.value }); } } - onFontInputSubmit(event) { + function handleFontSize(value) { + setState({ fontSize: value }); + dispatch(setFontSize(value)); + } + + function onFontInputSubmit(event) { event.preventDefault(); - let value = parseInt(this.state.fontSize, 10); + let value = parseInt(state.fontSize, 10); if (Number.isNaN(value)) { value = 16; } @@ -50,476 +65,397 @@ class Preferences extends React.Component { if (value < 8) { value = 8; } - this.setFontSize(value); - } - - setFontSize(value) { - this.setState({ fontSize: value }); - this.props.setFontSize(value); - } - - decreaseFontSize() { - const newValue = Number(this.state.fontSize) - 2; - this.setFontSize(newValue); - } - - increaseFontSize() { - const newValue = Number(this.state.fontSize) + 2; - this.setFontSize(newValue); + handleFontSize(value); } - handleUpdateAutosave(event) { - const value = event.target.value === 'true'; - this.props.setAutosave(value); + function decreaseFontSize() { + const newValue = Number(state.fontSize) - 2; + handleFontSize(newValue); } - handleUpdateLinewrap(event) { - const value = event.target.value === 'true'; - this.props.setLinewrap(value); + function increaseFontSize() { + const newValue = Number(state.fontSize) + 2; + handleFontSize(newValue); } - handleLintWarning(event) { - const value = event.target.value === 'true'; - this.props.setLintWarning(value); - } - - handleLineNumbers(event) { - const value = event.target.value === 'true'; - this.props.setLineNumbers(value); - } + const fontSizeInputRef = useRef(null); - render() { - const beep = new Audio(beepUrl); - - return ( -
- - p5.js Web Editor | Preferences - - - -
- -

- {this.props.t('Preferences.GeneralSettings')} -

-
- -

- {this.props.t('Preferences.Accessibility')} -

-
-
-
- -
-

- {this.props.t('Preferences.Theme')} -

-
- this.props.setTheme('light')} - aria-label={this.props.t('Preferences.LightThemeARIA')} - name="light theme" - id="light-theme-on" - className="preference__radio-button" - value="light" - checked={this.props.theme === 'light'} - /> - - this.props.setTheme('dark')} - aria-label={this.props.t('Preferences.DarkThemeARIA')} - name="dark theme" - id="dark-theme-on" - className="preference__radio-button" - value="dark" - checked={this.props.theme === 'dark'} - /> - - this.props.setTheme('contrast')} - aria-label={this.props.t('Preferences.HighContrastThemeARIA')} - name="high contrast theme" - id="high-contrast-theme-on" - className="preference__radio-button" - value="contrast" - checked={this.props.theme === 'contrast'} - /> - -
-
-
-

- {this.props.t('Preferences.TextSize')} + return ( +
+ + p5.js Web Editor | Preferences + + + +
+ +

+ {t('Preferences.GeneralSettings')}

- -
- - { - this.fontSizeInput = element; - }} - onClick={() => { - this.fontSizeInput.select(); - }} - /> -
-
+
+ +
+

{t('Preferences.Theme')}

+
+ dispatch(setTheme('light'))} + aria-label={t('Preferences.LightThemeARIA')} + name="light theme" + id="light-theme-on" + className="preference__radio-button" + value="light" + checked={theme === 'light'} + /> + + dispatch(setTheme('dark'))} + aria-label={t('Preferences.DarkThemeARIA')} + name="dark theme" + id="dark-theme-on" + className="preference__radio-button" + value="dark" + checked={theme === 'dark'} + /> + + dispatch(setTheme('contrast'))} + aria-label={t('Preferences.HighContrastThemeARIA')} + name="high contrast theme" + id="high-contrast-theme-on" + className="preference__radio-button" + value="contrast" + checked={theme === 'contrast'} + /> +
-
-

- {this.props.t('Preferences.Autosave')} -

-
- this.props.setAutosave(true)} - aria-label={this.props.t('Preferences.AutosaveOnARIA')} - name="autosave" - id="autosave-on" - className="preference__radio-button" - value="On" - checked={this.props.autosave} - /> - - this.props.setAutosave(false)} - aria-label={this.props.t('Preferences.AutosaveOffARIA')} - name="autosave" - id="autosave-off" - className="preference__radio-button" - value="Off" - checked={!this.props.autosave} - /> - -
+
+
+

{t('Preferences.TextSize')}

+ +
+ + { + fontSizeInputRef.current?.select(); + }} + /> +
+ +
+
+

{t('Preferences.Autosave')}

+
+ dispatch(setAutosave(true))} + aria-label={t('Preferences.AutosaveOnARIA')} + name="autosave" + id="autosave-on" + className="preference__radio-button" + value="On" + checked={autosave} + /> + + dispatch(setAutosave(false))} + aria-label={t('Preferences.AutosaveOffARIA')} + name="autosave" + id="autosave-off" + className="preference__radio-button" + value="Off" + checked={!autosave} + /> +
-
-

- {this.props.t('Preferences.AutocloseBracketsQuotes')} -

-
- this.props.setAutocloseBracketsQuotes(true)} - aria-label={this.props.t( - 'Preferences.AutocloseBracketsQuotesOnARIA' - )} - name="autoclosebracketsquotes" - id="autoclosebracketsquotes-on" - className="preference__radio-button" - value="On" - checked={this.props.autocloseBracketsQuotes} - /> - - this.props.setAutocloseBracketsQuotes(false)} - aria-label={this.props.t( - 'Preferences.AutocloseBracketsQuotesOffARIA' - )} - name="autoclosebracketsquotes" - id="autoclosebracketsquotes-off" - className="preference__radio-button" - value="Off" - checked={!this.props.autocloseBracketsQuotes} - /> - -
+
+
+

+ {t('Preferences.AutocloseBracketsQuotes')} +

+
+ dispatch(setAutocloseBracketsQuotes(true))} + aria-label={t('Preferences.AutocloseBracketsQuotesOnARIA')} + name="autoclosebracketsquotes" + id="autoclosebracketsquotes-on" + className="preference__radio-button" + value="On" + checked={autocloseBracketsQuotes} + /> + + dispatch(setAutocloseBracketsQuotes(false))} + aria-label={t('Preferences.AutocloseBracketsQuotesOffARIA')} + name="autoclosebracketsquotes" + id="autoclosebracketsquotes-off" + className="preference__radio-button" + value="Off" + checked={!autocloseBracketsQuotes} + /> +
-
-

- {this.props.t('Preferences.AutocompleteHinter')} -

-
- this.props.setAutocompleteHinter(true)} - aria-label={this.props.t( - 'Preferences.AutocompleteHinterOnARIA' - )} - name="autocompletehinter" - id="autocompletehinter-on" - className="preference__radio-button" - value="On" - checked={this.props.autocompleteHinter} - /> - - this.props.setAutocompleteHinter(false)} - aria-label={this.props.t( - 'Preferences.AutocompleteHinterOffARIA' - )} - name="autocompletehinter" - id="autocompletehinter-off" - className="preference__radio-button" - value="Off" - checked={!this.props.autocompleteHinter} - /> - -
+
+
+

+ {t('Preferences.AutocompleteHinter')} +

+
+ dispatch(setAutocompleteHinter(true))} + aria-label={t('Preferences.AutocompleteHinterOnARIA')} + name="autocompletehinter" + id="autocompletehinter-on" + className="preference__radio-button" + value="On" + checked={autocompleteHinter} + /> + + dispatch(setAutocompleteHinter(false))} + aria-label={t('Preferences.AutocompleteHinterOffARIA')} + name="autocompletehinter" + id="autocompletehinter-off" + className="preference__radio-button" + value="Off" + checked={!autocompleteHinter} + /> +
-
-

- {this.props.t('Preferences.WordWrap')} -

-
- this.props.setLinewrap(true)} - aria-label={this.props.t('Preferences.LineWrapOnARIA')} - name="linewrap" - id="linewrap-on" - className="preference__radio-button" - value="On" - checked={this.props.linewrap} - /> - - this.props.setLinewrap(false)} - aria-label={this.props.t('Preferences.LineWrapOffARIA')} - name="linewrap" - id="linewrap-off" - className="preference__radio-button" - value="Off" - checked={!this.props.linewrap} - /> - -
+
+
+

{t('Preferences.WordWrap')}

+
+ dispatch(setLinewrap(true))} + aria-label={t('Preferences.LineWrapOnARIA')} + name="linewrap" + id="linewrap-on" + className="preference__radio-button" + value="On" + checked={linewrap} + /> + + dispatch(setLinewrap(false))} + aria-label={t('Preferences.LineWrapOffARIA')} + name="linewrap" + id="linewrap-off" + className="preference__radio-button" + value="Off" + checked={!linewrap} + /> +
- - -
-

- {this.props.t('Preferences.LineNumbers')} -

-
- this.props.setLineNumbers(true)} - aria-label={this.props.t('Preferences.LineNumbersOnARIA')} - name="line numbers" - id="line-numbers-on" - className="preference__radio-button" - value="On" - checked={this.props.lineNumbers} - /> - - this.props.setLineNumbers(false)} - aria-label={this.props.t('Preferences.LineNumbersOffARIA')} - name="line numbers" - id="line-numbers-off" - className="preference__radio-button" - value="Off" - checked={!this.props.lineNumbers} - /> - -
+
+
+ +
+

+ {t('Preferences.LineNumbers')} +

+
+ dispatch(setLineNumbers(true))} + aria-label={t('Preferences.LineNumbersOnARIA')} + name="line numbers" + id="line-numbers-on" + className="preference__radio-button" + value="On" + checked={lineNumbers} + /> + + dispatch(setLineNumbers(false))} + aria-label={t('Preferences.LineNumbersOffARIA')} + name="line numbers" + id="line-numbers-off" + className="preference__radio-button" + value="Off" + checked={!lineNumbers} + /> +
-
-

- {this.props.t('Preferences.LintWarningSound')} -

-
- this.props.setLintWarning(true)} - aria-label={this.props.t('Preferences.LintWarningOnARIA')} - name="lint warning" - id="lint-warning-on" - className="preference__radio-button" - value="On" - checked={this.props.lintWarning} - /> - - this.props.setLintWarning(false)} - aria-label={this.props.t('Preferences.LintWarningOffARIA')} - name="lint warning" - id="lint-warning-off" - className="preference__radio-button" - value="Off" - checked={!this.props.lintWarning} - /> - - -
+
+
+

+ {t('Preferences.LintWarningSound')} +

+
+ dispatch(setLintWarning(true))} + aria-label={t('Preferences.LintWarningOnARIA')} + name="lint warning" + id="lint-warning-on" + className="preference__radio-button" + value="On" + checked={lintWarning} + /> + + dispatch(setLintWarning(false))} + aria-label={t('Preferences.LintWarningOffARIA')} + name="lint warning" + id="lint-warning-off" + className="preference__radio-button" + value="Off" + checked={!lintWarning} + /> + +
-
-

- {this.props.t('Preferences.AccessibleTextBasedCanvas')} -

-
- {this.props.t('Preferences.UsedScreenReader')} -
+
+
+

+ {t('Preferences.AccessibleTextBasedCanvas')} +

+
+ {t('Preferences.UsedScreenReader')} +
-
- { - this.props.setTextOutput(event.target.checked); - }} - aria-label={this.props.t('Preferences.TextOutputARIA')} - name="text output" - id="text-output-on" - value="On" - checked={this.props.textOutput} - /> - - { - this.props.setGridOutput(event.target.checked); - }} - aria-label={this.props.t('Preferences.TableOutputARIA')} - name="table output" - id="table-output-on" - value="On" - checked={this.props.gridOutput} - /> - -
+
+ { + dispatch(setTextOutput(event.target.checked)); + }} + aria-label={t('Preferences.TextOutputARIA')} + name="text output" + id="text-output-on" + value="On" + checked={textOutput} + /> + + { + dispatch(setGridOutput(event.target.checked)); + }} + aria-label={t('Preferences.TableOutputARIA')} + name="table output" + id="table-output-on" + value="On" + checked={gridOutput} + /> +
- - -
- ); - } +

+
+
+
+ ); } - -Preferences.propTypes = { - fontSize: PropTypes.number.isRequired, - lineNumbers: PropTypes.bool.isRequired, - setFontSize: PropTypes.func.isRequired, - autosave: PropTypes.bool.isRequired, - linewrap: PropTypes.bool.isRequired, - setLineNumbers: PropTypes.func.isRequired, - setAutosave: PropTypes.func.isRequired, - setLinewrap: PropTypes.func.isRequired, - textOutput: PropTypes.bool.isRequired, - gridOutput: PropTypes.bool.isRequired, - setTextOutput: PropTypes.func.isRequired, - setGridOutput: PropTypes.func.isRequired, - lintWarning: PropTypes.bool.isRequired, - setLintWarning: PropTypes.func.isRequired, - theme: PropTypes.string.isRequired, - setTheme: PropTypes.func.isRequired, - autocloseBracketsQuotes: PropTypes.bool.isRequired, - setAutocloseBracketsQuotes: PropTypes.func.isRequired, - autocompleteHinter: PropTypes.bool.isRequired, - setAutocompleteHinter: PropTypes.func.isRequired, - t: PropTypes.func.isRequired -}; - -export default withTranslation()(Preferences); diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index ba5aa2cab2..19b1da2ce2 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -273,30 +273,7 @@ class IDEView extends React.Component { ariaLabel={this.props.t('Preferences.Settings')} closeOverlay={this.props.closePreferences} > - + )}
@@ -505,15 +482,6 @@ IDEView.propTypes = { autocompleteHinter: PropTypes.bool.isRequired }).isRequired, closePreferences: PropTypes.func.isRequired, - setAutocloseBracketsQuotes: PropTypes.func.isRequired, - setAutocompleteHinter: PropTypes.func.isRequired, - setFontSize: PropTypes.func.isRequired, - setAutosave: PropTypes.func.isRequired, - setLineNumbers: PropTypes.func.isRequired, - setLinewrap: PropTypes.func.isRequired, - setLintWarning: PropTypes.func.isRequired, - setTextOutput: PropTypes.func.isRequired, - setGridOutput: PropTypes.func.isRequired, setAllAccessibleOutput: PropTypes.func.isRequired, selectedFile: PropTypes.shape({ id: PropTypes.string.isRequired, @@ -536,7 +504,6 @@ IDEView.propTypes = { closeShareModal: PropTypes.func.isRequired, closeKeyboardShortcutModal: PropTypes.func.isRequired, autosaveProject: PropTypes.func.isRequired, - setTheme: PropTypes.func.isRequired, setPreviousPath: PropTypes.func.isRequired, showErrorModal: PropTypes.func.isRequired, hideErrorModal: PropTypes.func.isRequired,